MCPcopy Create free account
hub / github.com/ElementsProject/lightning / inject_onionmsg_tlv

Function inject_onionmsg_tlv

tests/test_connection.py:4673–4688  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

4671
4672
4673def 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
4691def test_onionmessage_reply_path_zero_scid(node_factory):

Calls 3

digestMethod · 0.80
newMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected