coral-xyz / backpack

🎒 Next level crypto wallet
https://backpack.app
GNU General Public License v3.0
1.34k stars 800 forks source link

Checks for scam transactions and warn user #2555

Open AnishDe12020 opened 1 year ago

AnishDe12020 commented 1 year ago

Background: approved a scam transaction by mistake on Glow wallet yesterday (was on mobile, tired, didn't see the result of the transaction simulation and clicked approve), my wallet got drained. Yes it is my mistake but I have thought of a way to prevent (or at least lower the chances) of someone approving a scam transaction

So, Backpack already simulates the transactions, so what if we implement a check where backpack checks if a transaction can potentially drain a wallet (maybe, according to the simulation, all the tokens will be sent or even 30% of the wallet's worth is going to be sent). A big red warning message can then be shown to the user saying "triple-check the website and the transaction you are approving as the transaction may potentially drain your wallet". We can also add something like a dual confirmation for such transactions (alternatively disable the approve tx button for like 3 or 5 seconds so that the user actually gets a chance to see this message and looks at the tx simulation)

AnishDe12020 commented 1 year ago

A very basic implementation (#2557) but I am basically checking if the native amount in balanceChanges is greater than 30% of the the native amount available in the user's wallet and logging if it is dangerous or not

image

(lol i do have very less sol in my wallet)

In the final version, I plan to approach it like this -