@@ -2469,9 +2469,9 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
24692469
24702470 CReserveKey reservekey (this );
24712471 CWalletTx wtx;
2472- if (!CreateTransaction (vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, & coinControl, false ))
2472+ if (!CreateTransaction (vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false )) {
24732473 return false ;
2474-
2474+ }
24752475 if (nChangePosInOut != -1 )
24762476 tx.vout .insert (tx.vout .begin () + nChangePosInOut, wtx.tx ->vout [nChangePosInOut]);
24772477
@@ -2502,7 +2502,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
25022502}
25032503
25042504bool 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)
25062506{
25072507 CAmount nValue = 0 ;
25082508 int nChangePosRequest = nChangePosInOut;
@@ -2567,20 +2567,17 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
25672567 LOCK2 (cs_main, cs_wallet);
25682568 {
25692569 std::vector<COutput> vAvailableCoins;
2570- AvailableCoins (vAvailableCoins, true , coinControl );
2570+ AvailableCoins (vAvailableCoins, true , &coin_control );
25712571
25722572 // Create change script that will be used if we need change
25732573 // TODO: pass in scriptChange instead of reservekey so
25742574 // change transaction isn't always pay-to-bitcoin-address
25752575 CScript scriptChange;
25762576
25772577 // 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
25842581 // Note: We use a new key here to keep it from being obvious which side is the change.
25852582 // The drawback is that by not reusing a previous key, the change may be lost if a
25862583 // 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
26542651 if (pick_new_inputs) {
26552652 nValueIn = 0 ;
26562653 setCoins.clear ();
2657- if (!SelectCoins (vAvailableCoins, nValueToSelect, setCoins, nValueIn, coinControl ))
2654+ if (!SelectCoins (vAvailableCoins, nValueToSelect, setCoins, nValueIn, &coin_control ))
26582655 {
26592656 strFailReason = _ (" Insufficient funds" );
26602657 return false ;
@@ -2705,8 +2702,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27052702 // to avoid conflicting with other possible uses of nSequence,
27062703 // and in the spirit of "smallest possible change from prior
27072704 // 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 );
27102706 for (const auto & coin : setCoins)
27112707 txNew.vin .push_back (CTxIn (coin.outpoint ,CScript (),
27122708 nSequence));
@@ -2727,15 +2723,15 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27272723
27282724 // Allow to override the default confirmation target over the CoinControl instance
27292725 int currentConfirmationTarget = nTxConfirmTarget;
2730- if (coinControl && coinControl-> nConfirmTarget > 0 )
2731- currentConfirmationTarget = coinControl-> nConfirmTarget ;
2726+ if (coin_control. nConfirmTarget > 0 )
2727+ currentConfirmationTarget = coin_control. nConfirmTarget ;
27322728
27332729 // 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 );
27352731
27362732 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);
27392735
27402736 // If we made it here and we aren't even able to meet the relay fee on the next pass, give up
27412737 // because we must be at the maximum allowed fee.
0 commit comments