MCPcopy Create free account
hub / github.com/dfinity/examples / select_utxos_greedy

Function select_utxos_greedy

rust/basic_bitcoin/src/common.rs:22–47  ·  view source on GitHub ↗

Selects UTXOs using a greedy algorithm to cover the required amount plus fee. This function iterates through UTXOs in reverse order (oldest last) and accumulates them until the total value covers the payment amount plus transaction fee. This approach helps consolidate older UTXOs and can reduce wallet fragmentation. Returns an error if the total UTXO value is insufficient to cover the payment an

(
    own_utxos: &[Utxo],
    amount: u64,
    fee: u64,
)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers 3

build_transactionFunction · 0.85
build_transactionFunction · 0.85
build_transactionFunction · 0.85

Calls 2

OkClass · 0.85
iterMethod · 0.80

Tested by

no test coverage detected