mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
feat: make a support of Qt app to show Platform Transfer transaction as a new type of transaction
This commit is contained in:
parent
28e20b31eb
commit
1fb67ece0e
@ -411,6 +411,7 @@ struct WalletTx
|
||||
int64_t time;
|
||||
std::map<std::string, std::string> value_map;
|
||||
bool is_coinbase;
|
||||
bool is_platform_transfer{false};
|
||||
bool is_denominate;
|
||||
};
|
||||
|
||||
|
@ -264,6 +264,11 @@ public:
|
||||
return nVersion >= SPECIAL_VERSION;
|
||||
}
|
||||
|
||||
bool IsPlatformTransfer() const noexcept
|
||||
{
|
||||
return IsSpecialTxVersion() && nType == TRANSACTION_ASSET_UNLOCK;
|
||||
}
|
||||
|
||||
bool HasExtraPayloadField() const noexcept
|
||||
{
|
||||
return IsSpecialTxVersion() && nType != TRANSACTION_NORMAL;
|
||||
|
@ -93,6 +93,10 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||
{
|
||||
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
|
||||
}
|
||||
else if (wtx.is_platform_transfer)
|
||||
{
|
||||
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Platform Transfer") + "<br>";
|
||||
}
|
||||
else if (wtx.value_map.count("from") && !wtx.value_map["from"].empty())
|
||||
{
|
||||
// Online transaction
|
||||
|
@ -39,7 +39,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(interfaces::Wal
|
||||
auto node = interfaces::MakeNode();
|
||||
auto& coinJoinOptions = node->coinJoinOptions();
|
||||
|
||||
if (nNet > 0 || wtx.is_coinbase)
|
||||
if (nNet > 0 || wtx.is_coinbase || wtx.is_platform_transfer)
|
||||
{
|
||||
//
|
||||
// Credit
|
||||
@ -74,6 +74,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(interfaces::Wal
|
||||
// Generated
|
||||
sub.type = TransactionRecord::Generated;
|
||||
}
|
||||
if (wtx.is_platform_transfer)
|
||||
{
|
||||
// Withdrawal from platform
|
||||
sub.type = TransactionRecord::PlatformTransfer;
|
||||
}
|
||||
|
||||
parts.append(sub);
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ public:
|
||||
CoinJoinCollateralPayment,
|
||||
CoinJoinMakeCollaterals,
|
||||
CoinJoinCreateDenominations,
|
||||
CoinJoinSend
|
||||
CoinJoinSend,
|
||||
PlatformTransfer,
|
||||
};
|
||||
|
||||
/** Number of confirmation recommended for accepting a transaction */
|
||||
|
@ -530,6 +530,7 @@ QVariant TransactionTableModel::amountColor(const TransactionRecord *rec) const
|
||||
case TransactionRecord::RecvWithCoinJoin:
|
||||
case TransactionRecord::RecvWithAddress:
|
||||
case TransactionRecord::RecvFromOther:
|
||||
case TransactionRecord::PlatformTransfer:
|
||||
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::GREEN);
|
||||
case TransactionRecord::CoinJoinSend:
|
||||
case TransactionRecord::SendToAddress:
|
||||
|
@ -90,6 +90,7 @@ TransactionView::TransactionView(QWidget* parent) :
|
||||
typeWidget->addItem(tr("%1 Collateral Payment").arg(strCoinJoinName), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinCollateralPayment));
|
||||
typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
|
||||
typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
|
||||
typeWidget->addItem(tr("Platform Transfer"), TransactionFilterProxy::TYPE(TransactionRecord::PlatformTransfer));
|
||||
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
|
||||
typeWidget->setCurrentIndex(settings.value("transactionType").toInt());
|
||||
|
||||
|
@ -81,6 +81,7 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
|
||||
result.time = wtx.GetTxTime();
|
||||
result.value_map = wtx.mapValue;
|
||||
result.is_coinbase = wtx.IsCoinBase();
|
||||
result.is_platform_transfer = wtx.IsPlatformTransfer();
|
||||
// The determination of is_denominate is based on simplified checks here because in this part of the code
|
||||
// we only want to know about mixing transactions belonging to this specific wallet.
|
||||
result.is_denominate = wtx.tx->vin.size() == wtx.tx->vout.size() && // Number of inputs is same as number of outputs
|
||||
|
@ -167,6 +167,8 @@ static void WalletTxToJSON(interfaces::Chain& chain, const CWalletTx& wtx, UniVa
|
||||
entry.pushKV("chainlock", chainlock);
|
||||
if (wtx.IsCoinBase())
|
||||
entry.pushKV("generated", true);
|
||||
if (wtx.IsPlatformTransfer())
|
||||
entry.pushKV("platform-transfer", true);
|
||||
if (confirms > 0)
|
||||
{
|
||||
entry.pushKV("blockhash", wtx.m_confirm.hashBlock.GetHex());
|
||||
@ -1403,6 +1405,10 @@ static void ListTransactions(const CWallet& wallet, const CWalletTx& wtx, int nM
|
||||
else
|
||||
entry.pushKV("category", "generate");
|
||||
}
|
||||
else if (wtx.IsPlatformTransfer())
|
||||
{
|
||||
entry.pushKV("category", "platform-transfer");
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.pushKV("category", "receive");
|
||||
@ -1467,7 +1473,8 @@ static RPCHelpMan listtransactions()
|
||||
"\"receive\" Non-coinbase transactions received.\n"
|
||||
"\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
|
||||
"\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
|
||||
"\"orphan\" Orphaned coinbase transactions received.\n"},
|
||||
"\"orphan\" Orphaned coinbase transactions received.\n"
|
||||
"\"platform-transfer\" Platform Transfer transactions received.\n"},
|
||||
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
|
||||
"for all other categories"},
|
||||
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any"},
|
||||
@ -1582,7 +1589,8 @@ static RPCHelpMan listsinceblock()
|
||||
"\"receive\" Non-coinbase transactions received.\n"
|
||||
"\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
|
||||
"\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
|
||||
"\"orphan\" Orphaned coinbase transactions received.\n"},
|
||||
"\"orphan\" Orphaned coinbase transactions received.\n"
|
||||
"\"platform-transfer\" Platform Transfer transactions received.\n"},
|
||||
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and is positive\n"
|
||||
"for all other categories"},
|
||||
{RPCResult::Type::NUM, "vout", "the vout value"},
|
||||
@ -1723,7 +1731,8 @@ static RPCHelpMan gettransaction()
|
||||
"\"receive\" Non-coinbase transactions received.\n"
|
||||
"\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
|
||||
"\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
|
||||
"\"orphan\" Orphaned coinbase transactions received.\n"},
|
||||
"\"orphan\" Orphaned coinbase transactions received.\n"
|
||||
"\"platform-transfer\" Platform Transfer transactions received.\n"},
|
||||
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT},
|
||||
{RPCResult::Type::STR, "label", "A comment for the address/transaction, if any"},
|
||||
{RPCResult::Type::NUM, "vout", "the vout value"},
|
||||
|
@ -592,6 +592,7 @@ public:
|
||||
void setConfirmed() { m_confirm.status = CWalletTx::CONFIRMED; }
|
||||
const uint256& GetHash() const { return tx->GetHash(); }
|
||||
bool IsCoinBase() const { return tx->IsCoinBase(); }
|
||||
bool IsPlatformTransfer() const { return tx->IsPlatformTransfer(); }
|
||||
bool IsImmatureCoinBase() const;
|
||||
|
||||
// Disable copying of CWalletTx objects to prevent bugs where instances get
|
||||
|
Loading…
Reference in New Issue
Block a user