jitrebalance: fix upstream changes

This commit is contained in:
Michael Schmoock
2022-12-28 18:25:12 +01:00
parent 748d50a2dc
commit be112f7b39
2 changed files with 11 additions and 10 deletions

View File

@@ -38,7 +38,7 @@ def get_circular_route(scid, chan, amt, peer, exclusions, request):
try:
route = plugin.rpc.getroute(
node_id=peer['id'],
msatoshi=last_amt,
amount_msat=last_amt,
riskfactor=1,
exclude=exclusions,
cltv=last_cltv,
@@ -49,7 +49,6 @@ def get_circular_route(scid, chan, amt, peer, exclusions, request):
'id': plugin.node_id,
'channel': scid,
'direction': chan['direction'],
'msatoshi': amt,
'amount_msat': '{}msat'.format(amt),
'delay': 9
}]
@@ -106,14 +105,16 @@ def try_rebalance(scid, chan, amt, peer, request):
"payment_hash={}".format(scid, payment_hash))
return
except RpcError as e:
error = e.error['data']
if not "data" in e.error:
raise e
data = e.error['data']
# The erring_channel field can not be present (shouldn't happen) or
# can be "0x0x0"
erring_channel = error.get('erring_channel', '0x0x0')
erring_channel = data.get('erring_channel', '0x0x0')
if erring_channel != '0x0x0':
if erring_channel == scid:
break
erring_direction = error['erring_direction']
erring_direction = data['erring_direction']
exclusions.append("{}/{}".format(erring_channel,
erring_direction))
plugin.log("Excluding {} due to a failed attempt"
@@ -182,7 +183,7 @@ def on_htlc_accepted(htlc, onion, plugin, request, **kwargs):
# TODO If we are the funder we need to take the cost of an HTLC into
# account as well.
# funder = chan['msatoshi_to_us_max'] == chan['msatoshi_total']
forward_amt = Millisatoshi(onion['forward_amount'])
forward_amt = Millisatoshi(onion['forward_msat'])
# If we have enough capacity just let it through now. Otherwise the
# Millisatoshi raises an error for negative amounts in the calculation

View File

@@ -46,7 +46,7 @@ def test_simple_rebalance(node_factory):
# Send 9 million millisatoshis + reserve + a tiny fee allowance from l3 to
# l2 for the actual payment
inv = l2.rpc.invoice(
chan['our_channel_reserve_satoshis'] * 1000 + 9000000 + 100,
chan['our_reserve_msat'] + 9000000 + 100,
"imbalance", "imbalance"
)
time.sleep(1)
@@ -59,7 +59,7 @@ def test_simple_rebalance(node_factory):
wait_for(no_pending_htlcs)
chan = l2.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
assert(chan['spendable_msatoshi'] < amt)
assert(int(chan['spendable_msat']) < amt)
# Get (l2, l5) so we can exclude it when routing from l1 to l4
peer = l2.rpc.listpeers(l5.info['id'])['peers'][0]
@@ -113,7 +113,7 @@ def test_rebalance_failure(node_factory):
# Send 9 million millisatoshis + reserve + a tiny fee allowance from l3 to
# l2 for the actual payment
inv = l2.rpc.invoice(
chan['our_channel_reserve_satoshis'] * 1000 + 9000000 + 100,
chan['our_reserve_msat'] + 9000000 + 100,
"imbalance", "imbalance"
)
time.sleep(1)
@@ -126,7 +126,7 @@ def test_rebalance_failure(node_factory):
wait_for(no_pending_htlcs)
chan = l2.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
assert(chan['spendable_msatoshi'] < amt)
assert(int(chan['spendable_msat']) < amt)
# Get (l2, l5) so we can exclude it when routing from l1 to l4
peer = l2.rpc.listpeers(l5.info['id'])['peers'][0]