-
Notifications
You must be signed in to change notification settings - Fork 0
add p2sh and segwit options to bitcoin-tx outscript command #10
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
Conversation
src/bitcoin-tx.cpp
Outdated
| strUsage += HelpMessageOpt("-create", _("Create new, empty TX.")); | ||
| strUsage += HelpMessageOpt("-json", _("Select JSON output")); | ||
| strUsage += HelpMessageOpt("-txid", _("Output only the hex-encoded transaction id of the resultant transaction.")); | ||
| strUsage += HelpMessageOpt("-segwit", _("Produce a segwit output.")); |
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.
Maybe 'Transform "outscript" commands to add a segwit output, instead.' - its a bit clearer whats going on then.
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.
So for instance would you rather transform the outscript command such that it accepts the following:
VALUE:SCRIPT:SEGWIT
VALUE:SCRIPT:P2SH
VALUE:SCRIPT:SEGWIT:P2SH
?
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.
Yea, that seems like a better API to me?
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.
ok I'll do that then
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'd prefer adding a single new field for all flags, ie:
VALUE:SCRIPT[:FLAGS]
where FLAGS can be:
Sfor P2WSH,Hfor P2SH andSHfor P2WSH wrapped in P2SH.
That makes the API more easily extensible if we want to add additional flags in future.
TheBlueMatt
left a comment
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.
Code looks good...kinda a strage API, though. Most of the API does exactly what the command was instead of having modifiers on what commands do. Still, not sure its incorrect, per se, so feel free to clarify the docs and PR upstream if you want more feedback.
|
One thought -- bitcoin#8499 introduces code to prevent addwitnessaddress from working with an uncompressed pubkey. Perhaps bitcoin-tx should be doing the same, if it can tell that you're using an uncompressed pubkey with a segwit output? Edit: meh, maybe not, i dunno... |
6bd35e5 to
1a27e46
Compare
|
@sdaftuar shouldn't that check be put into |
|
As discussed, this PR replicates the functionality of #5 . Rather than have two different PRs that implement different APIs for the same functionality, we should merge them before pushing upstream to bitcoin/bitcoin. |
| (pos == 0)) | ||
| // separate VALUE:SCRIPT(:SEGWIT)(:P2SH) | ||
| std::vector<std::string> vStrInput; | ||
| boost::split(vStrInput, strInput, boost::is_any_of(":")); |
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.
There seems to be a general move away from Boost (https://github.com/bitcoin/bitcoin/projects/3). Sadly, I don't think there's anything in c++11 as simple as boost::split for splitting a string (see RegisterSet() for another way of splitting the string).
It's probably cleaner to keep this as is, but you may want to consider doing it without boost.
|
I've added a couple of comments. Let me know once you've addressed those and squashed your commit. I'll merge the rest of my functionality on top and then we can open a PR to bitcoin/bitcoin. |
1a27e46 to
e3ffc53
Compare
|
@czzarr , as discussed this morning, I've updated the API and merged my changes into this branch. I've also added test cases covering all the new functionality. Are you happy for me to go ahead and open the PR against bitcoin/bitcoin? Note that I've rebased this branch and squashed your commits together, so you'll need to fetch the branch from origin and throw away your local changes. |
czzarr
left a comment
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.
What do you think of S as a flag for scripthash instead of H?
Also made two other small comments, lmk what you think.
Rest looks great, props for the tests.
src/bitcoin-tx.cpp
Outdated
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.
nit: should probably be called MutateTxAddOutMultiSig to stay inline with the rest of the nomenclature.
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.
Yes, agree.
src/bitcoin-tx.cpp
Outdated
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.
Question: do these options make sense for a pubkey output?
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.
Yes - as discussed, this is the way to create P2WPKH (since you need to input the pubkey, not the address for that) and P2WPKH wrapped in P2SH.
|
Agree - I'll change the option to be |
e3ffc53 to
c23fa1d
Compare
|
Thanks for the code review @czzarr. I've made suggested changes and squashed my commits. I'll open a PR against bitcoin/bitcoin. |
|
PR opened: bitcoin#8883 . Closing this PR. |
This adds the option of creating p2sh, segwit and segwit wrapped into p2sh outputs from
bitcoin-tx.This is a proof-of-concept, just to check that it's ok on principle.