From fbf485c9b2bf1d056bfea77345a15cf56a9cd786 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 4 Jun 2021 20:31:04 -0400 Subject: Allow tr() import only when Taproot is active To avoid issues around fund loss, only allow descriptor wallets to import tr() descriptors after taproot has activated. --- src/wallet/rpcdump.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/wallet') 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(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()) { -- cgit v1.2.3