| 16 | |
| 17 | @plugin.hook("htlc_accepted") |
| 18 | def on_htlc_accepted(htlc, onion, plugin, **kwargs): |
| 19 | # Stash the onion so the test can check it |
| 20 | fname = os.path.join(tempfile.mkdtemp(), "onion.json") |
| 21 | with open(fname, 'w') as f: |
| 22 | f.write(json.dumps(onion)) |
| 23 | |
| 24 | plugin.log("Holding onto an incoming htlc for {hold_time} seconds".format( |
| 25 | hold_time=plugin.hold_time |
| 26 | )) |
| 27 | |
| 28 | time.sleep(plugin.hold_time) |
| 29 | |
| 30 | print("Onion written to {}".format(fname)) |
| 31 | |
| 32 | # Give the tester something to look for |
| 33 | plugin.log("htlc_accepted hook called") |
| 34 | return {'result': plugin.hold_result} |
| 35 | |
| 36 | |
| 37 | plugin.add_option( |