Skip to content

Integrate package context into fee and weight calculations#38

Draft
evanlinjin wants to merge 1 commit intobitcoindevkit:masterfrom
evanlinjin:feat/package-fee-and-weight
Draft

Integrate package context into fee and weight calculations#38
evanlinjin wants to merge 1 commit intobitcoindevkit:masterfrom
evanlinjin:feat/package-fee-and-weight

Conversation

@evanlinjin
Copy link
Member

When a Package is set via with_package(), all fee and weight calculations now automatically include parent transaction context:

  • weight() returns child_weight + parent_weight
  • fee() returns child_fee + parent_fee
  • implied_feerate() returns package feerate

New methods for when child-only values are needed:

  • weight_without_package()
  • fee_without_package()
  • package() accessor

RBF calculations (replacement_excess) use child weight only since Bitcoin's RBF rule 4 applies to the replacing transaction, not the package.

When a Package is set via with_package(), all fee and weight calculations
now automatically include parent transaction context:

- weight() returns child_weight + parent_weight
- fee() returns child_fee + parent_fee
- implied_feerate() returns package feerate

New methods for when child-only values are needed:
- weight_without_package()
- fee_without_package()
- package() accessor

RBF calculations (replacement_excess) use child weight only since
Bitcoin's RBF rule 4 applies to the replacing transaction, not the package.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@aagbotemi aagbotemi left a comment

Choose a reason for hiding this comment

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

The approach of adding Package to CoinSelector is good one and works well for the UTXO selection for CPFP use case.

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.

2 participants