diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-12-18 10:39:19 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2023-04-05 09:32:39 -0300 |
commit | 9d9689e5a657956db8a30829c994600ec7d3098b (patch) | |
tree | 7b78dedc65fde36adbec7afdc78bbdf9101a1ddd /src/wallet/coinselection.h | |
parent | 6107ec2229c5f5b4e944a6b10d38010c850094ac (diff) | |
download | bitcoin-9d9689e5a657956db8a30829c994600ec7d3098b.tar.xz |
coin selection: heap-ify SRD, don't return selection if exceeds max tx weight
Uses a min-effective-value heap, so we can remove the least valuable input/s
while the selected weight exceeds the maximum allowed weight.
Co-authored-by: Murch <murch@murch.one>
Diffstat (limited to 'src/wallet/coinselection.h')
-rw-r--r-- | src/wallet/coinselection.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/wallet/coinselection.h b/src/wallet/coinselection.h index 807e75ee30..06506aec0d 100644 --- a/src/wallet/coinselection.h +++ b/src/wallet/coinselection.h @@ -416,9 +416,12 @@ util::Result<SelectionResult> SelectCoinsBnB(std::vector<OutputGroup>& utxo_pool * * @param[in] utxo_pool The positive effective value OutputGroups eligible for selection * @param[in] target_value The target value to select for - * @returns If successful, a SelectionResult, otherwise, std::nullopt + * @param[in] rng The randomness source to shuffle coins + * @param[in] max_weight The maximum allowed weight for a selection result to be valid + * @returns If successful, a valid SelectionResult, otherwise, util::Error */ -util::Result<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& utxo_pool, CAmount target_value, FastRandomContext& rng); +util::Result<SelectionResult> SelectCoinsSRD(const std::vector<OutputGroup>& utxo_pool, CAmount target_value, FastRandomContext& rng, + int max_weight); // Original coin selection algorithm as a fallback util::Result<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, const CAmount& nTargetValue, |