Basic Taproot derivation support for descriptors#22051
Merged
laanwj merged 9 commits intobitcoin:masterfrom Jun 3, 2021
Merged
Basic Taproot derivation support for descriptors#22051laanwj merged 9 commits intobitcoin:masterfrom
laanwj merged 9 commits intobitcoin:masterfrom
Conversation
This is just a small simplification to prepare for the follow-up instruction
of a CTxDestination variant for taproot outputs.
In the old code, WITNESS_V1_TAPROOT and WITNESS_UNKNOWN both produced
{version, program} as Solver() output. Change this so that WITNESS_V1_TAPROOT
produces just {program}, like WITNESS_V0_* do.
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking).
This class functions as a utility for building taproot outputs, from internal key and script leaves.
This adds a new descriptor with syntax e.g. tr(KEY,{S1,{{S2,S3},S4})
where KEY is a key expression for the internal key and S_i are
script expression for the leaves. They have to be organized in
nested {A,B} groups, with exactly two elements.
tr() only exists at the top level, and inside the script expressions
only pk() scripts are allowed for now.
208138b to
2667366
Compare
Member
|
utACK 2667366 (based on #21365 (comment) review, plus the new functional test) |
lsilva01
reviewed
May 29, 2021
fjahr
reviewed
May 31, 2021
Member
|
Code Review ACK 2667366 |
sidhujag
pushed a commit
to syscoin/syscoin
that referenced
this pull request
Jun 3, 2021
fjahr
reviewed
Jun 6, 2021
| std::holds_alternative<WitnessUnknown>(dest)) { | ||
| return OutputType::BECH32; | ||
| } | ||
| return std::nullopt; |
Contributor
There was a problem hiding this comment.
nit: could add a comment that this is for CNoDestination.
| return obj; | ||
| } | ||
|
|
||
| UniValue operator()(const WitnessV1Taproot& id) const { return UniValue(UniValue::VOBJ); } |
Contributor
There was a problem hiding this comment.
nit: param seems to be named tap everywhere else
jnewbery
reviewed
Jun 8, 2021
Comment on lines
+190
to
+201
| @staticmethod | ||
| def rand_keys(n): | ||
| ret = [] | ||
| idxes = set() | ||
| for _ in range(n): | ||
| while True: | ||
| i = random.randrange(len(KEYS)) | ||
| if not i in idxes: | ||
| break | ||
| idxes.add(i) | ||
| ret.append(KEYS[i]) | ||
| return ret |
Contributor
There was a problem hiding this comment.
I think this can be replaced with set(random.sample(KEYS, k=n))
meshcollider
added a commit
that referenced
this pull request
Jun 17, 2021
458a345 Add support for SIGHASH_DEFAULT in RPCs, and make it default (Pieter Wuille) c0f0c8e tests: check spending of P2TR (Pieter Wuille) a238012 Basic Taproot signing logic in script/sign.cpp (Pieter Wuille) 49487bc Make GetInputUTXO safer: verify non-witness UTXO match (Pieter Wuille) fd3f689 Construct and use PrecomputedTransactionData in PSBT signing (Pieter Wuille) 5cb6502 Construct and use PrecomputedTransactionData in SignTransaction (Pieter Wuille) 5d2e224 Don't nuke witness data when signing fails (Pieter Wuille) ce93531 Permit full precomputation in PrecomputedTransactionData (Pieter Wuille) e841fb5 Add precomputed txdata support to MutableTransactionSignatureCreator (Pieter Wuille) a91d532 Add CKey::SignSchnorr function for BIP 340/341 signing (Pieter Wuille) e77a283 Use HandleMissingData also in CheckSchnorrSignature (Pieter Wuille) dbb0ce9 Add TaprootSpendData data structure, equivalent to script map for P2[W]SH (Pieter Wuille) Pull request description: Builds on top of #22051, adding signing support after derivation support. Nothing is changed in descriptor features. Signing works for key path and script path spending, through the normal sending functions, and PSBT-based RPCs. However, PSBT usability is rather low as no extensions have been defined to convey Taproot-specific information, so all script information must be known to the signing wallet. ACKs for top commit: achow101: re-ACK 458a345 fjahr: Code review ACK 458a345 Sjors: ACK 458a345 Tree-SHA512: 30ed212cf7754763a4a81624ebc084c51727b8322711ac0b390369213c1a891d367ed8b123882ac08c99595320c11ec57ee42304ff22a69afdc3d1a0d55cc711
apoelstra
pushed a commit
to apoelstra/elements
that referenced
this pull request
Aug 19, 2021
apoelstra
added a commit
to apoelstra/elements
that referenced
this pull request
Aug 19, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
apoelstra
added a commit
to apoelstra/elements
that referenced
this pull request
Aug 19, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 19, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 23, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 24, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 24, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 24, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 24, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 24, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 24, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
bitcoin/bitcoin#22051 (6/9) Modified to use the old-style Optional rather than std::optional
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
sanket1729
pushed a commit
to sanket1729/elements
that referenced
this pull request
Aug 25, 2021
That results in a much safer interface (making the tweak commit to the key implicitly using a fixed tag means it can't be used for unrelated tweaking). bitcoin/bitcoin#22051 (5/9) We actually preserve the "unrelated tweaking" method so we can use it in OP_TWEAKVERIFY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a subset of #21365, to aide review.
This adds support
tr(KEY)ortr(KEY,SCRIPT)ortr(KEY,{{S1,{{S2,S3},...}},...})descriptors, describing Taproot outputs with specified internal key, and optionally any number of scripts, in nested groups of 2 inside{/}if there are more than one. While it permits importingtr(KEY), anything beyond that is just laying foundations for more features later.Missing:
pk(KEY)is supported for now). In particular, a multisig policy based on the newOP_CHECKSIGADDopcode would be very useful.tr()descriptors from outputs (given sufficient information).getaddressinfosupport.