From 876fcec717b429dbbb58643aec28ac40f08b48ca Mon Sep 17 00:00:00 2001 From: sairajzero Date: Fri, 7 Sep 2018 19:18:28 +0530 Subject: [PATCH] Update --- src/wallet/wallet.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 610f60bd0..75678a561 100755 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2851,8 +2851,8 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CWalletT } txNew.vout.push_back(txout); } - - CTxDestination destChange; + + CTxDestination destChange; // Choose coins to use if (pick_new_inputs) { nValueIn = 0; @@ -2862,13 +2862,14 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CWalletT strFailReason = _("Insufficient funds"); return false; } + // Send Change Back to Same (sending) Address + if(!coinControlDestChange && gArgs.GetBoolArg("-SendChangeToBack", false)){ + scriptChange = GetScriptForDestination(destChange); + change_prototype_txout = CTxOut(0, scriptChange); + change_prototype_size = GetSerializeSize(change_prototype_txout, SER_DISK, 0); + } } - // Send Change Back to Same (sending) Address - if(!coinControlDestChange && gArgs.GetBoolArg("-SendChangeToBack", false)){ - scriptChange = GetScriptForDestination(destChange); - CTxOut change_prototype_txout(0, scriptChange); - size_t change_prototype_size = GetSerializeSize(change_prototype_txout, SER_DISK, 0); - } + const CAmount nChange = nValueIn - nValueToSelect;