mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 04:42:36 -03:00
Display tx nLockTime correctly when set to block #
Previously when a transaction was set to lock at a specific block the calculation was reversed, returning a negative number. This broke the UI and caused it to display %n in place of the actual number. In addition the previous calculation would display "Open for 0 blocks" when the block height was such that the next block created would finalize the transaction. Inserted the word "more" and changed the calculation so that the last message would be "Open for 1 more block" to better match user expectations.
This commit is contained in:
parent
429915bd0d
commit
10046e27db
4 changed files with 6 additions and 4 deletions
|
@ -14,7 +14,7 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
|
|||
if (!wtx.IsFinal())
|
||||
{
|
||||
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
|
||||
return tr("Open for %n block(s)", "", nBestHeight - wtx.nLockTime);
|
||||
return tr("Open for %n more block(s)", "", wtx.nLockTime - nBestHeight + 1);
|
||||
else
|
||||
return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime));
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
|||
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
|
||||
{
|
||||
status.status = TransactionStatus::OpenUntilBlock;
|
||||
status.open_for = nBestHeight - wtx.nLockTime;
|
||||
status.open_for = wtx.nLockTime - nBestHeight + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -47,7 +47,9 @@ public:
|
|||
@{*/
|
||||
Status status;
|
||||
int64 depth;
|
||||
int64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number of blocks */
|
||||
int64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
|
||||
of additional blocks that need to be mined before
|
||||
finalization */
|
||||
/**@}*/
|
||||
|
||||
/** Current number of blocks (to know whether cached status is still valid) */
|
||||
|
|
|
@ -280,7 +280,7 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons
|
|||
switch(wtx->status.status)
|
||||
{
|
||||
case TransactionStatus::OpenUntilBlock:
|
||||
status = tr("Open for %n block(s)","",wtx->status.open_for);
|
||||
status = tr("Open for %n more block(s)","",wtx->status.open_for);
|
||||
break;
|
||||
case TransactionStatus::OpenUntilDate:
|
||||
status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
|
||||
|
|
Loading…
Reference in a new issue