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. | ||||
#ifdef HAVE_CONFIG_H | |||||
#include <config/bitcoin-config.h> | |||||
#endif | |||||
#include <qt/walletmodeltransaction.h> | #include <qt/walletmodeltransaction.h> | ||||
#include <interfaces/node.h> | #include <interfaces/node.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
WalletModelTransaction::WalletModelTransaction( | WalletModelTransaction::WalletModelTransaction( | ||||
const QList<SendCoinsRecipient> &_recipients) | const QList<SendCoinsRecipient> &_recipients) | ||||
: recipients(_recipients), fee() {} | : recipients(_recipients), fee() {} | ||||
Show All 17 Lines | |||||
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(); | const CTransaction *walletTransaction = &wtx->get(); | ||||
int i = 0; | int i = 0; | ||||
for (SendCoinsRecipient &rcp : recipients) { | for (SendCoinsRecipient &rcp : recipients) { | ||||
#ifdef ENABLE_BIP70 | |||||
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); | ||||
if (out.amount() <= 0) { | if (out.amount() <= 0) { | ||||
continue; | continue; | ||||
} | } | ||||
if (i == nChangePosRet) { | if (i == nChangePosRet) { | ||||
i++; | i++; | ||||
} | } | ||||
subtotal += walletTransaction->vout[i].nValue; | subtotal += walletTransaction->vout[i].nValue; | ||||
i++; | i++; | ||||
} | } | ||||
rcp.amount = subtotal; | rcp.amount = subtotal; | ||||
} else { | } | ||||
// normal recipient (no payment request) | // normal recipient (no payment request) | ||||
else | |||||
#endif | |||||
{ | |||||
if (i == nChangePosRet) { | if (i == nChangePosRet) { | ||||
i++; | i++; | ||||
} | } | ||||
rcp.amount = walletTransaction->vout[i].nValue; | rcp.amount = walletTransaction->vout[i].nValue; | ||||
i++; | i++; | ||||
} | } | ||||
} | } | ||||
Show All 9 Lines |