Skip to content

Commit 95d4450

Browse files
committed
[wallet] Tidy up CWallet::FundTransaction
1 parent 8ab6c0b commit 95d4450

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/wallet/wallet.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,18 +2592,18 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
25922592
{
25932593
std::vector<CRecipient> vecSend;
25942594

2595-
// Turn the txout set into a CRecipient vector
2596-
for (size_t idx = 0; idx < tx.vout.size(); idx++)
2597-
{
2595+
// Turn the txout set into a CRecipient vector.
2596+
for (size_t idx = 0; idx < tx.vout.size(); idx++) {
25982597
const CTxOut& txOut = tx.vout[idx];
25992598
CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, setSubtractFeeFromOutputs.count(idx) == 1};
26002599
vecSend.push_back(recipient);
26012600
}
26022601

26032602
coinControl.fAllowOtherInputs = true;
26042603

2605-
for (const CTxIn& txin : tx.vin)
2604+
for (const CTxIn& txin : tx.vin) {
26062605
coinControl.Select(txin.prevout);
2606+
}
26072607

26082608
CReserveKey reservekey(this);
26092609
CWalletTx wtx;
@@ -2613,31 +2613,29 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
26132613

26142614
if (nChangePosInOut != -1) {
26152615
tx.vout.insert(tx.vout.begin() + nChangePosInOut, wtx.tx->vout[nChangePosInOut]);
2616-
// we don't have the normal Create/Commit cycle, and don't want to risk reusing change,
2617-
// so just remove the key from the keypool here.
2616+
// We don't have the normal Create/Commit cycle, and don't want to risk
2617+
// reusing change, so just remove the key from the keypool here.
26182618
reservekey.KeepKey();
26192619
}
26202620

2621-
// Copy output sizes from new transaction; they may have had the fee subtracted from them
2622-
for (unsigned int idx = 0; idx < tx.vout.size(); idx++)
2621+
// Copy output sizes from new transaction; they may have had the fee
2622+
// subtracted from them.
2623+
for (unsigned int idx = 0; idx < tx.vout.size(); idx++) {
26232624
tx.vout[idx].nValue = wtx.tx->vout[idx].nValue;
2625+
}
26242626

2625-
// Add new txins (keeping original txin scriptSig/order)
2626-
for (const CTxIn& txin : wtx.tx->vin)
2627-
{
2628-
if (!coinControl.IsSelected(txin.prevout))
2629-
{
2627+
// Add new txins while keeping original txin scriptSig/order.
2628+
for (const CTxIn& txin : wtx.tx->vin) {
2629+
if (!coinControl.IsSelected(txin.prevout)) {
26302630
tx.vin.push_back(txin);
26312631

2632-
if (lockUnspents)
2633-
{
2634-
LOCK2(cs_main, cs_wallet);
2635-
LockCoin(txin.prevout);
2632+
if (lockUnspents) {
2633+
LOCK2(cs_main, cs_wallet);
2634+
LockCoin(txin.prevout);
26362635
}
26372636
}
26382637
}
26392638

2640-
26412639
return true;
26422640
}
26432641

0 commit comments

Comments
 (0)