Skip to content

Commit 3da1bdb

Browse files
21M4TWShahanaFarooqui
authored andcommitted
pyln-client: Adding disableoffer, enableoffer, fetchinvoice, listoffers and offer commands
Changelog-None.
1 parent 1dee02c commit 3da1bdb

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

contrib/pyln-client/pyln/client/lightning.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,15 @@ def dev_slowcmd(self, msec=None):
717717
}
718718
return self.call("dev", payload)
719719

720+
def disableoffer(self, offer_id):
721+
"""
722+
Disable an offer, so that no further invoices will be given out.
723+
"""
724+
payload = {
725+
"offer_id": offer_id,
726+
}
727+
return self.call("disableoffer", payload)
728+
720729
def disconnect(self, peer_id, force=False):
721730
"""
722731
Disconnect from peer with {peer_id}, optional {force} even if has active channel.
@@ -727,6 +736,15 @@ def disconnect(self, peer_id, force=False):
727736
}
728737
return self.call("disconnect", payload)
729738

739+
def enableoffer(self, offer_id):
740+
"""
741+
Enable an offer, after it has been disabled.
742+
"""
743+
payload = {
744+
"offer_id": offer_id,
745+
}
746+
return self.call("enableoffer", payload)
747+
730748
def feerates(self, style, urgent=None, normal=None, slow=None):
731749
"""
732750
Supply feerate estimates manually.
@@ -739,6 +757,26 @@ def feerates(self, style, urgent=None, normal=None, slow=None):
739757
}
740758
return self.call("feerates", payload)
741759

760+
def fetchinvoice(self, offer, amount_msat=None, quantity=None, recurrence_counter=None,
761+
recurrence_start=None, recurrence_label=None, timeout=None, payer_note=None,
762+
payer_metadata=None, bip353=None):
763+
"""
764+
Fetch an invoice for an offer.
765+
"""
766+
payload = {
767+
"offer": offer,
768+
"amount_msat": amount_msat,
769+
"quantity": quantity,
770+
"recurrence_counter": recurrence_counter,
771+
"recurrence_start": recurrence_start,
772+
"recurrence_label": recurrence_label,
773+
"timeout": timeout,
774+
"payer_note": payer_note,
775+
"payer_metadata": payer_metadata,
776+
"bip353": bip353,
777+
}
778+
return self.call("fetchinvoice", payload)
779+
742780
def fundchannel(self, node_id, amount, feerate=None, announce=True,
743781
minconf=None, utxos=None, push_msat=None, close_to=None,
744782
request_amt=None, compact_lease=None,
@@ -981,6 +1019,18 @@ def listnodes(self, node_id=None):
9811019
}
9821020
return self.call("listnodes", payload)
9831021

1022+
def listoffers(self, offer_id=None, active_only=None):
1023+
"""List offers
1024+
1025+
List all offers, or with {offer_id}, only the offer with that {offer_id} (if it exists).
1026+
1027+
"""
1028+
payload = {
1029+
"offer_id": offer_id,
1030+
"active_only": active_only,
1031+
}
1032+
return self.call("listoffers", payload)
1033+
9841034
def listpays(self, bolt11=None, payment_hash=None, status=None, index=None, start=None, limit=None):
9851035
"""
9861036
Show outgoing payments, regarding {bolt11} or {payment_hash} if set
@@ -1074,6 +1124,29 @@ def newaddr(self, addresstype=None):
10741124
"""
10751125
return self.call("newaddr", {"addresstype": addresstype})
10761126

1127+
def offer(self, amount, description=None, issuer=None, label=None, quantity_max=None, absolute_expiry=None,
1128+
recurrence=None, recurrence_base=None, recurrence_paywindow=None, recurrence_limit=None,
1129+
single_use=None, recurrence_start_any_period=None):
1130+
"""
1131+
Create an offer (or returns an existing one), which is a precursor to creating one or more invoices.
1132+
It automatically enables the processing of an incoming invoice_request, and issuing of invoices.
1133+
"""
1134+
payload = {
1135+
"amount": amount,
1136+
"description": description,
1137+
"issuer": issuer,
1138+
"label": label,
1139+
"quantity_max": quantity_max,
1140+
"absolute_expiry": absolute_expiry,
1141+
"recurrence": recurrence,
1142+
"recurrence_base": recurrence_base,
1143+
"recurrence_paywindow": recurrence_paywindow,
1144+
"recurrence_limit": recurrence_limit,
1145+
"single_use": single_use,
1146+
"recurrence_start_any_period": recurrence_start_any_period,
1147+
}
1148+
return self.call("offer", payload)
1149+
10771150
def pay(self, bolt11, amount_msat=None, label=None, riskfactor=None,
10781151
maxfeepercent=None, retry_for=None,
10791152
maxdelay=None, exemptfee=None, localinvreqid=None, exclude=None,

0 commit comments

Comments
 (0)