Skip to content

Conversation

@ALiberalVoluntarist
Copy link
Collaborator

Description of Changes

Optimized transaction preimage calculation by refactoring the tx_preimage function to directly compute the preimage for a specified input, avoiding unnecessary computation for all inputs
Achieved a 3× performance improvement in scenarios with 250 inputs, based on benchmarking

  • I have added new unit tests - there are a test of tx_preimage on test_transaction.py
  • [ x] All tests pass locally
  • [x ] I have tested manually in my local environment

Checklist:

  • [x ] I have performed a self-review of my own code
  • [x ] I have made corresponding changes to the documentation
  • [x ] My changes generate no new warnings
  • [x ] I have updated CHANGELOG.md with my changes
  • [x ] I have run the linter

Previously, the default fee rate was hardcoded to 10 satoshis per kilobyte. This update allows users to configure the default fee rate via the TRANSACTION_FEE_RATE variable in constants.py or through the environment file.
A test for the default fee rate has also been added.
- Refactored tx_preimage function to directly calculate preimage for a single input
- Eliminated redundant calculations from tx_preimages function
- Improved clarity of sighash flag handling

This change improves performance for single-input signing scenarios by avoiding
unnecessary preimage calculations for inputs that won't be signed.
@voyager1708
Copy link
Collaborator

This pull request introduces several improvements and fixes.

@ALiberalVoluntarist ALiberalVoluntarist self-assigned this Mar 26, 2025
Copy link
Collaborator

@voyager1708 voyager1708 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request introduces several improvements and fixes.

@voyager1708 voyager1708 merged commit c8b8f1c into master Mar 26, 2025
4 checks 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.

3 participants