Fix wrong CT / RingCT amounts in transaction history when wallet locked#1001
Fix wrong CT / RingCT amounts in transaction history when wallet locked#1001seanPhill merged 8 commits intoVeil-Project:masterfrom
Conversation
|
The current changes of the PR already work and solve the problem. However, it is still marked as draft because currently when the wallet is unlocked it does the full
|
|
Btw. what will the bounty be for solving this soon three year old issue with as far as I can read in #922 quite high impact for Veil users 😉 ? |
|
Just noticed it still doesn't work if the user unlocks the wallet while the transaction is still unconfirmed. |
|
That sounds like a locking issue. I think I forgot to lock also |
That's the expected behavior for transactions that had already arrived before. For the "Hidden" text to be displayed the transaction has to have income through the wallet that has the changes of this PR. However, once you unlock the wallet (and it doesn't hang up) also the old "0.00000000" values should be replaced by the correct ones. |
- When a CT transaction arrives while the wallet is locked (or unlocked
for staking only):
- Instead of a wrong amount show "Hidden" in the transaction history
entry.
- In the tooltip of the transaction row show the message "Unlock wallet
to see hidden amount".
- When the wallet is then unlocked, automatically do a
`rescanringctwallet`.
- Fix `rescanringctwallet` to properly update corresponding entries in
the transaction history GUI.
If the incoming CTs come from a zerocoin spend and the transaction arrived while the wallet was locked, they were shown in the transaction history with an amount of "0.00000000" instead of "Hidden".
This caused such transactions to show up in the GUI as "(n/a)" if the wallet was locked when the transaction arrived.
…ctions Show "Hidden" instead of wrong amounts like "0.00000000" in the "Incoming transaction" GUI notification that is shown to the user.
AnonWallet::RescanWallet did not unblind CT / RingCT outputs of unconfirmed transactions. Thus, when such a transaction is received it is shown with "Hidden" value, but if the user unlocked the wallet while the transaction is still unconfirmed, the value (in the GUI) wasn't updated even when the transaction gets confirmed. Only after a wallet restart the correct value was displayed. With this commit, the correct value is displayed directly after unlocking the wallet, also if the transaction is still unconfirmed.
Keep track of locked CT/RingCT transactions that arrive while the wallet is locked and contain blinded values, in order to only rescan those transactions when unlocking the wallet instead of doing a full rescan each time.
|
This PR is now ready for extensive testing and review. |
|
I don't know how the translation stuff currently works. Since I added the new strings "Hidden" and "Unlock wallet to see hidden amount", should some translations be added? If yes, how exactly is that handled? |
CWallet::EncryptWallet doesn't release its `cs_wallet` lock before calling CWallet::Unlock, which ends up calling AnonWallet::UnlockWallet, which does the partial wallet rescan and for that acquires locks `cs_main` and `cs_wallet`. Thus, the order of lock acquisition in this case is `cs_wallet`, `cs_main`. However, across the entire application consistently the order `cs_main`, `cs_wallet` is used. This leads to a deadlock if another thread already holds `cs_main` and is waiting for `cs_wallet`, but the AnonWallet::UnlockWallet currently has `cs_wallet`, and is waiting for `cs_main`. Since rescaning the anon wallet is anyway not required when encrypting the wallet (because it restarts the wallet and then the user has to unlock it again), the simple solution was to not do this rescan when unlocking during wallet encryption, thus there is no need to acquire `cs_main`.
|
I just had an issue with this function tonight. [Don't know if this is related to the requested changes.] While it has normally worked fine for me, my testnet wallet had been locked (and / or closed) and receiving a lot of transactions for about twenty hours, and maybe I unlocked it a bit soon after starting it up, but when I did, the transactions this time did not correct themselves. I was still getting the mouseover message about needing to unlock to see the correct amounts. I waited a few minutes, and tried locking the wallet again and unlocking it again, and it still did not correct the transactions list. ... I then manually did This is a wallet with over 55,000 transaction rows in the course of twenty days from fresh seed. The issue was with the 62 received CT amounts over the course of 20 hours, while the wallet was either locked or turned off. |
I already pushed the requested changes (and marked them as solved), don't know why it still shows "Changes requested".
If full |
|
I've retested with the wallet again, with a few days of transactions to reveal. No problem. That failure a few days ago I will have to consider an anomaly that might not ever happen to anyone without such a large wallet as my test wallet. Could not be reproduced, and the solution was very simple anyway ( |
|
@Zannick can you confirm that your requested changes have been made? ... -> code review. Everything should be ready. |
|
utACK 6333d87 |
|
This PR solves the issue that caused an exchange in early 2019 to reverse their decision to allow stealth withdrawals. |







Problem
When receiving a CT transaction while the wallet is locked (or unlocked for staking only), the amount displayed in the transaction history is wrong, and keeps wrong until a
rescanringctwalletrpc is called and the wallet is restarted.Root Cause
veil/src/veil/ringct/outputrecord.h
Line 43 in 7c8bee1
ORF_OWNEDflag was not set correctly, leading to RingCT transactions being showed as "(n/a)" in the transaction history, if they arrived while the wallet was locked.Solution
rescanringctwalletto properly update corresponding entries in the transaction history GUI.rescanringctwalletwhich only rescans those tracked locked transactions, and thus should be fast also for wallets having a very long transaction history.Bounty Payment Address
sv1qqpjsrc60t60jhaywj5krmwla52ska70twc7wun6qnee65guxhvtxegpqwhuxypra4jn3pq86s24ryltcw6g2ss4573hyqac9u4g23m9mvxpyqqqwny49kTesting Results
Fixes #922, #668