Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
|
Concept ACK Thanks for working on this. Increasing the address to scriptpubkey decoding tests to include bech32 seems desirable. I think this would mean that we could remove the The way the equivalent base58 function
I think for completion it could be worth adding the equivalent Woudl be curious what others think on this though... |
|
Yes, I agree the todo can be removed since there are no other address types to add.
|
4b95be0 to
f0426fe
Compare
|
Thanks for reviewing, I made the update. |
josibake
left a comment
There was a problem hiding this comment.
Concept ACK
Thanks for tackling a TODO! I'm guessing there are other places in the functional tests where we would want coverage for more than just base58 addresses, so definitely a worthwhile change. Overall, looks good! I left a few suggestions and style comments in my review. Mainly:
- I think for consistency you can use the
decode_segwit_addressfunction fromsegwit_addr.py. This avoids having the logic for decoding bech32 addresses in multiple places. - Even though a lot of these files don't adhere to PEP8 guidelines, we want to make sure any new code introduced does follow the guidelines. What I typically do is run
flake8on the file I plan to work on before making any changes and then runflake8again after my changes to make sure all of my new changes follow PEP8 guidelines
f0426fe to
479e3e7
Compare
479e3e7 to
9aac917
Compare
|
ACK 9aac917 Thanks for incorporating the feedback and addressing the style comments! Looks good. |
9aac917 to
becdc60
Compare
becdc60 to
9e377f4
Compare
|
ACK 9e377f4 nice work! |
theStack
left a comment
There was a problem hiding this comment.
Concept ACK
Thanks for tackling this, and warm welcome as a new contributor!
With this change, we don't have to issue getaddressinfo or validateaddress RPCs anymore to convert from address to scriptPubKey.
To ensure that the helper address_to_scriptpubkey works as expected, I think it would be good to call it least once with a segwit address in a functional test. One possible candidate is e.g. replacing the RPC call in this line:
This reveals that the added decoding support currently doesn't work as expected, see review comment below.
Adds bech32_to_bytes() which can decode a bech32 address and return the version as an `int` and the payload in bytes. bech32_to_bytes() is used by the test_bech32_decode unit test to test decoding of segwit addresses.
This permits functional tests to decode bech32 addresses to scriptpubkeys.
9e377f4 to
d178082
Compare
|
ACK d178082 I tested this by making sure the I'd love to see a follow-up PR targeting areas where we are a) only testing base58 addresses but should be testing bech32 as well and b) anywhere we are making a |
theStack
left a comment
There was a problem hiding this comment.
ACK d178082 ✔️
I'd love to see a follow-up PR targeting areas where we are a) only testing base58 addresses but should be testing bech32 as well and b) anywhere we are making a getaddressinfo RPC call to get the spk to instead use address_to_scriptpubkey
👍 If anyone wants to work on this, feel free to tag me as reviewer.
|
review-beg: @willcl-ark |
willcl-ark
left a comment
There was a problem hiding this comment.
ACK d178082
I also tested two of the BIP173 Test Vectors:
check_bech32_decode(bytes.fromhex('0020000000c4a5cad46221b2a187905e5266362b99d5e91c6ce24d165dab93e86433'), 1)
check_bech32_decode(bytes.fromhex('00201863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262'), 1)...which also passed. In doing so I noticed the hardcoding of human readable part hrp in address.py#L196 was limiting which test vectors I could use, and I think un-hardcoding this would be great to do as a followup.
|
|
||
| def bech32_to_bytes(address): | ||
| hrp = address.split('1')[0] | ||
| if hrp not in ['bc', 'tb', 'bcrt']: |
There was a problem hiding this comment.
I think this is totally fine as is here for now, but in the future we may want to put these all in a list/enum
|
|
||
| def test_bech32_decode(self): | ||
| def check_bech32_decode(payload, version): | ||
| hrp = "tb" |
There was a problem hiding this comment.
Instead of hardcoding the hrp here, why not have check_bech32_decode() take hrp as a parameter, then we can add bc1 test vectors instead of being limited to tb1?
edit: I don't consider this a blocker or needing reponse before merging, but will be nice to consider in the future.
…d of RPC call e47ce42 refactor: use address_to_scriptpubkey to retrieve addresses scriptpubkey (ismaelsadeeq) 4142d19 refactor: move address_to_scriptpubkey to address.py (ismaelsadeeq) Pull request description: PR #27269 enables the function address_to_scriptpubkey() to decode all address types and return their corresponding scriptpubkeys. As a result, there is no longer any need to call getaddressinfo or validateaddress RPCs in order to retrieve an address scriptpubkey, as explained in the comments on this pull request (see bitcoin/bitcoin#27269 (review) and bitcoin/bitcoin#27269 (comment)). Instead of using RPC calls, this update replaces the process of obtaining an address scriptPubkey with the address_to_scriptpubkey method, resulting in improved performance for functional tests. ACKs for top commit: josibake: re-ACK bitcoin/bitcoin@e47ce42 theStack: ACK e47ce42 🌱 Tree-SHA512: 05285349a7d5ce7097b8f2582e573a5135c6deef85ea9936f68f6ce94e9ebb1d84d94f7fc7e5ed833a698e01585addd80deb52e6338f8aee985bf14db45417d2
rpc_scantxoutset.py sendtodestination only sends to legacy addresses and scriptPubkeys because wallet.py address_to_scriptpubkey does not support conversion of segwit address.
This update enables address_to_scriptpubkey to support the conversion of testnet segwit addresses to scriptPubkeys.
This change will enable rpc_scantxoutset.py ScantxoutsetTest to have more test coverage by adding more sendtodestination calls with bech32 and bech32m testnet addresses, then test the bech32 and bech32m derivation subsets UTXO amount in Test extended key derivation.
I will add the test coverage in a subsequent Pull request.