diff options
author | Gregory Sanders <gsanders87@gmail.com> | 2019-06-13 14:12:01 -0400 |
---|---|---|
committer | Gregory Sanders <gsanders87@gmail.com> | 2019-07-10 11:38:37 -0400 |
commit | d9ff862f2d24784ee081a8f62a76ffdfe409c10a (patch) | |
tree | 62978768688e6a9c502fb96de79a2d5e4c5caaaf /src/wallet/wallet.cpp | |
parent | 6c1e45c4c41676f80ac6fb8d48cfbcf839593f19 (diff) |
CreateTransaction calls KeepDestination on ReserveDestination before success
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a9bd1e3164..75c3989a25 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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, |