Skip to content

Commit

Permalink
gui: add assumed confirmed state
Browse files Browse the repository at this point in the history
Create a separate status for transactions that are confirmed in a block that is assumed valid pending background validation.

Use the same icon as for transactions with a single confirmation.
  • Loading branch information
Sjors committed Oct 9, 2023
1 parent b9024e6 commit 57afbba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
37 changes: 13 additions & 24 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,42 +175,31 @@ void TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, cons

// For generated transactions, determine maturity
if (type == TransactionRecord::Generated) {
if (wtx.blocks_to_maturity > 0)
{
if (wtx.blocks_to_maturity > 0) {
status.status = TransactionStatus::Immature;

if (wtx.is_in_main_chain)
{
if (wtx.is_in_main_chain) {
status.matures_in = wtx.blocks_to_maturity;
}
else
{
} else {
status.status = TransactionStatus::NotAccepted;
}
}
else
{
} else {
status.status = TransactionStatus::Confirmed;
}
}
else
{
if (status.depth < 0)
{
} else {
if (status.depth < 0) {
status.status = TransactionStatus::Conflicted;
}
else if (status.depth == 0)
{
else if (status.depth == 0) {
status.status = TransactionStatus::Unconfirmed;
if (wtx.is_abandoned)
if (wtx.is_abandoned) {
status.status = TransactionStatus::Abandoned;
}
else if (status.depth < RecommendedNumConfirmations)
{
}
} else if (wtx.is_assumed) {
status.status = TransactionStatus::AssumedConfirmed;
} else if (status.depth < RecommendedNumConfirmations) {
status.status = TransactionStatus::Confirming;
}
else
{
} else {
status.status = TransactionStatus::Confirmed;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct TransactionStatus {
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
/// Normal (sent/received) transactions
Unconfirmed, /**< Not yet mined into a block **/
AssumedConfirmed, /**< Confirmed, but background validation hasn't finished */
Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/
Conflicted, /**< Conflicts with other transaction or mempool **/
Abandoned, /**< Abandoned from the wallet **/
Expand Down
14 changes: 13 additions & 1 deletion src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons
case TransactionStatus::Abandoned:
status = tr("Abandoned");
break;
case TransactionStatus::AssumedConfirmed:
status = tr("%1 confirmations, pending verification of historical blocks").arg(wtx->status.depth);
break;
case TransactionStatus::Confirming:
status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations);
break;
Expand Down Expand Up @@ -465,6 +468,8 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
return QIcon(":/icons/transaction_0");
case TransactionStatus::Abandoned:
return QIcon(":/icons/transaction_abandoned");
case TransactionStatus::AssumedConfirmed:
return QIcon(":/icons/transaction_1");
case TransactionStatus::Confirming:
switch(wtx->status.depth)
{
Expand Down Expand Up @@ -639,7 +644,14 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return details;
}
case ConfirmedRole:
return rec->status.status == TransactionStatus::Status::Confirming || rec->status.status == TransactionStatus::Status::Confirmed;
switch (rec->status.status) {
case TransactionStatus::Status::AssumedConfirmed:
case TransactionStatus::Status::Confirming:
case TransactionStatus::Status::Confirmed:
return true;
default:
return false;
}
case FormattedAmountRole:
// Used for copy/export, so don't include separators
return formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER);
Expand Down

0 comments on commit 57afbba

Please sign in to comment.