1 // Copyright (c) 2011-2019 The Bitcoin Core developers 2 // Distributed under the MIT software license, see the accompanying 3 // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 5 #ifdef HAVE_CONFIG_H 6 #include <config/bitcoin-config.h> 7 #endif 8 9 #include <qt/walletmodeltransaction.h> 10 11 #include <policy/policy.h> 12 WalletModelTransaction(const QList<SendCoinsRecipient> & _recipients)13WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) : 14 recipients(_recipients), 15 fee(0) 16 { 17 } 18 getRecipients() const19QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const 20 { 21 return recipients; 22 } 23 getWtx()24CTransactionRef& WalletModelTransaction::getWtx() 25 { 26 return wtx; 27 } 28 getTransactionSize()29unsigned int WalletModelTransaction::getTransactionSize() 30 { 31 return wtx ? GetVirtualTransactionSize(*wtx) : 0; 32 } 33 getTransactionFee() const34CAmount WalletModelTransaction::getTransactionFee() const 35 { 36 return fee; 37 } 38 setTransactionFee(const CAmount & newFee)39void WalletModelTransaction::setTransactionFee(const CAmount& newFee) 40 { 41 fee = newFee; 42 } 43 reassignAmounts(int nChangePosRet)44void WalletModelTransaction::reassignAmounts(int nChangePosRet) 45 { 46 const CTransaction* walletTransaction = wtx.get(); 47 int i = 0; 48 for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it) 49 { 50 SendCoinsRecipient& rcp = (*it); 51 { 52 if (i == nChangePosRet) 53 i++; 54 rcp.amount = walletTransaction->vout[i].nValue; 55 i++; 56 } 57 } 58 } 59 getTotalTransactionAmount() const60CAmount WalletModelTransaction::getTotalTransactionAmount() const 61 { 62 CAmount totalTransactionAmount = 0; 63 for (const SendCoinsRecipient &rcp : recipients) 64 { 65 totalTransactionAmount += rcp.amount; 66 } 67 return totalTransactionAmount; 68 } 69