BIP69: examples file fixes and update to python3 #1943

pull prestoalvarez wants to merge 2 commits into bitcoin:master from prestoalvarez:patch-1 changing 1 files +12 −6
  1. prestoalvarez commented at 1:57 pm on August 22, 2025: none

    In bip-0069_examples.py:

    • Fix print_outputs() to use sorted output tuples instead of unsorted
    • Add Python 3 compatibility using functools.cmp_to_key()
    • Convert string hashes to byte arrays in second example
    • Make file executable with shebang for python3
    • Add clearer output formatting with transaction hashes and section headers
  2. jonatack commented at 7:10 pm on August 22, 2025: member
    Patch looks correct but this python2 file could be updated to have executable file permissions and to be able to run with python3, would you like to do that?
  3. prestoalvarez requested review from jonatack on Aug 22, 2025
  4. jonatack commented at 9:34 pm on August 22, 2025: member

    ACK. Could you please make the commit names clearer, and what do you think about adding this diff to the last commit?

     0 def print_inputs(ordered_input_tuples):
     1+       print("inputs")
     2        index = 0
     3        for prev_tx_hash_byte_arr_little_endian, prev_tx_output_index in ordered_input_tuples:
     4                prev_tx_hash_hex = binascii.hexlify(bytearray(prev_tx_hash_byte_arr_little_endian))
     5@@ -57,6 +58,7 @@ def sort_outputs(output_tuples):
     6        return sorted(output_tuples, key=cmp_to_key(output_cmp))
     7 
     8 def print_outputs(ordered_output_tuples):
     9+       print("outputs")
    10        index = 0
    11        for amount, scriptPubKey_byte_arr in ordered_output_tuples:
    12                scriptPubKey_hex = binascii.hexlify(bytearray(scriptPubKey_byte_arr))
    13@@ -84,6 +86,7 @@ def main():
    14                ([0x7d, 0x03, 0x7c, 0xeb, 0x2e, 0xe0, 0xdc, 0x03, 0xe8, 0x2f, 0x17, 0xbe, 0x79, 0x35, 0xd2, 0x38, 0xb3, 0x5d, 0x1d, 0xea, 0xbf, 0x95, 0x3a, 0x89, 0x2a, 0x45, 0x07, 0xbf, 0xbe, 0xeb, 0x3b, 0xa4], 1),
    15                ([0x6c, 0x1d, 0x56, 0xf3, 0x1b, 0x2d, 0xe4, 0xbf, 0xc6, 0xaa, 0xea, 0x28, 0x39, 0x6b, 0x33, 0x31, 0x02, 0xb1, 0xf6, 0x00, 0xda, 0x9c, 0x6d, 0x61, 0x49, 0xe9, 0x6c, 0xa4, 0x3f, 0x11, 0x02, 0xb1], 1),
    16                ([0xb4, 0x11, 0x2b, 0x8f, 0x90, 0x0a, 0x7c, 0xa0, 0xc8, 0xb0, 0xe7, 0xc4, 0xdf, 0xad, 0x35, 0xc6, 0xbe, 0x5f, 0x6b, 0xe4, 0x6b, 0x34, 0x58, 0x97, 0x49, 0x88, 0xe1, 0xcd, 0xb2, 0xfa, 0x61, 0xb8], 0)]
    17+       print("\ntx 0a6a357e2f7796444e02638749d9611c008b253fb55f5dc88b739b230ed0c4c3")
    18        tx_0a6a_sorted_input_tuples = sort_inputs(tx_0a6a_input_tuples)
    19        print_inputs(tx_0a6a_sorted_input_tuples)
    20 
    21@@ -99,7 +102,7 @@ def main():
    22                # (prev_tx_hash_byte_arr_little_endian, prev_tx_output_index)
    23                ([0x55, 0x60, 0x5d, 0xc6, 0x5f, 0x3c, 0xcc, 0x4d, 0xb1, 0xd8, 0x56, 0x4a, 0x28, 0x04, 0x2b, 0xdb, 0x2c, 0x2b, 0xe3, 0x85, 0xea, 0xb2, 0xeb, 0xea, 0x41, 0x19, 0xee, 0x9c, 0x26, 0x8d, 0x28, 0x35], 0),
    24                ([0x55, 0x60, 0x5d, 0xc6, 0x5f, 0x3c, 0xcc, 0x4d, 0xb1, 0xd8, 0x56, 0x4a, 0x28, 0x04, 0x2b, 0xdb, 0x2c, 0x2b, 0xe3, 0x85, 0xea, 0xb2, 0xeb, 0xea, 0x41, 0x19, 0xee, 0x9c, 0x26, 0x8d, 0x28, 0x35], 1)] #duplicate prev_tx_hash
    25-
    26+       print("\ntx 28204cad1d7fc1d199e8ef4fa22f182de6258a3eaafe1bbe56ebdcacd3069a5f")
    27        tx_2820_sorted_input_tuples = sort_inputs(tx_2820_input_tuples)
    28        print_inputs(tx_2820_sorted_input_tuples)
    
  5. jonatack renamed this:
    Fix BIP-69 example output inconsistency
    BIP69: examples file fixes and update to python3
    on Aug 22, 2025
  6. jonatack added the label Bug fix on Aug 22, 2025
  7. prestoalvarez commented at 9:52 pm on August 22, 2025: none
    @jonatack updated
  8. jonatack approved
  9. jonatack commented at 10:55 pm on August 22, 2025: member
    ACK 6cc7eb78053a676f20f39dd14b727c2702d9deb5
  10. jonatack commented at 10:57 pm on August 22, 2025: member
    Pinging BIP authors @kristovatlas @dcousens for feedback / sign-off.
  11. jonatack commented at 11:02 pm on August 22, 2025: member
    @prestoalvarez it would be good to update the file permissions, e.g. with chmod 755 bip-0069_examples.py, and either squash your commits or give clear naming for each of them.
  12. BIP69: fix output inconsistency and update to python3
    - Fix print_outputs() to use sorted output tuples instead of unsorted
    - Add Python 3 compatibility using functools.cmp_to_key()
    - Convert string hashes to byte arrays in second example
    - Make file executable with shebang for python3
    - Add clearer output formatting with transaction hashes and section headers
    ba843e29b1
  13. prestoalvarez force-pushed on Aug 23, 2025
  14. murchandamus added the label Pending acceptance on Aug 25, 2025
  15. prestoalvarez commented at 10:44 am on September 1, 2025: none
  16. jonatack commented at 2:57 pm on September 1, 2025: member
    @prestoalvarez the commit message looks good, and thank you for squashing. Would be good if you can update the file permissions, please, e.g. with chmod 755 bip-0069_examples.py, and then would be good to see approval of the change by the BIP authors.
  17. jonatack added the label PR Author action required on Sep 2, 2025
  18. Fix file permissions for bip-0069_examples.py d9888173b6
  19. prestoalvarez commented at 8:36 pm on September 7, 2025: none
  20. jonatack removed the label PR Author action required on Sep 7, 2025
  21. jonatack approved
  22. jonatack commented at 9:52 pm on September 7, 2025: member

    ACK d9888173b6cd6009e79a6c6e235f079fa0e1eaa6

    Thank you for updating.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-13 09:10 UTC

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