Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 3,066 Lines • ▼ Show 20 Lines | CMutableTransaction txNew; | ||||
// dummy destination in case we don't need change. | // dummy destination in case we don't need change. | ||||
CTxDestination dest; | CTxDestination dest; | ||||
if (!reservedest.GetReservedDestination(dest, true)) { | if (!reservedest.GetReservedDestination(dest, true)) { | ||||
error = _("Transaction needs a change address, but we can't " | error = _("Transaction needs a change address, but we can't " | ||||
"generate it. Please call keypoolrefill first."); | "generate it. Please call keypoolrefill first."); | ||||
} | } | ||||
scriptChange = GetScriptForDestination(dest); | scriptChange = GetScriptForDestination(dest); | ||||
assert(!dest.empty() || scriptChange.empty()); | // A valid destination implies a change script (and | ||||
// vice-versa). An empty change script will abort later, if the | |||||
// change keypool ran out, but change is required. | |||||
CHECK_NONFATAL(IsValidDestination(dest) != scriptChange.empty()); | |||||
} | } | ||||
CTxOut change_prototype_txout(Amount::zero(), scriptChange); | CTxOut change_prototype_txout(Amount::zero(), scriptChange); | ||||
coin_selection_params.change_output_size = | coin_selection_params.change_output_size = | ||||
GetSerializeSize(change_prototype_txout); | GetSerializeSize(change_prototype_txout); | ||||
// Get the fee rate to use effective values in coin selection | // Get the fee rate to use effective values in coin selection | ||||
CFeeRate nFeeRateNeeded = GetMinimumFeeRate(*this, coin_control); | CFeeRate nFeeRateNeeded = GetMinimumFeeRate(*this, coin_control); | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | CMutableTransaction txNew; | ||||
} | } | ||||
// Include more fee and try again. | // Include more fee and try again. | ||||
nFeeRet = nFeeNeeded; | nFeeRet = nFeeNeeded; | ||||
coin_selection_params.use_bnb = false; | coin_selection_params.use_bnb = false; | ||||
continue; | continue; | ||||
} | } | ||||
// Give up if change keypool ran out and we failed to find a solution | // Give up if change keypool ran out and change is required | ||||
// without change: | |||||
if (scriptChange.empty() && nChangePosInOut != -1) { | if (scriptChange.empty() && nChangePosInOut != -1) { | ||||
return false; | return false; | ||||
} | } | ||||
// Shuffle selected coins and fill in final vin | // Shuffle selected coins and fill in final vin | ||||
txNew.vin.clear(); | txNew.vin.clear(); | ||||
std::vector<CInputCoin> selected_coins(setCoins.begin(), | std::vector<CInputCoin> selected_coins(setCoins.begin(), | ||||
setCoins.end()); | setCoins.end()); | ||||
▲ Show 20 Lines • Show All 1,725 Lines • Show Last 20 Lines |