CreateTransaction calls KeepDestination on ReserveDestination before success
This commit is contained in:
parent
6c1e45c4c4
commit
d9ff862f2d
2 changed files with 4 additions and 8 deletions
|
@ -281,9 +281,6 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
|
|||
return Result::WALLET_ERROR;
|
||||
}
|
||||
|
||||
// If change key hasn't been ReturnKey'ed by this point, we take it out of keypool
|
||||
reservedest.KeepDestination();
|
||||
|
||||
// Write back new fee if successful
|
||||
new_fee = fee_ret;
|
||||
|
||||
|
|
|
@ -2674,9 +2674,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
|
|||
|
||||
if (nChangePosInOut != -1) {
|
||||
tx.vout.insert(tx.vout.begin() + nChangePosInOut, tx_new->vout[nChangePosInOut]);
|
||||
// We don't have the normal Create/Commit cycle, and don't want to risk
|
||||
// reusing change, so just remove the key from the keypool here.
|
||||
reservedest.KeepDestination();
|
||||
}
|
||||
|
||||
// Copy output sizes from new transaction; they may have had the fee
|
||||
|
@ -3070,8 +3067,6 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
|||
}
|
||||
}
|
||||
|
||||
if (nChangePosInOut == -1) reservedest.ReturnDestination(); // Return any reserved address if we don't have change
|
||||
|
||||
// Shuffle selected coins and fill in final vin
|
||||
txNew.vin.clear();
|
||||
std::vector<CInputCoin> selected_coins(setCoins.begin(), setCoins.end());
|
||||
|
@ -3134,6 +3129,10 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
|||
}
|
||||
}
|
||||
|
||||
// Before we return success, we assume any change key will be used to prevent
|
||||
// accidental re-use.
|
||||
reservedest.KeepDestination();
|
||||
|
||||
WalletLogPrintf("Fee Calculation: Fee:%d Bytes:%u Needed:%d Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n",
|
||||
nFeeRet, nBytes, nFeeNeeded, feeCalc.returnedTarget, feeCalc.desiredTarget, StringForFeeReason(feeCalc.reason), feeCalc.est.decay,
|
||||
feeCalc.est.pass.start, feeCalc.est.pass.end,
|
||||
|
|
Loading…
Reference in a new issue