@@ -30,11 +30,11 @@ using interfaces::FoundBlock;
30
30
namespace wallet {
31
31
static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100 };
32
32
33
- int CalculateMaximumSignedInputSize (const CTxOut& txout, const COutPoint outpoint, const SigningProvider* provider, const CCoinControl* coin_control)
33
+ int CalculateMaximumSignedInputSize (const CTxOut& txout, const COutPoint outpoint, const SigningProvider* provider, bool can_grind_r, const CCoinControl* coin_control)
34
34
{
35
35
CMutableTransaction txn;
36
36
txn.vin .push_back (CTxIn (outpoint));
37
- if (!provider || !DummySignInput (*provider, txn.vin [0 ], txout, coin_control)) {
37
+ if (!provider || !DummySignInput (*provider, txn.vin [0 ], txout, can_grind_r, coin_control)) {
38
38
return -1 ;
39
39
}
40
40
return GetVirtualTransactionInputSize (txn.vin [0 ]);
@@ -43,7 +43,7 @@ int CalculateMaximumSignedInputSize(const CTxOut& txout, const COutPoint outpoin
43
43
int CalculateMaximumSignedInputSize (const CTxOut& txout, const CWallet* wallet, const CCoinControl* coin_control)
44
44
{
45
45
const std::unique_ptr<SigningProvider> provider = wallet->GetSolvingProvider (txout.scriptPubKey );
46
- return CalculateMaximumSignedInputSize (txout, COutPoint (), provider.get (), coin_control);
46
+ return CalculateMaximumSignedInputSize (txout, COutPoint (), provider.get (), wallet-> CanGrindR (), coin_control);
47
47
}
48
48
49
49
// txouts needs to be in the order of tx.vin
@@ -163,6 +163,7 @@ util::Result<PreSelectedInputs> FetchSelectedInputs(const CWallet& wallet, const
163
163
PreSelectedInputs result;
164
164
std::vector<COutPoint> vPresetInputs;
165
165
coin_control.ListSelected (vPresetInputs);
166
+ const bool can_grind_r = wallet.CanGrindR ();
166
167
for (const COutPoint& outpoint : vPresetInputs) {
167
168
int input_bytes = -1 ;
168
169
CTxOut txout;
@@ -181,7 +182,7 @@ util::Result<PreSelectedInputs> FetchSelectedInputs(const CWallet& wallet, const
181
182
}
182
183
183
184
if (input_bytes == -1 ) {
184
- input_bytes = CalculateMaximumSignedInputSize (txout, outpoint, &coin_control.m_external_provider , &coin_control);
185
+ input_bytes = CalculateMaximumSignedInputSize (txout, outpoint, &coin_control.m_external_provider , can_grind_r, &coin_control);
185
186
}
186
187
187
188
// If available, override calculated size with coin control specified size
@@ -214,6 +215,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
214
215
const int min_depth = {coinControl ? coinControl->m_min_depth : DEFAULT_MIN_DEPTH};
215
216
const int max_depth = {coinControl ? coinControl->m_max_depth : DEFAULT_MAX_DEPTH};
216
217
const bool only_safe = {coinControl ? !coinControl->m_include_unsafe_inputs : true };
218
+ const bool can_grind_r = wallet.CanGrindR ();
217
219
218
220
std::set<uint256> trusted_parents;
219
221
for (const auto & entry : wallet.mapWallet )
@@ -305,7 +307,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
305
307
306
308
std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider (output.scriptPubKey );
307
309
308
- int input_bytes = CalculateMaximumSignedInputSize (output, COutPoint (), provider.get (), coinControl);
310
+ int input_bytes = CalculateMaximumSignedInputSize (output, COutPoint (), provider.get (), can_grind_r, coinControl);
309
311
bool solvable = provider ? InferDescriptor (output.scriptPubKey , *provider)->IsSolvable () : false ;
310
312
bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
311
313
@@ -828,7 +830,7 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
828
830
coin_selection_params.change_output_size = GetSerializeSize (change_prototype_txout);
829
831
830
832
// Get size of spending the change output
831
- int change_spend_size = CalculateMaximumSignedInputSize (change_prototype_txout, &wallet);
833
+ int change_spend_size = CalculateMaximumSignedInputSize (change_prototype_txout, &wallet, /* coin_control= */ nullptr );
832
834
// If the wallet doesn't know how to sign change output, assume p2sh-p2wpkh
833
835
// as lower-bound to allow BnB to do it's thing
834
836
if (change_spend_size == -1 ) {
0 commit comments