From 2464c328a2433cc466d44a300fae445d23e71531 Mon Sep 17 00:00:00 2001 From: Moller40 Date: Tue, 29 Sep 2020 12:21:12 +0200 Subject: [PATCH] autopilot: Improve calculation of available funds Deduct the funds that are awaiting lockin and can't be used. --- autopilot/autopilot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autopilot/autopilot.py b/autopilot/autopilot.py index f429282..b11e665 100755 --- a/autopilot/autopilot.py +++ b/autopilot/autopilot.py @@ -133,7 +133,8 @@ def init(configuration, options, plugin): def run_once(plugin, dryrun=False): # Let's start by inspecting the current state of the node funds = plugin.rpc.listfunds() - output_funds = sum([o['value'] for o in funds['outputs'] if o['status'] == 'confirmed']) + awaiting_lockin_funds = sum([o['channel_sat'] for o in funds['channels'] if o['state'] == 'CHANNELD_AWAITING_LOCKIN']) + output_funds = sum([o['value'] for o in funds['outputs'] if o['status'] == 'confirmed']) - awaiting_lockin_funds channels = funds['channels'] available_funds = output_funds / 100.0 * plugin.percent