Skip to content

Specify extension to bip69 #60

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

Merged
merged 1 commit into from
Sep 30, 2022
Merged

Specify extension to bip69 #60

merged 1 commit into from
Sep 30, 2022

Conversation

bitjson
Copy link
Member

@bitjson bitjson commented Sep 29, 2022

Fixes #51

readme.md Outdated
As with the existing algorithm, the additional fields are ordered for sorting efficiency:

1. Output value – ascending
2. locking bytecode – sorted lexicographically, ascending, short-to-long (e.g. `0x51` < `0x5161`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's not necessary to say short-to-long since this is what lexicographical sort implies -- however if you do that and use an example, it's best to clarify that the first and foremost criterion is not length, but rather byte content. Only when there is a "tie" and 1 string is a prefix of another, the shorter prefix string sorts smaller.

I point this out because bitcoin core specified BIP69 as being exactly lex sort here.. but they implemented it incorrectly (they used length as the "winning" criterion, and only on ties of length do they examine bytes..).

Anyway I would add here:

Suggested change
2. locking bytecode – sorted lexicographically, ascending, short-to-long (e.g. `0x51` < `0x5161`)
2. locking bytecode – sorted lexicographically, ascending, prefixes sort less than longer strings with the same prefix (e.g. `0x51` < `0x5161` but `0x61` > `0x5161`)

@cculianu
Copy link
Contributor

Looks good to me. Agree about the BIP69 sort order, but I had a nit comment regarding the lex example (so as to clarify it precisely and avoid the bug core had here).

@bitjson
Copy link
Member Author

bitjson commented Sep 30, 2022

Ah, thanks! Clarified 👍

Good to merge this?

@cculianu
Copy link
Contributor

Yes! You have my approval.

@bitjson bitjson merged commit cd86f8a into master Sep 30, 2022
@bitjson bitjson deleted the bip69 branch November 8, 2022 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specify BIP69 sort order for txouts containing tokens
2 participants