Add support for inferring tr() descriptors#22166
Add support for inferring tr() descriptors#22166meshcollider merged 3 commits intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
achow101
left a comment
There was a problem hiding this comment.
ACK 77466ae5c58b4a46e545d3d24521fa635f7b8fbe
|
ACK f9d6f9a52c61833bbc5c611ff6a3e59066e1c92f |
|
Reviewed that the consensus commit (e3739fb3b042c3805b5b6357f6f79df787d11144) is a pure refactor. Code review ACK 13c6ab699eb6906c6554b4319a377c33fa0d157f |
|
re-ACK 13c6ab699eb6906c6554b4319a377c33fa0d157f |
src/script/descriptor.cpp
Outdated
There was a problem hiding this comment.
I would have a slight preference to use constants here instead of hardcoding 0x02 (and 0x03 below) and 33.
There was a problem hiding this comment.
I agree with this, but prefer keeping it for a follow-up. There are several places where this is already done, and I'd like to introduce constants for it, as well as using them everywhere in the same PR - doing so here would be a distraction.
3f2ffb2 to
8349355
Compare
|
Addressed some comments, and also made this observable change: if (permit_uncompressed || key.IsCompressed()) {
CPubKey pubkey = key.GetPubKey();
out.keys.emplace(pubkey.GetID(), key);
- return std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey);
+ return std::make_unique<ConstPubkeyProvider>(key_exp_index, pubkey, ctx == ParseScriptContext::P2TR);
} else {Which will make descriptors with a provided private key inside |
|
re-ACK 834935511c2c799c8cb2312d617dbed6336000c4 |
|
It's too hot here to review code, but I can confirm that this correctly infers my |
Same, I propose we postpone the feature freeze a bit. Not able to concentrate at the moment. |
Sjors
left a comment
There was a problem hiding this comment.
tACK 8349355
However I glanced over InferTaprootTree. I think it would help to include tests for the various problems that function is checking for.
src/script/descriptor.cpp
Outdated
There was a problem hiding this comment.
834935511c2c799c8cb2312d617dbed6336000c4: rather than failing, could we return raw() (at least for leaf_ver == TAPROOT_LEAF_TAPSCRIPT)? That can wait for a followup though, since we can't have tr() descriptors with raw leaves in the wallet anyway atm, and raw() is still limited to the top level.
There was a problem hiding this comment.
I think that's exactly what this code does.
|
Rebased, will work on adding some tests for failure cases of |
|
@Sjors Oops, thanks for catching that. I redid the rebase; does it look better now? |
|
re-ACK d637a9b Rebase looks good. |
|
re-utACK d637a9b Much better |
meshcollider
left a comment
There was a problem hiding this comment.
Code review ACK d637a9b
| std::vector<std::tuple<int, CScript, int>> ret; | ||
| if (spenddata.merkle_root.IsNull()) return ret; | ||
|
|
||
| /** Data structure to represent the nodes of the tree we're going to be build. */ |
There was a problem hiding this comment.
touched up the various nits in #22323, feel free to add any others there
|
|
||
| /** Data structure to represent the nodes of the tree we're going to be build. */ | ||
| struct TreeNode { | ||
| /** Hash of this none, if known; 0 otherwise. */ |
| bool done = false; | ||
| }; | ||
|
|
||
| // Build tree from the provides branches. |
184d453 script, doc: spelling update (Jon Atack) Pull request description: Clears out the report from `test/lint/lint-spelling.sh` and touches up the leftover nits in bitcoin/bitcoin#22166 (review). Happy to add any others people are aware of. ACKs for top commit: MarcoFalke: cr ACK 184d453 Sjors: utACK 184d453 Tree-SHA512: 3b0ef6bd5ff227363b0bda79eeb66763151c74f607bc3a2a7bfe7823e3eef196587bccfe639e714e8e27b918ba57e8317eda06f225143c32c736685087dbcd24
184d453 script, doc: spelling update (Jon Atack) Pull request description: Clears out the report from `test/lint/lint-spelling.sh` and touches up the leftover nits in bitcoin#22166 (review). Happy to add any others people are aware of. ACKs for top commit: MarcoFalke: cr ACK 184d453 Sjors: utACK 184d453 Tree-SHA512: 3b0ef6bd5ff227363b0bda79eeb66763151c74f607bc3a2a7bfe7823e3eef196587bccfe639e714e8e27b918ba57e8317eda06f225143c32c736685087dbcd24
08f57a0 Assert that IsComplete() in GetSpendData() (Pieter Wuille) d8f4b97 Remove default nHashTypeIn arguments to MutableTransactionSignatureCreator (Pieter Wuille) c7048aa Simplify SignTransaction precomputation loop (Pieter Wuille) addb9b5 Improve comments in taproot signing logic (Pieter Wuille) Pull request description: This addresses a few review comments from #21365 that were left at the time of merge (as well as some from #22166 applying to the commit it shared with #21365). I do not think any are blockers for a 22.0 release. ACKs for top commit: theStack: re-ACK 08f57a0 🌴 Zero-1729: crACK 08f57a0 jonatack: Code review ACK 08f57a0 per `git range-diff e9d6eb1 9336670 08f57a0` followed by re-code review per commit to swap context back into memory and debug build/run unit tests + feature_taproot.py as a sanity check Tree-SHA512: 968750109ba8d6faf3016035a38f81c6aefb724c632a3cab0bbf43cf31b9d187b6b0fddd8772768f57338df11eb07ab9c4c6dacdf3cf35b71f29699c67a301ea
08f57a0 Assert that IsComplete() in GetSpendData() (Pieter Wuille) d8f4b97 Remove default nHashTypeIn arguments to MutableTransactionSignatureCreator (Pieter Wuille) c7048aa Simplify SignTransaction precomputation loop (Pieter Wuille) addb9b5 Improve comments in taproot signing logic (Pieter Wuille) Pull request description: This addresses a few review comments from bitcoin#21365 that were left at the time of merge (as well as some from bitcoin#22166 applying to the commit it shared with bitcoin#21365). I do not think any are blockers for a 22.0 release. ACKs for top commit: theStack: re-ACK 08f57a0 🌴 Zero-1729: crACK 08f57a0 jonatack: Code review ACK 08f57a0 per `git range-diff e9d6eb1 9336670 08f57a0` followed by re-code review per commit to swap context back into memory and debug build/run unit tests + feature_taproot.py as a sanity check Tree-SHA512: 968750109ba8d6faf3016035a38f81c6aefb724c632a3cab0bbf43cf31b9d187b6b0fddd8772768f57338df11eb07ab9c4c6dacdf3cf35b71f29699c67a301ea
| } | ||
|
|
||
| static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, const std::vector<unsigned char>& program, const CScript& script, uint256& tapleaf_hash) | ||
| uint256 ComputeTapleafHash(uint8_t leaf_version, const CScript& script) |
There was a problem hiding this comment.
I mildly object the the use of the type CScript here. While it is true that BIP-341 names this stack item "script", this value is only interpreted as a CScript in the case of BIP-342 where the leaf_version is equal to TAPROOT_LEAF_TAPSCRIPT (modulo TAPROOT_LEAF_MASK). Otherwise it is simply a bytestring.
Includes:
getaddressinforeport tr() descriptors as solvable (so that inferred descriptors are shown), despite not having signing code for them.