Skip to content

feat: Add Transaction input/output helper methods and extreme tx test#176

Open
JAGADISHSUNILPEDNEKAR wants to merge 1 commit intokarask:masterfrom
JAGADISHSUNILPEDNEKAR:t_helper
Open

feat: Add Transaction input/output helper methods and extreme tx test#176
JAGADISHSUNILPEDNEKAR wants to merge 1 commit intokarask:masterfrom
JAGADISHSUNILPEDNEKAR:t_helper

Conversation

@JAGADISHSUNILPEDNEKAR
Copy link
Contributor

Summary

This PR implements helper methods for the Transaction class to simplify input and output management, addressing several TODO items. It also adds a new test case for transactions with a large number of outputs to verify serialization limits.

Changes

  • bitcoinutils/transactions.py:
    • Added add_input, update_input, remove_input
    • Added add_output, update_output, remove_output
    • Ensure add_input automatically adds an empty witness when has_segwit is True, keeping the lists synchronized.
  • tests/test_transaction_helpers.py: New unit tests for the helper methods.
  • tests/test_extreme_txs.py: New test case creating a transaction with 260 outputs.

Motivation

  • Addresses TODO item: "think how to add/remove existing inputs/outputs to a Tx object"
  • Addresses TODO item: "create test with 260 outputs"
  • Improves usability and safety by preventing mismatched inputs/witnesses lists.

Verification

  • Added new tests in tests/test_transaction_helpers.py and tests/test_extreme_txs.py.
  • Ran full test suite via python -m unittest discover tests/ and all 103 tests passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant