mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Add wallet tests for spending rawtr()
This commit is contained in:
parent
e1e3081200
commit
544b4332f0
1 changed files with 16 additions and 1 deletions
|
@ -20,6 +20,7 @@ from test_framework.script import (
|
||||||
OP_NUMEQUAL,
|
OP_NUMEQUAL,
|
||||||
taproot_construct,
|
taproot_construct,
|
||||||
)
|
)
|
||||||
|
from test_framework.segwit_addr import encode_segwit_address
|
||||||
|
|
||||||
# xprvs/xpubs, and m/* derived x-only pubkeys (created using independent implementation)
|
# xprvs/xpubs, and m/* derived x-only pubkeys (created using independent implementation)
|
||||||
KEYS = [
|
KEYS = [
|
||||||
|
@ -182,6 +183,9 @@ def compute_taproot_address(pubkey, scripts):
|
||||||
"""Compute the address for a taproot output with given inner key and scripts."""
|
"""Compute the address for a taproot output with given inner key and scripts."""
|
||||||
return output_key_to_p2tr(taproot_construct(pubkey, scripts).output_pubkey)
|
return output_key_to_p2tr(taproot_construct(pubkey, scripts).output_pubkey)
|
||||||
|
|
||||||
|
def compute_raw_taproot_address(pubkey):
|
||||||
|
return encode_segwit_address("bcrt", 1, pubkey)
|
||||||
|
|
||||||
class WalletTaprootTest(BitcoinTestFramework):
|
class WalletTaprootTest(BitcoinTestFramework):
|
||||||
"""Test generation and spending of P2TR address outputs."""
|
"""Test generation and spending of P2TR address outputs."""
|
||||||
|
|
||||||
|
@ -216,7 +220,12 @@ class WalletTaprootTest(BitcoinTestFramework):
|
||||||
args = []
|
args = []
|
||||||
for j in range(len(keys)):
|
for j in range(len(keys)):
|
||||||
args.append(keys[j]['pubs'][i])
|
args.append(keys[j]['pubs'][i])
|
||||||
return compute_taproot_address(*treefn(*args))
|
tree = treefn(*args)
|
||||||
|
if isinstance(tree, tuple):
|
||||||
|
return compute_taproot_address(*tree)
|
||||||
|
if isinstance(tree, bytes):
|
||||||
|
return compute_raw_taproot_address(tree)
|
||||||
|
assert False
|
||||||
|
|
||||||
def do_test_addr(self, comment, pattern, privmap, treefn, keys):
|
def do_test_addr(self, comment, pattern, privmap, treefn, keys):
|
||||||
self.log.info("Testing %s address derivation" % comment)
|
self.log.info("Testing %s address derivation" % comment)
|
||||||
|
@ -444,6 +453,12 @@ class WalletTaprootTest(BitcoinTestFramework):
|
||||||
[True, False],
|
[True, False],
|
||||||
lambda k1, k2: (key(k2), [multi_a(1, ([H_POINT] * rnd_pos) + [k1] + ([H_POINT] * (MAX_PUBKEYS_PER_MULTI_A - 1 - rnd_pos)))])
|
lambda k1, k2: (key(k2), [multi_a(1, ([H_POINT] * rnd_pos) + [k1] + ([H_POINT] * (MAX_PUBKEYS_PER_MULTI_A - 1 - rnd_pos)))])
|
||||||
)
|
)
|
||||||
|
self.do_test(
|
||||||
|
"rawtr(XPRV)",
|
||||||
|
"rawtr($1/*)",
|
||||||
|
[True],
|
||||||
|
lambda k1: key(k1)
|
||||||
|
)
|
||||||
|
|
||||||
self.log.info("Sending everything back...")
|
self.log.info("Sending everything back...")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue