Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,641 Lines • ▼ Show 20 Lines | int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, | ||||
return GetSerializeSize(txNew, PROTOCOL_VERSION); | return GetSerializeSize(txNew, PROTOCOL_VERSION); | ||||
} | } | ||||
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *wallet, | int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *wallet, | ||||
bool use_max_sig) { | bool use_max_sig) { | ||||
CMutableTransaction txn; | CMutableTransaction txn; | ||||
txn.vin.push_back(CTxIn(COutPoint())); | txn.vin.push_back(CTxIn(COutPoint())); | ||||
if (!wallet->DummySignInput(txn.vin[0], txout, use_max_sig)) { | if (!wallet->DummySignInput(txn.vin[0], txout, use_max_sig)) { | ||||
// This should never happen, because IsAllFromMe(ISMINE_SPENDABLE) | |||||
// implies that we can sign for every input. | |||||
return -1; | return -1; | ||||
} | } | ||||
return GetSerializeSize(txn.vin[0], PROTOCOL_VERSION); | return GetSerializeSize(txn.vin[0], PROTOCOL_VERSION); | ||||
} | } | ||||
void CWalletTx::GetAmounts(std::list<COutputEntry> &listReceived, | void CWalletTx::GetAmounts(std::list<COutputEntry> &listReceived, | ||||
std::list<COutputEntry> &listSent, Amount &nFee, | std::list<COutputEntry> &listSent, Amount &nFee, | ||||
const isminefilter &filter) const { | const isminefilter &filter) const { | ||||
▲ Show 20 Lines • Show All 1,495 Lines • ▼ Show 20 Lines | CMutableTransaction txNew; | ||||
txNew.vout.push_back(txout); | txNew.vout.push_back(txout); | ||||
} | } | ||||
// Choose coins to use | // Choose coins to use | ||||
bool bnb_used = false; | bool bnb_used = false; | ||||
if (pick_new_inputs) { | if (pick_new_inputs) { | ||||
nValueIn = Amount::zero(); | nValueIn = Amount::zero(); | ||||
setCoins.clear(); | setCoins.clear(); | ||||
int change_spend_size = CalculateMaximumSignedInputSize( | |||||
change_prototype_txout, this); | |||||
// If the wallet doesn't know how to sign change output, assume | |||||
// p2pkh as lower-bound to allow BnB to do it's thing | |||||
if (change_spend_size == -1) { | |||||
coin_selection_params.change_spend_size = | coin_selection_params.change_spend_size = | ||||
CalculateMaximumSignedInputSize(change_prototype_txout, | DUMMY_P2PKH_INPUT_SIZE; | ||||
this); | } else { | ||||
coin_selection_params.change_spend_size = | |||||
size_t(change_spend_size); | |||||
} | |||||
coin_selection_params.effective_fee = nFeeRateNeeded; | coin_selection_params.effective_fee = nFeeRateNeeded; | ||||
if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, | if (!SelectCoins(vAvailableCoins, nValueToSelect, setCoins, | ||||
nValueIn, coin_control, coin_selection_params, | nValueIn, coin_control, coin_selection_params, | ||||
bnb_used)) { | bnb_used)) { | ||||
// If BnB was used, it was the first pass. No longer the | // If BnB was used, it was the first pass. No longer the | ||||
// first pass and continue loop with knapsack. | // first pass and continue loop with knapsack. | ||||
if (bnb_used) { | if (bnb_used) { | ||||
coin_selection_params.use_bnb = false; | coin_selection_params.use_bnb = false; | ||||
▲ Show 20 Lines • Show All 1,880 Lines • Show Last 20 Lines |