aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2022-08-09 16:26:17 -0400
committerAndrew Chow <achow101-github@achow101.com>2022-08-09 16:36:00 -0400
commitac59112a6a093e641ce2803260dd9de97b1cd961 (patch)
tree0d5e7e69bd3ac628195cfad542bb95c607160494 /test
parentc012875b9ded0a5183602f002738ca823d559518 (diff)
parent544b4332f0e122167bdb94dc963405422faa30cb (diff)
downloadbitcoin-ac59112a6a093e641ce2803260dd9de97b1cd961.tar.xz
Merge bitcoin/bitcoin#23480: Add rawtr() descriptor for P2TR with specified (tweaked) output key
544b4332f0e122167bdb94dc963405422faa30cb Add wallet tests for spending rawtr() (Pieter Wuille) e1e3081200a71b6c9b0dcf236bc2a37ed1aa7552 If P2TR tweaked key is available, sign with it (Pieter Wuille) 8d9670ccb756592bddb2a269bf5078d62658537b Add rawtr() descriptor for P2TR with unknown tweak (Pieter Wuille) Pull request description: It may be useful to be able to represent P2TR outputs in descriptors whose script tree and/or internal key aren't known. This PR does that, by adding a `rawtr(KEY)` descriptor, where the KEY represents the output key directly. If the private key corresponding to that output key is known, it also permits signing with it. I'm not convinced this is desirable, but presumably "tr(KEY)" sounds more intended for direct use than "rawtr(KEY)". ACKs for top commit: achow101: ACK 544b4332f0e122167bdb94dc963405422faa30cb sanket1729: code review ACK 544b4332f0e122167bdb94dc963405422faa30cb w0xlt: reACK https://github.com/bitcoin/bitcoin/pull/23480/commits/544b4332f0e122167bdb94dc963405422faa30cb Tree-SHA512: 0de08de517468bc22ab0c00db471ce33144f5dc211ebc2974c6ea95709f44e830532ec5cdb0128c572513d352120bd651c4559516d4500b5b0a3d257c4b45aca
Diffstat (limited to 'test')
-rw-r--r--test/functional/data/rpc_decodescript.json2
-rwxr-xr-xtest/functional/wallet_taproot.py17
2 files changed, 17 insertions, 2 deletions
diff --git a/test/functional/data/rpc_decodescript.json b/test/functional/data/rpc_decodescript.json
index 8903f5efac..4a15ae8792 100644
--- a/test/functional/data/rpc_decodescript.json
+++ b/test/functional/data/rpc_decodescript.json
@@ -4,7 +4,7 @@
{
"asm": "1 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"address": "bcrt1pamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhqz6nvlh",
- "desc": "addr(bcrt1pamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhwamhqz6nvlh)#v52jnujz",
+ "desc": "rawtr(eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee)#jk7c6kys",
"type": "witness_v1_taproot"
}
],
diff --git a/test/functional/wallet_taproot.py b/test/functional/wallet_taproot.py
index c8d4a1da45..3c630ba433 100755
--- a/test/functional/wallet_taproot.py
+++ b/test/functional/wallet_taproot.py
@@ -20,6 +20,7 @@ from test_framework.script import (
OP_NUMEQUAL,
taproot_construct,
)
+from test_framework.segwit_addr import encode_segwit_address
# xprvs/xpubs, and m/* derived x-only pubkeys (created using independent implementation)
KEYS = [
@@ -182,6 +183,9 @@ def compute_taproot_address(pubkey, 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)
+def compute_raw_taproot_address(pubkey):
+ return encode_segwit_address("bcrt", 1, pubkey)
+
class WalletTaprootTest(BitcoinTestFramework):
"""Test generation and spending of P2TR address outputs."""
@@ -216,7 +220,12 @@ class WalletTaprootTest(BitcoinTestFramework):
args = []
for j in range(len(keys)):
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):
self.log.info("Testing %s address derivation" % comment)
@@ -444,6 +453,12 @@ class WalletTaprootTest(BitcoinTestFramework):
[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)))])
)
+ self.do_test(
+ "rawtr(XPRV)",
+ "rawtr($1/*)",
+ [True],
+ lambda k1: key(k1)
+ )
self.log.info("Sending everything back...")