mirror of
https://github.com/accumulator/charge-lnd.git
synced 2026-08-13 12:33:01 +02:00
Add synced_to_chain to the onchain matcher
Add synced_to_chain as a criterion to the onchain matcher. synced_to_chain becomes false if LND is not synced to the chain for more than 5 minutes. In the past, this was an indicator of a severe issue that required a hotfix for lnd.
This commit is contained in:
parent
401101f03b
commit
2b103c8d57
4 changed files with 27 additions and 1 deletions
|
|
@ -198,6 +198,7 @@ Currently available properties:
|
|||
| **onchain.conf_target** | defines the confirmation target that is used for the determination of the onchain fee rate (default: 6)|# blocks|
|
||||
| **onchain.min_fee_rate** | match on the onchain fee rate|# sat per vbyte|
|
||||
| **onchain.max_fee_rate** | match on the onchain fee rate|# sat per vbyte|
|
||||
| **onchain.synced_to_chain** | match on the synced to chain. False if lnd is not synced to chain for 5 minutes.|true\|false|
|
||||
|
||||
|
||||
File references should contain 1 item per line
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ class Lnd:
|
|||
self.graph = None
|
||||
self.info = None
|
||||
self.version = None
|
||||
self.synced_to_chain = None
|
||||
self.channels = None
|
||||
self.node_info = {}
|
||||
self.chan_info = {}
|
||||
|
|
@ -68,6 +69,19 @@ class Lnd:
|
|||
|
||||
def supports_inbound_fees(self):
|
||||
return self.min_version(0, 18)
|
||||
|
||||
def get_synced_to_chain(self):
|
||||
# It can happen that lnd is not synced to the chain for a few seconds, typically
|
||||
# after a new block has been found or after a restart of lnd. If lnd is still
|
||||
# not synced to the chain after 5 minutes, we set the parameter to false.
|
||||
if self.synced_to_chain is None:
|
||||
self.synced_to_chain = False
|
||||
for _ in range(300):
|
||||
if self.lnstub.GetInfo(ln.GetInfoRequest()).synced_to_chain:
|
||||
self.synced_to_chain = True
|
||||
break
|
||||
time.sleep(1)
|
||||
return self.synced_to_chain
|
||||
|
||||
def get_feereport(self):
|
||||
feereport = self.lnstub.FeeReport(ln.FeeReportRequest())
|
||||
|
|
|
|||
|
|
@ -382,12 +382,16 @@ class Policies:
|
|||
return True
|
||||
|
||||
def match_by_onchain(self, channel, config):
|
||||
accepted = ['min_fee_rate', 'max_fee_rate', 'conf_target']
|
||||
accepted = ['min_fee_rate', 'max_fee_rate',
|
||||
'conf_target', 'synced_to_chain']
|
||||
|
||||
for key in config.keys():
|
||||
if key.split(".")[0] == 'onchain' and key.split(".")[1] not in accepted:
|
||||
raise Exception("Unknown property '%s'" % key)
|
||||
|
||||
if 'onchain.synced_to_chain' in config and not config.getboolean('onchain.synced_to_chain') == self.lnd.get_synced_to_chain():
|
||||
return False
|
||||
|
||||
fee_rate = self.lnd.get_fee_estimate(config.getint('onchain.conf_target', DEFAULT_CONF_TARGET))
|
||||
|
||||
if 'onchain.max_fee_rate' in config and not config.getfloat('onchain.max_fee_rate') >= fee_rate:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ base_fee_msat = 0
|
|||
onchan.min_fee_rate = 500
|
||||
base_fee_msat = 5_000
|
||||
|
||||
[lost-onchain-sync]
|
||||
# The fact that lnd was not synchronized with the chain for more than 5 minutes
|
||||
# was an indicator of a severe problem in the past.
|
||||
onchain.synced_to_chain = false
|
||||
base_fee_msat = 210_000
|
||||
fee_ppm = 210_000
|
||||
|
||||
[ignored_channels]
|
||||
# don't let charge-lnd set fees (strategy=ignore) for channels to/from the specified nodes
|
||||
node.id = 02da8d5a759ee9e4438da617cfdb61c87f723fb76c4b6371b877d0347abe953a4f,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue