From 7227564819e271f63ebf706c99b174f443b4845d Mon Sep 17 00:00:00 2001 From: 21M4TW <21m4tw@proton.me> Date: Wed, 26 Mar 2025 21:34:00 -0400 Subject: [PATCH] pyln-client: Adding disableoffer, enableoffer, fetchinvoice, listoffers and offer commands Changelog-None. --- contrib/pyln-client/pyln/client/lightning.py | 73 ++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/contrib/pyln-client/pyln/client/lightning.py b/contrib/pyln-client/pyln/client/lightning.py index a53efa13c665..1706a4727e3b 100644 --- a/contrib/pyln-client/pyln/client/lightning.py +++ b/contrib/pyln-client/pyln/client/lightning.py @@ -717,6 +717,15 @@ def dev_slowcmd(self, msec=None): } return self.call("dev", payload) + def disableoffer(self, offer_id): + """ + Disable an offer, so that no further invoices will be given out. + """ + payload = { + "offer_id": offer_id, + } + return self.call("disableoffer", payload) + def disconnect(self, peer_id, force=False): """ Disconnect from peer with {peer_id}, optional {force} even if has active channel. @@ -727,6 +736,15 @@ def disconnect(self, peer_id, force=False): } return self.call("disconnect", payload) + def enableoffer(self, offer_id): + """ + Enable an offer, after it has been disabled. + """ + payload = { + "offer_id": offer_id, + } + return self.call("enableoffer", payload) + def feerates(self, style, urgent=None, normal=None, slow=None): """ Supply feerate estimates manually. @@ -739,6 +757,26 @@ def feerates(self, style, urgent=None, normal=None, slow=None): } return self.call("feerates", payload) + def fetchinvoice(self, offer, amount_msat=None, quantity=None, recurrence_counter=None, + recurrence_start=None, recurrence_label=None, timeout=None, payer_note=None, + payer_metadata=None, bip353=None): + """ + Fetch an invoice for an offer. + """ + payload = { + "offer": offer, + "amount_msat": amount_msat, + "quantity": quantity, + "recurrence_counter": recurrence_counter, + "recurrence_start": recurrence_start, + "recurrence_label": recurrence_label, + "timeout": timeout, + "payer_note": payer_note, + "payer_metadata": payer_metadata, + "bip353": bip353, + } + return self.call("fetchinvoice", payload) + def fundchannel(self, node_id, amount, feerate=None, announce=True, minconf=None, utxos=None, push_msat=None, close_to=None, request_amt=None, compact_lease=None, @@ -981,6 +1019,18 @@ def listnodes(self, node_id=None): } return self.call("listnodes", payload) + def listoffers(self, offer_id=None, active_only=None): + """List offers + + List all offers, or with {offer_id}, only the offer with that {offer_id} (if it exists). + + """ + payload = { + "offer_id": offer_id, + "active_only": active_only, + } + return self.call("listoffers", payload) + def listpays(self, bolt11=None, payment_hash=None, status=None, index=None, start=None, limit=None): """ Show outgoing payments, regarding {bolt11} or {payment_hash} if set @@ -1074,6 +1124,29 @@ def newaddr(self, addresstype=None): """ return self.call("newaddr", {"addresstype": addresstype}) + def offer(self, amount, description=None, issuer=None, label=None, quantity_max=None, absolute_expiry=None, + recurrence=None, recurrence_base=None, recurrence_paywindow=None, recurrence_limit=None, + single_use=None, recurrence_start_any_period=None): + """ + Create an offer (or returns an existing one), which is a precursor to creating one or more invoices. + It automatically enables the processing of an incoming invoice_request, and issuing of invoices. + """ + payload = { + "amount": amount, + "description": description, + "issuer": issuer, + "label": label, + "quantity_max": quantity_max, + "absolute_expiry": absolute_expiry, + "recurrence": recurrence, + "recurrence_base": recurrence_base, + "recurrence_paywindow": recurrence_paywindow, + "recurrence_limit": recurrence_limit, + "single_use": single_use, + "recurrence_start_any_period": recurrence_start_any_period, + } + return self.call("offer", payload) + def pay(self, bolt11, amount_msat=None, label=None, riskfactor=None, maxfeepercent=None, retry_for=None, maxdelay=None, exemptfee=None, localinvreqid=None, exclude=None,