C-Otto / rebalance-lnd

A script that can be used to balance lightning channels of a lnd node
MIT License
343 stars 82 forks source link

Error when rebalancing with specific peer. #155

Closed sendbitcoin closed 3 years ago

sendbitcoin commented 3 years ago

I'm getting this error when i try rebalancing with lightning-poker.com

https://1ml.com/node/03ad156742a9a9d0e82e0022f264d6857addfd534955d5e97de4a695bf8dd12af0

I get it every time.

rebalance.py -f 727024576244482048 -a 11216 --max-fee-factor 20

error (2)

mutatrum commented 3 years ago

A similar error here, from a different path:


  File "./rebalance.py", line 270, in <module>
    success = main()
  File "./rebalance.py", line 86, in main
    max_fee_factor).rebalance()
  File "/home/admin/download/rebalance-lnd/logic.py", line 49, in rebalance
    success = self.try_route(payment_request, route, routes, tried_routes)
  File "/home/admin/download/rebalance-lnd/logic.py", line 56, in try_route
    if self.route_is_invalid(route, routes):
  File "/home/admin/download/rebalance-lnd/logic.py", line 108, in route_is_invalid
    if self.low_local_ratio_after_sending(first_hop, route.total_amt):
  File "/home/admin/download/rebalance-lnd/logic.py", line 124, in low_local_ratio_after_sending
    remote = channel.remote_balance + total_amount
AttributeError: 'NoneType' object has no attribute 'remote_balance'```
C-Otto commented 3 years ago

There are two lines channel = self.get_channel_for_channel_id(channel_id) (in low_local_ratio_after_sending and high_local_ratio_after_receiving in file logic.py). Could you insert a debug line below those?

debug(repr(channel))

This should give more information about the channel in question, please paste this in here. If possible, please also get the corresponding information from lnd itself: lncli listchannels

mutatrum commented 3 years ago

Added debug code, now running but haven't seen this error yet.

C-Otto commented 3 years ago

Thanks, I deleted the comment because it contains somewhat sensitive information. I'm having a look at it now.

C-Otto commented 3 years ago

That doesn't help much, I'm afraid. I just pushed code that gives more helpful information. Could you please reset your changes and try again with the new code?

mutatrum commented 3 years ago
Trying route #40
736053765682626560 -> 737114794363060224 -> 741759131487633409 -> 737465538513928193 -> 697044192630013953 -> 741350113135558656
Temporary channel failure, ignoring channel 737465538513928193 (from 03271338633d2d37b285dae4df40b413d8c6c791fbee7797bc5dc70812196d7d5c to 03cde60a6323f7122d5178255766e38114b4722ede08f7c9e0c5df9b912cc201d6)
Unable to find channel with id 742019715804758016!
Unable to get channel information for hop chan_id: 742019715804758016
chan_capacity: 2500000
amt_to_forward: 100003
fee: 1
expiry: 679379
amt_to_forward_msat: 100003301
fee_msat: 1100
pub_key: "035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226"
tlv_payload: true

First hop would have low local ratio after sending, Unable to find channel with id 742019715804758016!
Traceback (most recent call last):
  File "./rebalance.py", line 270, in <module>
    success = main()
  File "./rebalance.py", line 86, in main
    max_fee_factor).rebalance()
  File "/home/bitcoin/rebalance-lnd/logic.py", line 49, in rebalance
    success = self.try_route(payment_request, route, routes, tried_routes)
  File "/home/bitcoin/rebalance-lnd/logic.py", line 56, in try_route
    if self.route_is_invalid(route, routes):
  File "/home/bitcoin/rebalance-lnd/logic.py", line 114, in route_is_invalid
    routes.ignore_first_hop(self.get_channel_for_channel_id(first_hop.chan_id))
  File "/home/bitcoin/rebalance-lnd/routes.py", line 82, in ignore_first_hop
    other_key = channel.remote_pubkey
AttributeError: 'NoneType' object has no attribute 'remote_pubkey'
C-Otto commented 3 years ago

Alright, something is wrong with 742019715804758016 / 035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226. Any idea what that might be?

C-Otto commented 3 years ago

What does lncli listchannels | grep 035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226 -B 1 -A 45 say?

mutatrum commented 3 years ago
            "active": true,
            "remote_pubkey": "035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226",
            "channel_point": "7dcf105222004c8e4b1e9bf9904bd4dae2760371fbeb561345eb6a4f682f65fb:0",
            "chan_id": "742019715804758016",
            "capacity": "2500000",
            "local_balance": "1313388",
            "remote_balance": "1169288",
            "commit_fee": "17324",
            "commit_weight": "724",
            "fee_per_kw": "23927",
            "unsettled_balance": "0",
            "total_satoshis_sent": "5975402",
            "total_satoshis_received": "4806113",
            "num_updates": "1023",
            "pending_htlcs": [
            ],
            "csv_delay": 300,
            "private": false,
            "initiator": true,
            "chan_status_flags": "ChanStatusDefault",
            "local_chan_reserve_sat": "25000",
            "remote_chan_reserve_sat": "25000",
            "static_remote_key": true,
            "commitment_type": "STATIC_REMOTE_KEY",
            "lifetime": "530746",
            "uptime": "530535",
            "close_address": "",
            "push_amount_sat": "0",
            "thaw_height": 0,
            "local_constraints": {
                "csv_delay": 300,
                "chan_reserve_sat": "25000",
                "dust_limit_sat": "573",
                "max_pending_amt_msat": "2475000000",
                "min_htlc_msat": "1",
                "max_accepted_htlcs": 483
            },
            "remote_constraints": {
                "csv_delay": 300,
                "chan_reserve_sat": "25000",
                "dust_limit_sat": "573",
                "max_pending_amt_msat": "2475000000",
                "min_htlc_msat": "1",
                "max_accepted_htlcs": 483
            }
C-Otto commented 3 years ago

Looks OK to me. Does the channel maybe toggle between active/inactive?

C-Otto commented 3 years ago

Commit 9f8e8374 might have fixed that. Let's see.