cryptoadvance / specter-diy

DIY airgapped hardware wallet that uses QR codes for communication with the host
MIT License
441 stars 73 forks source link

Keep track of receiving and change addresses #50

Closed stepansnigirev closed 4 years ago

stepansnigirev commented 4 years ago

Software wallets often have a gap limit of 20 addresses, so if my last change address was m/.../1/123 and in the next transaction I use a change m/.../1/9999 it can cause lock of funds. We should warn the user if the change index is weird. To do this we should store the largest change index and warn if the next one is more than 20 larger.

gorazdko commented 4 years ago

Is that meant when scrolling over wallet addresses (with Next/Previous button), we should warn at the address that exceeds the gap limit?

We could determine the address index from the scanned PSBT's inputs and store it into _wallet.json if bigger?

To determine the address index we need to loop wallet.address(idx, change) with incrementing idx for both change values and match with PSBT inputs?

stepansnigirev commented 4 years ago

My thinking is:

I think the address screen should start by default with a stored index, not zero. And it makes sense to add a warning if the displayed address is higher than index+gap_limit. Both in browse address screen and when we verify the address.

The warning can be just another label, with red text, or a "prompt", I don't know what's better.

What do you think, does it make sense?

stepansnigirev commented 4 years ago

To determine the address index we need to loop wallet.address(idx, change) with incrementing idx for both change values and match with PSBT inputs?

PSBT inputs and outputs contain information about derivation indexes, so we don't need to loop through the indexes, we can get them from PSBT directly

gorazdko commented 4 years ago

Ok makes sense. I will grab this issue then.