@@ -27,20 +27,20 @@ using interfaces::FoundBlock;
2727namespace wallet {
2828static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100 };
2929
30- int CalculateMaximumSignedInputSize (const CTxOut& txout, const SigningProvider* provider, bool use_max_sig )
30+ int CalculateMaximumSignedInputSize (const CTxOut& txout, const COutPoint outpoint, const SigningProvider* provider, const CCoinControl* coin_control )
3131{
3232 CMutableTransaction txn;
33- txn.vin .push_back (CTxIn (COutPoint () ));
34- if (!provider || !DummySignInput (*provider, txn.vin [0 ], txout, use_max_sig )) {
33+ txn.vin .push_back (CTxIn (outpoint ));
34+ if (!provider || !DummySignInput (*provider, txn.vin [0 ], txout, coin_control )) {
3535 return -1 ;
3636 }
3737 return GetVirtualTransactionInputSize (txn.vin [0 ]);
3838}
3939
40- int CalculateMaximumSignedInputSize (const CTxOut& txout, const CWallet* wallet, bool use_max_sig )
40+ int CalculateMaximumSignedInputSize (const CTxOut& txout, const CWallet* wallet, const CCoinControl* coin_control )
4141{
4242 const std::unique_ptr<SigningProvider> provider = wallet->GetSolvingProvider (txout.scriptPubKey );
43- return CalculateMaximumSignedInputSize (txout, provider.get (), use_max_sig );
43+ return CalculateMaximumSignedInputSize (txout, COutPoint (), provider.get (), coin_control );
4444}
4545
4646// txouts needs to be in the order of tx.vin
@@ -193,7 +193,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
193193 // Filter by spendable outputs only
194194 if (!spendable && only_spendable) continue ;
195195
196- int input_bytes = CalculateMaximumSignedInputSize (output, provider.get (), coinControl && coinControl-> fAllowWatchOnly );
196+ int input_bytes = CalculateMaximumSignedInputSize (output, COutPoint (), provider.get (), coinControl);
197197 result.coins .emplace_back (outpoint, output, nDepth, input_bytes, spendable, solvable, safeTx, wtx.GetTxTime (), tx_from_me, feerate);
198198 result.total_amount += output.nValue ;
199199
@@ -286,7 +286,7 @@ std::map<CTxDestination, std::vector<COutput>> ListCoins(const CWallet& wallet)
286286 if (ExtractDestination (FindNonChangeParentOutput (wallet, *wtx.tx , output.n ).scriptPubKey , address)) {
287287 const auto out = wtx.tx ->vout .at (output.n );
288288 result[address].emplace_back (
289- COutPoint (wtx.GetHash (), output.n ), out, depth, CalculateMaximumSignedInputSize (out, &wallet, false ), /* spendable=*/ true , /* solvable=*/ true , /* safe=*/ false , wtx.GetTxTime (), CachedTxIsFromMe (wallet, wtx, ISMINE_ALL));
289+ COutPoint (wtx.GetHash (), output.n ), out, depth, CalculateMaximumSignedInputSize (out, &wallet, /* coin_control= */ nullptr ), /* spendable=*/ true , /* solvable=*/ true , /* safe=*/ false , wtx.GetTxTime (), CachedTxIsFromMe (wallet, wtx, ISMINE_ALL));
290290 }
291291 }
292292 }
@@ -443,14 +443,14 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
443443 if (ptr_wtx->tx ->vout .size () <= outpoint.n ) {
444444 return std::nullopt ;
445445 }
446- input_bytes = CalculateMaximumSignedInputSize (ptr_wtx->tx ->vout [outpoint.n ], &wallet, false );
447446 txout = ptr_wtx->tx ->vout .at (outpoint.n );
447+ input_bytes = CalculateMaximumSignedInputSize (txout, &wallet, &coin_control);
448448 } else {
449449 // The input is external. We did not find the tx in mapWallet.
450450 if (!coin_control.GetExternalOutput (outpoint, txout)) {
451451 return std::nullopt ;
452452 }
453- input_bytes = CalculateMaximumSignedInputSize (txout, &coin_control.m_external_provider , /* use_max_sig= */ true );
453+ input_bytes = CalculateMaximumSignedInputSize (txout, outpoint, &coin_control.m_external_provider , &coin_control );
454454 }
455455 // If available, override calculated size with coin control specified size
456456 if (coin_control.HasInputWeight (outpoint)) {
0 commit comments