-
Notifications
You must be signed in to change notification settings - Fork 906
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
PSBT comparison problems #4752
PSBT comparison problems #4752
Conversation
f815087
to
ad1bd9d
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.
Ack ad1bd9d
Minor change to remove ctx arg only.
common/psbt_open.c
Outdated
bool psbt_contribs_changed(const tal_t *ctx, | ||
struct wally_psbt *orig, | ||
struct wally_psbt *new) | ||
{ |
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.
This is an antipattern! It doesn't return an allocated object, so why pass in a ctx?
I think you meant to use tmpctx internally.
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, yes i can do that. Since this is common it seems .. better? to use an internal allocation/free cycle -- is that the wrong intuition?
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.
Hmm, tmpctx is pretty universal now. Either way.
Also remove all the unused code (checking for differences for a side etc)
Otherwise libwally pushes the psbt-key for 'witness script' onto the serialized version and we fail the 'is this identical' check. Relevant line from libwally, where if bytes, we push a psbt_key. ``` static void push_typed_varbuff(unsigned char **cursor, size_t *max, uint64_t type, const unsigned char *bytes, size_t bytes_len) { if (bytes) { push_psbt_key(cursor, max, type, NULL, 0); push_varbuff(cursor, max, bytes, bytes_len); } } ``` Reported-By: @grubles Changelog-Fixed: openchannel_signed would fail on PSBT comparison of materially identical PSBTs
ad1bd9d
to
1fb4e58
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.
Ack 1fb4e58
* @new - 'updated' psbt, to verify is unchanged | ||
*/ | ||
bool psbt_contribs_changed(struct wally_psbt *orig, | ||
struct wally_psbt *new); |
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.
These should also be const struct wally_psbt, no?
@grubles found a bug where our PSBT 'is identical' code was failing -- the updated version included a witness script, whereas the original did not.
libwally
pushes a type-byte onto the serialized version if there's any bytes at all -- setting the bytes to null avoids this.