autopilot: Improve calculation of available funds

Deduct the funds that are awaiting lockin and can't be used.
This commit is contained in:
Moller40
2020-09-29 12:21:12 +02:00
committed by Christian Decker
parent de1cd7314f
commit 2464c328a2

View File

@@ -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