-
Notifications
You must be signed in to change notification settings - Fork 34
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
Pset roundtrip fix #184
Pset roundtrip fix #184
Conversation
0518dc4
to
9798e51
Compare
Need to fix the CI for serde errors, however, I would like to have feedback on the approach |
2691615
to
a31f5b8
Compare
TxOut is encoded/decoded without the witness, it is handled separetely during transaction encoding/decoding (segwit). For PSET the TxOut encoding is reused but in this case the witness is not handled separately. This commit introduce TxOutWithWitness which is logically a TxOut with the exception that also the witness is encoded/decoded. 4 Existing tests breaks with this change because they are using string test vectors not containing the witness. To avoid too many changes this tests are temporary ignored, they will be re-added in following commit in the same PR.
pset_swap_tutorial test vector is updated with the updated serialization of TxOutWithWitness. Note the old test vector doesn't contain a input.witness_utxo.witness but the changed encoding require to find an empty value there. To achieve so, decode of TxOutWitness has been temporary changed to skip the witness decoding, the parsed PSET is then encoded with the updated encoding. The result is then used as `pset_swap_tutorial.hex`
a31f5b8
to
676b789
Compare
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.
Concept ACK
The pset from the added example
Seems to fail Another non-breaking but technical-debt-making approach would be to have a new key
with another field in pset |
Indeed this fails in Elements
|
The value is very likely to be searched in We are validating this and will close if confirmed |
I confirm @apoelstra in hindsight I think it's a bad design to have struct with fields that are not initialized when decoded even if they are logically part of the struct. With this I don't mean we have to change it now, but if we were designing from scratch I would. |
@LeoComandini noticed some data from the PSET disappeared when going to_str/from_str
This draft contains a failing test for the issue.
The issue is due to the reuse in the pset serialization of the
TxOut::Encodable
logic which is skipping the serialization ofwitness
, which is handled separately inTransaction::Encodable
but this is not done in the pset logic.To fix I thik I am going to create a wrapper type
TxOutAll
which wrapsTxOut
and has From/To methods and in whichEncodable
serialize also the witness. This type will be the used in the psetInput.witness_utxo.witness
field