-
Notifications
You must be signed in to change notification settings - Fork 137
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
Stable serialization for psbt inputs/outputs #214
Comments
@niftynei a comparison function would be my preferred choice. Do you need a lexicographical compare or just an equality function? edit: I've checked out the dual funding PR and it seems equality is all that's needed. Might be nice to add a map_sort call so callers can at their preference have stable serialisation by sorting the maps themselves. |
@niftynei Please try the above PR. If you sort your input/output maps before linearizing them that should work for you until such time as comparison gets exposed. |
Another possibility here to detect changes is to merge any maps being compared and see if their length changes, since adding items ignores duplicates (and under PSBT rules new values in the map entries can be ignored since either old or new values can be chosen). Looking at the comparison as done by c-lightning I'm going to close this for now, I don't think a compare function thats sufficiently powerful and generic can really be implemented at the library level; for app specific use there is always going to be some bespoke processing that requires custom checking. |
c-lightning has a requirement that we can identify modified PSBT entries (inputs + outputs). The comparison function we're using currently uses a linearized form of the PSBT to do a comparison, however this will fail for input/outputs that have identical yet unordered maps as the map data is not sorted before serialization.
Either we should update serialization to be 'stable' i.e. sort all maps before serialization, or add a comparison function.
The text was updated successfully, but these errors were encountered: