Repository navigation
p2wsh and p2sh-p2wsh address in decodescript - #12321
Conversation
|
Again I'm only considering the edge cases after clicking "create pull request".. What if the script contains a checksig with an uncompressed pubkey? |
|
@fivepiece feel free to add [WIP] to the title of your PR if its work in progress :) It's usually fine to open up a PR before its completely ready because other contributors might like to give feedback on the approach or high level concept ACK/NACKs regardless. Thanks for helping out! |
|
Cheers, title changed |
|
Ideas welcome, returning a p2wsh for a p2pk or multisig with an uncompressed pubkey can result in fund loss, then again |
|
concept ACK I think returning garbage is fine. It can be something unprovably unspendable even, and I don't think it's the job of this tool to check. Wonder if it's worth it to have it also return a p2sh-p2wsh version, in other words interpreting the script as a witnessscript, if applicable? |
|
Agreed. Keeping the simple check that this is not a bare witness program seems to be in line with the check above it not letting p2sh be re-encoded into p2sh. |
promag
left a comment
There was a problem hiding this comment.
Missing tests for new keys.
Doesn't make sense to move this to ScriptPubKeyToUniv?
|
@promag wouldn't moving this to I will be looking into adding tests as well. |
|
I've made some changes to this:
Various examples of the output can be seen here : Caveats :
|
03aefb2 to
d0164ba
Compare
|
This is pretty much a complete rewrite taking into account @sipa's suggestion (on irc) to use the same logic from
|
|
kicked travis.
hm? Your gist has examples that you could use. |
|
Specifically, I don't know how to assert that a value (say |
|
in python |
|
Ah, I was trying to bend |
|
Added tests for checking |
There was a problem hiding this comment.
could you generate this dynamically instead of hardcoding the long hex?
There was a problem hiding this comment.
could you generate this dynamically instead of hardcoding the long hex?
|
utACK 785bd02 I think you can squash almost all these commits. |
|
Cool, I'll squash it all into a single commit if this current change looks good, or two if it's better to separate work done on core from the tests. Let me know which is better. |
|
whatever's easier to you, 1 or 2 |
85a6a66 to
19272ef
Compare
|
Two commits now. No problem changing later on if needed. |
There was a problem hiding this comment.
just return r here. then remove the conditional later?
There was a problem hiding this comment.
Ah I see what you mean, looking into this.
1355786 to
4f933b3
Compare
|
Good call. All in a single commit now. |
|
re-utACK 4f933b3 |
| r.pushKV("p2sh", EncodeDestination(CScriptID(script))); | ||
| // P2SH and witness programs cannot be wrapped in P2WSH, if this script | ||
| // is a witness program, don't return addresses for a segwit programs. | ||
| if (type.get_str().find("witness") == std::string::npos) { |
There was a problem hiding this comment.
Searching for a string in the type name seems brittle - if we have to work with strings here (there seems to be no other accessible way) let's explicitly list the options. e.g. according to current selection that would be
"nonstandard"
"pubkey"
"pubkeyhash"
"scripthash"
"multisig"
"nulldata"
|
Updated to address @laanwj's comment |
|
Thank you |
41ff967 list the types of scripts we should consider for a witness program (fivepiece) 4f933b3 p2wpkh, p2wsh and p2sh-nested scripts in decodescript (fivepiece) Pull request description: Attempts to address #12244 . `p2wsh` addresses are returned only for scripts that are neither `p2sh` nor any witness program. Tree-SHA512: eb47f094c1a4c2ad2bcf27a8032307e43cf787d50bf739281aeb4101d97316a2f307b05118bf138298c937fa34e15f91436443a9b313f809fad2c43e94cd1831
Attempts to address #12244 .
p2wshaddresses are returned only for scripts that are neitherp2shnor any witness program.