mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-23 15:14:49 +01:00
Taproot support for wallets (#2830)
* Support taproot for HotWallet * Support taproot for hardware wallets * Fix NBX version * Undo formatting * Do not show Taproot when not supported * Create taproot wallet from xpub * Bug Fix
This commit is contained in:
@@ -222,7 +222,21 @@ namespace BTCPayServer.Controllers
|
||||
continue;
|
||||
}
|
||||
|
||||
if (addressType == "segwit")
|
||||
if (!network.NBitcoinNetwork.Consensus.SupportTaproot && addressType == "taproot")
|
||||
{
|
||||
await websocketHelper.Send("{ \"error\": \"taproot-notsupported\"}", cancellationToken);
|
||||
continue;
|
||||
}
|
||||
if (addressType == "taproot")
|
||||
{
|
||||
keyPath = new KeyPath("86'").Derive(network.CoinType).Derive(accountNumber, true);
|
||||
xpub = await device.GetXPubAsync(keyPath);
|
||||
strategy = factory.CreateDirectDerivationStrategy(xpub, new DerivationStrategyOptions()
|
||||
{
|
||||
ScriptPubKeyType = ScriptPubKeyType.TaprootBIP86
|
||||
});
|
||||
}
|
||||
else if (addressType == "segwit")
|
||||
{
|
||||
keyPath = new KeyPath("84'").Derive(network.CoinType).Derive(accountNumber, true);
|
||||
xpub = await device.GetXPubAsync(keyPath);
|
||||
@@ -337,6 +351,8 @@ askdevice:
|
||||
private ScriptPubKeyType GetScriptPubKeyType(RootedKeyPath keyPath)
|
||||
{
|
||||
var path = keyPath.KeyPath.ToString();
|
||||
if (path.StartsWith("86'", StringComparison.OrdinalIgnoreCase))
|
||||
return ScriptPubKeyType.TaprootBIP86;
|
||||
if (path.StartsWith("84'", StringComparison.OrdinalIgnoreCase))
|
||||
return ScriptPubKeyType.Segwit;
|
||||
if (path.StartsWith("49'", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
Reference in New Issue
Block a user