GUI: TransactionRecord: Add asset issuance record type

This commit is contained in:
Luke Dashjr 2018-12-15 22:07:28 +00:00 committed by Gregory Sanders
parent e6b3676b37
commit 51e789722f
6 changed files with 37 additions and 3 deletions

View file

@ -61,8 +61,14 @@ static WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx) EXCLUSIVE_LO
WalletTx result;
result.tx = wtx.tx;
result.txin_is_mine.reserve(wtx.tx->vin.size());
for (const auto& txin : wtx.tx->vin) {
result.txin_issuance_asset.resize(wtx.tx->vin.size());
result.txin_issuance_token.resize(wtx.tx->vin.size());
for (unsigned int i = 0; i < wtx.tx->vin.size(); ++i) {
const auto& txin = wtx.tx->vin[i];
result.txin_is_mine.emplace_back(wallet.IsMine(txin));
wtx.GetIssuanceAssets(i, &result.txin_issuance_asset[i], &result.txin_issuance_token[i]);
result.txin_issuance_asset_amount.emplace_back(wtx.GetIssuanceAmount(i, false));
result.txin_issuance_token_amount.emplace_back(wtx.GetIssuanceAmount(i, true));
}
result.txout_is_mine.reserve(wtx.tx->vout.size());
result.txout_address.reserve(wtx.tx->vout.size());

View file

@ -337,6 +337,10 @@ struct WalletTx
std::vector<isminetype> txout_address_is_mine;
std::vector<CAmount> txout_amounts;
std::vector<CAsset> txout_assets;
std::vector<CAmount> txin_issuance_asset_amount;
std::vector<CAsset> txin_issuance_asset;
std::vector<CAmount> txin_issuance_token_amount;
std::vector<CAsset> txin_issuance_token;
CAmountMap credit;
CAmountMap debit;
CAmountMap change;

View file

@ -80,10 +80,27 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
{
bool involvesWatchAddress = false;
isminetype fAllFromMe = ISMINE_SPENDABLE;
for (const isminetype mine : wtx.txin_is_mine)
for (size_t i = 0; i < wtx.tx->vin.size(); ++i)
{
isminetype mine = wtx.txin_is_mine[i];
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllFromMe > mine) fAllFromMe = mine;
if (!wtx.txin_issuance_asset[i].IsNull()) {
TransactionRecord sub(hash, nTime);
sub.involvesWatchAddress = involvesWatchAddress;
sub.asset = wtx.txin_issuance_asset[i];
sub.amount = wtx.txin_issuance_asset_amount[i];
sub.type = TransactionRecord::IssuedAsset;
parts.append(sub);
}
if (!wtx.txin_issuance_token[i].IsNull()) {
TransactionRecord sub(hash, nTime);
sub.involvesWatchAddress = involvesWatchAddress;
sub.asset = wtx.txin_issuance_token[i];
sub.amount = wtx.txin_issuance_token_amount[i];
sub.type = TransactionRecord::IssuedAsset;
parts.append(sub);
}
}
isminetype fAllToMe = ISMINE_SPENDABLE;

View file

@ -83,7 +83,8 @@ public:
RecvWithAddress,
RecvFromOther,
SendToSelf,
Fee
Fee,
IssuedAsset,
};
/** Number of confirmation recommended for accepting a transaction */

View file

@ -354,6 +354,8 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
return tr("Mined");
case TransactionRecord::Fee:
return tr("Fee");
case TransactionRecord::IssuedAsset:
return tr("Issuance");
default:
return QString();
}
@ -364,6 +366,7 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
switch(wtx->type)
{
case TransactionRecord::Generated:
case TransactionRecord::IssuedAsset:
return QIcon(":/icons/tx_mined");
case TransactionRecord::RecvWithAddress:
case TransactionRecord::RecvFromOther:
@ -392,6 +395,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::IssuedAsset:
return lookupAddress(wtx->address, tooltip) + watchAddress;
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address) + watchAddress;
@ -409,6 +413,7 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::IssuedAsset:
{
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
if(label.isEmpty())

View file

@ -125,6 +125,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
typeWidget->addItem(tr("Fee"), TransactionFilterProxy::TYPE(TransactionRecord::Fee));
typeWidget->addItem(tr("Issuance"), TransactionFilterProxy::TYPE(TransactionRecord::IssuedAsset));
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
hlayout->addWidget(typeWidget);