test: Add support for mainnet addresses in address_to_scriptpubkey #32060

pull VolodymyrBg wants to merge 1 commits into bitcoin:master from VolodymyrBg:AE2233KT changing 1 files +13 −2
  1. VolodymyrBg commented at 5:11 pm on March 13, 2025: none

    This commit adds support for mainnet addresses (P2PKH and P2SH) in the address_to_scriptpubkey function in the test framework. Previously, the function only supported testnet addresses and segwit addresses.

    The changes include:

    • Adding support for mainnet P2PKH addresses (version 0)
    • Adding support for mainnet P2SH addresses (version 5)
    • Adding tests to verify the new functionality
  2. DrahtBot commented at 5:11 pm on March 13, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32060.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept NACK luke-jr, achow101

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #31974 (Drop testnet3 by Sjors)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. DrahtBot added the label Tests on Mar 13, 2025
  4. in test/functional/test_framework/address.py:196 in 2d37a7de69 outdated
    192@@ -193,7 +193,10 @@ def address_to_scriptpubkey(address):
    193         return keyhash_to_p2pkh_script(payload)
    194     elif version == 196:  # testnet script hash
    195         return scripthash_to_p2sh_script(payload)
    196-    # TODO: also support other address formats
    


    davidgumberg commented at 9:42 pm on March 13, 2025:
    nit: There are other address types to support so the todo comment should not be removed
  5. in test/functional/test_framework/address.py:195 in 2d37a7de69 outdated
    192@@ -193,7 +193,10 @@ def address_to_scriptpubkey(address):
    193         return keyhash_to_p2pkh_script(payload)
    194     elif version == 196:  # testnet script hash
    195         return scripthash_to_p2sh_script(payload)
    196-    # TODO: also support other address formats
    197+    elif version == 0:  # mainnet pubkey hash
    198+        return keyhash_to_p2pkh_script(payload)
    199+    elif version == 5:  # mainnet script hash
    200+        return scripthash_to_p2sh_script(payload)
    


    davidgumberg commented at 9:48 pm on March 13, 2025:
    0    if version == 111 or version == 0:  # testnet or mainnet pubkey hash
    1        return keyhash_to_p2pkh_script(payload)
    2    elif version == 196 or version == 5:  # testnet or mainnet script hash
    3        return scripthash_to_p2sh_script(payload)
    4    # TODO: also support other address formats
    

    VolodymyrBg commented at 2:14 pm on March 14, 2025:

    Suggested change return keyhash_to_p2pkh_script(payload) elif version == 196: # testnet script hash return scripthash_to_p2sh_script(payload) # TODO: also support other address formats elif version == 0: # mainnet pubkey hash return keyhash_to_p2pkh_script(payload) elif version == 5: # mainnet script hash return scripthash_to_p2sh_script(payload) if version == 111 or version == 0: # testnet or mainnet pubkey hash return keyhash_to_p2pkh_script(payload) elif version == 196 or version == 5: # testnet or mainnet script hash return scripthash_to_p2sh_script(payload) # TODO: also support other address formats Applying suggestions on deleted lines is currently not supported.

    I can’t commit your suggestion @davidgumberg


    davidgumberg commented at 4:35 pm on March 14, 2025:
    You could also apply the suggestion yourself

    VolodymyrBg commented at 2:34 pm on April 3, 2025:
    Commits squased, test added and all the checks passed
  6. VolodymyrBg requested review from davidgumberg on Mar 14, 2025
  7. maflcko commented at 2:33 pm on March 14, 2025: member
  8. test: Add support for mainnet addresses in address_to_scriptpubkey
    This commit adds support for mainnet addresses (P2PKH and P2SH) in the
    address_to_scriptpubkey function in the test framework. Previously, the
    function only supported testnet addresses and segwit addresses.
    
    The changes include:
    - Adding support for mainnet P2PKH addresses (version 0)
    - Adding support for mainnet P2SH addresses (version 5)
    - Adding tests to verify the new functionality
    - Removing the TODO comment as the requested functionality has been implemented
    
    This enhancement improves the test framework's ability to handle different
    address formats, making it more versatile for testing scenarios that involve
    mainnet addresses.
    6b0f8bfd08
  9. VolodymyrBg force-pushed on Mar 14, 2025
  10. VolodymyrBg commented at 5:33 pm on March 14, 2025: none
    @maflcko Done
  11. VolodymyrBg commented at 5:35 pm on March 14, 2025: none
    @davidgumberg I applied myself. Thank you
  12. VolodymyrBg commented at 4:33 pm on March 17, 2025: none
    @maflcko @davidgumberg is something wrong?
  13. VolodymyrBg commented at 3:37 pm on March 24, 2025: none
    @maflcko @davidgumberg could you check it please when you have a free moment?
  14. VolodymyrBg commented at 5:43 pm on April 7, 2025: none
    @l0rinc What could you say about this PR? is this worth or I should close it, too?
  15. l0rinc commented at 6:10 pm on April 7, 2025: contributor
    @VolodymyrBg, unlike in many other open source projects that are eager to receive any contribution whatsoever, the PoW (i.e., the amount of preparation and effort required for your contribution to minimize the workload for reviewers) needed in Bitcoin Core is a lot higher. Most people won’t have the patience to explain how to do git interactive rebases, how to tell a story in logical, reviewable commits, or how to update your PR after receiving feedback. Contributors are expected to research these processes themselves and demonstrate technical competence before their changes will be seriously considered. It’s painful, but often the lack of feedback is feedback. We all have to learn this the hard way.
  16. VolodymyrBg commented at 6:19 pm on April 7, 2025: none

    @VolodymyrBg, unlike in many other open source projects that are eager to receive any contribution whatsoever, the PoW (i.e., the amount of preparation and effort required for your contribution to minimize the workload for reviewers) needed in Bitcoin Core is a lot higher. Most people won’t have the patience to explain how to do git interactive rebases, how to tell a story in logical, reviewable commits, or how to update your PR after receiving feedback. Contributors are expected to research these processes themselves and demonstrate technical competence before their changes will be seriously considered. It’s painful, but often the lack of feedback is feedback. We all have to learn this the hard way.

    I completely agree with you, sorry for taking your time.

  17. luke-jr commented at 2:18 am on April 10, 2025: member
    NACK without a rationale.
  18. achow101 commented at 7:37 pm on April 10, 2025: member

    Concept NACK

    Why? This functionality is not used or needed in any tests. If it is needed in a test in a (future) PR, then it can be added at that time.

  19. maflcko commented at 6:05 am on April 11, 2025: member
    Closing for now, due to controversy and feedback. It can be picked up again in the future, when there is a proper motivation and larger picture where this fits in.
  20. maflcko closed this on Apr 11, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-05 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me