util/address: make address encoding more modular#643
util/address: make address encoding more modular#643sanket1729 merged 3 commits intorust-bitcoin:masterfrom
Conversation
sanket1729
left a comment
There was a problem hiding this comment.
concept ACK. I don't see any reason not to support this. There is a CI failure on 1.29 MSRV
|
concept ACK. I'd like the bech32 hrp to be |
3951ee9 to
a8209e8
Compare
Imho it would be better to defer I added a separate lifetime for |
a8209e8 to
f8739d1
Compare
dr-orlovsky
left a comment
There was a problem hiding this comment.
Concept ACK. Unfortunatelly will need a refactor once taproot addresses will get merged from #563
|
Needs rebase & editing since we've got P2TR into master |
f8739d1 to
1dca495
Compare
@dr-orlovsky Sorry for the delay. I finally rebased this PR. I also snuck in another small fix here which I extracted into another PR: #698 |
dr-orlovsky
left a comment
There was a problem hiding this comment.
Found several ways of improving the code. This is not related to the PR and rather affects the code we had before, but since we are moving/touching that code anyway I propose also to improve its readibility
37d1ec4 to
f01e7f6
Compare
src/util/address.rs
Outdated
There was a problem hiding this comment.
Could this be represented in type?
There was a problem hiding this comment.
I couldn't work out a way, did you have a concrete idea?
There was a problem hiding this comment.
I do: pls see my commend below
There was a problem hiding this comment.
I meant taking struct CompressedPublicKey(secp256k1::PublicKey) which guarantees the key being compressed. We could then push checking to the boundary and also have a helpful compress(self) -> CompressedPublicKey method. (Might make sense to implement in secp256k1.)
|
I think this is ready to be merged. @sanket1729 |
sanket1729
left a comment
There was a problem hiding this comment.
Left a few comments. I think rest is good to go
src/util/address.rs
Outdated
There was a problem hiding this comment.
This should be a reference to Secp256k1<C>
There was a problem hiding this comment.
Rebased this PR, should be good to go now!
|
LGTM. Agree with @sanket1729 on having Secp by ref |
fa9a8ef to
ec776ff
Compare
src/util/address.rs
Outdated
There was a problem hiding this comment.
nit: There is a to_bytes() method for doing this. I don't like using psbt specific utilities for this.
sanket1729
left a comment
There was a problem hiding this comment.
Just one more small thing.
|
Thanks for your continued contributions @benma.
Could you address this suggestion please, either by implementing it or by commenting on why you think it should not be implemented. If you want to implement it as suggested its just a quick fix Legend, |
This was addressed here already: |
|
Thanks @benma, I'll try to be more careful next time and look through all the comments before messaging :) |
Did you mean to suggest we should move |
There was a problem hiding this comment.
I just recalled that we should use existing functions PublicKey::(w)pubkey_hash() and Script::(w)script_hash() everywhere and get rid of the most of this code duplicating business logic which is already present there (BTW, unlike this code, it does no allocations)
src/util/address.rs
Outdated
There was a problem hiding this comment.
I do: pls see my commend below
41f88bc to
f53c9b7
Compare
I did this in all places I could find, and put it into a new commit for easier review. Please check it out. |
dr-orlovsky
left a comment
There was a problem hiding this comment.
utACK f53c9b7b956a94eef47d4c929fa896577cf140ab
|
ACK f53c9b7 |
|
Oh, now it requires rebase :( |
f53c9b7 to
87a75d2
Compare
Rebased |
|
First commit fails to build, pls check & fix the history with |
This allow library clients to plug their own encoding parameters in a backwards compatible manner.
Simpler code, less duplication.
87a75d2 to
506e03f
Compare
|
@dr-orlovsky good catch - fixed |
dr-orlovsky
left a comment
There was a problem hiding this comment.
tACK f53c9b7b956a94eef47d4c929fa896577cf140ab
All tests are passing for each of the commits in the history
|
Please merge. |
|
Sorry, it took this long. Merging this since this has been open for quite some time. If there are other comments from other reviewers we can address those in follow-up PRs. |
This allow library clients to plug their own encoding parameters in a
backwards compatible manner.