Test explicit invoice 'preimage'.
(node_factory)
| 132 | |
| 133 | |
| 134 | def test_invoice_preimage(node_factory): |
| 135 | """Test explicit invoice 'preimage'. |
| 136 | """ |
| 137 | l1, l2 = node_factory.line_graph(2, wait_for_announce=True) |
| 138 | |
| 139 | # I promise the below number is randomly generated |
| 140 | invoice_preimage = "17b08f669513b7379728fc1abcea5eaf3448bc1eba55a68ca2cd1843409cdc04" |
| 141 | |
| 142 | # Make invoice and pay it |
| 143 | inv = l2.rpc.invoice(amount_msat=123456, label="inv", description="?", preimage=invoice_preimage) |
| 144 | payment = l1.rpc.xpay(inv['bolt11']) |
| 145 | |
| 146 | # Check preimage was given. |
| 147 | payment_preimage = payment['payment_preimage'] |
| 148 | assert invoice_preimage == payment_preimage |
| 149 | |
| 150 | # Creating a new invoice with same preimage should error. |
| 151 | with pytest.raises(RpcError, match=r'preimage already used'): |
| 152 | l2.rpc.invoice(123456, 'inv2', '?', preimage=invoice_preimage) |
| 153 | |
| 154 | |
| 155 | @unittest.skipIf(TEST_NETWORK != 'regtest', "Amounts too low, dominated by fees in elements") |
nothing calls this directly
no test coverage detected