What are the practical steps to regenerate a wallet using --import-seed-phrase?

@aszepieniec I was trying to re-create my wallet using the neptune-cli import-seed-phrase but could not manage it.

I re-named the ‘wallet’ directory for both the /home/name/.local/share/neptune/main/databases/wallet and also for the /home/name/.local/share/neptune/main/wallet.

I then ran neptune-cli import-seed-phrase and entered the seed phrase correctly.

However, when I ran neptune-core with its peers, my balance was 0. I then tried neptune-cli with the –scan-blocks option, but that did not help.

How do I use the import-seed-phrase to regenerate a wallet (e.g. on a new computer)? Or does this process only work if you download the blockchain from the start as well? Reading this ( Can I sync all past transactions & mining rewards using only the seed phrase? - #4 by aszepieniec ), my impression is that you would have to use neptune-cli import-seed-phrase, then download the blockchain from the genesis block while using the —scan blocks option in order to identify the transactions that pertain to the regenerated wallet. Is that correct?

Many thanks again.

The argument --scan-blocks only works on incoming blocks. In particular, it does nothing with blocks that were already downloaded and stored previously. In order to recover the balance of a different master seed, you have to ensure that all balance-affecting blocks are downloaded again. (Note: this could be through --import-blocks-from-directory, which has the same effect and no bandwidth cost.)

Here’s what to do:

  • Rename /home/name/.local/neptune/ to /home/name/.local/neptune-backup/.
  • Run neptune-cli import-seed-phrase.
  • Run the node from scratch: neptune-cli –import-blocks-from-directory /home/name/.local/neptune-backup/main/blocks/.

I may have gotten a few details wrong but if you’ve gotten so far I’m sure you can correct for them. (And if so, please correct in here so that the next person to stumble across this problem knows what to do.)

Note that @sword-smith is busy working on a new schema in the database of archival nodes that indexes UTXO-related data from blocks. While I don’t think this use case is currently targeted, the changes in that PR pave the way for the workflow whereby you swap out just the wallet.dat file and recover your balance without re-processing all balance-affecting blocks.

  • Can you make neptune-core (daemon) independent of the wallet concept?
  • Then allow neptune-cli to create many wallets (not just one).
  • Each wallet would consist of “mywallet.keys” file (only the seed phrase, must be backed up) and “mywallet” file (extra data related to that wallet, that ideally should be backed up (to not waste time) but can be recovered by syncing to daemon from scratch if the file is lost).

That is roughly what Monero does. Could Neptune do similar?

It feels a bit “unclean” to have the daemon concept related to wallet files. (Two concepts, mixed together?)

Just to clarify, with monero-cli, you can choose where you keep your wallets. Could be in ~/Documents, for example.

It was always IMO a much cleaner design than Bitcoin Core (and currently Neptune, whose daemon/wallet design is similar to Bitcoin Core in this way).

TLDR (IMO):

  • daemon unrelated to wallets, cli at startup can choose wallet (Monero): :+1:
  • daemon/wallet concepts mixed together (Bitcoin Core and Neptune): :-1:

Can you make neptune-core (daemon) independent of the wallet concept?

Answering literally: yes. There is no technical obstacle.

Then allow neptune-cli to create many wallets (not just one).

Also possible.

I guess the reasons why the daemon and the wallet are merged are:

  1. We use bitcoin-core as a template moreso than anything else. Whenever we are confused about something, it pays to research and understand why Bitcoin or bitcoin-core makes the choices it does.
  2. The codebase evolved largely in incremental features rather than up-front intentional design – and I think it could not have happened any other way, because in order to make a good architecture you need to have intimate knowledge of the problems it is supposed to solve, and you only get that intimate knowledge by solving them.

In this particular case I side with Monero and against bitcoin-core. IMHO it is cleaner to separate the daemon and the wallet into separate processes, and once you have that separation in place nothing stops you from plugging in multiple wallets into the daemon.

That said, moving in this direction is a rather sizeable undertaking and probably not on top of the priority list in the foreseeable future.

1 Like

The currently ongoing work, e.g. @sword-smith work, how much as it assuming the current Bitcoin Core structure of daemon/wallet? (If you wait until later to change it, will the change get increasingly harder over time, or not much difference?)

The new UTXO index was just merged. The work can be seen here: Utxo index v2 by Sword-Smith · Pull Request #833 · Neptune-Crypto/neptune-core · GitHub . The new UTXO index just maps relevant information from each block into the UTXO index. It does not make assumptions about the wallet implementation and is designed to service both the neptune-core built-in wallet and to serve future light clients and wallets.

The UTXO index is considered a “heavy duty” index and is not activated by default. You have to start the client with the --utxo-indexflag set. Four CLI commands are provided for rescanning historical blocks:

neptune-cli rescan-announced <first> <last>
neptune-cli rescan-expected <first> <last>
neptune-cli rescan-outgoing <first> <last>
neptune-cli rescan-guesser-rewards <first> <last>

First time you start the client with the `–utxo-index` set, it needs to go through all historical blocks and apply them to the index. This process may take up to ten minutes when applying all blocks on main net which is around 24.000.

1 Like