lnd icon indicating copy to clipboard operation
lnd copied to clipboard

Cannot force close inactive channels

Open kiaraho opened this issue 7 years ago • 2 comments

Background

Experienced an issue when upgrading from 0.4.2 to 0.5.1 that forced me to restore a backup of my .lnd folder that I made on 2018-11-27. Reverted to 0.4.2 since that was version I was running when I made the backup. lncli listchannels shows 0 active and 18 inactive channels. None of the channels will close whether I run lncli closeallchannels --force or try close each channel individually.

Your environment

  • lnd version 0.4.2-beta commit=7cf5ebe2650b6798182e10be198c7ffc1f1d6e19
  • Linux hostname 4.15.0-43-generic #46~16.04.1-Ubuntu SMP Fri Dec 7 13:31:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Bitcoin Core Daemon version v0.17.0.0-ge1ed37edaedc85b8c3468bd9a726046344036243

Steps to reproduce

lncli closeallchannels --force lncli closechannel --funding_txid=[TXID] --output_index=[INDEX] --force

Expected behaviour

Channels should close.

Actual behaviour

Channels fail to close, LND throws a "[lncli] rpc error: code = Unavailable desc = transport is closing" message after some time, and wallet gets locked. Contents of my lnd.log shown below from my attempt to close a channel with this command:

lncli closechannel --funding_txid=fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4 --output_index=1 --force


lnd.log

2018-12-31 23:17:11.357 [INF] LTND: Version 0.4.2-beta commit=7cf5ebe2650b6798182e10be198c7ffc1f1d6e19 2018-12-31 23:17:11.357 [INF] LTND: Active chain: Bitcoin (network=mainnet) 2018-12-31 23:17:11.358 [INF] CHDB: Checking for schema update: latest_version=0, db_version=0 2018-12-31 23:17:11.378 [INF] RPCS: password RPC server listening on 127.0.0.1:10009 2018-12-31 23:17:11.379 [INF] RPCS: password gRPC proxy started at 127.0.0.1:8080 2018-12-31 23:17:11.379 [INF] LTND: Waiting for wallet encryption password. Use lncli create to create wallet, or lncli unlock to unlock already created wallet. 2018-12-31 23:17:24.819 [INF] LNWL: Opened wallet 2018-12-31 23:17:24.888 [INF] LTND: Primary chain is set to: bitcoin 2018-12-31 23:17:24.888 [INF] LTND: Initializing bitcoind backed fee estimator 2018-12-31 23:17:25.977 [INF] LNWL: Opened wallet 2018-12-31 23:17:25.980 [INF] LNWL: Started listening for blocks via ZMQ on tcp://127.0.0.1:28332 2018-12-31 23:17:27.082 [INF] LNWL: The wallet has been unlocked without a time limit 2018-12-31 23:17:27.082 [INF] LTND: LightningWallet opened 2018-12-31 23:17:27.084 [DBG] LTND: Adding debug invoice (*channeldb.Invoice)(0xc4200cb1e0)({ Memo: ([]uint8) , Receipt: ([]uint8) , PaymentRequest: ([]uint8) , CreationDate: (time.Time) 2018-12-31 23:17:27.084437308 +0000 UTC m=+15.779694045, SettleDate: (time.Time) 0001-01-01 00:00:00 +0000 UTC, Terms: (channeldb.ContractTerm) { PaymentPreimage: ([32]uint8) (len=32 cap=32) { 00000000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 |................| 00000010 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 |................| }, Value: (lnwire.MilliSatoshi) 100000000000000 mSAT, Settled: (bool) false } })

