mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-18 19:47:53 +02:00
Merge bitcoin/bitcoin#22166: Add support for inferring tr() descriptors
d637a9b397Taproot descriptor inference (Pieter Wuille)c7388e5adaReport address as solvable based on inferred descriptor (Pieter Wuille)29e5dd1a5bconsensus refactor: extract ComputeTapleafHash, ComputeTaprootMerkleRoot (Pieter Wuille) Pull request description: Includes: * First commit from #21365, adding TaprootSpendData in SigningProvider * A refactor to expose ComputeTapleafHash and ComputeTaprootMerkleRoot from script/interpreter * A tiny change to make `getaddressinfo` report tr() descriptors as solvable (so that inferred descriptors are shown), despite not having signing code for them. * Logic to infer the script tree back from TaprootSpendData, and then use that to infer descriptors. ACKs for top commit: achow101: re-ACKd637a9b397Sjors: re-utACKd637a9bmeshcollider: Code review ACKd637a9b397Tree-SHA512: 5ab9b95da662382d8549004be4a1297a577d7caca6b068f875c7c9343723931d03fa9cbf133de11f83b74e4851490ce820fb80413c77b9e8495a5f812e505d86
This commit is contained in:
@@ -230,6 +230,12 @@ class WalletTaprootTest(BitcoinTestFramework):
|
||||
if treefn is not None:
|
||||
addr_r = self.make_addr(treefn, keys, i)
|
||||
assert_equal(addr_g, addr_r)
|
||||
desc_a = self.addr_gen.getaddressinfo(addr_g)['desc']
|
||||
if desc.startswith("tr("):
|
||||
assert desc_a.startswith("tr(")
|
||||
rederive = self.nodes[1].deriveaddresses(desc_a)
|
||||
assert_equal(len(rederive), 1)
|
||||
assert_equal(rederive[0], addr_g)
|
||||
|
||||
# tr descriptors cannot be imported when Taproot is not active
|
||||
result = self.privs_tr_enabled.importdescriptors([{"desc": desc, "timestamp": "now"}])
|
||||
@@ -374,6 +380,20 @@ class WalletTaprootTest(BitcoinTestFramework):
|
||||
None,
|
||||
2
|
||||
)
|
||||
self.do_test(
|
||||
"tr(XPRV,{XPUB,XPUB})",
|
||||
"tr($1/*,{pk($2/*),pk($2/*)})",
|
||||
[True, False],
|
||||
lambda k1, k2: (key(k1), [pk(k2), pk(k2)]),
|
||||
2
|
||||
)
|
||||
self.do_test(
|
||||
"tr(XPRV,{{XPUB,H},{H,XPUB}})",
|
||||
"tr($1/*,{{pk($2/*),pk($H)},{pk($H),pk($2/*)}})",
|
||||
[True, False],
|
||||
lambda k1, k2: (key(k1), [[pk(k2), pk(H_POINT)], [pk(H_POINT), pk(k2)]]),
|
||||
2
|
||||
)
|
||||
self.do_test(
|
||||
"tr(XPUB,{{H,{H,XPUB}},{H,{H,{H,XPRV}}}})",
|
||||
"tr($1/*,{{pk($H),{pk($H),pk($2/*)}},{pk($H),{pk($H),{pk($H),pk($3/*)}}}})",
|
||||
@@ -381,6 +401,13 @@ class WalletTaprootTest(BitcoinTestFramework):
|
||||
lambda k1, k2, k3: (key(k1), [[pk(H_POINT), [pk(H_POINT), pk(k2)]], [pk(H_POINT), [pk(H_POINT), [pk(H_POINT), pk(k3)]]]]),
|
||||
3
|
||||
)
|
||||
self.do_test(
|
||||
"tr(XPRV,{XPUB,{{XPUB,{H,H}},{{H,H},XPUB}}})",
|
||||
"tr($1/*,{pk($2/*),{{pk($2/*),{pk($H),pk($H)}},{{pk($H),pk($H)},pk($2/*)}}})",
|
||||
[True, False],
|
||||
lambda k1, k2: (key(k1), [pk(k2), [[pk(k2), [pk(H_POINT), pk(H_POINT)]], [[pk(H_POINT), pk(H_POINT)], pk(k2)]]]),
|
||||
2
|
||||
)
|
||||
|
||||
self.log.info("Sending everything back...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user