[this](https://github.com/lightningnetwork/lnd/issues/3473) or
[this](https://github.com/lightningnetwork/lnd/issues/3473) or
[this](https://github.com/lightningnetwork/lnd/issues/4102), it is possible
[this](https://github.com/lightningnetwork/lnd/issues/4102), it is possible
that a simple compaction (a full copy in safe mode) can solve your problem.
that a simple compaction (a full copy in safe mode) can solve your problem.
See [`chantools compactdb`](doc/chantools_compactdb.md).
See [`chantools compactdb`](doc/chantools_compactdb.md).
<br/><br/>
<br/><br/>
If that doesn't work and you need to continue the recovery, make sure you can
If that doesn't work and you need to continue the recovery, make sure you can
at least extract the `channel.backup` file and if somehow possible any version
at least extract the `channel.backup` file and if somehow possible any
of the `channel.db` from the node.
version
<br/><br/>
of the `channel.db` from the node.
Whatever you do, do **never, ever** replace your `channel.db` file with an old
<br/><br/>
version (from a file based backup) and start your node that way.
Whatever you do, do **never, ever** replace your `channel.db` file with an
[Read this explanation why that can lead to loss of funds.](https://github.com/lightningnetwork/lnd/blob/master/docs/safety.md#file-based-backups)
old
version (from a file based backup) and start your node that way.
[Read this explanation why that can lead to loss of
funds.][safety-file-backup]
2. **Rescue on-chain balance**: To start the recovery process, we are going to
2. **Rescue on-chain balance**: To start the recovery process, we are going to
re-create the node from scratch. To make sure we don't overwrite any old data
re-create the node from scratch. To make sure we don't overwrite any old data
in the process, make sure the old data directory of your node (usually `.lnd`
in the process, make sure the old data directory of your node (usually `.lnd`
in the user's home directory) is safely moved away (or the whole folder
in the user's home directory) is safely moved away (or the whole folder
renamed) before continuing.<br/>
renamed) before continuing.<br/>
To start the on-chain recovery, [follow the sub step "Starting On-Chain Recovery" of this guide](https://github.com/lightningnetwork/lnd/blob/master/docs/recovery.md#starting-on-chain-recovery).
To start the on-chain recovery, [follow the sub step "Starting On-Chain
Don't follow the whole guide, only this single chapter!
Recovery" of this guide][2].
<br/><br/>
Don't follow the whole guide, only this single chapter!
This step is completed once the `lncli getinfo` command shows both
<br/><br/>
`"synced_to_chain": true` and `"synced_to_graph": true` which can take several
This step is completed once the `lncli getinfo` command shows both
hours depending on the speed of your hardware. **Do not be alarmed** that the
`"synced_to_chain": true` and `"synced_to_graph": true` which can take
`lncli getinfo` command shows 0 channels. This is normal as we haven't started
several
the off-chain recovery yet.
hours depending on the speed of your hardware. **Do not be alarmed** that the
`lncli getinfo` command shows 0 channels. This is normal as we haven't
started
the off-chain recovery yet.
3. **Recover channels using SCB**: Now that the node is fully synced, we can try
3. **Recover channels using SCB**: Now that the node is fully synced, we can try
to recover the channels using the [Static Channel Backups (SCB)](https://github.com/lightningnetwork/lnd/blob/master/docs/safety.md#static-channel-backups-scbs).
to recover the channels using the [Static Channel Backups (SCB)][safety-scb].
For this, you need a file called `channel.backup`. Simply run the command
For this, you need a file called `channel.backup`. Simply run the command
If you know the peer of a zombie channel and have a way to contact them, you
If you know the peer of a zombie channel and have a way to contact them, you
can also skip the registration/matching process and [create your own match
can also skip the registration/matching process and [create your own match
file](doc/zombierecovery.md#file-format).
file](doc/zombierecovery.md#file-format).
## Seed and passphrase input
## Seed and passphrase input
All commands that require the seed (and, if set, the seed's passphrase) offer
All commands that require the seed (and, if set, the seed's passphrase) offer
three distinct possibilities to specify it:
three distinct possibilities to specify it:
1. **Enter manually on the terminal**: This is the safest option as it makes
1. **Enter manually on the terminal**: This is the safest option as it makes
sure that the seed isn't stored in the terminal's command history.
sure that the seed isn't stored in the terminal's command history.
2. **Pass the extened master root key as parameter**: This is added as an option
2. **Pass the extened master root key as parameter**: This is added as an option
for users who don't have the full seed anymore, possibly because they used
for users who don't have the full seed anymore, possibly because they used
`lnd`'s `--noseedbackup` flag and extracted the `xprv` from the wallet
`lnd`'s `--noseedbackup` flag and extracted the `xprv` from the wallet
database with the `walletinfo` command. Those users can specify the master
database with the `walletinfo` command. Those users can specify the master
root key by passing the `--rootkey` command line flag to each command that
root key by passing the `--rootkey` command line flag to each command that
requires the seed.
requires the seed.
3. **Use environment variables**: This option makes it easy to automate usage of
3. **Use environment variables**: This option makes it easy to automate usage of
`chantools` by removing the need to type into the terminal. There are three
`chantools` by removing the need to type into the terminal. There are three
environment variables that can be set to skip entering values through the
environment variables that can be set to skip entering values through the
terminal:
terminal:
- `AEZEED_MNEMONIC`: Specifies the 24 word `lnd` aezeed.
- `AEZEED_MNEMONIC`: Specifies the 24 word `lnd` aezeed.
- `AEZEED_PASSPHRASE`: Specifies the passphrase for the aezeed. If no
- `AEZEED_PASSPHRASE`: Specifies the passphrase for the aezeed. If no
passphrase was used during the creation of the seed, the special value
passphrase was used during the creation of the seed, the special value
@ -260,6 +390,7 @@ Your BIP32 HD root key is: xprv9s21ZrQH1...
```
```
### Are my funds safe?
### Are my funds safe?
Some commands require the seed. But your seed will never leave your computer.
Some commands require the seed. But your seed will never leave your computer.
Most commands don't require an internet connection: you can and should
Most commands don't require an internet connection: you can and should
@ -270,7 +401,7 @@ run them on a computer with a firewall that blocks outgoing connections.
```text
```text
This tool provides helper functions that can be used rescue
This tool provides helper functions that can be used rescue
funds locked in lnd channels in case lnd itself cannot run properly anymore.
funds locked in lnd channels in case lnd itself cannot run properly anymore.
Complete documentation is available at https://github.com/guggero/chantools/.
Complete documentation is available at https://github.com/lightninglabs/chantools/.
Usage:
Usage:
chantools [command]
chantools [command]
@ -281,6 +412,7 @@ Available Commands:
compactdb Create a copy of a channel.db file in safe/read-only mode
compactdb Create a copy of a channel.db file in safe/read-only mode
deletepayments Remove all (failed) payments from a channel DB
deletepayments Remove all (failed) payments from a channel DB
derivekey Derive a key with a specific derivation path
derivekey Derive a key with a specific derivation path
doublespendinputs Tries to double spend the given inputs by deriving the private for the address and sweeping the funds to the given address. This can only be used with inputs that belong to an lnd wallet.
dropchannelgraph Remove all graph related data from a channel DB
dropchannelgraph Remove all graph related data from a channel DB
dumpbackup Dump the content of a channel.backup file
dumpbackup Dump the content of a channel.backup file
dumpchannels Dump all channel information from an lnd channel database
dumpchannels Dump all channel information from an lnd channel database
@ -319,32 +451,61 @@ Use "chantools [command] --help" for more information about a command.
Detailed documentation for each sub command is available in the
Detailed documentation for each sub command is available in the
[docs](doc/chantools.md) folder.
[docs](doc/chantools.md) folder.
Quick access:
The following table provides quick access to each command's documentation.
| [chanbackup](doc/chantools_chanbackup.md) | :pencil: Extract a `channel.backup` file from a `channel.db` file |
+ [migratedb](doc/chantools_migratedb.md)
| [closepoolaccount](doc/chantools_closepoolaccount.md) | :pencil: Manually close an expired Lightning Pool account |
+ [recoverloopin](doc/chantools_recoverloopin.md)
| [compactdb](doc/chantools_compactdb.md) | Run database compaction manually to reclaim space |
+ [removechannel](doc/chantools_removechannel.md)
| [deletepayments](doc/chantools_deletepayments.md) | Remove ALL payments from a `channel.db` file to reduce size |
+ [rescueclosed](doc/chantools_rescueclosed.md)
| [derivekey](doc/chantools_derivekey.md) | :pencil: Derive a single private/public key from `lnd`'s seed, use to test seed |
+ [rescuefunding](doc/chantools_rescuefunding.md)
| [doublespendinputs](doc/chantools_doublespendinputs.md) | :pencil: Tries to double spend the given inputs by deriving the private for the address and sweeping the funds to the given address |
+ [showrootkey](doc/chantools_showrootkey.md)
| [dropchannelgraph](doc/chantools_dropchannelgraph.md) | (:warning:) Completely drop the channel graph from a `channel.db` to force re-sync |
| [recoverloopin](doc/chantools_recoverloopin.md) | :pencil: Recover funds from a failed Lightning Loop inbound swap |
| [removechannel](doc/chantools_removechannel.md) | (:skull: :warning:) Remove a single channel from a `channel.db` file |
| [rescueclosed](doc/chantools_rescueclosed.md) | :pencil: (:pushpin:) Rescue funds in a legacy (pre `STATIC_REMOTE_KEY`) channel output |
| [rescuefunding](doc/chantools_rescuefunding.md) | :pencil: (:pushpin:) Rescue funds from a funding transaction. Deprecated, use [zombierecovery](doc/chantools_zombierecovery.md) instead |
| [showrootkey](doc/chantools_showrootkey.md) | :pencil: Display the master root key (`xprv`) from your seed (DO NOT SHARE WITH ANYONE) |
| [signrescuefunding](doc/chantools_signrescuefunding.md) | :pencil: (:pushpin:) Sign to funds from a funding transaction. Deprecated, use [zombierecovery](doc/chantools_zombierecovery.md) instead |
| [summary](doc/chantools_summary.md) | Create a summary of channel funds from a `channel.db` file |
| [sweepremoteclosed](doc/chantools_sweepremoteclosed.md) | :pencil: Find channel funds from remotely force closed channels and sweep them |
| [sweeptimelock](doc/chantools_sweeptimelock.md) | :pencil: Sweep funds in locally force closed channels once time lock has expired (requires `channel.db`) |
| [sweeptimelockmanual](doc/chantools_sweeptimelockmanual.md) | :pencil: Manually sweep funds in a locally force closed channel where no `channel.db` file is available |
| [triggerforceclose](doc/chantools_triggerforceclose.md) | :pencil: (:pushpin:) Request certain CLN peers to force close a channel that don't react to normal SCB recovery requests |
| [vanitygen](doc/chantools_vanitygen.md) | Generate an `lnd` seed for a node public key that starts with a certain sequence of hex digits |
| [walletinfo](doc/chantools_walletinfo.md) | Show information from a `wallet.db` file, requires access to the wallet password |
| [zombierecovery](doc/chantools_zombierecovery.md) | :pencil: Cooperatively rescue funds from channels where normal recovery is not possible (see [full guide here][zombie-recovery]) |