2018-12-31 23:17:27.085 [DBG] SRVR: Debug HTLC invoice inserted, preimage=0101010101010101010101010101010101010101010101010101010101010101, hash=72cd6e8422c407fb6d098690f1130b7ded7ec2f7f5e1d30bd9d521f015363793 2018-12-31 23:17:27.087 [INF] HSWC: Restoring in-memory circuit state from disk 2018-12-31 23:17:27.096 [INF] HSWC: Payment circuits loaded: num_pending=33, num_open=1 2018-12-31 23:17:27.106 [INF] HSWC: Trimming open circuits for chan_id=526679:951:0, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=537554:2566:0, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=528817:763:0, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=519751:2270:0, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=537372:927:1, start_htlc_id=45 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=519805:929:0, start_htlc_id=1 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=549300:2523:1, start_htlc_id=5 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=538170:1165:1, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=519823:1295:0, start_htlc_id=2 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=546586:1772:0, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=543767:440:1, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=520794:952:1, start_htlc_id=0 2018-12-31 23:17:27.107 [INF] HSWC: Trimming open circuits for chan_id=526444:1295:1, start_htlc_id=0 2018-12-31 23:17:27.165 [INF] RPCS: RPC server listening on 127.0.0.1:10009 2018-12-31 23:17:27.165 [INF] RPCS: gRPC proxy started at 127.0.0.1:8080 2018-12-31 23:17:27.166 [INF] LTND: Waiting for chain backend to finish sync, start_height=556454 2018-12-31 23:17:27.179 [INF] LNWL: Started rescan from block 00000000000000000022df70be977e89462fe8f4b312bd1d69e9be5b7d6789b2 (height 556453) for 443 addresses 2018-12-31 23:17:27.321 [INF] LNWL: Starting rescan from block 00000000000000000022df70be977e89462fe8f4b312bd1d69e9be5b7d6789b2 2018-12-31 23:17:27.526 [INF] LNWL: Rescan finished at 556454 (0000000000000000001a4f66b822fc8eb791d4324394f1f0622732239488bddb) 2018-12-31 23:17:27.526 [INF] LNWL: Catching up block hashes to height 556454, this might take a while 2018-12-31 23:17:27.527 [INF] LNWL: Done catching up block hashes 2018-12-31 23:17:27.528 [INF] LNWL: Finished rescan for 443 addresses (synced to block 0000000000000000001a4f66b822fc8eb791d4324394f1f0622732239488bddb, height 556454) 2018-12-31 23:17:28.184 [INF] LTND: Chain backend is fully synced (end_height=556454)! 2018-12-31 23:17:28.185 [INF] LNWL: Started listening for blocks via ZMQ on tcp://127.0.0.1:28332 2018-12-31 23:17:28.190 [INF] HSWC: Starting HTLC Switch 2018-12-31 23:17:28.190 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.229 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.243 [INF] UTXN: Processing outputs from missed blocks. Starting with blockHeight=556453, to current blockHeight=556454 2018-12-31 23:17:28.243 [DBG] UTXN: Attempting to graduate outputs at height=556454 2018-12-31 23:17:28.243 [INF] UTXN: Attempting to graduate height=556454: num_kids=0, num_babies=0 2018-12-31 23:17:28.247 [INF] UTXN: UTXO Nursery is now fully synced 2018-12-31 23:17:28.280 [INF] CNCT: Creating ChannelArbitrators for 13 active channels 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(b0e78f723d68ad2055a19f3ca1cf22c9ea4a87feec017e901d846021159212d7:0) 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(cda04aab04aa14c1a3b58c4c6a1dee8fad5d767b556906b61dd109fc42a1c0da:0) 2018-12-31 23:17:28.280 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.280 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(e0664ad6f2adf5f0a0800e8b049d1bc64483c2422767400b0407a9ee1089536a:0) 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(be99b03c8b7474ef8c3fe241a98f8bf47540d5e1745d358bfba479a8c0122b17:0) 2018-12-31 23:17:28.280 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.280 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(825f7a52a6ac12b40f5ae110baf00441a080bea290abcf403d2172eebe90126e:1) 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(d052843a55985b5ad580f5f7f44211d437ea11dd50f2fcf81cd8c669b0f6c7df:0) 2018-12-31 23:17:28.280 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.280 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.280 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(2e0147f8afdc9c4df15028947069bf538d068b6a50afaf24ebcae653e34eabec:1) 2018-12-31 23:17:28.281 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4:1) 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.281 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(2bd2da653f4ec930cc7b819556f86a7e119643710ecfd0cfc3a91d94340c12f9:0) 2018-12-31 23:17:28.281 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(357fe1c6920c31e28df3666d07b501e791435a307a0285490b92a3a4e348a531:0) 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.281 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(d8f70c221a8acc01cbab2c47e9267eec5cf5dfb98ca6daaef38fa92a62504676:1) 2018-12-31 23:17:28.281 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(c092af497325556005abf7dbf20438bd205ad4dc51579bb16ed9af6637aa1f2b:1) 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.281 [DBG] CNCT: New ChainEventSubscription(id=0) for ChannelPoint(c60cd977853a106a0ccf787d372fdfe4c325101606f36692e95f82446264581e:1) 2018-12-31 23:17:28.281 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.289 [INF] CNCT: Creating ChannelArbitrators for 1 closing channels 2018-12-31 23:17:28.289 [DBG] CNCT: Starting chain watcher for ChannelPoint(c60cd977853a106a0ccf787d372fdfe4c325101606f36692e95f82446264581e:1) 2018-12-31 23:17:28.289 [INF] NTFN: New block epoch subscription 2018-12-31 23:17:28.289 [INF] NTFN: New spend subscription: utxo=c60cd977853a106a0ccf787d372fdfe4c325101606f36692e95f82446264581e:1 2018-12-31 23:17:28.291 [DBG] CNCT: Starting chain watcher for ChannelPoint(e0664ad6f2adf5f0a0800e8b049d1bc64483c2422767400b0407a9ee1089536a:0) 2018-12-31 23:17:28.291 [INF] NTFN: New spend subscription: utxo=e0664ad6f2adf5f0a0800e8b049d1bc64483c2422767400b0407a9ee1089536a:0 2018-12-31 23:17:28.291 [INF] CNCT: Close observer for ChannelPoint(c60cd977853a106a0ccf787d372fdfe4c325101606f36692e95f82446264581e:1) active 2018-12-31 23:17:28.391 [DBG] CNCT: Starting chain watcher for ChannelPoint(2e0147f8afdc9c4df15028947069bf538d068b6a50afaf24ebcae653e34eabec:1) 2018-12-31 23:17:28.391 [INF] NTFN: New spend subscription: utxo=2e0147f8afdc9c4df15028947069bf538d068b6a50afaf24ebcae653e34eabec:1 2018-12-31 23:17:28.391 [INF] CNCT: Close observer for ChannelPoint(e0664ad6f2adf5f0a0800e8b049d1bc64483c2422767400b0407a9ee1089536a:0) active 2018-12-31 23:18:39.610 [DBG] LNWL: ChannelPoint(fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4:1), starting local commitment: (*lnwallet.commitment)(0xc4202a23c0)({ height: (uint64) 239, isOurs: (bool) true, ourMessageIndex: (uint64) 0, theirMessageIndex: (uint64) 0, ourHtlcIndex: (uint64) 0, theirHtlcIndex: (uint64) 0, txn: (*wire.MsgTx)(0xc4206ffc40)({ Version: (int32) 2, TxIn: ([]*wire.TxIn) (len=1 cap=1) { (*wire.TxIn)(0xc420a14a80)({ PreviousOutPoint: (wire.OutPoint) fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4:1, SignatureScript: ([]uint8) { }, Witness: (wire.TxWitness) , Sequence: (uint32) 2159204002 }) }, TxOut: ([]*wire.TxOut) (len=1 cap=1) { (wire.TxOut)(0xc4202feb60)({ Value: (int64) 4835290, PkScript: ([]uint8) (len=34 cap=34) { 00000000 00 20 f4 4f 23 db c1 4d c5 15 8e 10 60 80 94 7b |. .O#..M......{| 00000010 8d f1 e0 a3 12 06 b5 51 da d2 c9 63 47 a8 48 d9 |.......Q...cG.H.| 00000020 84 f4 |..| } }) }, LockTime: (uint32) 537477010 }), sig: ([]uint8) (len=71 cap=71) { 00000000 30 45 02 21 00 bf 7a 98 06 62 2c c5 15 e7 fc b1 |0E.!..z..b,.....| 00000010 39 80 ca 98 1e 61 4e 0f e1 02 28 26 e0 37 b0 a5 |9....aN...(&.7..| 00000020 64 f9 8b 95 ac 02 20 60 b9 66 17 b1 be 2a 1f a0 |d..... .f.....| 00000030 ca 66 c3 09 de 4f dd 8a 23 59 a9 ba 10 10 49 97 |.f...O..#Y....I.| 00000040 8b e3 e6 fd 2e bb 4d |......M| }, ourBalance: (lnwire.MilliSatoshi) 4835290000 mSAT, theirBalance: (lnwire.MilliSatoshi) 0 mSAT, fee: (btcutil.Amount) 0.00007421 BTC, feePerKw: (lnwallet.SatPerKWeight) 10250, dustLimit: (btcutil.Amount) 0.00000573 BTC, outgoingHTLCs: ([]lnwallet.PaymentDescriptor) , incomingHTLCs: ([]lnwallet.PaymentDescriptor) , outgoingHTLCIndex: (map[int32]*lnwallet.PaymentDescriptor) { }, incomingHTLCIndex: (map[int32]*lnwallet.PaymentDescriptor) { } })

