In 4439bf4b41a6997d4d965f00a8c40efa9cf6895b “wallet, spend: Remove fWatchOnly from CCoinControl”
The UseMaxSig
function now tests only for the input being externally selected. The only usage of this function is inside MaxInputWeight
function. Maybe the following diff so that this function still remains generic (instead of the above suggestion #32618 (review))? Also aligns well with the function doc.
0@@ -51,10 +51,10 @@ static bool IsSegwit(const Descriptor& desc) {
1 }
2
3 /** Whether to assume ECDSA signatures' will be high-r. */
4-static bool UseMaxSig(const std::optional<CTxIn>& txin, const CCoinControl* coin_control) {
5- // Use max sig if watch only inputs were used or if this particular input is an external input
6+static bool UseMaxSig(const std::optional<CTxIn>& txin, const CCoinControl* coin_control, const bool can_grind_r) {
7+ // Use max sig if the wallet can't grind R or if this particular input is an external input
8 // to ensure a sufficient fee is attained for the requested feerate.
9- return coin_control && txin && coin_control->IsExternalSelected(txin->prevout);
10+ return (!can_grind_r || (coin_control && txin && coin_control->IsExternalSelected(txin->prevout)));
11 }
12
13 /** Get the size of an input (in witness units) once it's signed.
14@@ -68,7 +68,7 @@ static bool UseMaxSig(const std::optional<CTxIn>& txin, const CCoinControl* coin
15 static std::optional<int64_t> MaxInputWeight(const Descriptor& desc, const std::optional<CTxIn>& txin,
16 const CCoinControl* coin_control, const bool tx_is_segwit,
17 const bool can_grind_r) {
18- if (const auto sat_weight = desc.MaxSatisfactionWeight(!can_grind_r || UseMaxSig(txin, coin_control))) {
19+ if (const auto sat_weight = desc.MaxSatisfactionWeight(UseMaxSig(txin, coin_control, can_grind_r))) {
20 if (const auto elems_count = desc.MaxSatisfactionElems()) {
21 const bool is_segwit = IsSegwit(desc);
22 // Account for the size of the scriptsig and the number of elements on the witness stack. Note