aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-06-12 17:09:28 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-06-12 17:22:41 +0200
commitb0e5fbf6fad854ad03ce092ff5f1582166e5b24e (patch)
treeb2118c95f679857b2eac0200b3b79858460e1346 /test
parent6f3fbc062f97183f19a8551177371cc74a33351d (diff)
parentfbf485c9b2bf1d056bfea77345a15cf56a9cd786 (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 'test')
-rwxr-xr-xtest/functional/wallet_taproot.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/test/functional/wallet_taproot.py b/test/functional/wallet_taproot.py
index 65ca7bdef7..5803c0cf54 100755
--- a/test/functional/wallet_taproot.py
+++ b/test/functional/wallet_taproot.py
@@ -172,9 +172,9 @@ class WalletTaprootTest(BitcoinTestFramework):
"""Test generation and spending of P2TR address outputs."""
def set_test_params(self):
- self.num_nodes = 2
+ self.num_nodes = 3
self.setup_clean_chain = True
- self.extra_args = [['-keypool=100'], ['-keypool=100']]
+ self.extra_args = [['-keypool=100'], ['-keypool=100'], ["-vbparams=taproot:1:1"]]
self.supports_cli = False
def skip_test_if_missing_module(self):
@@ -230,12 +230,34 @@ class WalletTaprootTest(BitcoinTestFramework):
addr_r = self.make_addr(treefn, keys, i)
assert_equal(addr_g, addr_r)
+ # tr descriptors cannot be imported when Taproot is not active
+ result = self.privs_tr_enabled.importdescriptors([{"desc": desc, "timestamp": "now"}])
+ assert(result[0]["success"])
+ result = self.privs_tr_disabled.importdescriptors([{"desc": desc, "timestamp": "now"}])
+ assert(not result[0]["success"])
+ assert_equal(result[0]["error"]["code"], -4)
+ assert_equal(result[0]["error"]["message"], "Cannot import tr() descriptor when Taproot is not active")
+ result = self.pubs_tr_enabled.importdescriptors([{"desc": desc_pub, "timestamp": "now"}])
+ assert(result[0]["success"])
+ result = self.pubs_tr_disabled.importdescriptors([{"desc": desc_pub, "timestamp": "now"}])
+ assert(not result[0]["success"])
+ assert_equal(result[0]["error"]["code"], -4)
+ assert_equal(result[0]["error"]["message"], "Cannot import tr() descriptor when Taproot is not active")
+
def do_test(self, comment, pattern, privmap, treefn, nkeys):
keys = self.rand_keys(nkeys)
self.do_test_addr(comment, pattern, privmap, treefn, keys)
def run_test(self):
self.log.info("Creating wallets...")
+ self.nodes[0].createwallet(wallet_name="privs_tr_enabled", descriptors=True, blank=True)
+ self.privs_tr_enabled = self.nodes[0].get_wallet_rpc("privs_tr_enabled")
+ self.nodes[2].createwallet(wallet_name="privs_tr_disabled", descriptors=True, blank=True)
+ self.privs_tr_disabled=self.nodes[2].get_wallet_rpc("privs_tr_disabled")
+ self.nodes[0].createwallet(wallet_name="pubs_tr_enabled", descriptors=True, blank=True, disable_private_keys=True)
+ self.pubs_tr_enabled = self.nodes[0].get_wallet_rpc("pubs_tr_enabled")
+ self.nodes[2].createwallet(wallet_name="pubs_tr_disabled", descriptors=True, blank=True, disable_private_keys=True)
+ self.pubs_tr_disabled=self.nodes[2].get_wallet_rpc("pubs_tr_disabled")
self.nodes[0].createwallet(wallet_name="addr_gen", descriptors=True, disable_private_keys=True, blank=True)
self.addr_gen = self.nodes[0].get_wallet_rpc("addr_gen")