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

Function on_htlc_accepted

tests/plugins/replace_payload.py:13–31  ·  view source on GitHub ↗
(htlc, onion, plugin, **kwargs)

Source from the content-addressed store, hash-verified

11
12@plugin.hook("htlc_accepted")
13def on_htlc_accepted(htlc, onion, plugin, **kwargs):
14 # eg. '2902017b04016d0821fff5b6bd5018c8731aa0496c3698ef49f132ef9a3000c94436f4957e79a2f8827b'
15 # (but values change depending on pay's randomness!)
16 print("payload was:{}".format(onion['payload']))
17 assert onion['payload'][0:2] == '29'
18
19 if plugin.replace_payload == 'corrupt_secret':
20 # Note: we don't include length prefix in returned payload, since it doesn't
21 # support the pre-TLV legacy form.
22 if onion['payload'][18] == '0':
23 newpayload = onion['payload'][2:18] + '1' + onion['payload'][19:]
24 else:
25 newpayload = onion['payload'][2:18] + '0' + onion['payload'][19:]
26 else:
27 newpayload = plugin.replace_payload
28 print("payload was:{}".format(onion['payload']))
29 print("payload now:{}".format(newpayload))
30
31 return {'result': 'continue', 'payload': newpayload}
32
33
34@plugin.method('setpayload')

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected