mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Make sure we don't confuse user between derivation scheme of coldcard or btcpay
This commit is contained in:
parent
f2da64adad
commit
836c3a5b3a
2 changed files with 5 additions and 2 deletions
|
@ -53,7 +53,7 @@ namespace BTCPayServer
|
|||
return new DirectDerivationStrategy(extPubKey) { Segwit = true };
|
||||
if (labels[0] == "legacy")
|
||||
return new DirectDerivationStrategy(extPubKey) { Segwit = false };
|
||||
if (labels[0] == "p2sh")
|
||||
if (labels[0] == "p2sh") // segwit p2sh
|
||||
return new DerivationStrategyFactory(Network).Parse(extPubKey.ToString() + "-[p2sh]");
|
||||
throw new FormatException();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace BTCPayServer
|
|||
if (network == null)
|
||||
throw new ArgumentNullException(nameof(network));
|
||||
var result = new DerivationSchemeSettings();
|
||||
result.Source = "Coldcard";
|
||||
var derivationSchemeParser = new DerivationSchemeParser(network.NBitcoinNetwork);
|
||||
JObject jobj = null;
|
||||
try
|
||||
|
@ -48,6 +49,8 @@ namespace BTCPayServer
|
|||
{
|
||||
result.AccountOriginal = jobj["xpub"].Value<string>().Trim();
|
||||
result.AccountDerivation = derivationSchemeParser.ParseElectrum(result.AccountOriginal);
|
||||
if (result.AccountDerivation is DirectDerivationStrategy direct && !direct.Segwit)
|
||||
result.AccountOriginal = null; // Saving this would be confusing for user, as xpub of electrum is legacy derivation, but for btcpay, it is segwit derivation
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -109,7 +112,7 @@ namespace BTCPayServer
|
|||
}
|
||||
[JsonIgnore]
|
||||
public BTCPayNetwork Network { get; set; }
|
||||
|
||||
public string Source { get; set; }
|
||||
public KeyPath AccountKeyPath { get; set; }
|
||||
|
||||
public DerivationStrategyBase AccountDerivation { get; set; }
|
||||
|
|
Loading…
Add table
Reference in a new issue