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
    • Removing the TODO comment as the requested functionality has been implemented
  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. A summary of reviews will appear here.

    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
  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?

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-03-28 15:12 UTC

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