From 8048a6d8bfab74292e7b150c22f769eddfd2d403 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 9 Apr 2019 13:29:31 -0400 Subject: [PATCH] QT: have output amounts propagated for subtractfeefromoutput logic --- src/interfaces/wallet.cpp | 5 ++++- src/interfaces/wallet.h | 1 + src/qt/walletmodel.cpp | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp index 9766fc5f9e..53e142c892 100644 --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -231,6 +231,7 @@ public: bool sign, int& change_pos, CAmount& fee, + std::vector& out_amounts, std::string& fail_reason) override { LOCK2(cs_main, m_wallet.cs_wallet); @@ -243,10 +244,12 @@ public: pending->m_keys.emplace_back(new CReserveKey(&m_wallet)); } } + BlindDetails blind_details; if (!m_wallet.CreateTransaction(recipients, pending->m_tx, pending->m_keys, fee, change_pos, - fail_reason, coin_control, sign)) { + fail_reason, coin_control, sign, &blind_details)) { return {}; } + out_amounts = blind_details.o_amounts; return std::move(pending); } bool transactionCanBeAbandoned(const uint256& txid) override { return m_wallet.TransactionCanBeAbandoned(txid); } diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 87d1891863..d608aab0ad 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -138,6 +138,7 @@ public: bool sign, int& change_pos, CAmount& fee, + std::vector& out_amounts, std::string& fail_reason) = 0; //! Return whether transaction can be abandoned. diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 7131cd7ef0..6123cf7941 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -234,9 +234,10 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact auto& newTx = transaction.getWtx(); std::vector out_amounts; - newTx = m_wallet->createTransaction(vecSend, coinControl, true /* sign */, nChangePosRet, nFeeRequired, strFailReason); + newTx = m_wallet->createTransaction(vecSend, coinControl, true /* sign */, nChangePosRet, nFeeRequired, out_amounts, strFailReason); transaction.setTransactionFee(nFeeRequired); if (fSubtractFeeFromAmount && newTx) + assert(out_amounts.size() == newTx->get().vout.size()); transaction.reassignAmounts(out_amounts, nChangePosRet); if(!newTx)