|
20 | 20 | OP_NUMEQUAL, |
21 | 21 | taproot_construct, |
22 | 22 | ) |
| 23 | +from test_framework.segwit_addr import encode_segwit_address |
23 | 24 |
|
24 | 25 | # xprvs/xpubs, and m/* derived x-only pubkeys (created using independent implementation) |
25 | 26 | KEYS = [ |
@@ -182,6 +183,9 @@ def compute_taproot_address(pubkey, scripts): |
182 | 183 | """Compute the address for a taproot output with given inner key and scripts.""" |
183 | 184 | return output_key_to_p2tr(taproot_construct(pubkey, scripts).output_pubkey) |
184 | 185 |
|
| 186 | +def compute_raw_taproot_address(pubkey): |
| 187 | + return encode_segwit_address("bcrt", 1, pubkey) |
| 188 | + |
185 | 189 | class WalletTaprootTest(BitcoinTestFramework): |
186 | 190 | """Test generation and spending of P2TR address outputs.""" |
187 | 191 |
|
@@ -216,7 +220,12 @@ def make_addr(treefn, keys, i): |
216 | 220 | args = [] |
217 | 221 | for j in range(len(keys)): |
218 | 222 | 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 |
220 | 229 |
|
221 | 230 | def do_test_addr(self, comment, pattern, privmap, treefn, keys): |
222 | 231 | self.log.info("Testing %s address derivation" % comment) |
@@ -444,6 +453,12 @@ def run_test(self): |
444 | 453 | [True, False], |
445 | 454 | lambda k1, k2: (key(k2), [multi_a(1, ([H_POINT] * rnd_pos) + [k1] + ([H_POINT] * (MAX_PUBKEYS_PER_MULTI_A - 1 - rnd_pos)))]) |
446 | 455 | ) |
| 456 | + self.do_test( |
| 457 | + "rawtr(XPRV)", |
| 458 | + "rawtr($1/*)", |
| 459 | + [True], |
| 460 | + lambda k1: key(k1) |
| 461 | + ) |
447 | 462 |
|
448 | 463 | self.log.info("Sending everything back...") |
449 | 464 |
|
|
0 commit comments