mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +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 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,
|
||||
derivationSettings.AccountDerivation.GetExtPubKeys().Select(p => p.GetPublicKey()).ToArray(),
|
||||
var foundKeyPath = await hw.FindKeyPathFromDerivation(network,
|
||||
derivationSettings.AccountDerivation,
|
||||
normalOperationTimeout.Token);
|
||||
derivationSettings.AccountKeyPath = foundKeyPath ?? throw new HardwareWalletException($"This store is not configured to use this ledger");
|
||||
storeData.SetSupportedPaymentMethod(derivationSettings);
|
||||
|
||||
@@ -31,13 +31,20 @@ namespace BTCPayServer.Services
|
||||
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>();
|
||||
if (network.NBitcoinNetwork.Consensus.SupportSegwit)
|
||||
derivations.Add(new KeyPath("49'"));
|
||||
{
|
||||
if (derivation.Redeem?.IsWitness is true ||
|
||||
derivation.ScriptPubKey.IsWitness) // Native or p2sh segwit
|
||||
derivations.Add(new KeyPath("49'"));
|
||||
if (derivation.Redeem == null && derivation.ScriptPubKey.IsWitness) // Native segwit
|
||||
derivations.Add(new KeyPath("84'"));
|
||||
}
|
||||
derivations.Add(new KeyPath("44'"));
|
||||
derivations.Add(new KeyPath("84'"));
|
||||
KeyPath foundKeyPath = null;
|
||||
foreach (var account in
|
||||
derivations
|
||||
|
||||
Reference in New Issue
Block a user