New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(wallet): Detect Reorgs And RBFs #1081
Conversation
Bitkit now tracks < 6-conf txs and notifies users of a relevant reorg or RBF. Added "unconfirmedTransactions" to wallet reducer. Created several new methods for tracking unconfirmed txs. Added a button to inject a fake transaction in the Dev menu. Added "exists" to IActivityItem types. Updated mergeActivityItems method. Added methods to clear store objects when rescanning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I've pushed fix for e2e tests |
Tested the |
@@ -325,6 +326,15 @@ const OnchainActivityDetail = ({ | |||
); | |||
} | |||
|
|||
if (activityType === EActivityType.onchain && !exists) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will always be true since we're in OnchainActivityDetail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to appease typescript. Otherwise, exists would have to be added to each ActivityItem type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is not true. TS will know that activityType
will always be EActivityType.onchain
here and that exists
will be there.
Description
unconfirmedTransactions
towallet
reducer.exists
toIActivityItem
types.mergeActivityItems
method.With this update we're concerned with two main things that can happen to transactions with less than 6 confirmations.
In the event number one occurs, Bitkit will detect that a previously confirmed transaction is now no longer confirmed and notifies the user accordingly. This is a best-case scenario where a user may only need to wait for the tx to confirm again. The only action that needs to be taken is ensuring the activity item is no longer marked as confirmed and the stored transaction height is adjusted.
In the event number two occurs, Bitkit will detect that a tracked transaction is no longer in the mempool and alert the user accordingly of a potential reorg or RBF. This situation is more severe since the transaction in question is now gone, reverting ownership of any received or sent funds. In this situation, Bitkit will set the
exists
state to false in the activity list item and highlight the tx entry in red in the activity list. Bitkit will also perform a rescan of the wallet to ensure funds and stored transactions are accurate.Type of change
Tests
Screenshot / Video
QA Notes
To test a reorg:
/regtest-deposit <address> 0.00005000
/regtest-mine 1
/regtest-invalidate-block <blockhash>
Expected: A blue notification should appear that matches the attached screenshot after detecting the reorg. The transaction should no longer appear as confirmed in the activity list.
To test an RBF or getting bumped from the mempool:
Expected: A red notification should appear that matches the attached screenshot after detecting the ghost/invalid tx. The tx in question should be red in the activity list. When tapping the activity list item the status should display "Removed from Mempool".
Notes