elements/src/qt/walletmodeltransaction.cpp

76 lines
1.8 KiB
C++
Raw Normal View History

// Copyright (c) 2011-2021 The Bitcoin Core developers
2014-12-13 12:09:33 +08:00
// Distributed under the MIT software license, see the accompanying
// 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 <policy/policy.h>
2019-01-08 14:18:10 +00:00
#define SendCoinsRecipient SendAssetsRecipient
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient>& _recipients)
: recipients(_recipients)
{
}
2019-01-08 14:18:10 +00:00
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const
{
return recipients;
}
CTransactionRef& WalletModelTransaction::getWtx()
{
return wtx;
}
2020-02-21 22:28:40 +01:00
void WalletModelTransaction::setWtx(const CTransactionRef& newTx)
{
wtx = newTx;
}
2014-11-02 00:14:47 +01:00
unsigned int WalletModelTransaction::getTransactionSize()
{
return wtx ? GetVirtualTransactionSize(*wtx) : 0;
2014-11-02 00:14:47 +01:00
}
CAmount WalletModelTransaction::getTransactionFee() const
{
return fee;
}
2014-04-22 15:46:19 -07:00
void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
{
fee = newFee;
}
2019-01-08 14:18:10 +00:00
void WalletModelTransaction::reassignAmounts(const std::vector<CAmount>& outAmounts, int nChangePosRet)
{
const CTransaction* walletTransaction = wtx.get();
int i = 0;
for (auto it = recipients.begin(); it != recipients.end(); ++it)
{
auto& rcp = (*it);
{
if (i == nChangePosRet)
i++;
2019-04-10 13:53:54 -04:00
rcp.asset_amount = g_con_elementsmode ? outAmounts[i] : walletTransaction->vout[i].nValue.GetAmount();
i++;
}
}
}
2019-01-08 14:18:10 +00:00
CAmountMap WalletModelTransaction::getTotalTransactionAmount() const
{
2019-01-08 14:18:10 +00:00
CAmountMap totalTransactionAmount;
for (const auto &rcp : recipients)
{
2019-01-08 14:18:10 +00:00
totalTransactionAmount[rcp.asset] += rcp.asset_amount;
}
return totalTransactionAmount;
}