cryptoadvance / specter-desktop

A desktop GUI for Bitcoin Core optimised to work with hardware wallets
MIT License
802 stars 238 forks source link

What will happen if I connect to a different Bitcoin Core instance? #1184

Open real-or-random opened 3 years ago

real-or-random commented 3 years ago

I wonder: What will happen if I connect to a different Bitcoin Core instance? Is this bad? Will Specter complain? Or will it just add the wallets there? Will I lose labels? etc...

The answer could go the FAQ or the UI, not sure.

edit: This is also relevant to backups. What should I backup as a user?

ben-kaufman commented 3 years ago

Hi, currently this would mean the user will need to recreate the wallets (Specter will prompt the user with the option to either recreate and rescan or delete the wallet). We are still looking into a way to allow moving wallets between nodes. Do you know if the wallet.dat file is self contained? (i.e. can be just moved from node to node and just work?). Once we implement a way to migrate wallets between nodes we could just automate this process. That's actually something I was hoping to look into now.

real-or-random commented 3 years ago

Thanks for the quick reply.

Do you know if the wallet.dat file is self contained? (i.e. can be just moved from node to node and just work?).

AFAIU yes, but I don't have any specific knowledge about the code (other than from reading the docs). See https://github.com/bitcoin/bitcoin/blob/master/doc/files.md#multi-wallet-environment.

edit: Maybe it's a good idea to tell the user in the UI that the instance is not supposed to change/wallets will be created there. A lot of tools simply require a running Bitcoin Core for obtaining blockchain state. But Specter Desktop is different because it uses the wallet features of Core. This may be unexpected, in particular because one can at any time open the settings page and reconfigure.

ben-kaufman commented 3 years ago

Thanks. Yes it would make sense to explain that to the users, it's just a question of where to put that? Maybe in the node settings page?

real-or-random commented 3 years ago

Thanks. Yes it would make sense to explain that to the users, it's just a question of where to put that? Maybe in the node settings page?

That's what I had in mind, yes.

ben-kaufman commented 3 years ago

Makes sense, I'll add that. Btw, I think the main problem would actually be due to pruned node support, with them you can't just move the .dat file. So we will need to implement an option to recreate by exporting and importing all txs and labels, not that easy but possible.

Edit: My mistake, it actually does seem to work copying the .dat file. So maybe what we could do is save the wallet.dat file in the Specter data folder and load it from there (but how to do that with a node running remotely?). I need to recheck but sounds like it could work.

real-or-random commented 3 years ago

Edit: My mistake, it actually does seem to work copying the .dat file. So maybe what we could do is save the wallet.dat file in the Specter data folder and load it from there (but how to do that with a node running remotely?). I need to recheck but sounds like it could work.

You can set walletdir but bitcoind won't be able to access its existing wallets... It feels less fragile to let the wallets with bitcoind, also because this works with remote bitcoind.

Copying the .dat file could potentially lead to a situation where you have two forked .dat files in two bitcoind instances, and then weird things may happen (e.g., you reuse addresses).

Maybe the first step here is just to write a migration guide? This seems like an expert thing unfortunately. :/