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 "interface/node.h" | |||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "wallet/wallet.h" | |||||
WalletModelTransaction::WalletModelTransaction( | WalletModelTransaction::WalletModelTransaction( | ||||
const QList<SendCoinsRecipient> &_recipients) | const QList<SendCoinsRecipient> &_recipients) | ||||
: recipients(_recipients), walletTransaction(0), fee() {} | : recipients(_recipients), fee() {} | ||||
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const { | QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const { | ||||
return recipients; | return recipients; | ||||
} | } | ||||
CTransactionRef &WalletModelTransaction::getTransaction() { | std::unique_ptr<interface::PendingWalletTx> &WalletModelTransaction::getWtx() { | ||||
return walletTransaction; | return wtx; | ||||
} | } | ||||
unsigned int WalletModelTransaction::getTransactionSize() { | unsigned int WalletModelTransaction::getTransactionSize() { | ||||
return !walletTransaction ? 0 | // TODO Fix "virtual" size | ||||
: CTransaction(*walletTransaction).GetTotalSize(); | return wtx ? wtx->getVirtualSize() : 0; | ||||
} | } | ||||
Amount WalletModelTransaction::getTransactionFee() const { | Amount WalletModelTransaction::getTransactionFee() const { | ||||
return fee; | return fee; | ||||
} | } | ||||
void WalletModelTransaction::setTransactionFee(const Amount newFee) { | void WalletModelTransaction::setTransactionFee(const Amount newFee) { | ||||
fee = newFee; | fee = newFee; | ||||
} | } | ||||
void WalletModelTransaction::reassignAmounts(int nChangePosRet) { | void WalletModelTransaction::reassignAmounts(int nChangePosRet) { | ||||
const CTransaction *walletTransaction = &wtx->get(); | |||||
int i = 0; | int i = 0; | ||||
for (SendCoinsRecipient &rcp : recipients) { | for (SendCoinsRecipient &rcp : recipients) { | ||||
if (rcp.paymentRequest.IsInitialized()) { | if (rcp.paymentRequest.IsInitialized()) { | ||||
Amount subtotal = Amount::zero(); | Amount subtotal = Amount::zero(); | ||||
const payments::PaymentDetails &details = | const payments::PaymentDetails &details = | ||||
rcp.paymentRequest.getDetails(); | rcp.paymentRequest.getDetails(); | ||||
for (int j = 0; j < details.outputs_size(); j++) { | for (int j = 0; j < details.outputs_size(); j++) { | ||||
const payments::Output &out = details.outputs(j); | const payments::Output &out = details.outputs(j); | ||||
Show All 23 Lines | |||||
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) { | ||||
totalTransactionAmount += rcp.amount; | totalTransactionAmount += rcp.amount; | ||||
} | } | ||||
return totalTransactionAmount; | return totalTransactionAmount; | ||||
} | } | ||||
void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet) { | |||||
keyChange.reset(new CReserveKey(wallet)); | |||||
} | |||||
CReserveKey *WalletModelTransaction::getPossibleKeyChange() { | |||||
return keyChange.get(); | |||||
} |