aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/coinselection.h
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-12-18 10:39:19 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-04-05 09:32:39 -0300
commit9d9689e5a657956db8a30829c994600ec7d3098b (patch)
tree7b78dedc65fde36adbec7afdc78bbdf9101a1ddd /src/wallet/coinselection.h
parent6107ec2229c5f5b4e944a6b10d38010c850094ac (diff)
downloadbitcoin-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.h7
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,