@@ -2674,9 +2674,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
2674
2674
2675
2675
if (nChangePosInOut != -1 ) {
2676
2676
tx.vout .insert (tx.vout .begin () + nChangePosInOut, tx_new->vout [nChangePosInOut]);
2677
- // We don't have the normal Create/Commit cycle, and don't want to risk
2678
- // reusing change, so just remove the key from the keypool here.
2679
- reservedest.KeepDestination ();
2680
2677
}
2681
2678
2682
2679
// 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
3070
3067
}
3071
3068
}
3072
3069
3073
- if (nChangePosInOut == -1 ) reservedest.ReturnDestination (); // Return any reserved address if we don't have change
3074
-
3075
3070
// Shuffle selected coins and fill in final vin
3076
3071
txNew.vin .clear ();
3077
3072
std::vector<CInputCoin> selected_coins (setCoins.begin (), setCoins.end ());
@@ -3134,6 +3129,10 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
3134
3129
}
3135
3130
}
3136
3131
3132
+ // Before we return success, we assume any change key will be used to prevent
3133
+ // accidental re-use.
3134
+ reservedest.KeepDestination ();
3135
+
3137
3136
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 " ,
3138
3137
nFeeRet, nBytes, nFeeNeeded, feeCalc.returnedTarget , feeCalc.desiredTarget , StringForFeeReason (feeCalc.reason ), feeCalc.est .decay ,
3139
3138
feeCalc.est .pass .start , feeCalc.est .pass .end ,
0 commit comments