diff options
author | W. J. van der Laan <laanwj@protonmail.com> | 2021-06-12 17:09:28 +0200 |
---|---|---|
committer | W. J. van der Laan <laanwj@protonmail.com> | 2021-06-12 17:22:41 +0200 |
commit | b0e5fbf6fad854ad03ce092ff5f1582166e5b24e (patch) | |
tree | b2118c95f679857b2eac0200b3b79858460e1346 /src/wallet | |
parent | 6f3fbc062f97183f19a8551177371cc74a33351d (diff) | |
parent | fbf485c9b2bf1d056bfea77345a15cf56a9cd786 (diff) |
Merge bitcoin/bitcoin#22156: Allow tr() import only when Taproot is active
fbf485c9b2bf1d056bfea77345a15cf56a9cd786 Allow tr() import only when Taproot is active (Andrew Chow)
Pull request description:
To avoid issues around fund loss, only allow descriptor wallets to import `tr()` descriptors after taproot has activated.
ACKs for top commit:
sipa:
utACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786
fjahr:
Code review ACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786
laanwj:
Code review ACK fbf485c9b2bf1d056bfea77345a15cf56a9cd786
prayank23:
utACK https://github.com/bitcoin/bitcoin/pull/22156/commits/fbf485c9b2bf1d056bfea77345a15cf56a9cd786
Tree-SHA512: 83c43376515eea523dbc89bc5a0fde53e54aec492e49a40c2a33d80fc94aac459e232ae07b024b4bd75b58078c8d090bc7a2d69541c5d3d4834d2f4cfc9c8208
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/rpcdump.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 726b13beac..4e9ba83ead 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -1530,6 +1530,18 @@ static UniValue ProcessDescriptorImport(CWallet& wallet, const UniValue& data, c } } + // Taproot descriptors cannot be imported if Taproot is not yet active. + // Check if this is a Taproot descriptor + CTxDestination dest; + ExtractDestination(scripts[0], dest); + if (std::holds_alternative<WitnessV1Taproot>(dest)) { + // Check if Taproot is active + if (!wallet.chain().isTaprootActive()) { + // Taproot is not active, raise an error + throw JSONRPCError(RPC_WALLET_ERROR, "Cannot import tr() descriptor when Taproot is not active"); + } + } + // If private keys are enabled, check some things. if (!wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { if (keys.keys.empty()) { |