diff --git a/lightspark/__init__.py b/lightspark/__init__.py index 842e8d2..784ccce 100644 --- a/lightspark/__init__.py +++ b/lightspark/__init__.py @@ -21,6 +21,7 @@ from lightspark.objects.ChannelClosingTransaction import ChannelClosingTransaction from lightspark.objects.ChannelFees import ChannelFees from lightspark.objects.ChannelOpeningTransaction import ChannelOpeningTransaction +from lightspark.objects.ChannelSnapshot import ChannelSnapshot from lightspark.objects.ChannelStatus import ChannelStatus from lightspark.objects.ChannelToTransactionsConnection import ( ChannelToTransactionsConnection, diff --git a/lightspark/objects/Account.py b/lightspark/objects/Account.py index b313368..8263e74 100644 --- a/lightspark/objects/Account.py +++ b/lightspark/objects/Account.py @@ -1136,6 +1136,7 @@ def get_transactions( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + outgoing_payment_payment_preimage: payment_preimage } ... on RoutingTransaction { __typename diff --git a/lightspark/objects/ChannelSnapshot.py b/lightspark/objects/ChannelSnapshot.py new file mode 100644 index 0000000..ea456f8 --- /dev/null +++ b/lightspark/objects/ChannelSnapshot.py @@ -0,0 +1,72 @@ +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping, Optional + +from lightspark.requests.requester import Requester + +from .CurrencyAmount import CurrencyAmount +from .CurrencyAmount import from_json as CurrencyAmount_from_json + + +@dataclass +class ChannelSnapshot: + requester: Requester + + local_balance: Optional[CurrencyAmount] + + local_unsettled_balance: Optional[CurrencyAmount] + + local_channel_reserve: Optional[CurrencyAmount] + + +FRAGMENT = """ +fragment ChannelSnapshotFragment on ChannelSnapshot { + __typename + channel_snapshot_local_balance: local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_unsettled_balance: local_unsettled_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_channel_reserve: local_channel_reserve { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } +} +""" + + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot: + return ChannelSnapshot( + requester=requester, + local_balance=CurrencyAmount_from_json( + requester, obj["channel_snapshot_local_balance"] + ) + if obj["channel_snapshot_local_balance"] + else None, + local_unsettled_balance=CurrencyAmount_from_json( + requester, obj["channel_snapshot_local_unsettled_balance"] + ) + if obj["channel_snapshot_local_unsettled_balance"] + else None, + local_channel_reserve=CurrencyAmount_from_json( + requester, obj["channel_snapshot_local_channel_reserve"] + ) + if obj["channel_snapshot_local_channel_reserve"] + else None, + ) diff --git a/lightspark/objects/Entity.py b/lightspark/objects/Entity.py index 619babf..2155656 100644 --- a/lightspark/objects/Entity.py +++ b/lightspark/objects/Entity.py @@ -1070,6 +1070,7 @@ class Entity: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + outgoing_payment_payment_preimage: payment_preimage } ... on OutgoingPaymentAttempt { __typename @@ -1099,6 +1100,33 @@ class Entity: outgoing_payment_attempt_outgoing_payment: outgoing_payment { id } + outgoing_payment_attempt_channel_snapshot: channel_snapshot { + __typename + channel_snapshot_local_balance: local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_unsettled_balance: local_unsettled_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_channel_reserve: local_channel_reserve { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } } ... on RoutingTransaction { __typename diff --git a/lightspark/objects/IdAndSignature.py b/lightspark/objects/IdAndSignature.py index e9130d8..bde38ec 100644 --- a/lightspark/objects/IdAndSignature.py +++ b/lightspark/objects/IdAndSignature.py @@ -7,8 +7,10 @@ @dataclass class IdAndSignature: id: str + """The id of the message.""" signature: str + """The signature of the message.""" def from_json(obj: Mapping[str, Any]) -> IdAndSignature: diff --git a/lightspark/objects/LightningTransaction.py b/lightspark/objects/LightningTransaction.py index f690924..104091b 100644 --- a/lightspark/objects/LightningTransaction.py +++ b/lightspark/objects/LightningTransaction.py @@ -377,6 +377,7 @@ class LightningTransaction(Transaction, Entity): currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + outgoing_payment_payment_preimage: payment_preimage } ... on RoutingTransaction { __typename @@ -490,6 +491,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact ) if obj["outgoing_payment_uma_post_transaction_data"] else None, + payment_preimage=obj["outgoing_payment_payment_preimage"], ) if obj["__typename"] == "RoutingTransaction": # pylint: disable=import-outside-toplevel diff --git a/lightspark/objects/OutgoingPayment.py b/lightspark/objects/OutgoingPayment.py index e57ad79..fffc85e 100644 --- a/lightspark/objects/OutgoingPayment.py +++ b/lightspark/objects/OutgoingPayment.py @@ -75,6 +75,9 @@ class OutgoingPayment(LightningTransaction, Transaction, Entity): uma_post_transaction_data: Optional[List[PostTransactionData]] """The post transaction data which can be used in KYT payment registration.""" + + payment_preimage: Optional[str] + """The preimage of the payment.""" typename: str def get_attempts( @@ -123,6 +126,33 @@ def get_attempts( outgoing_payment_attempt_outgoing_payment: outgoing_payment { id } + outgoing_payment_attempt_channel_snapshot: channel_snapshot { + __typename + channel_snapshot_local_balance: local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_unsettled_balance: local_unsettled_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_channel_reserve: local_channel_reserve { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } } } } @@ -423,6 +453,7 @@ def get_attempts( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + outgoing_payment_payment_preimage: payment_preimage } """ @@ -467,4 +498,5 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPayment: ) if obj["outgoing_payment_uma_post_transaction_data"] else None, + payment_preimage=obj["outgoing_payment_payment_preimage"], ) diff --git a/lightspark/objects/OutgoingPaymentAttempt.py b/lightspark/objects/OutgoingPaymentAttempt.py index af9c4e1..1aeb4ed 100644 --- a/lightspark/objects/OutgoingPaymentAttempt.py +++ b/lightspark/objects/OutgoingPaymentAttempt.py @@ -9,6 +9,8 @@ from lightspark.requests.requester import Requester from lightspark.utils.enums import parse_enum, parse_enum_optional +from .ChannelSnapshot import ChannelSnapshot +from .ChannelSnapshot import from_json as ChannelSnapshot_from_json from .CurrencyAmount import CurrencyAmount from .CurrencyAmount import from_json as CurrencyAmount_from_json from .Entity import Entity @@ -57,6 +59,9 @@ class OutgoingPaymentAttempt(Entity): outgoing_payment_id: str """The outgoing payment for this attempt.""" + + channel_snapshot: Optional[ChannelSnapshot] + """The channel snapshot at the time the outgoing payment attempt was made.""" typename: str def get_hops( @@ -147,6 +152,33 @@ def get_hops( outgoing_payment_attempt_outgoing_payment: outgoing_payment { id } + outgoing_payment_attempt_channel_snapshot: channel_snapshot { + __typename + channel_snapshot_local_balance: local_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_unsettled_balance: local_unsettled_balance { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + channel_snapshot_local_channel_reserve: local_channel_reserve { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + } } """ @@ -175,4 +207,9 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentAt if obj["outgoing_payment_attempt_fees"] else None, outgoing_payment_id=obj["outgoing_payment_attempt_outgoing_payment"]["id"], + channel_snapshot=ChannelSnapshot_from_json( + requester, obj["outgoing_payment_attempt_channel_snapshot"] + ) + if obj["outgoing_payment_attempt_channel_snapshot"] + else None, ) diff --git a/lightspark/objects/RegisterPaymentInput.py b/lightspark/objects/RegisterPaymentInput.py index a503997..1e7244a 100644 --- a/lightspark/objects/RegisterPaymentInput.py +++ b/lightspark/objects/RegisterPaymentInput.py @@ -14,12 +14,16 @@ @dataclass class RegisterPaymentInput: provider: ComplianceProvider + """The compliance provider that is going to screen the node. You need to be a customer of the selected provider and store the API key on the Lightspark account setting page.""" payment_id: str + """The Lightspark ID of the lightning payment you want to register. It can be the id of either an OutgoingPayment or an IncomingPayment.""" node_pubkey: str + """The public key of the counterparty lightning node, which would be the public key of the recipient node if it is to register an outgoing payment, or the public key of the sender node if it is to register an incoming payment.""" direction: PaymentDirection + """Indicates whether this payment is an OutgoingPayment or an IncomingPayment.""" def from_json(obj: Mapping[str, Any]) -> RegisterPaymentInput: diff --git a/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py b/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py index f95e043..bf27849 100644 --- a/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py +++ b/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py @@ -7,10 +7,13 @@ @dataclass class ReleaseChannelPerCommitmentSecretInput: channel_id: str + """The unique identifier of the channel.""" per_commitment_secret: str + """The per-commitment secret to be released.""" per_commitment_index: int + """The index associated with the per-commitment secret.""" def from_json(obj: Mapping[str, Any]) -> ReleaseChannelPerCommitmentSecretInput: diff --git a/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py b/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py index 929bfdf..83bb66b 100644 --- a/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py +++ b/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py @@ -11,6 +11,7 @@ class ReleaseChannelPerCommitmentSecretOutput: requester: Requester channel_id: str + """The channel object after the per-commitment secret release operation.""" FRAGMENT = """ diff --git a/lightspark/objects/ReleasePaymentPreimageOutput.py b/lightspark/objects/ReleasePaymentPreimageOutput.py index 44b5821..d153036 100644 --- a/lightspark/objects/ReleasePaymentPreimageOutput.py +++ b/lightspark/objects/ReleasePaymentPreimageOutput.py @@ -11,6 +11,7 @@ class ReleasePaymentPreimageOutput: requester: Requester invoice_id: str + """The invoice of the transaction.""" FRAGMENT = """ diff --git a/lightspark/objects/RemoteSigningSubEventType.py b/lightspark/objects/RemoteSigningSubEventType.py index e1090d6..182bd31 100644 --- a/lightspark/objects/RemoteSigningSubEventType.py +++ b/lightspark/objects/RemoteSigningSubEventType.py @@ -15,3 +15,6 @@ class RemoteSigningSubEventType(Enum): DERIVE_KEY_AND_SIGN = "DERIVE_KEY_AND_SIGN" RELEASE_PAYMENT_PREIMAGE = "RELEASE_PAYMENT_PREIMAGE" REQUEST_INVOICE_PAYMENT_HASH = "REQUEST_INVOICE_PAYMENT_HASH" + REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET = ( + "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET" + ) diff --git a/lightspark/objects/ScreenNodeInput.py b/lightspark/objects/ScreenNodeInput.py index cda76cd..f2be0c2 100644 --- a/lightspark/objects/ScreenNodeInput.py +++ b/lightspark/objects/ScreenNodeInput.py @@ -12,8 +12,10 @@ @dataclass class ScreenNodeInput: provider: ComplianceProvider + """The compliance provider that is going to screen the node. You need to be a customer of the selected provider and store the API key on the Lightspark account setting page.""" node_pubkey: str + """The public key of the lightning node that needs to be screened.""" def from_json(obj: Mapping[str, Any]) -> ScreenNodeInput: diff --git a/lightspark/objects/SetInvoicePaymentHashInput.py b/lightspark/objects/SetInvoicePaymentHashInput.py index 6e5f767..a216aac 100644 --- a/lightspark/objects/SetInvoicePaymentHashInput.py +++ b/lightspark/objects/SetInvoicePaymentHashInput.py @@ -1,7 +1,7 @@ # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass -from typing import Any, Mapping +from typing import Any, Mapping, Optional @dataclass @@ -12,8 +12,8 @@ class SetInvoicePaymentHashInput: payment_hash: str """The 32-byte hash of the payment preimage.""" - preimage_nonce: str - """The 32-byte nonce used to generate the invoice preimage.""" + preimage_nonce: Optional[str] + """The 32-byte nonce used to generate the invoice preimage if applicable. It will later be included in RELEASE_PAYMENT_PREIMAGE webhook to help recover the raw preimage.""" def from_json(obj: Mapping[str, Any]) -> SetInvoicePaymentHashInput: diff --git a/lightspark/objects/SignInvoiceInput.py b/lightspark/objects/SignInvoiceInput.py index 12b6959..b47e97a 100644 --- a/lightspark/objects/SignInvoiceInput.py +++ b/lightspark/objects/SignInvoiceInput.py @@ -7,10 +7,13 @@ @dataclass class SignInvoiceInput: invoice_id: str + """The unique identifier of the invoice to be signed.""" signature: str + """The cryptographic signature for the invoice.""" recovery_id: int + """The recovery identifier for the signature.""" def from_json(obj: Mapping[str, Any]) -> SignInvoiceInput: diff --git a/lightspark/objects/SignInvoiceOutput.py b/lightspark/objects/SignInvoiceOutput.py index e775b73..19869ff 100644 --- a/lightspark/objects/SignInvoiceOutput.py +++ b/lightspark/objects/SignInvoiceOutput.py @@ -11,6 +11,7 @@ class SignInvoiceOutput: requester: Requester invoice_id: str + """ The signed invoice object.""" FRAGMENT = """ diff --git a/lightspark/objects/SignMessagesInput.py b/lightspark/objects/SignMessagesInput.py index 7bad790..de68ded 100644 --- a/lightspark/objects/SignMessagesInput.py +++ b/lightspark/objects/SignMessagesInput.py @@ -10,6 +10,7 @@ @dataclass class SignMessagesInput: signatures: List[IdAndSignature] + """The list of the message ids and signatures.""" def from_json(obj: Mapping[str, Any]) -> SignMessagesInput: diff --git a/lightspark/objects/SignMessagesOutput.py b/lightspark/objects/SignMessagesOutput.py index ee88d83..c170c17 100644 --- a/lightspark/objects/SignMessagesOutput.py +++ b/lightspark/objects/SignMessagesOutput.py @@ -14,6 +14,7 @@ class SignMessagesOutput: requester: Requester signed_payloads: List[SignablePayload] + """The list of signed payloads.""" FRAGMENT = """ diff --git a/lightspark/objects/SignablePayloadStatus.py b/lightspark/objects/SignablePayloadStatus.py index fd340ee..2818591 100644 --- a/lightspark/objects/SignablePayloadStatus.py +++ b/lightspark/objects/SignablePayloadStatus.py @@ -9,3 +9,4 @@ class SignablePayloadStatus(Enum): CREATED = "CREATED" SIGNED = "SIGNED" VALIDATION_FAILED = "VALIDATION_FAILED" + INVALID_SIGNATURE = "INVALID_SIGNATURE" diff --git a/lightspark/objects/Transaction.py b/lightspark/objects/Transaction.py index 8a5256d..ae401d4 100644 --- a/lightspark/objects/Transaction.py +++ b/lightspark/objects/Transaction.py @@ -472,6 +472,7 @@ class Transaction(Entity): currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + outgoing_payment_payment_preimage: payment_preimage } ... on RoutingTransaction { __typename @@ -711,6 +712,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Transaction: ) if obj["outgoing_payment_uma_post_transaction_data"] else None, + payment_preimage=obj["outgoing_payment_payment_preimage"], ) if obj["__typename"] == "RoutingTransaction": # pylint: disable=import-outside-toplevel diff --git a/lightspark/objects/Wallet.py b/lightspark/objects/Wallet.py index 9c5fa76..4316eca 100644 --- a/lightspark/objects/Wallet.py +++ b/lightspark/objects/Wallet.py @@ -502,6 +502,7 @@ def get_transactions( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } } + outgoing_payment_payment_preimage: payment_preimage } ... on RoutingTransaction { __typename diff --git a/lightspark/objects/WebhookEventType.py b/lightspark/objects/WebhookEventType.py index 26caf6e..c1829af 100644 --- a/lightspark/objects/WebhookEventType.py +++ b/lightspark/objects/WebhookEventType.py @@ -9,6 +9,8 @@ class WebhookEventType(Enum): ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" PAYMENT_FINISHED = "PAYMENT_FINISHED" + WITHDRAWAL_FINISHED = "WITHDRAWAL_FINISHED" + FUNDS_RECEIVED = "FUNDS_RECEIVED" NODE_STATUS = "NODE_STATUS" WALLET_STATUS = "WALLET_STATUS" WALLET_OUTGOING_PAYMENT_FINISHED = "WALLET_OUTGOING_PAYMENT_FINISHED" @@ -16,3 +18,4 @@ class WebhookEventType(Enum): WALLET_WITHDRAWAL_FINISHED = "WALLET_WITHDRAWAL_FINISHED" WALLET_FUNDS_RECEIVED = "WALLET_FUNDS_RECEIVED" REMOTE_SIGNING = "REMOTE_SIGNING" + LOW_BALANCE = "LOW_BALANCE" diff --git a/lightspark/objects/WithdrawalRequestStatus.py b/lightspark/objects/WithdrawalRequestStatus.py index 98cfa3a..63f531e 100644 --- a/lightspark/objects/WithdrawalRequestStatus.py +++ b/lightspark/objects/WithdrawalRequestStatus.py @@ -8,6 +8,7 @@ class WithdrawalRequestStatus(Enum): ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" + CREATED = "CREATED" FAILED = "FAILED" IN_PROGRESS = "IN_PROGRESS" SUCCESSFUL = "SUCCESSFUL"