Skip to content

Commit 5dbcf54

Browse files
authored
Add incoming_payments_for_invoice query (#31)
Also bumping the version to 2.6.0.
2 parents 60e2b1e + fc5246c commit 5dbcf54

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
# v2.6.0
4+
5+
- Use a 64-bit nonce for signed requests to avoid conflicts.
6+
- Add `is_internal_payment` fields to payment objects.
7+
- Add `multisig_wallet_address_validation_parameters` to support validating node wallet addresses used for deposits.
8+
- Add `incoming_payments_for_invoice` to get all incoming payments for an invoice.
9+
310
# v2.5.1
411

512
- Ensure that the README and LICENSE are included in the pypi package.

lightspark/lightspark_client.py

+32
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
from lightspark.objects.FeeEstimate import from_json as FeeEstimate_from_json
3131
from lightspark.objects.IncomingPayment import IncomingPayment
3232
from lightspark.objects.IncomingPayment import from_json as IncomingPayment_from_json
33+
from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import (
34+
from_json as IncomingPaymentsForInvoiceQueryOutput_from_json,
35+
)
3336
from lightspark.objects.Invoice import Invoice
3437
from lightspark.objects.Invoice import from_json as Invoice_from_json
3538
from lightspark.objects.InvoiceData import InvoiceData
@@ -83,6 +86,9 @@
8386
from lightspark.scripts.delete_api_token import DELETE_API_TOKEN_MUTATION
8487
from lightspark.scripts.fetch_uma_invitation import FETCH_UMA_INVITATION_QUERY
8588
from lightspark.scripts.fund_node import FUND_NODE_MUTATION
89+
from lightspark.scripts.incoming_payments_for_invoice import (
90+
INCOMING_PAYMENTS_FOR_INVOICE_QUERY,
91+
)
8692
from lightspark.scripts.lightning_fee_estimate_for_invoice import (
8793
LIGHTNING_FEE_ESTIMATE_FOR_INVOICE_QUERY,
8894
)
@@ -686,6 +692,32 @@ def outgoing_payments_for_invoice(
686692
for payment in json["outgoing_payments_for_invoice"]["payments"]
687693
]
688694

695+
def incoming_payments_for_invoice(
696+
self,
697+
invoice_id: str,
698+
transaction_statuses: Optional[List[TransactionStatus]] = None,
699+
) -> List[IncomingPayment]:
700+
"""
701+
Fetches the incoming payments (if any) which have been made for a given invoice.
702+
703+
Args:
704+
invoice_id: The encoded invoice for which to fetch the incoming payments.
705+
transaction_statuses: The statuses of the transactions to fetch. If not specified, all transactions will be fetched.
706+
"""
707+
708+
variables: Dict[str, Any] = {"invoice_id": invoice_id}
709+
if transaction_statuses is not None:
710+
variables["transaction_statuses"] = transaction_statuses
711+
json = self._requester.execute_graphql(
712+
INCOMING_PAYMENTS_FOR_INVOICE_QUERY, variables
713+
)
714+
if "incoming_payments_for_invoice" not in json:
715+
return []
716+
output = IncomingPaymentsForInvoiceQueryOutput_from_json(
717+
self._requester, json["incoming_payments_for_invoice"]
718+
)
719+
return output.payments
720+
689721
def create_uma_invitation(
690722
self,
691723
inviter_uma: str,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import (
4+
FRAGMENT as IncomingPaymentsForInvoiceQueryOutputFragment,
5+
)
6+
7+
INCOMING_PAYMENTS_FOR_INVOICE_QUERY = f"""
8+
query IncomingPaymentsForInvoice(
9+
$invoice_id: ID!
10+
$transaction_statuses: [TransactionStatus!]
11+
) {{
12+
incoming_payments_for_invoice(input: {{
13+
invoice_id: $invoice_id
14+
transaction_statuses: $statuses
15+
}}) {{
16+
...IncomingPaymentsForInvoiceQueryOutputFragment
17+
}}
18+
}}
19+
20+
{IncomingPaymentsForInvoiceQueryOutputFragment}
21+
"""

lightspark/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.5.1"
1+
__version__ = "2.6.0"

0 commit comments

Comments
 (0)