Skip to content

Commit 544b433

Browse files
committed
Add wallet tests for spending rawtr()
1 parent e1e3081 commit 544b433

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/functional/wallet_taproot.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
OP_NUMEQUAL,
2121
taproot_construct,
2222
)
23+
from test_framework.segwit_addr import encode_segwit_address
2324

2425
# xprvs/xpubs, and m/* derived x-only pubkeys (created using independent implementation)
2526
KEYS = [
@@ -182,6 +183,9 @@ def compute_taproot_address(pubkey, scripts):
182183
"""Compute the address for a taproot output with given inner key and scripts."""
183184
return output_key_to_p2tr(taproot_construct(pubkey, scripts).output_pubkey)
184185

186+
def compute_raw_taproot_address(pubkey):
187+
return encode_segwit_address("bcrt", 1, pubkey)
188+
185189
class WalletTaprootTest(BitcoinTestFramework):
186190
"""Test generation and spending of P2TR address outputs."""
187191

@@ -216,7 +220,12 @@ def make_addr(treefn, keys, i):
216220
args = []
217221
for j in range(len(keys)):
218222
args.append(keys[j]['pubs'][i])
219-
return compute_taproot_address(*treefn(*args))
223+
tree = treefn(*args)
224+
if isinstance(tree, tuple):
225+
return compute_taproot_address(*tree)
226+
if isinstance(tree, bytes):
227+
return compute_raw_taproot_address(tree)
228+
assert False
220229

221230
def do_test_addr(self, comment, pattern, privmap, treefn, keys):
222231
self.log.info("Testing %s address derivation" % comment)
@@ -444,6 +453,12 @@ def run_test(self):
444453
[True, False],
445454
lambda k1, k2: (key(k2), [multi_a(1, ([H_POINT] * rnd_pos) + [k1] + ([H_POINT] * (MAX_PUBKEYS_PER_MULTI_A - 1 - rnd_pos)))])
446455
)
456+
self.do_test(
457+
"rawtr(XPRV)",
458+
"rawtr($1/*)",
459+
[True],
460+
lambda k1: key(k1)
461+
)
447462

448463
self.log.info("Sending everything back...")
449464

0 commit comments

Comments
 (0)