mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-26 03:41:04 +02:00
Merge bitcoin-core/gui#552: Refactor TransactionDesc::FormatTxStatus
and TransactionStatus
343f83d0886ae39c9dacb29762ce712711b2bad2 qt, refactor: Use member initializers in TransactionStatus (w0xlt)
66d58ad7a99a98b5e78fd97ddf777ea00e6091cf qt, refactor: remove unused field `qint64 TransactionStatus::open_for` (w0xlt)
ad6adedb46e25870bcdabeca93c51c3ac2a33de7 qt, refactor: remove unused parameters in `TransactionDesc::FormatTxStatus()` (w0xlt)
045f8d0310d2340aa32db6f7e582dea45950d28a scripted-diff: rename nDepth -> depth (w0xlt)
b1bc1431db1e86eefaf4a91e08663628d94656fc qt, refactor: remove redundant scope in `TransactionDesc::FormatTxStatus()` (w0xlt)
Pull request description:
This PR implements the changes suggested in https://github.com/bitcoin-core/gui/issues/538#issuecomment-1021913294 .
. remove redundant scope, rename `nDepth` -> `depth`, remove unused parameters and add translator comments in `TransactionDesc::FormatTxStatus()`
. Use member initializers and remove unused field `qint64 TransactionStatus::open_for` in `TransactionStatus`.
Closes https://github.com/bitcoin-core/gui/issues/538
ACKs for top commit:
hebasto:
ACK 343f83d0886ae39c9dacb29762ce712711b2bad2, I have reviewed the code and it looks OK, I agree it can be merged.
jarolrod:
Code Review ACK 343f83d088
Tree-SHA512: cc7333d85b7eb731aa8cdd2d8dfc707341532c93e1b5e3858e8341446cf055ba055b601f9662e8d4602726b1bedf13149c46256a60a0ce1a562f94c9986d945a
This commit is contained in:
commit
7190de9fb8
@ -32,20 +32,18 @@ using wallet::ISMINE_SPENDABLE;
|
|||||||
using wallet::ISMINE_WATCH_ONLY;
|
using wallet::ISMINE_WATCH_ONLY;
|
||||||
using wallet::isminetype;
|
using wallet::isminetype;
|
||||||
|
|
||||||
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
|
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTxStatus& status, bool inMempool)
|
||||||
{
|
{
|
||||||
{
|
int depth = status.depth_in_main_chain;
|
||||||
int nDepth = status.depth_in_main_chain;
|
if (depth < 0) {
|
||||||
if (nDepth < 0) {
|
return tr("conflicted with a transaction with %1 confirmations").arg(-depth);
|
||||||
return tr("conflicted with a transaction with %1 confirmations").arg(-nDepth);
|
} else if (depth == 0) {
|
||||||
} else if (nDepth == 0) {
|
const QString abandoned{status.is_abandoned ? QLatin1String(", ") + tr("abandoned") : QString()};
|
||||||
const QString abandoned{status.is_abandoned ? QLatin1String(", ") + tr("abandoned") : QString()};
|
return tr("0/unconfirmed, %1").arg(inMempool ? tr("in memory pool") : tr("not in memory pool")) + abandoned;
|
||||||
return tr("0/unconfirmed, %1").arg(inMempool ? tr("in memory pool") : tr("not in memory pool")) + abandoned;
|
} else if (depth < 6) {
|
||||||
} else if (nDepth < 6) {
|
return tr("%1/unconfirmed").arg(depth);
|
||||||
return tr("%1/unconfirmed").arg(nDepth);
|
} else {
|
||||||
} else {
|
return tr("%1 confirmations").arg(depth);
|
||||||
return tr("%1 confirmations").arg(nDepth);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +93,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
|||||||
CAmount nDebit = wtx.debit;
|
CAmount nDebit = wtx.debit;
|
||||||
CAmount nNet = nCredit - nDebit;
|
CAmount nNet = nCredit - nDebit;
|
||||||
|
|
||||||
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx, status, inMempool, numBlocks);
|
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(status, inMempool);
|
||||||
strHTML += "<br>";
|
strHTML += "<br>";
|
||||||
|
|
||||||
strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
|
strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
TransactionDesc() {}
|
TransactionDesc() {}
|
||||||
|
|
||||||
static QString FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks);
|
static QString FormatTxStatus(const interfaces::WalletTxStatus& status, bool inMempool);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_TRANSACTIONDESC_H
|
#endif // BITCOIN_QT_TRANSACTIONDESC_H
|
||||||
|
@ -20,13 +20,7 @@ struct WalletTxStatus;
|
|||||||
|
|
||||||
/** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
|
/** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
|
||||||
*/
|
*/
|
||||||
class TransactionStatus
|
struct TransactionStatus {
|
||||||
{
|
|
||||||
public:
|
|
||||||
TransactionStatus() : countsForBalance(false), sortKey(""),
|
|
||||||
matures_in(0), status(Unconfirmed), depth(0), open_for(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
enum Status {
|
enum Status {
|
||||||
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
|
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
|
||||||
/// Normal (sent/received) transactions
|
/// Normal (sent/received) transactions
|
||||||
@ -40,28 +34,25 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Transaction counts towards available balance
|
/// Transaction counts towards available balance
|
||||||
bool countsForBalance;
|
bool countsForBalance{false};
|
||||||
/// Sorting key based on status
|
/// Sorting key based on status
|
||||||
std::string sortKey;
|
std::string sortKey;
|
||||||
|
|
||||||
/** @name Generated (mined) transactions
|
/** @name Generated (mined) transactions
|
||||||
@{*/
|
@{*/
|
||||||
int matures_in;
|
int matures_in{0};
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** @name Reported status
|
/** @name Reported status
|
||||||
@{*/
|
@{*/
|
||||||
Status status;
|
Status status{Unconfirmed};
|
||||||
qint64 depth;
|
qint64 depth{0};
|
||||||
qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
|
|
||||||
of additional blocks that need to be mined before
|
|
||||||
finalization */
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/** Current block hash (to know whether cached status is still valid) */
|
/** Current block hash (to know whether cached status is still valid) */
|
||||||
uint256 m_cur_block_hash{};
|
uint256 m_cur_block_hash{};
|
||||||
|
|
||||||
bool needsUpdate;
|
bool needsUpdate{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
/** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
|
/** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
|
||||||
|
Loading…
x
Reference in New Issue
Block a user