Have `sender` build a one-hop onion message carrying `tlv` and inject it into `dest` as if it had arrived from the network.
(sender, dest, tlv)
| 4671 | |
| 4672 | |
| 4673 | def inject_onionmsg_tlv(sender, dest, tlv): |
| 4674 | """Have `sender` build a one-hop onion message carrying `tlv` and inject |
| 4675 | it into `dest` as if it had arrived from the network.""" |
| 4676 | dest_pub = bytes.fromhex(dest.info['id']) |
| 4677 | blinding = coincurve.PrivateKey() |
| 4678 | path_key = blinding.public_key.format(True) |
| 4679 | |
| 4680 | # Route-blinding tweak so the onion decrypts as dest's real key. |
| 4681 | ss = blinding.ecdh(coincurve.PublicKey(dest_pub).public_key) |
| 4682 | tweak = hmac.new(b'blinded_node_id', ss, sha256).digest() |
| 4683 | blinded_pub = coincurve.PublicKey(dest_pub).multiply(tweak).format(True) |
| 4684 | |
| 4685 | onion = sender.rpc.createonion(hops=[{'pubkey': blinded_pub.hex(), |
| 4686 | 'payload': tlv.to_bytes().hex()}], |
| 4687 | assocdata="") |
| 4688 | dest.rpc.injectonionmessage(message=onion['onion'], path_key=path_key.hex()) |
| 4689 | |
| 4690 | |
| 4691 | def test_onionmessage_reply_path_zero_scid(node_factory): |
no test coverage detected