lightningnetwork / lnd

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

[bug]: Failed recover on-chain testnet funds with neutrino #9055

Open AleAndForCode opened 2 months ago

AleAndForCode commented 2 months ago

Background

I was testing lnd recovery by attempting to recover a recently created testnet wallet with a non-zero balance. I followed the on-chain recovery instructions. After executing the recovery process, the recovery status showed as complete:

lncli getrecoveryinfo
{
    "recovery_mode": true,
    "recovery_finished": true,
    "progress": 1
}

However, the recovered wallet balance was zero.

Additionally, when generating a new address with lncli newaddress p2wkh, it produced the same address as before the restore. In my case, the address tb1qaa898gjprr5uh002kyqtnmpj02ur4vvw4v3ujh still has a balance, as confirmed by the testnet explorer here.

I also tried rebooting lnd and unlocking with a doubled recovery window, as well as launching lnd with the --reset-wallet-transactions flag. None of these steps resolved the issue. Please see the provided logs and screenshots for more details.

Logs contain a lot of such error messages:

[ERR] LNWL: Unable to synchronize wallet to chain, trying again in 5s: unable to perform wallet recovery: failed to store sync information 00000000f2ba832b40294ba33f8f005221af639aa3458d3fbc1b8da0a6a58105: failed to fetch block hash for height 2902302: block not found

fail_to_recover fail_to_recover_by_unlock logs.zip

Environment

version: '3'

services:
    lnd:
      image: lightninglabs/lnd:v0.18.2-beta
      container_name: lnd-testnet
      environment:
        LNCLI_NETWORK: testnet
      volumes:
        - ./testnet-data:/root/.lnd
      command: >
        --bitcoin.active
        --bitcoin.testnet
        --bitcoin.node=neutrino
        --feeurl https://pastacity.nl/VjtaVK73NZwGBAisrA3iFg
        --debuglevel=debug

Steps to reproduce

Start the lnd service. Follow the on-chain recovery instructions. Use lncli to create a seed and passphrase from an existing, recently created lnd wallet with a non-zero on-chain balance. Set the recovery window to the default value. Wait until lncli getrecoveryinfo shows recovery_finished = true. Check the wallet balance with lncli walletbalance.

Expected behaviour

The wallet should show the restored on-chain balance after recovery.

Actual behaviour

The recovered wallet balance is zero:

{
    "total_balance":  "0",
    "confirmed_balance":  "0",
    "unconfirmed_balance":  "0",
    "locked_balance":  "0",
    "reserved_balance_anchor_chan":  "0",
    "account_balance":  {
        "default":  {
            "confirmed_balance":  "0",
            "unconfirmed_balance":  "0"
        }
    }
}
guggero commented 2 months ago

Did you abort the recovery process at some point (e.g. restart lnd) while it was still scanning the chain? That unfortunately will stop the recovery and then it won't continue on the next startup (it's a known issue, see https://github.com/lightningnetwork/lnd/issues/7111).