Skip to content

Commit c1274f6

Browse files
Lagrang3rustyrussell
authored andcommitted
xpay: add regtest for blinded path fees
When the paying node is the entry point to the blinded path it will send the wrong amount to the next peer. Instead of sending AMT_MSAT it will send AMT_MSAT+FEES_MSAT. # we pay fees to ourselves htlcs = l1.rpc.listhtlcs()["htlcs"] assert len(htlcs) == 1 assert htlcs[0]["payment_hash"] == b12_decode["invoice_payment_hash"] > assert htlcs[0]["amount_msat"] == AMT_MSAT E assert 15000 == 10000 Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
1 parent 508ce92 commit c1274f6

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/test_xpay.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,3 +1072,38 @@ def mock_getblockhash(req):
10721072
# Now let it catch up, and it will retry, and succeed.
10731073
l1.daemon.rpcproxy.mock_rpc('getblockhash')
10741074
fut.result(TIMEOUT)
1075+
1076+
1077+
@pytest.mark.xfail(strict=True)
1078+
def test_blinded_path_fees(node_factory):
1079+
"""Test that we don't send the amount+fees to our direct peer (we should
1080+
only send the required amount) when the sending node is the entry point in
1081+
the blinded path."""
1082+
AMT_MSAT = 10000
1083+
FEES_MSAT = 5000
1084+
l1, l2 = node_factory.get_nodes(
1085+
2, opts={"may_reconnect": True, "fee-base": FEES_MSAT, "fee-per-satoshi": 0}
1086+
)
1087+
node_factory.join_nodes([l1, l2], wait_for_announce=True)
1088+
1089+
offer = l2.rpc.offer(amount="any", fronting_nodes=[l1.info["id"]])["bolt12"]
1090+
b12 = l1.rpc.fetchinvoice(offer, AMT_MSAT)["invoice"]
1091+
1092+
b12_decode = l1.rpc.decode(b12)
1093+
assert b12_decode["invoice_amount_msat"] == AMT_MSAT
1094+
assert len(b12_decode["invoice_paths"]) == 1
1095+
assert b12_decode["invoice_paths"][0]["first_node_id"] == l1.info["id"]
1096+
assert b12_decode["invoice_paths"][0]["payinfo"]["fee_base_msat"] == FEES_MSAT
1097+
assert b12_decode["invoice_paths"][0]["payinfo"]["fee_proportional_millionths"] == 0
1098+
1099+
ret = l1.rpc.xpay(invstring=b12)
1100+
assert ret["failed_parts"] == 0
1101+
assert ret["successful_parts"] == 1
1102+
assert ret["amount_msat"] == AMT_MSAT
1103+
assert ret["amount_sent_msat"] == AMT_MSAT + FEES_MSAT
1104+
1105+
# we pay fees to ourselves
1106+
htlcs = l1.rpc.listhtlcs()["htlcs"]
1107+
assert len(htlcs) == 1
1108+
assert htlcs[0]["payment_hash"] == b12_decode["invoice_payment_hash"]
1109+
assert htlcs[0]["amount_msat"] == AMT_MSAT

0 commit comments

Comments
 (0)