Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletmodeltransaction.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "walletmodeltransaction.h" | #include "walletmodeltransaction.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
WalletModelTransaction::WalletModelTransaction( | WalletModelTransaction::WalletModelTransaction( | ||||
const QList<SendCoinsRecipient> &_recipients) | const QList<SendCoinsRecipient> &_recipients) | ||||
: recipients(_recipients), walletTransaction(0), fee() { | : recipients(_recipients), walletTransaction(0), fee() {} | ||||
walletTransaction = new CWalletTx(); | |||||
} | |||||
WalletModelTransaction::~WalletModelTransaction() { | |||||
delete walletTransaction; | |||||
} | |||||
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const { | QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const { | ||||
return recipients; | return recipients; | ||||
} | } | ||||
CWalletTx *WalletModelTransaction::getTransaction() const { | CTransactionRef &WalletModelTransaction::getTransaction() { | ||||
return walletTransaction; | return walletTransaction; | ||||
} | } | ||||
unsigned int WalletModelTransaction::getTransactionSize() { | unsigned int WalletModelTransaction::getTransactionSize() { | ||||
return !walletTransaction ? 0 | return !walletTransaction ? 0 | ||||
: CTransaction(*walletTransaction).GetTotalSize(); | : CTransaction(*walletTransaction).GetTotalSize(); | ||||
} | } | ||||
Show All 17 Lines | for (SendCoinsRecipient &rcp : recipients) { | ||||
if (out.amount() <= 0) { | if (out.amount() <= 0) { | ||||
continue; | continue; | ||||
} | } | ||||
if (i == nChangePosRet) { | if (i == nChangePosRet) { | ||||
i++; | i++; | ||||
} | } | ||||
subtotal += walletTransaction->tx->vout[i].nValue; | subtotal += walletTransaction->vout[i].nValue; | ||||
i++; | i++; | ||||
} | } | ||||
rcp.amount = subtotal; | rcp.amount = subtotal; | ||||
} else { | } else { | ||||
// normal recipient (no payment request) | // normal recipient (no payment request) | ||||
if (i == nChangePosRet) { | if (i == nChangePosRet) { | ||||
i++; | i++; | ||||
} | } | ||||
rcp.amount = walletTransaction->tx->vout[i].nValue; | rcp.amount = walletTransaction->vout[i].nValue; | ||||
i++; | i++; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
Amount WalletModelTransaction::getTotalTransactionAmount() const { | Amount WalletModelTransaction::getTotalTransactionAmount() const { | ||||
Amount totalTransactionAmount = Amount::zero(); | Amount totalTransactionAmount = Amount::zero(); | ||||
for (const SendCoinsRecipient &rcp : recipients) { | for (const SendCoinsRecipient &rcp : recipients) { | ||||
Show All 12 Lines |