Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lightspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 72 additions & 0 deletions lightspark/objects/ChannelSnapshot.py
Original file line number Diff line number Diff line change
@@ -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,
)
28 changes: 28 additions & 0 deletions lightspark/objects/Entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lightspark/objects/IdAndSignature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions lightspark/objects/LightningTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions lightspark/objects/OutgoingPayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
}
}
}
}
Expand Down Expand Up @@ -423,6 +453,7 @@ def get_attempts(
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
}
outgoing_payment_payment_preimage: payment_preimage
}
"""

Expand Down Expand Up @@ -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"],
)
37 changes: 37 additions & 0 deletions lightspark/objects/OutgoingPaymentAttempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
}
}
"""

Expand Down Expand Up @@ -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,
)
4 changes: 4 additions & 0 deletions lightspark/objects/RegisterPaymentInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ReleaseChannelPerCommitmentSecretOutput:
requester: Requester

channel_id: str
"""The channel object after the per-commitment secret release operation."""


FRAGMENT = """
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/ReleasePaymentPreimageOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ReleasePaymentPreimageOutput:
requester: Requester

invoice_id: str
"""The invoice of the transaction."""


FRAGMENT = """
Expand Down
3 changes: 3 additions & 0 deletions lightspark/objects/RemoteSigningSubEventType.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
2 changes: 2 additions & 0 deletions lightspark/objects/ScreenNodeInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions lightspark/objects/SetInvoicePaymentHashInput.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions lightspark/objects/SignInvoiceInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/SignInvoiceOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SignInvoiceOutput:
requester: Requester

invoice_id: str
""" The signed invoice object."""


FRAGMENT = """
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/SignMessagesInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading