gui: add assumed confirmed state

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.
This commit is contained in:
Sjors Provoost 2024-10-01 13:45:21 +02:00
parent a6c53bb244
commit 3e281590c7
No known key found for this signature in database
GPG key ID: 57FF9BDBCC301009
4 changed files with 33 additions and 25 deletions

View file

@ -0,0 +1,6 @@
GUI changes
------
- Transactions that are confirmed while assume utxo background sync is in progress,
will have a clock icon and a tooltip explaining that historical blocks are still
being verified. (#28616)

View file

@ -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;
}
}

View file

@ -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 **/

View file

@ -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;
@ -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)
{
@ -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);