Skip to content

Instantly share code, notes, and snippets.

@Sosthene00
Created May 12, 2019 16:13
Show Gist options
  • Save Sosthene00/cd6f74689b0d630e735b5f1b4b72d93b to your computer and use it in GitHub Desktop.
Save Sosthene00/cd6f74689b0d630e735b5f1b4b72d93b to your computer and use it in GitHub Desktop.
# Back-up the .lnd dir
`cp -r .lnd/ .lnd.old`
# copy the .lnd dir to another machine that runs a non-pruned full node
`scp [source] [target]`
# Install GO
`wget https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz`
`sha256sum go1.12.3.linux-amd64.tar.gz | awk -F " " '{ print $1 }'`
# output should be `3924819eed16e55114f02d25d03e77c916ec40b7fd15c8acb5838b63135b03df`
`tar -C /usr/local -xzf go1.12.3.linux-amd64.tar.gz`
`export PATH=$PATH:/usr/local/go/bin`
# clone the btcwallet repo
`git clone https://github.com/btcsuite/btcwallet $GOPATH/src/github.com/btcsuite/btcwallet`
# run dropwtxmgr
`cd $GOPATH/src/github.com/btcsuite/btcwallet`
`GO111MODULE=on go install ./dropwtxmgr`
`cd $GOPATH/bin`
`dropwtxmgr --db=/path/to/data/chain/bitcoin/mainnet/wallet.db`
# Restart lnd, it should run a full rescan from genesis block, that might be a bit long though (24 hours on my machine)
@Kukks
Copy link

Kukks commented May 13, 2019

Thanks for this, being an absolute newbie with Go and linux in general, this gave me a starting point.

In my case, I wanted to recover rescan an lnd instance using an existing mainnet btcpay deployment that I use for testing. Since the docker images used are alpine based, I ran into some trouble with the guide.

For running on alpine, I first ran before your guide:

apk update && apk add git 
apk --no-cache --allow-untrusted -X https://apkproxy.herokuapp.com/sgerrand/alpine-pkg-glibc add glibc glibc-bin

and instead of

`cd $GOPATH/src/github.com/btcsuite/btcwallet`
`GO111MODULE=on go install ./dropwtxmgr`
`cd $GOPATH/bin`
`dropwtxmgr --db=/path/to/data/chain/bitcoin/mainnet/wallet.db`

I did:

cd cmd/dropwtxmgr
go run main.go --db=/data/data/chain/bitcoin/mainnet/wallet.db

How long does the drop command take? Mine has been stuck there for a few mins now with no output:
Drop all btcwallet transaction history? [y/N] y

This is a horrible experience, no user should be needing to do this painful technical stuff to fix their lnd.

@Sosthene00
Copy link
Author

Haha, yes, it makes you realise that lightning is still hardcore now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment