(node_factory, chainparams)
| 5387 | |
| 5388 | @unittest.skipIf(TEST_NETWORK != 'regtest', "Invoice is network specific") |
| 5389 | def test_pay_bolt11_metadata(node_factory, chainparams): |
| 5390 | l1, l2 = node_factory.line_graph(2) |
| 5391 | |
| 5392 | # Generate a normal invoice on l2, then use bolt11-cli to re-encode it with |
| 5393 | # payment metadata added. old_hsmsecret gives l2 a known private key. |
| 5394 | inv = l2.rpc.invoice(amount_msat=123000, label='label1', description='desc', preimage='00' * 32) |
| 5395 | inv_decoded = l1.rpc.decode(inv['bolt11']) |
| 5396 | inv_with_metadata = subprocess.check_output(['devtools/bolt11-cli', 'encode', |
| 5397 | # l2's private key (old_hsmsecret, WIF byte stripped) |
| 5398 | '0c633a7c17c701a0980158f5483035e01fa8bd091b47fadf2e86e589a9f93fca', |
| 5399 | f"currency={chainparams['bip173_prefix']}", |
| 5400 | f"p={inv['payment_hash']}", |
| 5401 | f"s={inv['payment_secret']}", |
| 5402 | "d=desc", |
| 5403 | "amount=123000msat", |
| 5404 | f"x={inv_decoded['expiry']}", |
| 5405 | f"c={inv_decoded['min_final_cltv_expiry']}", |
| 5406 | f"9={inv_decoded['features']}", |
| 5407 | "m=" + b'this is metadata'.hex()]).decode('utf-8').strip() |
| 5408 | |
| 5409 | # They should be basically identical |
| 5410 | post_decoded = l1.rpc.decode(inv_with_metadata) |
| 5411 | del inv_decoded['signature'] |
| 5412 | del post_decoded['signature'] |
| 5413 | del post_decoded['payment_metadata'] |
| 5414 | del inv_decoded['created_at'] |
| 5415 | del post_decoded['created_at'] |
| 5416 | assert inv_decoded == post_decoded |
| 5417 | |
| 5418 | with pytest.raises(RpcError, match=r'Unexpected error \(invalid_onion_payload\) from final node'): |
| 5419 | l1.rpc.xpay(inv_with_metadata) |
| 5420 | |
| 5421 | l2.daemon.wait_for_log("Unexpected payment_metadata {}".format(b'this is metadata'.hex())) |
| 5422 | |
| 5423 | |
| 5424 | def test_pay_middle_fail(node_factory, bitcoind, executor): |
nothing calls this directly
no test coverage detected