Repository: btcpayserver/btcpayserver (csharp)

Issue:
Newline during import of multisig xpub results in different addresses for wallet
Here is the video illustrating the issue, when I am entering multisig xpub for the second time I am adding newline and that causes wallets with `3...`

https://github.com/user-attachments/assets/2aa321bf-5b8a-4dec-a29b-875a77d10bb9

Expected addresses:
![image](https://github.com/user-attachments/assets/a200361e-54f9-46b3-8896-4b2d33a1bcdb)

Addresses with newline in multisig:
![image](https://github.com/user-attachments/assets/305703e5-e5a3-4a5c-b029-06663adf2208)

Pull request description:
Fix #6328

Patch:
diff --git a/BTCPayServer/DerivationSchemeParser.cs b/BTCPayServer/DerivationSchemeParser.cs
index 92b278b968..fa895d8414 100644
--- a/BTCPayServer/DerivationSchemeParser.cs
+++ b/BTCPayServer/DerivationSchemeParser.cs
@@ -100,6 +100,7 @@ public DerivationStrategyBase Parse(string str)
         {
             ArgumentNullException.ThrowIfNull(str);
             str = str.Trim();
+            str = str.Replace("\r\n","").Replace("\n", "");
             HashSet<string> hintedLabels = new HashSet<string>();
             if (!Network.Consensus.SupportSegwit)
             {


Test patch:
diff --git a/BTCPayServer.Tests/FastTests.cs b/BTCPayServer.Tests/FastTests.cs
index 43dc12b0bf..d2494d46b5 100644
--- a/BTCPayServer.Tests/FastTests.cs
+++ b/BTCPayServer.Tests/FastTests.cs
@@ -868,6 +868,10 @@ public void CanParseDerivationSchemes()
             Assert.IsType<MultisigDerivationStrategy>(((P2WSHDerivationStrategy)strategyBase).Inner);
             Assert.Equal(expected, strategyBase.ToString());
 
+            var expectedWithNewLines = "2-of-tpubDDXgATYzdQkHHhZZCMcNJj8BGDENvzMVou5v9NdxiP4rxDLj33nS233dGFW4htpVZSJ6zds9eVqAV9RyRHHiKtwQKX8eR4n4KN3Dwmj7A3h-\r\ntpubDC8a54NFtQtMQAZ97VhoU9V6jVTvi9w4Y5SaAXJSBYETKg3AoX5CCKndznhPWxJUBToPCpT44s86QbKdGpKAnSjcMTGW4kE6UQ8vpBjcybW-tpubDChjnP9LXNrJp43biqjY7FH93wgRRNrNxB4Q8pH7PPRy8UPcH2S6V46WGVJ47zVGF7SyBJNCpnaogsFbsybVQckGtVhCkng3EtFn8qmxptS";
+            strategyBase = parser.Parse(expectedWithNewLines);
+            Assert.Equal(expected, strategyBase.ToString());
+
             var inner = (MultisigDerivationStrategy)((P2WSHDerivationStrategy)strategyBase).Inner;
             Assert.False(inner.IsLegacy);
             Assert.Equal(3, inner.Keys.Count);