-
-
Save kiwiidb/ee126e23f74e146fa06cbc2ea6892a57 to your computer and use it in GitHub Desktop.
c-lightning hodl invoice plugin example only
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
#!/usr/bin/env python3 | |
from lightning.plugin import Plugin | |
import json | |
plugin = Plugin() | |
heldinvoices = dict() | |
@plugin.init() | |
def init(options, configuration, plugin): | |
plugin.log("Plugin hodl-invoice initialized") | |
# WARNING: This turns ALL invoices into hodl invoices | |
@plugin.async_hook("invoice_payment") | |
def on_invoice_payment(plugin, payment, request): | |
heldinvoices[payment['label']] = request | |
@plugin.method("hodlinvoice") | |
def hodl_invoice(plugin, label): | |
"""Add an invoice to be held | |
""" | |
heldinvoices[label].set_result({}) | |
return json.loads({label: label, message: 'Invoice settled.'}) | |
@plugin.method("settleinvoice") | |
def settle_invoice(plugin, label): | |
"""Settle a held invoice | |
""" | |
heldinvoices[label].set_result({}) | |
return json.loads({label: label, message: 'Invoice settled.'}) | |
@plugin.method("cancelinvoice") | |
def cancel_invoice(plugin, label): | |
"""Cancel a held invoice | |
""" | |
heldinvoices[label].set_result({failure_code:8194}) | |
return json.loads({label: label, message: 'Invoice cancelled.'}) | |
plugin.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment