Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ void BitcoinGUI::updateWidth()
int nWidthWidestButton{0};
int nButtonsVisible{0};
for (QAbstractButton* button : tabGroup->buttons()) {
if (!button->isEnabled() || !button->isVisible()) {
if (!button->isVisible()) {
continue;
}
QFontMetrics fm(button->font());
Expand Down
2 changes: 1 addition & 1 deletion src/qt/masternodemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ QVariant MasternodeModel::data(const QModelIndex& index, int role) const
if (auto ban_height = entry->poseBanHeight(); ban_height && *ban_height > 0) {
return m_current_height - *ban_height;
}
return 0; // Unknown ban time, treat as freshly banned
return 1; // Unknown ban time, still positive so filter works
} else {
// Active nodes use negative values
int32_t active_height = entry->registeredHeight();
Expand Down
25 changes: 25 additions & 0 deletions src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#include <interfaces/node.h>
#include <interfaces/wallet.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <validation.h>
#include <wallet/ismine.h>
#include <script/script.h>

#include <stdint.h>
#include <string>
Expand Down Expand Up @@ -294,6 +296,29 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
strHTML += "<b>" + tr("Output index") + ":</b> " + QString::number(rec->getOutputIndex()) + "<br>";
strHTML += "<b>" + tr("Transaction total size") + ":</b> " + QString::number(wtx.tx->GetTotalSize()) + " bytes<br>";

// List all OP_RETURN payloads
if (rec->type == TransactionRecord::DataTransaction) {
for (const auto& txout : wtx.tx->vout) {
if (!TransactionRecord::IsDataScript(txout.scriptPubKey)) {
continue;
}
const auto& script{txout.scriptPubKey};
// Extract all data pushes after OP_RETURN
const auto payload = [&script]() {
auto pc = script.begin() + 1; // Skip opcode
opcodetype opcode;
std::vector<uint8_t> ret{}, vch{};
while (pc < script.end() && script.GetOp(pc, opcode, vch)) {
ret.insert(ret.end(), vch.begin(), vch.end());
}
return ret;
}();
if (!payload.empty()) {
strHTML += "<b>" + tr("Payload") + ":</b> " + QString::fromStdString(HexStr(payload)) + "<br>";
}
}
}

// Message from normal dash:URI (dash:XyZ...?message=example)
for (const std::pair<std::string, std::string>& r : orderForm) {
if (r.first == "Message")
Expand Down
18 changes: 17 additions & 1 deletion src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <interfaces/node.h>

#include <wallet/ismine.h>
#include <script/script.h>

#include <cstdint>

Expand Down Expand Up @@ -102,6 +103,15 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(interfaces::Nod

parts.append(sub);
}
else if (!wtx.is_coinbase && IsDataScript(txout.scriptPubKey))
{
TransactionRecord sub(hash, nTime);
sub.idx = i;
sub.credit = txout.nValue;
sub.type = TransactionRecord::DataTransaction;
sub.strAddress = "";
parts.append(sub);
}
}
}
else
Expand Down Expand Up @@ -236,7 +246,13 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(interfaces::Nod
continue;
}

if (!std::get_if<CNoDestination>(&wtx.txout_address[nOut]))
if (IsDataScript(txout.scriptPubKey))
{
sub.type = TransactionRecord::DataTransaction;
sub.strAddress = "";
sub.txDest = DecodeDestination(sub.strAddress);
}
else if (!std::get_if<CNoDestination>(&wtx.txout_address[nOut]))
{
// Sent to Dash Address
sub.type = TransactionRecord::SendToAddress;
Expand Down
8 changes: 8 additions & 0 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct WalletTx;
struct WalletTxStatus;
}

class CScript;

/** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
*/
struct TransactionStatus {
Expand Down Expand Up @@ -87,11 +89,17 @@ class TransactionRecord
CoinJoinSend,
PlatformTransfer,
DustReceive,
DataTransaction,
};

/** Number of confirmation recommended for accepting a transaction */
static const int RecommendedNumConfirmations = 6;

/** Check if script is an OP_RETURN data script */
static bool IsDataScript(const CScript& script) {
return script.IsUnspendable() && !script.empty() && script[0] == OP_RETURN;
}

TransactionRecord():
hash(), time(0), type(Other), debit(0), credit(0), idx(0)
{
Expand Down
5 changes: 5 additions & 0 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
return tr("Mined");
case TransactionRecord::PlatformTransfer:
return tr("Platform Transfer");
case TransactionRecord::DataTransaction:
return tr("Data Transaction");
case TransactionRecord::DustReceive:
return tr("Dust Receive");

Expand Down Expand Up @@ -489,6 +491,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
case TransactionRecord::CoinJoinCollateralPayment:
case TransactionRecord::CoinJoinMakeCollaterals:
case TransactionRecord::CoinJoinCreateDenominations:
case TransactionRecord::DataTransaction:
case TransactionRecord::Other:
break; // use fail-over here
} // no default case, so the compiler can warn about missing cases
Expand Down Expand Up @@ -517,6 +520,7 @@ QVariant TransactionTableModel::addressColor(const TransactionRecord *wtx) const
case TransactionRecord::CoinJoinMixing:
case TransactionRecord::CoinJoinMakeCollaterals:
case TransactionRecord::CoinJoinCollateralPayment:
case TransactionRecord::DataTransaction:
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::BAREADDRESS);
case TransactionRecord::SendToOther:
case TransactionRecord::RecvFromOther:
Expand Down Expand Up @@ -551,6 +555,7 @@ QVariant TransactionTableModel::amountColor(const TransactionRecord *rec) const
case TransactionRecord::CoinJoinSend:
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
case TransactionRecord::DataTransaction:
case TransactionRecord::Other:
return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::RED);
case TransactionRecord::SendToSelf:
Expand Down
1 change: 1 addition & 0 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ TransactionView::TransactionView(QWidget* parent) :
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("Data Transaction"), TransactionFilterProxy::TYPE(TransactionRecord::DataTransaction));
typeWidget->addItem(tr("Dust Receive"), TransactionFilterProxy::TYPE(TransactionRecord::DustReceive));
typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));
typeWidget->setCurrentIndex(settings.value("transactionType").toInt());
Expand Down