(node_factory, executor)
| 6536 | |
| 6537 | |
| 6538 | def test_injectpaymentonion_blindedpath(node_factory, executor): |
| 6539 | l1, l2 = node_factory.line_graph(2, |
| 6540 | wait_for_announce=True, |
| 6541 | # avoids trying to create a blinded path to next node |
| 6542 | opts=[{}, {'dev-allow-localhost': None}]) |
| 6543 | blockheight = l1.rpc.getinfo()['blockheight'] |
| 6544 | # Test bolt12, with stub blinded path. |
| 6545 | offer = l2.rpc.offer('any') |
| 6546 | inv7 = l1.rpc.fetchinvoice(offer['bolt12'], '1000msat') |
| 6547 | |
| 6548 | decoded = l1.rpc.decode(inv7['invoice']) |
| 6549 | assert len(decoded['invoice_paths']) == 1 |
| 6550 | path_key = decoded['invoice_paths'][0]['first_path_key'] |
| 6551 | assert decoded['invoice_paths'][0]['first_node_id'] == l2.info['id'] |
| 6552 | path = decoded['invoice_paths'][0]['path'] |
| 6553 | assert len(path) == 1 |
| 6554 | |
| 6555 | # Manually encode the onion payload to include blinded info |
| 6556 | # BOLT #4: |
| 6557 | # - For every node inside a blinded route: |
| 6558 | # - MUST include the `encrypted_recipient_data` provided by the recipient |
| 6559 | # - For the first node in the blinded route: |
| 6560 | # - MUST include the `path_key` provided by the recipient in `current_path_key` |
| 6561 | # - If it is the final node: |
| 6562 | # - MUST include `amt_to_forward`, `outgoing_cltv_value` and `total_amount_msat`. |
| 6563 | # - The value set for `outgoing_cltv_value`: |
| 6564 | # - MUST use the current block height as a baseline value. |
| 6565 | # - if a [random offset](07-routing-gossip.md#recommendations-for-routing) was added to improve privacy: |
| 6566 | # - SHOULD add the offset to the baseline value. |
| 6567 | # - MUST NOT include any other tlv field. |
| 6568 | final_tlvs = TlvPayload() |
| 6569 | |
| 6570 | # BOLT #4: |
| 6571 | # 1. type: 2 (`amt_to_forward`) |
| 6572 | # 2. data: |
| 6573 | # * [`tu64`:`amt_to_forward`] |
| 6574 | # 1. type: 4 (`outgoing_cltv_value`) |
| 6575 | # 2. data: |
| 6576 | # * [`tu32`:`outgoing_cltv_value`] |
| 6577 | # ... |
| 6578 | # 1. type: 10 (`encrypted_recipient_data`) |
| 6579 | # 2. data: |
| 6580 | # * [`...*byte`:`encrypted_recipient_data`] |
| 6581 | # 1. type: 12 (`current_path_key`) |
| 6582 | # 2. data: |
| 6583 | # * [`point`:`path_key`] |
| 6584 | # ... |
| 6585 | # 1. type: 18 (`total_amount_msat`) |
| 6586 | # 2. data: |
| 6587 | # * [`tu64`:`total_msat`] |
| 6588 | final_tlvs.add_field(2, tu64_encode(1000)) |
| 6589 | final_tlvs.add_field(4, tu64_encode(blockheight + 18)) |
| 6590 | final_tlvs.add_field(10, bytes.fromhex(path[0]['encrypted_recipient_data'])) |
| 6591 | final_tlvs.add_field(12, bytes.fromhex(path_key)) |
| 6592 | final_tlvs.add_field(18, tu64_encode(1000)) |
| 6593 | |
| 6594 | hops = [{'pubkey': l1.info['id'], |
| 6595 | 'payload': serialize_payload_tlv(1000, 18 + 6, first_scid(l1, l2), blockheight).hex()}, |
nothing calls this directly
no test coverage detected