Skip to content

Commit 7f3fdd5

Browse files
committed
Add create hold invoice method
santi/hold-invoice-b
1 parent 8053c92 commit 7f3fdd5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lightspark/lightspark_client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
PrivateFormat,
1616
PublicFormat,
1717
)
18+
1819
from lightspark.exceptions import LightsparkException
1920
from lightspark.objects.Account import Account
2021
from lightspark.objects.Account import from_json as Account_from_json
@@ -187,6 +188,27 @@ def create_invoice(
187188

188189
return Invoice_from_json(self._requester, json["create_invoice"]["invoice"])
189190

191+
def create_hold_invoice(
192+
self,
193+
node_id: str,
194+
amount_msats: int,
195+
memo: Optional[str] = None,
196+
payment_hash: Optional[str] = None,
197+
expiry_secs: Optional[int] = None,
198+
) -> Invoice:
199+
logger.info("Creating an invoice for node %s.", node_id)
200+
variables = {
201+
"amount_msats": amount_msats,
202+
"node_id": node_id,
203+
"payment_hash": payment_hash,
204+
"memo": memo,
205+
}
206+
if expiry_secs is not None:
207+
variables["expiry_secs"] = expiry_secs
208+
json = self._requester.execute_graphql(CREATE_INVOICE_MUTATION, variables)
209+
210+
return Invoice_from_json(self._requester, json["create_invoice"]["invoice"])
211+
190212
def create_lnurl_invoice(
191213
self,
192214
node_id: str,

0 commit comments

Comments
 (0)