@@ -2469,9 +2469,9 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
2469
2469
2470
2470
CReserveKey reservekey (this );
2471
2471
CWalletTx wtx;
2472
- if (!CreateTransaction (vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, & coinControl, false ))
2472
+ if (!CreateTransaction (vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false )) {
2473
2473
return false ;
2474
-
2474
+ }
2475
2475
if (nChangePosInOut != -1 )
2476
2476
tx.vout .insert (tx.vout .begin () + nChangePosInOut, wtx.tx ->vout [nChangePosInOut]);
2477
2477
@@ -2502,7 +2502,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
2502
2502
}
2503
2503
2504
2504
bool CWallet::CreateTransaction (const std::vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet,
2505
- int & nChangePosInOut, std::string& strFailReason, const CCoinControl* coinControl , bool sign)
2505
+ int & nChangePosInOut, std::string& strFailReason, const CCoinControl& coin_control , bool sign)
2506
2506
{
2507
2507
CAmount nValue = 0 ;
2508
2508
int nChangePosRequest = nChangePosInOut;
@@ -2567,20 +2567,17 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2567
2567
LOCK2 (cs_main, cs_wallet);
2568
2568
{
2569
2569
std::vector<COutput> vAvailableCoins;
2570
- AvailableCoins (vAvailableCoins, true , coinControl );
2570
+ AvailableCoins (vAvailableCoins, true , &coin_control );
2571
2571
2572
2572
// Create change script that will be used if we need change
2573
2573
// TODO: pass in scriptChange instead of reservekey so
2574
2574
// change transaction isn't always pay-to-bitcoin-address
2575
2575
CScript scriptChange;
2576
2576
2577
2577
// coin control: send change to custom address
2578
- if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange ))
2579
- scriptChange = GetScriptForDestination (coinControl->destChange );
2580
-
2581
- // no coin control: send change to newly generated address
2582
- else
2583
- {
2578
+ if (!boost::get<CNoDestination>(&coin_control.destChange )) {
2579
+ scriptChange = GetScriptForDestination (coin_control.destChange );
2580
+ } else { // no coin control: send change to newly generated address
2584
2581
// Note: We use a new key here to keep it from being obvious which side is the change.
2585
2582
// The drawback is that by not reusing a previous key, the change may be lost if a
2586
2583
// backup is restored, if the backup doesn't have the new private key for the change.
@@ -2654,7 +2651,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2654
2651
if (pick_new_inputs) {
2655
2652
nValueIn = 0 ;
2656
2653
setCoins.clear ();
2657
- if (!SelectCoins (vAvailableCoins, nValueToSelect, setCoins, nValueIn, coinControl ))
2654
+ if (!SelectCoins (vAvailableCoins, nValueToSelect, setCoins, nValueIn, &coin_control ))
2658
2655
{
2659
2656
strFailReason = _ (" Insufficient funds" );
2660
2657
return false ;
@@ -2705,8 +2702,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2705
2702
// to avoid conflicting with other possible uses of nSequence,
2706
2703
// and in the spirit of "smallest possible change from prior
2707
2704
// behavior."
2708
- bool rbf = coinControl ? coinControl->signalRbf : fWalletRbf ;
2709
- const uint32_t nSequence = rbf ? MAX_BIP125_RBF_SEQUENCE : (std::numeric_limits<unsigned int >::max () - 1 );
2705
+ const uint32_t nSequence = coin_control.signalRbf ? MAX_BIP125_RBF_SEQUENCE : (std::numeric_limits<unsigned int >::max () - 1 );
2710
2706
for (const auto & coin : setCoins)
2711
2707
txNew.vin .push_back (CTxIn (coin.outpoint ,CScript (),
2712
2708
nSequence));
@@ -2727,15 +2723,15 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2727
2723
2728
2724
// Allow to override the default confirmation target over the CoinControl instance
2729
2725
int currentConfirmationTarget = nTxConfirmTarget;
2730
- if (coinControl && coinControl-> nConfirmTarget > 0 )
2731
- currentConfirmationTarget = coinControl-> nConfirmTarget ;
2726
+ if (coin_control. nConfirmTarget > 0 )
2727
+ currentConfirmationTarget = coin_control. nConfirmTarget ;
2732
2728
2733
2729
// Allow to override the default fee estimate mode over the CoinControl instance
2734
- bool conservative_estimate = CalculateEstimateType (coinControl ? coinControl-> m_fee_mode : FeeEstimateMode::UNSET, rbf );
2730
+ bool conservative_estimate = CalculateEstimateType (coin_control. m_fee_mode , coin_control. signalRbf );
2735
2731
2736
2732
CAmount nFeeNeeded = GetMinimumFee (nBytes, currentConfirmationTarget, ::mempool, ::feeEstimator, &feeCalc, false /* ignoreGlobalPayTxFee */ , conservative_estimate);
2737
- if (coinControl && coinControl-> fOverrideFeeRate )
2738
- nFeeNeeded = coinControl-> nFeeRate .GetFee (nBytes);
2733
+ if (coin_control. fOverrideFeeRate )
2734
+ nFeeNeeded = coin_control. nFeeRate .GetFee (nBytes);
2739
2735
2740
2736
// If we made it here and we aren't even able to meet the relay fee on the next pass, give up
2741
2737
// because we must be at the maximum allowed fee.
0 commit comments