-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
openchannel hook: add new
close_to
field
Rounds out the application of `upfront_shutdown_script`, allowing an accepting node to specify a close_to address. Prior to this, only the opening node could specify one. Changelog-Added: Plugins: Allow the 'accepter' to specify an upfront_shutdown_script for a channel via a `close_to` field in the openchannel hook result
- Loading branch information
Showing
6 changed files
with
123 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
"""Simple plugin to test the openchannel_hook's | ||
'close_to' address functionality. | ||
If the funding amount is: | ||
- a multiple of 11: we send back a valid address (regtest) | ||
- a multiple of 7: we send back an empty address | ||
- a multiple of 5: we send back an address for the wrong chain (mainnet) | ||
- otherwise: we don't include the close_to | ||
""" | ||
|
||
from lightning import Plugin, Millisatoshi | ||
|
||
plugin = Plugin() | ||
|
||
|
||
@plugin.hook('openchannel') | ||
def on_openchannel(openchannel, plugin, **kwargs): | ||
# - a multiple of 11: we send back a valid address (regtest) | ||
if Millisatoshi(openchannel['funding_satoshis']).to_satoshi() % 11 == 0: | ||
return {'result': 'continue', 'close_to': 'bcrt1q7gtnxmlaly9vklvmfj06amfdef3rtnrdazdsvw'} | ||
|
||
# - a multiple of 7: we send back an empty address | ||
if Millisatoshi(openchannel['funding_satoshis']).to_satoshi() % 7 == 0: | ||
return {'result': 'continue', 'close_to': ''} | ||
|
||
# - a multiple of 5: we send back an address for the wrong chain (mainnet) | ||
if Millisatoshi(openchannel['funding_satoshis']).to_satoshi() % 5 == 0: | ||
return {'result': 'continue', 'close_to': 'bc1qlq8srqnz64wgklmqvurv7qnr4rvtq2u96hhfg2'} | ||
|
||
# - otherwise: we don't include the close_to | ||
return {'result': 'continue'} | ||
|
||
|
||
plugin.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters