rust-payjoin
rust-payjoin copied to clipboard
feat: add consolidation input selection strategy
Add Consolidation Input Selection Strategy
Overview
This PR introduces a new input selection strategy for receivers that optimizes for UTXO consolidation. This enables receivers to use payjoins as an opportunity to consolidate their UTXOs efficiently, improving their wallet's long-term UTXO management.
Features
- New
SelectionStrategy::Consolidateoption for receiver input selection - Configurable parameters to control consolidation behavior:
max_consolidation_fee_rate: Only consolidate when fees are below this thresholdmax_inputs: Limit the number of inputs to addtarget_value: Optionally stop adding inputs after reaching a target amountdust_limit: Minimum value for inputs to be considered
Implementation Details
- Inputs are sorted by value (ascending) and added until reaching either max_inputs or target_value
- Consolidation only proceeds if current transaction fee rate is below the specified threshold
- Maintains compatibility with existing privacy-preserving selection strategy
- V2 receiver implementation delegates to V1 for actual consolidation logic
Considerations
- Testing pending
- CLI changes pending to expose consolidation strategy and its parameters
- While providing numerous parameters could offer flexibility, it might also lead to unnecessary complexity. We need to strike the right balance between configurability and simplicity.
Related Issues
#460
Pull Request Test Coverage Report for Build 13778844253
Warning: This coverage report may be inaccurate.
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
- For more information on this, see Tracking coverage changes with pull request builds.
- To avoid this issue with future PRs, see these Recommended CI Configurations.
- For a quick fix, rebase this PR at GitHub. Your next report should be accurate.
Details
- 5 of 81 (6.17%) changed or added relevant lines in 3 files are covered.
- 11 unchanged lines in 1 file lost coverage.
- Overall coverage decreased (-1.2%) to 78.547%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| payjoin/src/receive/error.rs | 0 | 3 | 0.0% |
| payjoin/src/receive/v2/mod.rs | 5 | 30 | 16.67% |
| payjoin/src/receive/v1/mod.rs | 0 | 48 | 0.0% |
| <!-- | Total: | 5 | 81 |
| Files with Coverage Reduction | New Missed Lines | % |
|---|---|---|
| payjoin/src/receive/v2/mod.rs | 11 | 79.79% |
| <!-- | Total: | 11 |
| Totals | |
|---|---|
| Change from base Build 13751979319: | -1.2% |
| Covered Lines: | 4562 |
| Relevant Lines: | 5808 |
💛 - Coveralls
Closing as stale and due to the feature freeze for 1.0 milestone