Merge assumeutxo_unconfirmed_ux-28

This commit is contained in:
Luke Dashjr 2025-03-05 03:27:08 +00:00
commit 46c7684bc1
5 changed files with 24 additions and 12 deletions

View File

@ -58,7 +58,7 @@ QString TransactionDesc::FormatTxStatus(const interfaces::WalletTxStatus& status
s += QLatin1String(", ") + tr("abandoned");
}
return s;
} else if (depth < 6) {
} else if (depth < TransactionRecord::RecommendedNumConfirmations || status.is_assumed) {
/*: Text explaining the current status of a transaction, shown in the
status field of the details window for this transaction. This
status represents a transaction confirmed in at least one block,

View File

@ -321,7 +321,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons
status = tr("Abandoned");
break;
case TransactionStatus::AssumedConfirmed:
status = tr("%1 confirmations, pending verification of historical blocks").arg(wtx->status.depth);
status = tr("Unconfirmed (%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);
@ -465,11 +465,10 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
switch(wtx->status.status)
{
case TransactionStatus::Unconfirmed:
case TransactionStatus::AssumedConfirmed:
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)
{
@ -644,14 +643,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return details;
}
case ConfirmedRole:
switch (rec->status.status) {
case TransactionStatus::Status::AssumedConfirmed:
case TransactionStatus::Status::Confirming:
case TransactionStatus::Status::Confirmed:
return true;
default:
return false;
}
return rec->status.status == TransactionStatus::Status::Confirming || rec->status.status == TransactionStatus::Status::Confirmed;
case FormattedAmountRole:
// Used for copy/export, so don't include separators
return formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER);

View File

@ -1085,6 +1085,7 @@ static RPCHelpMan gettxout()
RPCResult{"Otherwise", RPCResult::Type::OBJ, "", "", {
{RPCResult::Type::STR_HEX, "bestblock", "The hash of the block at the tip of the chain"},
{RPCResult::Type::NUM, "confirmations", "The number of confirmations"},
{RPCResult::Type::NUM, "confirmations_assumed", /*optional=*/true, "The number of unverified confirmations (eg, in an assumed-valid UTXO set)"},
{RPCResult::Type::STR_AMOUNT, "value", "The transaction value in " + CURRENCY_UNIT},
{RPCResult::Type::OBJ, "scriptPubKey", "", {
{RPCResult::Type::STR, "asm", "Disassembly of the output script"},
@ -1140,7 +1141,13 @@ static RPCHelpMan gettxout()
if (coin.nHeight == MEMPOOL_HEIGHT) {
ret.pushKV("confirmations", 0);
} else {
const auto assumed_base_height = chainman.GetSnapshotBaseHeight();
if (assumed_base_height && coin.nHeight < *assumed_base_height) {
ret.pushKV("confirmations", 0);
ret.pushKV("confirmations_assumed", (int64_t)(pindex->nHeight - coin.nHeight + 1));
} else {
ret.pushKV("confirmations", (int64_t)(pindex->nHeight - coin.nHeight + 1));
}
}
ret.pushKV("value", ValueFromAmount(coin.out.nValue));
UniValue o(UniValue::VOBJ);

View File

@ -72,7 +72,13 @@ static void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
const CBlockIndex* pindex = active_chainstate.m_blockman.LookupBlockIndex(hashBlock);
if (pindex) {
if (active_chainstate.m_chain.Contains(pindex)) {
const auto assumed_base = active_chainstate.SnapshotBase();
if (assumed_base && pindex->nHeight < assumed_base->nHeight) {
entry.pushKV("confirmations", 0);
entry.pushKV("confirmations_assumed", 1 + active_chainstate.m_chain.Height() - pindex->nHeight);
} else {
entry.pushKV("confirmations", 1 + active_chainstate.m_chain.Height() - pindex->nHeight);
}
entry.pushKV("time", pindex->GetBlockTime());
entry.pushKV("blocktime", pindex->GetBlockTime());
}
@ -290,6 +296,7 @@ static RPCHelpMan getrawtransaction()
{RPCResult::Type::BOOL, "in_active_chain", /*optional=*/true, "Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
{RPCResult::Type::STR_HEX, "blockhash", /*optional=*/true, "the block hash"},
{RPCResult::Type::NUM, "confirmations", /*optional=*/true, "The confirmations"},
{RPCResult::Type::NUM, "confirmations_assumed", /*optional=*/true, "The number of unverified confirmations (eg, in an assumed-valid UTXO set)"},
{RPCResult::Type::NUM_TIME, "blocktime", /*optional=*/true, "The block time expressed in " + UNIX_EPOCH_TIME},
{RPCResult::Type::NUM, "time", /*optional=*/true, "Same as \"blocktime\""},
{RPCResult::Type::STR_HEX, "hex", "The serialized, hex-encoded data for 'txid'"},

View File

@ -19,7 +19,12 @@ static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue
{
interfaces::Chain& chain = wallet.chain();
int confirms = wallet.GetTxDepthInMainChain(wtx);
if (confirms > 0 && wallet.IsTxAssumed(wtx)) {
entry.pushKV("confirmations", 0);
entry.pushKV("confirmations_assumed", confirms);
} else {
entry.pushKV("confirmations", confirms);
}
if (wtx.IsCoinBase())
entry.pushKV("generated", true);
if (auto* conf = wtx.state<TxStateConfirmed>())
@ -406,6 +411,7 @@ static std::vector<RPCResult> TransactionDescriptionString()
{
return{{RPCResult::Type::NUM, "confirmations", "The number of confirmations for the transaction. Negative confirmations means the\n"
"transaction conflicted that many blocks ago."},
{RPCResult::Type::NUM, "confirmations_assumed", /*optional=*/true, "The number of unverified confirmations for the transaction (eg, in an assumed-valid UTXO set)."},
{RPCResult::Type::BOOL, "generated", /*optional=*/true, "Only present if the transaction's only input is a coinbase one."},
{RPCResult::Type::BOOL, "trusted", /*optional=*/true, "Whether we consider the transaction to be trusted and safe to spend from.\n"
"Only present when the transaction has 0 confirmations (or negative confirmations, if conflicted)."},