Commit Graph

31 Commits

Author SHA1 Message Date
Gálli Zoltán
a7a0007dce rebalance: handle HTLC timeout
In rare cases, HTLCs can be stuck for days. I don't know why it's happening, maybe it would worth investigating the situation.
2021-02-26 11:28:07 +01:00
Gálli Zoltán
38b03cdddc rebalance: channel wo scid
A channel can exist without a short_channel_id, in the CHANNELD_AWAITING_LOCKIN state, while the funding transaction is sent but not yet included in a block.

Running `rebalanceall` while opening a channel could throw an exception:
```
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py: Exception in thread Thread-5:
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py: Traceback (most recent call last):
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:   File \"/usr/lib/python3.6/threading.py\", line 916, in _bootstrap_inner
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:     self.run()
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:   File \"/usr/lib/python3.6/threading.py\", line 864, in run
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:     self._target(*self._args, **self._kwargs)
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:   File \"/home/user/plugins/rebalance/rebalance.py\", line 475, in rebalanceall_thread
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:     result = maybe_rebalance_once(plugin, failed_pairs)
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:   File \"/home/user/plugins/rebalance/rebalance.py\", line 443, in maybe_rebalance_once
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:     result = maybe_rebalance_pairs(plugin, ch1, ch2, failed_pairs)
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:   File \"/home/user/plugins/rebalance/rebalance.py\", line 425, in maybe_rebalance_pairs
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:     wait_for_htlcs(plugin, [scid1, scid2])
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:   File \"/home/user/plugins/rebalance/rebalance.py\", line 384, in wait_for_htlcs
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py:     if scids is not None and channel['short_channel_id'] not in scids:
2021-02-14T09:31:39 UNUSUAL plugin-rebalance.py: KeyError: 'short_channel_id'
```
2021-02-16 10:58:35 +01:00
Gálli Zoltán
d219c0abc1 rebalance: measure and log HTLC settlement time
log messages show how much time need for an HTLC settlement
2021-02-08 14:57:27 +01:00
Michael Schmoock
c277f9e10b rebalance: adds a check for no incoming liquidity 2021-02-04 14:54:37 +01:00
Michael Schmoock
5231bfff65 rebalance: speedup by checking for htlcs 2021-02-03 14:17:20 +01:00
Michael Schmoock
cf9b942966 rebalance: fix potential looping mistakes 2021-02-03 14:17:20 +01:00
Michael Schmoock
239a21ab6b rebalance: autofix code nits 2021-02-03 14:17:20 +01:00
Michael Schmoock
3cbe497976 rebalance: fix division by zero 2021-02-03 14:17:20 +01:00
Michael Schmoock
92aafe7404 chore: rename feeadjustertoggle to feeadjuster-toggle 2021-01-19 12:17:30 +01:00
Gálli Zoltán
b80c558ebd rebalance: better feeadjuster integration
- turns off feeadjuster's automatic fee updates while rebalance running
- runs feeadjust only once, at the end
- measures time for rebalance
2021-01-19 10:23:34 +01:00
Gálli Zoltán
03e599678b automatic rebalance: review fixes part 4
- even more Millisatoshi usage
- nit fixes
2020-12-14 21:01:18 +01:00
Gálli Zoltán
21aaa6e4f3 automatic rebalance: review fixes part 3
- better thread handling
- more Millisatoshi usage
2020-12-14 21:01:18 +01:00
Gálli Zoltán
e2ed65e187 automatic rebalance: review fixes part 2 2020-12-14 21:01:18 +01:00
Gálli Zoltán
06d771539d automatic rebalance: review fixes 2020-12-14 21:01:18 +01:00
Gálli Zoltán
0dee5017b3 automatic rebalance
- rebalances liquidity between channels through circular payments
- automatically selects appropriate channels and executes rebalance
- uses economic fee by default: the rebalance transaction fees are less than the node's default fee, so it is cheaper to fix the liquidity than it can be ruined by transaction forwards
- runs async in the background, sometimes for a very long time (maybe hours)
- tries to rebalance small channels to a 50/50 liquidity ratio and stores remaining liquidity in big channels
- does nothing if there is no cheap enough circular route for rebalance
2020-12-14 21:01:18 +01:00
Michael Schmoock
4cb12a41cd rebalance: reduce some log output to debug 2020-06-11 13:16:01 +02:00
darosior
e574a717b1 Add pyln-client requirement to all plugins 2019-12-27 17:17:58 +01:00
darosior
94c641ea58 rebalance: restore Python3.5 compat
Support old snakes that have not shed yet
2019-09-06 17:26:23 +02:00
Matt Whitlock
477bdd8f61 rebalance: round HTLC fees up
BOLT#7 requires that nodes "SHOULD accept HTLCs that pay a fee equal to or greater than:
fee_base_msat + ( amount_to_forward * fee_proportional_millionths / 1000000 )".

