diff options
author | Tom Harding <tomh@thinlink.com> | 2014-06-26 18:31:05 -0700 |
---|---|---|
committer | Tom Harding <tomh@thinlink.com> | 2014-06-27 07:54:21 -0700 |
commit | ada5a067c75f19a724cc054286ecf2254e5dbe8f (patch) | |
tree | dcbb99b8eb6dcce4c9ab8eae70f9a4923ca5f664 /src/qt/transactionrecord.cpp | |
parent | d640a3ceab4f4372c2a0f738c1286cfde4b41b50 (diff) |
UI to alert of respend attempt affecting wallet.
Respend transactions that conflict with transactions already in the
wallet are added to it. They are not displayed unless they also involve
the wallet, or get into a block. If they do not involve the wallet,
they continue not to affect balance.
Transactions that involve the wallet, and have conflicting non-equivalent
transactions, are highlighted in red. When the conflict first occurs, a
modal dialog is thrown.
CWallet::SyncMetaData is changed to sync only to equivalent transactions.
When a conflict is added to the wallet, counter nConflictsReceived is
incremented. This acts like a change in active block height for the
purpose of triggering UI updates.
Diffstat (limited to 'src/qt/transactionrecord.cpp')
-rw-r--r-- | src/qt/transactionrecord.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index eec2b57e8c..21f1b7356f 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -170,6 +170,8 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) status.depth = wtx.GetDepthInMainChain(); status.cur_num_blocks = chainActive.Height(); + status.hasConflicting = false; + if (!IsFinalTx(wtx, chainActive.Height() + 1)) { if (wtx.nLockTime < LOCKTIME_THRESHOLD) @@ -213,6 +215,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) if (status.depth < 0) { status.status = TransactionStatus::Conflicted; + status.hasConflicting = !(wtx.GetConflicts(false).empty()); } else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) { @@ -221,6 +224,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) else if (status.depth == 0) { status.status = TransactionStatus::Unconfirmed; + status.hasConflicting = !(wtx.GetConflicts(false).empty()); } else if (status.depth < RecommendedNumConfirmations) { @@ -231,13 +235,13 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx) status.status = TransactionStatus::Confirmed; } } - } -bool TransactionRecord::statusUpdateNeeded() +bool TransactionRecord::statusUpdateNeeded(int64_t nConflictsReceived) { AssertLockHeld(cs_main); - return status.cur_num_blocks != chainActive.Height(); + return (status.cur_num_blocks != chainActive.Height() || + status.cur_num_conflicts != nConflictsReceived); } QString TransactionRecord::getTxID() const |