Test that an intermediate nodes in a blinded path verify that the encrypted_recipient_data it receives matches its own relay policy.
(node_factory)
| 7419 | "pyln-testing here has no get_node(inline_plugin=): " |
| 7420 | "the helper plugin cannot be loaded") |
| 7421 | def test_blinded_forward_policy(node_factory): |
| 7422 | """Test that an intermediate nodes in a blinded path verify that the |
| 7423 | encrypted_recipient_data it receives matches its own relay policy.""" |
| 7424 | FEE_PPM = 1000 |
| 7425 | FINAL_AMT = 1000000 |
| 7426 | |
| 7427 | def bad_topology(plugin): |
| 7428 | """A plugin that sets an arbitary fee for incoming channels. Helper to |
| 7429 | test encrypted recepient data handling.""" |
| 7430 | |
| 7431 | @plugin.init() |
| 7432 | def init(configuration, options, plugin): |
| 7433 | plugin.incoming = None |
| 7434 | |
| 7435 | @plugin.hook("rpc_command") |
| 7436 | def on_rpc_command(plugin, rpc_command, **kwargs): |
| 7437 | if rpc_command["method"] == "listincoming" and plugin.incoming: |
| 7438 | plugin.log( |
| 7439 | "Producing fake listincoming with {}".format(plugin.incoming) |
| 7440 | ) |
| 7441 | return {"return": {"result": {"incoming": [plugin.incoming]}}} |
| 7442 | return {"result": "continue"} |
| 7443 | |
| 7444 | @plugin.method("setincoming") |
| 7445 | def setincoming(plugin, channel): |
| 7446 | plugin.incoming = channel |
| 7447 | |
| 7448 | def get_onion( |
| 7449 | rpc, invoice, blockheight, my_node, entry_point, scid, in_amount, final_amount |
| 7450 | ): |
| 7451 | assert len(invoice["invoice_paths"]) == 1 |
| 7452 | assert invoice["invoice_paths"][0]["first_node_id"] == entry_point |
| 7453 | path = invoice["invoice_paths"][0]["path"] |
| 7454 | path_key = invoice["invoice_paths"][0]["first_path_key"] |
| 7455 | assert len(path) == 2 |
| 7456 | |
| 7457 | final_tlvs = TlvPayload() |
| 7458 | final_tlvs.add_field(2, tu64_encode(final_amount)) |
| 7459 | final_tlvs.add_field(4, tu64_encode(blockheight + 18)) |
| 7460 | final_tlvs.add_field(10, bytes.fromhex(path[1]["encrypted_recipient_data"])) |
| 7461 | final_tlvs.add_field(18, tu64_encode(final_amount)) |
| 7462 | |
| 7463 | mid_tlvs = TlvPayload() |
| 7464 | mid_tlvs.add_field(10, bytes.fromhex(path[0]["encrypted_recipient_data"])) |
| 7465 | mid_tlvs.add_field(12, bytes.fromhex(path_key)) |
| 7466 | |
| 7467 | hops = [ |
| 7468 | { |
| 7469 | "pubkey": my_node, |
| 7470 | "payload": serialize_payload_tlv( |
| 7471 | in_amount, 18 + 6 + 6, scid, blockheight |
| 7472 | ).hex(), |
| 7473 | }, |
| 7474 | {"pubkey": entry_point, "payload": mid_tlvs.to_bytes().hex()}, |
| 7475 | { |
| 7476 | "pubkey": path[1]["blinded_node_id"], |
| 7477 | "payload": final_tlvs.to_bytes().hex(), |
| 7478 | }, |
nothing calls this directly
no test coverage detected