-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
descriptors: define script_code() for legacy outputs #127
descriptors: define script_code() for legacy outputs #127
Conversation
I still need to push some tests for legacy but it's based on https://github.com/bitcoin/bitcoin/blob/1cf73fb8eba3b89a30d5e943deaec5052a8b21b7/src/script/interpreter.cpp#L1586: what is called For witness programs it's special cased in |
236bcf5
to
5718bea
Compare
Now, this function is same as |
No it's not for |
Ah yes, you are right! I think the API(and the doc-comment) for |
Yep, the doccomment for |
// The item 5: | ||
// - For P2WPKH witness program, the scriptCode is `0x1976a914{20-byte-pubkey-hash}88ac`. | ||
Descriptor::Wpkh(ref pk) | Descriptor::ShWpkh(ref pk) => { | ||
let addr = bitcoin::Address::p2pkh(&pk.to_public_key(), bitcoin::Network::Bitcoin); | ||
Ok(addr.script_pubkey()) | ||
addr.script_pubkey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we update rust-bitcoin to get rust-bitcoin/rust-bitcoin#387 we won't need to do this silly round-trip-through-Address
business.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it make it into rust-bitcoin before the upcoming version bump ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before which version bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust-bitcoin ? Nevermind got my answer rust-bitcoin/rust-bitcoin#475 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so let's get rust-bitcoin bumped, then we'll update rust-miniscript and then update this PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think actually we shuold merge this now then do a general fixup where we remove all the uses of bitcoin::Address
in this crate (there are a few of them) when we were just trying to compute scriptpubkeys.
This fixes the incorrect assumption made in 283676e that the `scriptCode` was defined in bip-0143. Reported-by: Andrew Poelstra <apoelstra@wpsoftware.net> Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
5718bea
to
8582c17
Compare
FWIW this semantic divergence wrt witness_script seems to be about to be resolved as bitcoind is likely to call it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack 8582c17
This fixes my confusion in #123 that @apoelstra pointed out.