@@ -1072,3 +1072,36 @@ 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+ @unittest .skip
1078+ def test_bolt12_fees (node_factory ):
1079+ AMT_MSAT = 10000
1080+ FEES_MSAT = 5000
1081+ l1 , l2 = node_factory .get_nodes (
1082+ 2 , opts = {"may_reconnect" : True , "fee-base" : FEES_MSAT , "fee-per-satoshi" : 0 }
1083+ )
1084+ node_factory .join_nodes ([l1 , l2 ], wait_for_announce = True )
1085+
1086+ # BOLT 12, direct peer
1087+ offer = l2 .rpc .offer ("any" )["bolt12" ]
1088+ b12 = l1 .rpc .fetchinvoice (offer , AMT_MSAT )["invoice" ]
1089+
1090+ b12_decode = l1 .rpc .decode (b12 )
1091+ assert b12_decode ["invoice_amount_msat" ] == AMT_MSAT
1092+ assert len (b12_decode ["invoice_paths" ]) == 1
1093+ assert b12_decode ["invoice_paths" ][0 ]["first_node_id" ] == l1 .info ["id" ]
1094+ assert b12_decode ["invoice_paths" ][0 ]["payinfo" ]["fee_base_msat" ] == FEES_MSAT
1095+ assert b12_decode ["invoice_paths" ][0 ]["payinfo" ]["fee_proportional_millionths" ] == 0
1096+
1097+ ret = l1 .rpc .xpay (invstring = b12 )
1098+ assert ret ["failed_parts" ] == 0
1099+ assert ret ["successful_parts" ] == 1
1100+ assert ret ["amount_msat" ] == AMT_MSAT
1101+ assert ret ["amount_sent_msat" ] == AMT_MSAT + FEES_MSAT
1102+
1103+ # we pay fees to ourselves
1104+ htlcs = l1 .rpc .listhtlcs ()["htlcs" ]
1105+ assert len (htlcs ) == 1
1106+ assert htlcs [0 ]["payment_hash" ] == b12_decode ["invoice_payment_hash" ]
1107+ assert htlcs [0 ]["amount_msat" ] == AMT_MSAT
0 commit comments