mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-23 08:04:20 +01:00
cleanups: feeadjuster, drain and summary
This commit is contained in:
@@ -12,7 +12,7 @@ Community curated plugins for c-lightning.
|
|||||||
| [backup][backup] | A simple and reliable backup plugin |
|
| [backup][backup] | A simple and reliable backup plugin |
|
||||||
| [boltz-channel-creation][boltz] | A c-lightning plugin for Boltz Channel Creation Swaps |
|
| [boltz-channel-creation][boltz] | A c-lightning plugin for Boltz Channel Creation Swaps |
|
||||||
| [btcli4j][btcli4j] | A Bitcoin Backend to enable safely the pruning mode, and support also rest APIs. |
|
| [btcli4j][btcli4j] | A Bitcoin Backend to enable safely the pruning mode, and support also rest APIs. |
|
||||||
| [commando][commando] | Authorize peers to run commands on your node, and running commands on them. |
|
| [commando][commando] | Authorize peers to run commands on your node, and running commands on them. |
|
||||||
| [csvexportpays][csvexportpays] | A plugin that exports all payments to a CSV file |
|
| [csvexportpays][csvexportpays] | A plugin that exports all payments to a CSV file |
|
||||||
| [currencyrate][currencyrate] | A plugin to convert other currencies to BTC using web requests |
|
| [currencyrate][currencyrate] | A plugin to convert other currencies to BTC using web requests |
|
||||||
| [donations][donations] | A simple donations page to accept donations from the web |
|
| [donations][donations] | A simple donations page to accept donations from the web |
|
||||||
|
|||||||
@@ -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,18 +66,16 @@ 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
|
||||||
|
|
||||||
|
|
||||||
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"]),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ try:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
Channel = namedtuple('Channel', ['total', 'ours', 'theirs', 'pid', 'private', 'connected', 'scid', 'avail', 'base' ,'permil'])
|
Channel = namedtuple('Channel', ['total', 'ours', 'theirs', 'pid', 'private', 'connected', 'scid', 'avail', 'base', 'permil'])
|
||||||
Charset = namedtuple('Charset', ['double_left', 'left', 'bar', 'mid', 'right', 'double_right', 'empty'])
|
Charset = namedtuple('Charset', ['double_left', 'left', 'bar', 'mid', 'right', 'double_right', 'empty'])
|
||||||
if have_utf8:
|
if have_utf8:
|
||||||
draw = Charset('╟', '├', '─', '┼', '┤', '╢', '║')
|
draw = Charset('╟', '├', '─', '┼', '┤', '╢', '║')
|
||||||
@@ -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