mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-22 23:54:20 +01:00
cleanups: feeadjuster, drain and summary
This commit is contained in:
@@ -293,7 +293,7 @@ def try_for_htlc_fee(plugin, payload, peer_id, amount, chunk, spendable_before):
|
|||||||
return False # should not happen, but maybe API changes
|
return False # should not happen, but maybe API changes
|
||||||
payload['success_msg'].append(f"{amount + fees}msat sent over {len(route)} "
|
payload['success_msg'].append(f"{amount + fees}msat sent over {len(route)} "
|
||||||
f"hops to {payload['command']} {amount}msat "
|
f"hops to {payload['command']} {amount}msat "
|
||||||
f"[{chunk + 1}/{payload['chunks']}")
|
f"[{chunk + 1}/{payload['chunks']}]")
|
||||||
# we need to wait for HTLC to resolve, so remaining amounts
|
# we need to wait for HTLC to resolve, so remaining amounts
|
||||||
# can be calculated correctly for the next chunk
|
# can be calculated correctly for the next chunk
|
||||||
wait_ours(plugin, payload['scid'], ours)
|
wait_ours(plugin, payload['scid'], ours)
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ def get_ratio_hard(our_percentage):
|
|||||||
def get_peer_id_for_scid(plugin: Plugin, scid: str):
|
def get_peer_id_for_scid(plugin: Plugin, scid: str):
|
||||||
for peer in plugin.peers:
|
for peer in plugin.peers:
|
||||||
for ch in peer['channels']:
|
for ch in peer['channels']:
|
||||||
if 'short_channel_id' in ch:
|
if ch.get('short_channel_id') == scid:
|
||||||
if ch['short_channel_id'] == scid:
|
|
||||||
return peer['id']
|
return peer['id']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -75,8 +74,7 @@ def get_peer_id_for_scid(plugin: Plugin, scid: str):
|
|||||||
def get_local_channel_for_scid(plugin: Plugin, scid: str):
|
def get_local_channel_for_scid(plugin: Plugin, scid: str):
|
||||||
for peer in plugin.peers:
|
for peer in plugin.peers:
|
||||||
for ch in peer['channels']:
|
for ch in peer['channels']:
|
||||||
if 'short_channel_id' in ch:
|
if ch.get('short_channel_id') == scid:
|
||||||
if ch['short_channel_id'] == scid:
|
|
||||||
return ch
|
return ch
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -236,8 +234,8 @@ def feeadjust(plugin: Plugin, scid: str = None):
|
|||||||
for peer in plugin.peers:
|
for peer in plugin.peers:
|
||||||
for chan in peer["channels"]:
|
for chan in peer["channels"]:
|
||||||
if chan["state"] == "CHANNELD_NORMAL":
|
if chan["state"] == "CHANNELD_NORMAL":
|
||||||
_scid = chan["short_channel_id"]
|
_scid = chan.get("short_channel_id")
|
||||||
if scid != None and scid != _scid:
|
if scid is not None and scid != _scid:
|
||||||
continue
|
continue
|
||||||
plugin.adj_balances[_scid] = {
|
plugin.adj_balances[_scid] = {
|
||||||
"our": int(chan["to_us_msat"]),
|
"our": int(chan["to_us_msat"]),
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ def init_db(plugin, retry_time=4, sleep_time=1):
|
|||||||
retry += 1
|
retry += 1
|
||||||
|
|
||||||
if db is None:
|
if db is None:
|
||||||
raise Error("db initialization error")
|
raise RuntimeError("db initialization error")
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user