2018-12-31 23:18:39.613 [DBG] LNWL: ChannelPoint(fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4:1), starting remote commitment: (*lnwallet.commitment)(0xc4202a2600)({ height: (uint64) 239, isOurs: (bool) false, ourMessageIndex: (uint64) 0, theirMessageIndex: (uint64) 0, ourHtlcIndex: (uint64) 0, theirHtlcIndex: (uint64) 0, txn: (*wire.MsgTx)(0xc4206ffc80)({ Version: (int32) 2, TxIn: ([]*wire.TxIn) (len=1 cap=1) { (*wire.TxIn)(0xc420a14ae0)({ PreviousOutPoint: (wire.OutPoint) fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4:1, SignatureScript: ([]uint8) { }, Witness: (wire.TxWitness) , Sequence: (uint32) 2159204002 }) }, TxOut: ([]*wire.TxOut) (len=1 cap=1) { (*wire.TxOut)(0xc4202feba0)({ Value: (int64) 4835290, PkScript: ([]uint8) (len=22 cap=22) { 00000000 00 14 86 1e 7b 5a 0c b7 50 7d c2 0f e6 5d a6 8d |....{Z..P}...]..| 00000010 9d dc 46 58 b8 17 |..FX..| } }) }, LockTime: (uint32) 537477010 }), sig: ([]uint8) { }, ourBalance: (lnwire.MilliSatoshi) 4835290000 mSAT, theirBalance: (lnwire.MilliSatoshi) 0 mSAT, fee: (btcutil.Amount) 0.00007421 BTC, feePerKw: (lnwallet.SatPerKWeight) 10250, dustLimit: (btcutil.Amount) 0.00000573 BTC, outgoingHTLCs: ([]lnwallet.PaymentDescriptor) , incomingHTLCs: ([]lnwallet.PaymentDescriptor) , outgoingHTLCIndex: (map[int32]*lnwallet.PaymentDescriptor) { }, incomingHTLCIndex: (map[int32]*lnwallet.PaymentDescriptor) { } })

