Skip to content

Add waste metric for coin selection #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- added `OldestFirstCoinSelection` impl to `CoinSelectionAlgorithm`
- Added `OldestFirstCoinSelection` impl to `CoinSelectionAlgorithm`
- New MSRV set to `1.56`
- Unpinned tokio to `1`
- Add traits to reuse `Blockchain`s across multiple wallets (`BlockchainFactory` and `StatelessBlockchain`).
Expand All @@ -19,6 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Signing Taproot PSBTs (key spend and script spend)
- Support for `tr()` descriptors in the `descriptor!()` macro
- Add support for Bitcoin Core 23.0 when using the `rpc` blockchain
- Added `Waste` struct to `coinselection` module, with impl of
`Waste::calculate` to compute waste metric for coin selection algorithms.
- Added new type `WeightedTxOut`. It joins a TxOut with the satisfaction weight
needed to spend it in the future.
- Added new field `drain_output` to struct `CoinSelectionResult`. It'll hold
the created change output if needed.
- Added `weighted_drain_output` parameter for
`CoinSelectionAlgorithm::coin_select` to pass the TxOut to drain the change
joined with the satisfaction weight to spend it in the future.
- Changed `OutputGroup` owned `weighted_utxo` value to borrowed one.

## [v0.18.0] - [v0.17.0]

Expand Down
13 changes: 13 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@ pub struct WeightedUtxo {
pub utxo: Utxo,
}

/// A [`TxOut`] with its `satisfaction_weight`, if it were spend by the wallet owning the produced
/// UTXO from this TxOut.
#[derive(Debug, Clone, PartialEq)]
pub struct WeightedTxOut {
/// The weight of the witness data and `scriptSig` expressed in [weight units]. This is used to
/// properly compute the cost of change for waste metric.
///
/// [weight units]: https://en.bitcoin.it/wiki/Weight_units
pub satisfaction_weight: usize,
/// The TxOut
pub txout: TxOut,
}

#[derive(Debug, Clone, PartialEq)]
/// An unspent transaction output (UTXO).
pub enum Utxo {
Expand Down
Loading