(onion, plugin, **kwargs)
| 19 | |
| 20 | @plugin.hook("htlc_accepted") |
| 21 | def on_htlc_accepted(onion, plugin, **kwargs): |
| 22 | if plugin.expect is None or 'payment_metadata' not in onion: |
| 23 | return {'result': 'continue'} |
| 24 | preimage, metadata = plugin.expect |
| 25 | if onion['payment_metadata'] != metadata: |
| 26 | plugin.log(f"Unexpected metadata {onion['payment_metadata']}", level='broken') |
| 27 | return {'result': 'continue'} |
| 28 | return {'result': 'resolve', 'payment_key': preimage} |
| 29 | |
| 30 | |
| 31 | plugin.expect = None |