diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c81b45..223aef2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +# v2.6.0 + +- Use a 64-bit nonce for signed requests to avoid conflicts. +- Add `is_internal_payment` fields to payment objects. +- Add `multisig_wallet_address_validation_parameters` to support validating node wallet addresses used for deposits. +- Add `incoming_payments_for_invoice` to get all incoming payments for an invoice. + # v2.5.1 - Ensure that the README and LICENSE are included in the pypi package. diff --git a/lightspark/lightspark_client.py b/lightspark/lightspark_client.py index ba76a3f..3bcc6a5 100644 --- a/lightspark/lightspark_client.py +++ b/lightspark/lightspark_client.py @@ -30,6 +30,9 @@ from lightspark.objects.FeeEstimate import from_json as FeeEstimate_from_json from lightspark.objects.IncomingPayment import IncomingPayment from lightspark.objects.IncomingPayment import from_json as IncomingPayment_from_json +from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import ( + from_json as IncomingPaymentsForInvoiceQueryOutput_from_json, +) from lightspark.objects.Invoice import Invoice from lightspark.objects.Invoice import from_json as Invoice_from_json from lightspark.objects.InvoiceData import InvoiceData @@ -83,6 +86,9 @@ from lightspark.scripts.delete_api_token import DELETE_API_TOKEN_MUTATION from lightspark.scripts.fetch_uma_invitation import FETCH_UMA_INVITATION_QUERY from lightspark.scripts.fund_node import FUND_NODE_MUTATION +from lightspark.scripts.incoming_payments_for_invoice import ( + INCOMING_PAYMENTS_FOR_INVOICE_QUERY, +) from lightspark.scripts.lightning_fee_estimate_for_invoice import ( LIGHTNING_FEE_ESTIMATE_FOR_INVOICE_QUERY, ) @@ -686,6 +692,32 @@ def outgoing_payments_for_invoice( for payment in json["outgoing_payments_for_invoice"]["payments"] ] + def incoming_payments_for_invoice( + self, + invoice_id: str, + transaction_statuses: Optional[List[TransactionStatus]] = None, + ) -> List[IncomingPayment]: + """ + Fetches the incoming payments (if any) which have been made for a given invoice. + + Args: + invoice_id: The encoded invoice for which to fetch the incoming payments. + transaction_statuses: The statuses of the transactions to fetch. If not specified, all transactions will be fetched. + """ + + variables: Dict[str, Any] = {"invoice_id": invoice_id} + if transaction_statuses is not None: + variables["transaction_statuses"] = transaction_statuses + json = self._requester.execute_graphql( + INCOMING_PAYMENTS_FOR_INVOICE_QUERY, variables + ) + if "incoming_payments_for_invoice" not in json: + return [] + output = IncomingPaymentsForInvoiceQueryOutput_from_json( + self._requester, json["incoming_payments_for_invoice"] + ) + return output.payments + def create_uma_invitation( self, inviter_uma: str, diff --git a/lightspark/scripts/incoming_payments_for_invoice.py b/lightspark/scripts/incoming_payments_for_invoice.py new file mode 100644 index 0000000..0182669 --- /dev/null +++ b/lightspark/scripts/incoming_payments_for_invoice.py @@ -0,0 +1,21 @@ +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import ( + FRAGMENT as IncomingPaymentsForInvoiceQueryOutputFragment, +) + +INCOMING_PAYMENTS_FOR_INVOICE_QUERY = f""" +query IncomingPaymentsForInvoice( + $invoice_id: ID! + $transaction_statuses: [TransactionStatus!] +) {{ + incoming_payments_for_invoice(input: {{ + invoice_id: $invoice_id + transaction_statuses: $statuses + }}) {{ + ...IncomingPaymentsForInvoiceQueryOutputFragment + }} +}} + +{IncomingPaymentsForInvoiceQueryOutputFragment} +""" diff --git a/lightspark/version.py b/lightspark/version.py index 7a2056f..e5e59e3 100644 --- a/lightspark/version.py +++ b/lightspark/version.py @@ -1 +1 @@ -__version__ = "2.5.1" +__version__ = "2.6.0"