feat: implement fee model interface with SatoshisPerKilobyte#131
Merged
feat: implement fee model interface with SatoshisPerKilobyte#131
Conversation
Implements BSV::Transaction::FeeModels::SatoshisPerKilobyte with configurable sat/kB rate (default 50). Fee formula: ceil((size / 1000) * rate) matching all three reference SDKs. Also makes Transaction#estimated_size public so fee models can access it. Implements sub-task #128 of HLR #94. Co-Authored-By: Claude <noreply@anthropic.com>
Add TransactionOutput#change flag and Transaction#fee(model_or_value) that accepts a FeeModel, numeric fee, or nil (defaults to 50 sat/kB). Distributes change equally across change outputs; removes them if insufficient (excess goes to miners). Backwards-compatible with existing estimated_fee. Implements sub-task #129 of HLR #94. Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Use total_input_satoshis (which raises ArgumentError on nil) instead of silently coercing nil to 0, which could cause silent fund loss to miners. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the pluggable fee model architecture for HLR #94:
compute_fee(transaction)contract matching all three reference SDKs ([Task 1] Core: FeeModel base class #127)ceil((size / 1000) * rate)matching Go/TS/Python exactly ([Task 2] Implementation: SatoshisPerKilobyte fee model #128)543 lines added across 10 files. Full test suite: 1439 examples, 0 failures.
Closes #94, closes #127, closes #128, closes #129, closes #130
Test plan
🤖 Generated with Claude Code