Add all standard TXO types to bitcoin-tx - #5
Conversation
|
@czzarr do you mind code reviewing this for me? I think that passing the |
czzarr
left a comment
There was a problem hiding this comment.
I'm not sure exactly I understand how you split the different functions. For instance, a P2SH should always be a P2SH, whether it wraps a segwit output or not. I think maybe a way to deal with that would be to add P2SH as a step instead of an alternative.
| CBitcoinAddress addr(script); | ||
| scriptPubKey = GetScriptForDestination(addr.Get()); | ||
| } | ||
| else if (paytowitnessscripthash) { |
There was a problem hiding this comment.
I think technically this is not an if/else situation. You should be able to wrap your P2WSH in a P2SH.
There was a problem hiding this comment.
Yes, it's possible to create a P2WSH wrapped in a P2SH, but I haven't implemented that in bitcoin-tx. If you think that's going to be useful, you could add separate commands for:
- multisig in P2WSH wrapped in P2SH
- any script in P2WSH wrapped in P2SH
- P2WPK wrapped in P2SH
I don't think there's much use case for this, but feel free to create an additional PR on top of this if you think it'd be useful.
| // This could either refer to the scriptPubKey (for a bare pay-to-script) | ||
| // or the redeem script (for a P2SH or P2WSH) | ||
|
|
||
| if (paytoscripthash) { |
There was a problem hiding this comment.
I don't understand why you need this, it is a given that it is a scripthash output (from the arguments).
There was a problem hiding this comment.
as discussed, this function MutateTxAddOutScript() can be used to add the following kinds of TXO:
- bare script
- P2SH
- P2WSH
Currently, bitcoin-tx can only create bare script outputs. This flag paytoscripthash is used to signal that the TXO should be P2SH rather than a pay to script.
|
I've now merged all functionality into #10 . Closing this PR. |
bitcoin-tx can currently create transactions with the following TXO types:
This PR enhances bitcoin-tx so all remaining standard TXO types can be created: