diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 61d846cbe..326ca68b1 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.1.22 + 1.0.1.23 NU1701 diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 78605213f..f9649c034 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -207,7 +207,7 @@ namespace BTCPayServer.Controllers var network = _NetworkProvider.GetNetwork(cryptoCode); try { - var pubkey = await GetExtPubKey(ledger, network, new KeyPath("49'").Derive(network.CoinType).Derive(0, true)); + var pubkey = await GetExtPubKey(ledger, network, new KeyPath("49'").Derive(network.CoinType).Derive(0, true), false); var derivation = new DerivationStrategyFactory(network.NBitcoinNetwork).CreateDirectDerivationStrategy(pubkey, new DerivationStrategyOptions() { P2SH = true, @@ -390,8 +390,8 @@ namespace BTCPayServer.Controllers { try { - var extpubkey = await GetExtPubKey(ledger, network, account); - if (directStrategy.ToString().Contains(extpubkey.ToString())) + var extpubkey = await GetExtPubKey(ledger, network, account, true); + if (directStrategy.Root.PubKey == extpubkey.ExtPubKey.PubKey) { foundKeyPath = account; break; @@ -406,7 +406,7 @@ namespace BTCPayServer.Controllers return foundKeyPath; } - private static async Task GetExtPubKey(LedgerClient ledger, BTCPayNetwork network, KeyPath account) + private static async Task GetExtPubKey(LedgerClient ledger, BTCPayNetwork network, KeyPath account, bool onlyChaincode) { var pubKey = await ledger.GetWalletPubKeyAsync(account); if (pubKey.Address.Network != network.NBitcoinNetwork) @@ -414,8 +414,8 @@ namespace BTCPayServer.Controllers if (network.DefaultSettings.ChainType == NBXplorer.ChainType.Main) throw new Exception($"The opened ledger app should be for {network.NBitcoinNetwork.Name}, not for {pubKey.Address.Network}"); } - var parent = (await ledger.GetWalletPubKeyAsync(account.Parent)).UncompressedPublicKey.Compress(); - var extpubkey = new ExtPubKey(pubKey.UncompressedPublicKey.Compress(), pubKey.ChainCode, (byte)account.Indexes.Length, parent.Hash.ToBytes().Take(4).ToArray(), account.Indexes.Last()).GetWif(network.NBitcoinNetwork); + var fingerprint = onlyChaincode ? new byte[4] : (await ledger.GetWalletPubKeyAsync(account.Parent)).UncompressedPublicKey.Compress().Hash.ToBytes().Take(4).ToArray(); + var extpubkey = new ExtPubKey(pubKey.UncompressedPublicKey.Compress(), pubKey.ChainCode, (byte)account.Indexes.Length, fingerprint, account.Indexes.Last()).GetWif(network.NBitcoinNetwork); return extpubkey; } diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index 8776c0b9b..b8d670d53 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -95,7 +95,7 @@ namespace BTCPayServer.Hosting // Needed to debug U2F for ledger support //services.Configure(kestrel => //{ - // kestrel.Listen(IPAddress.Loopback, 5012, l => + // kestrel.Listen(IPAddress.Loopback, 5012, l => // { // l.UseHttps("devtest.pfx", "toto"); // }); diff --git a/BTCPayServer/Views/Stores/AddDerivationScheme.cshtml b/BTCPayServer/Views/Stores/AddDerivationScheme.cshtml index b7f2bd3c6..66398b744 100644 --- a/BTCPayServer/Views/Stores/AddDerivationScheme.cshtml +++ b/BTCPayServer/Views/Stores/AddDerivationScheme.cshtml @@ -30,8 +30,8 @@ -

- If you own a ledger wallet use chrome, open the app activates the Browser support, and refresh this page. +