(invoice, route, groupid, partid)
| 7115 | ) |
| 7116 | |
| 7117 | def pay_with_sendonion(invoice, route, groupid, partid): |
| 7118 | blockheight = l1.rpc.getinfo()["blockheight"] |
| 7119 | # Need to shift the parameters by one hop |
| 7120 | hops = [] |
| 7121 | for h, n in zip(route[:-1], route[1:]): |
| 7122 | # We tell the node h about the parameters to use for n (a.k.a. h + 1) |
| 7123 | hops.append( |
| 7124 | { |
| 7125 | "pubkey": h["node_id_out"], |
| 7126 | "payload": serialize_payload_tlv( |
| 7127 | n["amount_out_msat"], n["cltv_out"], n["short_channel_id_dir"].rsplit("/", 1)[0], blockheight |
| 7128 | ).hex(), |
| 7129 | } |
| 7130 | ) |
| 7131 | # The last hop has a special payload: |
| 7132 | hops.append( |
| 7133 | { |
| 7134 | "pubkey": route[-1]["node_id_out"], |
| 7135 | "payload": serialize_payload_final_tlv( |
| 7136 | route[-1]["amount_out_msat"], |
| 7137 | route[-1]["cltv_out"], |
| 7138 | invoice["amount_msat"], |
| 7139 | blockheight, |
| 7140 | invoice["payment_secret"], |
| 7141 | ).hex(), |
| 7142 | } |
| 7143 | ) |
| 7144 | onion = l1.rpc.createonion(hops=hops, assocdata=invoice["payment_hash"]) |
| 7145 | l1.rpc.call( |
| 7146 | "sendonion", |
| 7147 | { |
| 7148 | "onion": onion["onion"], |
| 7149 | "shared_secrets": onion["shared_secrets"], |
| 7150 | "first_hop": {"id": route[0]["node_id_out"], "amount_msat": route[0]["amount_out_msat"], "delay": route[0]["cltv_out"]}, |
| 7151 | "payment_hash": invoice["payment_hash"], |
| 7152 | "total_amount_msat": invoice["amount_msat"], |
| 7153 | "groupid": groupid, |
| 7154 | "partid": partid, |
| 7155 | }, |
| 7156 | ) |
| 7157 | |
| 7158 | pay_with_sendpay(inv, route2, 1, 1) |
| 7159 | pay_with_sendonion(inv, route8, 1, 2) |
no test coverage detected