The code in rebalance.py:setup_routing_fees was not strictly meeting the above requirement, as it was using truncating integer division to calculate the proportional part of the fee, which typically results in a fee that is strictly less than the theoretical, infinite-precision, required fee. Some node implementations may allow rounding down here, but some do not, resulting in sporadic WIRE_FEE_INSUFFICIENT errors.

This commit changes the fee calculation in setup_routing_fees so that it always rounds up to the next whole millisatoshi, thereby eliminating many WIRE_FEE_INSUFFICIENT errors and improving the success rate of the rebalance command.
2019-08-29 14:13:57 +02:00
Michael Schmoock
cd1b751f53 rebalance: fix route direction
This will set the correct `direction` on manual route hops (in/out).
Before this was not set, resulting in WIRE_FEE_INSUFFICIENT errors,
if fee was calcualted inconsistently with `direction`.
2019-06-11 15:56:36 +02:00
Michael Schmoock
300b963c9d rebalance: fix amount None 2019-06-03 19:26:26 +02:00
Michael Schmoock
f6309a2da0 Cleanup rebalance sendinvoiceless (#33)
* doc: cleanup and key-value for optional parameters

* rebalance: cleanup and refinements

* sendinvoiceless: cleanup and refinements

* summary: reflects upcoming changes of pylightning to_approx_str

* rebalance: check peer connection on local channels
2019-05-31 22:52:43 +02:00
Michael Schmoock
89c95e4fe8 rebalance: fix issue 29
I think this issue happens on older version of pylightning only.
2019-05-23 12:32:25 +02:00
Michael Schmoock
4c46275e38 fix: rebalance channel selection
The channel selection query didnt filter for channels not
having a short_channel_id yet (unconfirmed ones).

This lead to a KeyError whenever an unconfirmed channel existed.
2019-05-13 21:23:59 +02:00
Gálli Zoltán
5416decde2 rebalance: exclude all own channels from getroute
fix for #17
2019-05-08 12:47:59 +02:00
Michael Schmoock
799eb51528 fix: workaround for outdated pylightning versions #2601 2019-05-01 22:38:51 +02:00
Michael Schmoock
5efb86da46 feat: calculate optional amount 2019-05-01 22:38:51 +02:00
Michael Schmoock
ee9eaa9e31 chore: renames channel_id to scid where aprropriate 2019-05-01 22:38:51 +02:00
Michael Schmoock
3d9b3c8a22 chore: rewording peer2channel method to peer_from_scid 2019-05-01 22:38:51 +02:00
Gálli Zoltán
f22615ed65 using Millisatoshi 2019-04-16 12:05:19 +02:00
Gálli Zoltán
22f5579365 rebalance plugin in python
- this plugin helps to move some liquidity between your channels using circular payments
- previous conversations here: https://github.com/ElementsProject/lightning/pull/2567
2019-04-16 11:59:41 +02:00