2018-12-31 23:18:39.615 [INF] HSWC: Removing channel link with ChannelID(b465363e5d0885d41cca6447e1b4d187e0551337bb423aa77865147fcce149ff) 2018-12-31 23:18:39.615 [INF] CNCT: Attempting to force close ChannelPoint(fe49e1cc7f146578a73a42bb371355e087d1b4e14764ca1cd485085d3e3665b4:1) 2018-12-31 23:22:45.638 [ERR] SRVR: unable to start server: encoding/hex: invalid byte: U+0073 's'

2018-12-31 23:23:45.884 [INF] LTND: Version 0.4.2-beta commit=7cf5ebe2650b6798182e10be198c7ffc1f1d6e19 2018-12-31 23:23:45.884 [INF] LTND: Active chain: Bitcoin (network=mainnet) 2018-12-31 23:23:45.886 [INF] CHDB: Checking for schema update: latest_version=0, db_version=0 2018-12-31 23:23:45.907 [INF] RPCS: password RPC server listening on 127.0.0.1:10009 2018-12-31 23:23:45.907 [INF] RPCS: password gRPC proxy started at 127.0.0.1:8080 2018-12-31 23:23:45.907 [INF] LTND: Waiting for wallet encryption password. Use lncli create to create wallet, or lncli unlock to unlock already created wallet.

kiaraho avatar Dec 31 '18 23:12 kiaraho

After several SRVR errors and multiple lncli closeallchannels --force retries, the inactive channels appear to be closing. Confirmed all the closing transaction IDs have indeed been broadcast. Maturity block heights vary from 556,623 to 556,977 which I thought was odd. Regardless, it would still be nice to know why my initial attempts failed.

kiaraho avatar Jan 01 '19 05:01 kiaraho

It is generally not advised to restore from backups at this point.

The problem here seemed to be that the server was unable to start, possibly because of incompatibilities between the db version:

2018-12-31 23:22:45.638 [ERR] SRVR: unable to start server: encoding/hex: invalid byte: U+0073 's'

Please re-open if this happens on 0.5.1, as the relevant subsystems have been significantly changed since 0.4.2 :)

halseth avatar Jan 02 '19 10:01 halseth