BlueWallet / BlueWallet

Bitcoin wallet for iOS & Android. Built with React Native
https://bluewallet.io
MIT License
2.61k stars 794 forks source link

"Is it my address" doesn't work for offline device #6232

Open TimYorke opened 7 months ago

TimYorke commented 7 months ago

BlueWallet 6.5.5

I've discovered that the "Is it my address" feature doesn't recognise the receive address of an imported wallet (BlueWallet Vault) until I've connected BlueWallet to an electrum server and downloaded the transactions.

Before connecting to the electrum server, it doesn't recognise the scanned address, but afterwards and all the transactions have been downloaded, it correctly identifies the wallet when scanning the same address as before.

This is a problem when you want to use BlueWallet as a cold, air-gapped signing device. It's important to be able to check the receive address on a cold device. A side effect is that it displays incorrect amounts on transactions you're signing (because I guess it isn't subtracting the change UTXO).

I think a workaround will be to import the wallet without any seed phrases, connect and download transactions, and then permanently disconnect networks and then enter the seed phrase.

limpbrains commented 6 months ago

Hi! Thanks for reporting. Do you know the index of the address you are trying to find in BW?

ricaum commented 6 months ago

Parece que há um problema no layout, quando vai recuperar a seed no modo off-line. Aparece um gif girando (loding) e a opção (Use um caminho de derivação personalizada) vai para baixo e a opção fica escondida.

limpbrains commented 6 months ago

@ricaum I think your issue is unrelated to the one described above. Please open new issue, describe how to reproduce it, attach a video if possible, thx

limpbrains commented 6 months ago

I believe the issue lies in the offline wallet being unaware of the number of addresses already used. By default, BW generates only 20 addresses for receiving and 20 for change (gap limit). We need to update these indexes for offline wallets, but the exact location for this update is uncertain. Simply creating and signing a PSBT does not guarantee its broadcast. Perhaps we should only broadcast it if the user exports it using a file or QR code. Alternatively, we could introduce another index, such as "max_saw_address_index," update it in wallet.createTransaction, and consider it when generating the address list.

Any thoughts on this, @Overtorment?

Overtorment commented 6 months ago

It's even less for multisig, 10 i think. So blank just-imported multisig will be aware of only 10 receive addresses. How is it supposed to know that it was heavily used outside?

However, when importing psbts, we could move the last used index, as iirc psbts carry paths for used inputs and we could get the exact index