lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.71k stars 2.09k forks source link

[feature]: Add start_height to lnd.conf to manually set node "birthday" #8640

Open ezracarr opened 7 months ago

ezracarr commented 7 months ago

I'm building a system that relies on remote signing nodes and watch-only nodes that are derived from those remote signers. I constitute the watch only nodes by using the wallet accounts import functionality thereby importing the xpub from the remote signer into the watch only node.

The problem I am running into is that the node sync process takes way too long because the "birthday" of the node is unknown and hence it defaults to the segwit activation block (I think).

The node proceeds to rescann a couple hundred thousand blocks which takes many hours

I would love to be able to set the node's birthday block manually within the lnd.conf file. something like start_height=838000

Below is a snippet of the logs from the node that is taking a long time to sync. It is currently taking about 45 minutes to process 10,000 blocks.

2024-04-10 14:39:25.858 [INF] LTND: Waiting for chain backend to finish sync, start_height=838615
2024-04-10 14:39:27.201 [INF] LNWL: Started rescan from block 0000000000000000000fc00b39b775a505eb38375ebb569b7729a5e75070869b (height 646100) for 0 addresses
2024-04-10 14:45:19.409 [INF] LNWL: Started polling mempool to cache new transactions
2024-04-10 14:56:53.005 [INF] LNWL: Catching up block hashes to height 650000, this might take a while
2024-04-10 14:56:53.008 [INF] LNWL: Done catching up block hashes
2024-04-10 14:56:53.008 [INF] LNWL: Rescanned through block 0000000000000000000060e32d547b6ae2ded52aadbc6310808e4ae42b08cc6a (height 650000)
2024-04-10 15:48:24.235 [INF] LNWL: Catching up block hashes to height 660000, this might take a while
2024-04-10 15:48:24.236 [INF] LNWL: Done catching up block hashes
2024-04-10 15:48:24.237 [INF] LNWL: Rescanned through block 00000000000000000008eddcaf078f12c69a439dde30dbb5aac3d9d94e9c18f6 (height 660000)
guggero commented 7 months ago

How are you creating the initial wallet? Just a random one that you then don't use?

You should instead use lncli createwatchonly where you can pass in a wallet birthday, as described here: https://github.com/lightningnetwork/lnd/blob/b875084cbed0b2fb4fed30a184be37152ca6a5c5/docs/remote-signing.md#the-signer-node