@@ -301,11 +301,10 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
301
301
302
302
size_t ancestors, descendants;
303
303
wallet.chain ().getTransactionAncestry (output.outpoint .hash , ancestors, descendants);
304
- CInputCoin input_coin = output.GetInputCoin ();
305
304
306
305
// Make an OutputGroup containing just this output
307
306
OutputGroup group{coin_sel_params};
308
- group.Insert (input_coin, output. depth , output. from_me , ancestors, descendants, positive_only);
307
+ group.Insert (output, ancestors, descendants, positive_only);
309
308
310
309
// Check the OutputGroup's eligibility. Only add the eligible ones.
311
310
if (positive_only && group.GetSelectionAmount () <= 0 ) continue ;
@@ -317,18 +316,17 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
317
316
// We want to combine COutputs that have the same scriptPubKey into single OutputGroups
318
317
// except when there are more than OUTPUT_GROUP_MAX_ENTRIES COutputs grouped in an OutputGroup.
319
318
// To do this, we maintain a map where the key is the scriptPubKey and the value is a vector of OutputGroups.
320
- // For each COutput, we check if the scriptPubKey is in the map, and if it is, the COutput's CInputCoin is added
319
+ // For each COutput, we check if the scriptPubKey is in the map, and if it is, the COutput is added
321
320
// to the last OutputGroup in the vector for the scriptPubKey. When the last OutputGroup has
322
- // OUTPUT_GROUP_MAX_ENTRIES CInputCoins , a new OutputGroup is added to the end of the vector.
321
+ // OUTPUT_GROUP_MAX_ENTRIES COutputs , a new OutputGroup is added to the end of the vector.
323
322
std::map<CScript, std::vector<OutputGroup>> spk_to_groups_map;
324
323
for (const auto & output : outputs) {
325
324
// Skip outputs we cannot spend
326
325
if (!output.spendable ) continue ;
327
326
328
327
size_t ancestors, descendants;
329
328
wallet.chain ().getTransactionAncestry (output.outpoint .hash , ancestors, descendants);
330
- CInputCoin input_coin = output.GetInputCoin ();
331
- CScript spk = input_coin.txout .scriptPubKey ;
329
+ CScript spk = output.txout .scriptPubKey ;
332
330
333
331
std::vector<OutputGroup>& groups = spk_to_groups_map[spk];
334
332
@@ -337,7 +335,7 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
337
335
groups.emplace_back (coin_sel_params);
338
336
}
339
337
340
- // Get the last OutputGroup in the vector so that we can add the CInputCoin to it
338
+ // Get the last OutputGroup in the vector so that we can add the COutput to it
341
339
// A pointer is used here so that group can be reassigned later if it is full.
342
340
OutputGroup* group = &groups.back ();
343
341
@@ -349,8 +347,8 @@ std::vector<OutputGroup> GroupOutputs(const CWallet& wallet, const std::vector<C
349
347
group = &groups.back ();
350
348
}
351
349
352
- // Add the input_coin to group
353
- group->Insert (input_coin, output. depth , output. from_me , ancestors, descendants, positive_only);
350
+ // Add the output to group
351
+ group->Insert (output, ancestors, descendants, positive_only);
354
352
}
355
353
356
354
// Now we go through the entire map and pull out the OutputGroups
@@ -427,10 +425,10 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
427
425
{
428
426
for (const COutput& out : vCoins) {
429
427
if (!out.spendable ) continue ;
430
- /* Set depth, from_me, ancestors, and descendants to 0 or false as these don't matter for preset inputs as no actual selection is being done.
428
+ /* Set ancestors and descendants to 0 as these don't matter for preset inputs as no actual selection is being done.
431
429
* positive_only is set to false because we want to include all preset inputs, even if they are dust.
432
430
*/
433
- preset_inputs.Insert (out. GetInputCoin (), 0 , false , 0 , 0 , false );
431
+ preset_inputs.Insert (out, /* ancestors= */ 0 , /* descendants= */ 0 , /* positive_only= */ false );
434
432
}
435
433
SelectionResult result (nTargetValue);
436
434
result.AddInput (preset_inputs);
@@ -439,7 +437,7 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
439
437
}
440
438
441
439
// calculate value from preset inputs and store them
442
- std::set<CInputCoin> setPresetCoins ;
440
+ std::set<COutPoint> preset_coins ;
443
441
444
442
std::vector<COutPoint> vPresetInputs;
445
443
coin_control.ListSelected (vPresetInputs);
@@ -467,27 +465,29 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
467
465
input_bytes = GetVirtualTransactionSize (coin_control.GetInputWeight (outpoint), 0 , 0 );
468
466
}
469
467
470
- CInputCoin coin (outpoint, txout, input_bytes);
471
- if (coin.m_input_bytes == -1 ) {
468
+ if (input_bytes == -1 ) {
472
469
return std::nullopt; // Not solvable, can't estimate size for fee
473
470
}
474
- coin.effective_value = coin.txout .nValue - coin_selection_params.m_effective_feerate .GetFee (coin.m_input_bytes );
471
+
472
+ /* Set some defaults for depth, spendable, solvable, safe, time, and from_me as these don't matter for preset inputs since no selection is being done. */
473
+ COutput output (outpoint, txout, /* depth=*/ 0 , input_bytes, /* spendable=*/ true , /* solvable=*/ true , /* safe=*/ true , /* time=*/ 0 , /* from_me=*/ false );
474
+ output.effective_value = output.txout .nValue - coin_selection_params.m_effective_feerate .GetFee (output.input_bytes );
475
475
if (coin_selection_params.m_subtract_fee_outputs ) {
476
- value_to_select -= coin .txout .nValue ;
476
+ value_to_select -= output .txout .nValue ;
477
477
} else {
478
- value_to_select -= coin .effective_value ;
478
+ value_to_select -= output .effective_value ;
479
479
}
480
- setPresetCoins .insert (coin );
481
- /* Set depth, from_me, ancestors, and descendants to 0 or false as don't matter for preset inputs as no actual selection is being done.
480
+ preset_coins .insert (outpoint );
481
+ /* Set ancestors and descendants to 0 as they don't matter for preset inputs since no actual selection is being done.
482
482
* positive_only is set to false because we want to include all preset inputs, even if they are dust.
483
483
*/
484
- preset_inputs.Insert (coin, 0 , false , 0 , 0 , false );
484
+ preset_inputs.Insert (output, /* ancestors= */ 0 , /* descendants= */ 0 , /* positive_only= */ false );
485
485
}
486
486
487
487
// remove preset inputs from vCoins so that Coin Selection doesn't pick them.
488
488
for (std::vector<COutput>::iterator it = vCoins.begin (); it != vCoins.end () && coin_control.HasSelected ();)
489
489
{
490
- if (setPresetCoins .count (it->GetInputCoin () ))
490
+ if (preset_coins .count (it->outpoint ))
491
491
it = vCoins.erase (it);
492
492
else
493
493
++it;
@@ -802,7 +802,7 @@ static bool CreateTransactionInternal(
802
802
auto change_position = txNew.vout .insert (txNew.vout .begin () + nChangePosInOut, newTxOut);
803
803
804
804
// Shuffle selected coins and fill in final vin
805
- std::vector<CInputCoin > selected_coins = result->GetShuffledInputVector ();
805
+ std::vector<COutput > selected_coins = result->GetShuffledInputVector ();
806
806
807
807
// The sequence number is set to non-maxint so that DiscourageFeeSniping
808
808
// works.
0 commit comments