mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-19 06:54:19 +01:00
Don't scan 49' or 84' if not segwit
This commit is contained in:
@@ -561,8 +561,8 @@ namespace BTCPayServer.Controllers
|
|||||||
if (derivationSettings.AccountKeyPath == null)
|
if (derivationSettings.AccountKeyPath == null)
|
||||||
{
|
{
|
||||||
// If the saved wallet key path is not present or incorrect, let's scan the wallet to see if it can sign strategy
|
// If the saved wallet key path is not present or incorrect, let's scan the wallet to see if it can sign strategy
|
||||||
var foundKeyPath = await hw.FindKeyPathFromPubkeys(network,
|
var foundKeyPath = await hw.FindKeyPathFromDerivation(network,
|
||||||
derivationSettings.AccountDerivation.GetExtPubKeys().Select(p => p.GetPublicKey()).ToArray(),
|
derivationSettings.AccountDerivation,
|
||||||
normalOperationTimeout.Token);
|
normalOperationTimeout.Token);
|
||||||
derivationSettings.AccountKeyPath = foundKeyPath ?? throw new HardwareWalletException($"This store is not configured to use this ledger");
|
derivationSettings.AccountKeyPath = foundKeyPath ?? throw new HardwareWalletException($"This store is not configured to use this ledger");
|
||||||
storeData.SetSupportedPaymentMethod(derivationSettings);
|
storeData.SetSupportedPaymentMethod(derivationSettings);
|
||||||
|
|||||||
@@ -31,13 +31,20 @@ namespace BTCPayServer.Services
|
|||||||
return (await GetExtPubKey(network, keyPath, cancellation)).GetPublicKey();
|
return (await GetExtPubKey(network, keyPath, cancellation)).GetPublicKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<KeyPath> FindKeyPathFromPubkeys(BTCPayNetwork network, PubKey[] pubKeys, CancellationToken cancellation)
|
public async Task<KeyPath> FindKeyPathFromDerivation(BTCPayNetwork network, DerivationStrategyBase derivationScheme, CancellationToken cancellation)
|
||||||
{
|
{
|
||||||
|
var pubKeys = derivationScheme.GetExtPubKeys().Select(k => k.GetPublicKey()).ToArray();
|
||||||
|
var derivation = derivationScheme.Derive(new KeyPath(0));
|
||||||
List<KeyPath> derivations = new List<KeyPath>();
|
List<KeyPath> derivations = new List<KeyPath>();
|
||||||
if (network.NBitcoinNetwork.Consensus.SupportSegwit)
|
if (network.NBitcoinNetwork.Consensus.SupportSegwit)
|
||||||
|
{
|
||||||
|
if (derivation.Redeem?.IsWitness is true ||
|
||||||
|
derivation.ScriptPubKey.IsWitness) // Native or p2sh segwit
|
||||||
derivations.Add(new KeyPath("49'"));
|
derivations.Add(new KeyPath("49'"));
|
||||||
derivations.Add(new KeyPath("44'"));
|
if (derivation.Redeem == null && derivation.ScriptPubKey.IsWitness) // Native segwit
|
||||||
derivations.Add(new KeyPath("84'"));
|
derivations.Add(new KeyPath("84'"));
|
||||||
|
}
|
||||||
|
derivations.Add(new KeyPath("44'"));
|
||||||
KeyPath foundKeyPath = null;
|
KeyPath foundKeyPath = null;
|
||||||
foreach (var account in
|
foreach (var account in
|
||||||
derivations
|
derivations
|
||||||
|
|||||||
Reference in New Issue
Block a user