-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add support for encoding/decoding bech32 addresses using iterators #117
Add support for encoding/decoding bech32 addresses using iterators #117
Conversation
Done reviewing 5c9b549. This is definitely shaping up. |
Thanks for the review @apoelstra, I read your comments but didn't get to work on this today. I'm good to implement all suggestions except unsure about the thing I commented on. |
5c9b549
to
fa420a1
Compare
I pushed up what I've done. Currently there is no invariant on the checksum being in |
ooo, I've come up with something mad. Converting to draft while I polish it, will push shortly. |
Hey @apoelstra check this re-write of the EDIT: I originally called them |
433c973
to
d5360ed
Compare
@tcharding looks great! I'm unsure whether Agreed that the names are no good. I suggest
|
Used |
Removed |
bd690b0
to
d4051b4
Compare
Just the padding thing left to do. |
341ed48
to
b2e335e
Compare
Added non-zero padding checks. I changed two of the validate functions that convert from one type to another I found some bugs in the |
b2e335e
to
dfbee52
Compare
3ca7a19
to
3b541d8
Compare
Changes in force push (all to
|
@clarkmoody this one is ready for review if you have the cycles to spare please. Take your time. |
3b541d8
to
35ebe2e
Compare
While depending on this branch in |
Ah sorry @clarkmoody, might want to wait some more ... @apoelstra this HRP ("bc", "tb", "bcrt") thing is pernicious. I attempted to use this branch today in See rust-bitcoin/rust-bitcoin#1951 for usage of this branch, oh and BTW its pretty nice ;) |
Lol that Bitcoin Core doesn't even respect the "rule" that the HRP has to be bc or tb. It's a stupid rule and ACK dropping it. |
ACK e3d62d4 except that the last commit should be cleaned up (at least, fix the CI error and remove 'WIP' from the commit message). |
e3d62d4
to
de7da50
Compare
Cleaned up and squashed! Note also the additional functions on |
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 de7da50
Ok @clarkmoody, now its ready for you please if you have time. |
If/when this merges should we consider releasing a new version at this stage? The benefit is that the |
@tcharding we should look at the diff and see how many APIs we've deleted already, and consider trying to make best-effort replacements of those as a stop-gap. |
Actually, I think we should release this with a |
Good idea. |
Add support for: - Converting bytes to field elements using two extension traits (and iterator apaptors). - Checksumming an stream of field elements. - Decoding bech32 hrpstrings (as well as segwit addresses). - Encoding hrpstrings by way of an `Encoder` and a bunch of iterator adaptors.
de7da50
to
5478e2b
Compare
Pushed code comment change to bip-173 test to mirror the bip-350 one. |
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 5478e2b
If you are interested @clarkmoody there is a PR in |
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.
Massive changes! Thanks for the hard work. Agreed with the comment in rust-bitcoin
about a shortcut method to collapse that large iterator chain.
Thanks man, we worked hard on this one. |
Appears to have been an accidental addition during iteration on rust-bitcoin#117.
Appears to have been an accidental addition during iteration on rust-bitcoin#117.
(Friendly note: clarkmoody unless you are just loving all this iterator stuff I suggest you don't bother reviewing this one (or #113) until apoelstra acks :)
This is a slightly different approach to #113. Done on top of #116, so just the last patch.
iter
andhrpstring
#113 (still initer.rs
)iter
andhrpstring
#113Encoder
, uses a builder-like pattern to construct the encoder and then one can callchars()
to get a character iterator orfes()
to get a field-element iterator (over all the fes that go into the checksum).This should mean:
IMNSHO the bech32 spec is convoluted as f**k, hiding all the details is not totally possible but this new API attempts to make it possible to correctly use the API without having to spend two weeks reading and re-reading bips 173 and 350.
PR currently does not use the new API
For example usage see:
decode
andencode
encode.rs
anddecode.rs
tests/