From 9d1dd531f45c2ce3c9f75c00c5547440b46da19d Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Thu, 11 Jan 2024 09:10:09 -0800 Subject: [PATCH] Add the is_uma flag to payments. --- lightspark/objects/Account.py | 2 + lightspark/objects/CancelInvoiceInput.py | 2 + lightspark/objects/CancelInvoiceOutput.py | 2 + lightspark/objects/ChannelSnapshot.py | 71 +++++++++----- lightspark/objects/Entity.py | 98 +++++++++++--------- lightspark/objects/IncomingPayment.py | 6 ++ lightspark/objects/LightningTransaction.py | 4 + lightspark/objects/OutgoingPayment.py | 52 ++--------- lightspark/objects/OutgoingPaymentAttempt.py | 60 ++---------- lightspark/objects/Transaction.py | 4 + lightspark/objects/Wallet.py | 2 + lightspark/objects/all_entities.py | 9 ++ 12 files changed, 145 insertions(+), 167 deletions(-) diff --git a/lightspark/objects/Account.py b/lightspark/objects/Account.py index a2794c1..c4ac763 100644 --- a/lightspark/objects/Account.py +++ b/lightspark/objects/Account.py @@ -898,6 +898,7 @@ def get_transactions( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -933,6 +934,7 @@ def get_transactions( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } diff --git a/lightspark/objects/CancelInvoiceInput.py b/lightspark/objects/CancelInvoiceInput.py index 2a97c2b..35a8bba 100644 --- a/lightspark/objects/CancelInvoiceInput.py +++ b/lightspark/objects/CancelInvoiceInput.py @@ -6,6 +6,8 @@ @dataclass class CancelInvoiceInput: + """The unique identifier of the Invoice that should be cancelled. The invoice is supposed to be open, not settled and not expired.""" + invoice_id: str def to_json(self) -> Mapping[str, Any]: diff --git a/lightspark/objects/CancelInvoiceOutput.py b/lightspark/objects/CancelInvoiceOutput.py index 559fde3..cf2d0a1 100644 --- a/lightspark/objects/CancelInvoiceOutput.py +++ b/lightspark/objects/CancelInvoiceOutput.py @@ -8,6 +8,8 @@ @dataclass class CancelInvoiceOutput: + """The Invoice that was cancelled. If the invoice was already cancelled, the same invoice is returned.""" + requester: Requester invoice_id: str diff --git a/lightspark/objects/ChannelSnapshot.py b/lightspark/objects/ChannelSnapshot.py index 185b6c1..fe1c9c7 100644 --- a/lightspark/objects/ChannelSnapshot.py +++ b/lightspark/objects/ChannelSnapshot.py @@ -8,55 +8,70 @@ from .CurrencyAmount import CurrencyAmount from .CurrencyAmount import from_json as CurrencyAmount_from_json +from .Entity import Entity @dataclass -class ChannelSnapshot: +class ChannelSnapshot(Entity): requester: Requester - channel_id: str + id: str + """The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.""" - timestamp: datetime + created_at: datetime + """The date and time when the entity was first created.""" + + updated_at: datetime + """The date and time when the entity was last updated.""" local_balance: Optional[CurrencyAmount] local_unsettled_balance: Optional[CurrencyAmount] - local_channel_reserve: Optional[CurrencyAmount] - remote_balance: Optional[CurrencyAmount] remote_unsettled_balance: Optional[CurrencyAmount] + channel_id: str + + local_channel_reserve: Optional[CurrencyAmount] + + timestamp: datetime + """The timestamp that was used to query the snapshot of the channel""" + typename: str + def to_json(self) -> Mapping[str, Any]: return { - "channel_snapshot_channel": {"id": self.channel_id}, - "channel_snapshot_timestamp": self.timestamp.isoformat(), + "__typename": "ChannelSnapshot", + "channel_snapshot_id": self.id, + "channel_snapshot_created_at": self.created_at.isoformat(), + "channel_snapshot_updated_at": self.updated_at.isoformat(), "channel_snapshot_local_balance": self.local_balance.to_json() if self.local_balance else None, "channel_snapshot_local_unsettled_balance": self.local_unsettled_balance.to_json() if self.local_unsettled_balance else None, - "channel_snapshot_local_channel_reserve": self.local_channel_reserve.to_json() - if self.local_channel_reserve - else None, "channel_snapshot_remote_balance": self.remote_balance.to_json() if self.remote_balance else None, "channel_snapshot_remote_unsettled_balance": self.remote_unsettled_balance.to_json() if self.remote_unsettled_balance else None, + "channel_snapshot_channel": {"id": self.channel_id}, + "channel_snapshot_local_channel_reserve": self.local_channel_reserve.to_json() + if self.local_channel_reserve + else None, + "channel_snapshot_timestamp": self.timestamp.isoformat(), } FRAGMENT = """ fragment ChannelSnapshotFragment on ChannelSnapshot { __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp + channel_snapshot_id: id + channel_snapshot_created_at: created_at + channel_snapshot_updated_at: updated_at channel_snapshot_local_balance: local_balance { __typename currency_amount_original_value: original_value @@ -73,7 +88,7 @@ def to_json(self) -> Mapping[str, Any]: 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 { + channel_snapshot_remote_balance: remote_balance { __typename currency_amount_original_value: original_value currency_amount_original_unit: original_unit @@ -81,7 +96,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } - channel_snapshot_remote_balance: remote_balance { + channel_snapshot_remote_unsettled_balance: remote_unsettled_balance { __typename currency_amount_original_value: original_value currency_amount_original_unit: original_unit @@ -89,7 +104,10 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } - channel_snapshot_remote_unsettled_balance: remote_unsettled_balance { + channel_snapshot_channel: channel { + id + } + channel_snapshot_local_channel_reserve: local_channel_reserve { __typename currency_amount_original_value: original_value currency_amount_original_unit: original_unit @@ -97,6 +115,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } + channel_snapshot_timestamp: timestamp } """ @@ -104,8 +123,10 @@ def to_json(self) -> Mapping[str, Any]: def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot: return ChannelSnapshot( requester=requester, - channel_id=obj["channel_snapshot_channel"]["id"], - timestamp=datetime.fromisoformat(obj["channel_snapshot_timestamp"]), + typename="ChannelSnapshot", + id=obj["channel_snapshot_id"], + created_at=datetime.fromisoformat(obj["channel_snapshot_created_at"]), + updated_at=datetime.fromisoformat(obj["channel_snapshot_updated_at"]), local_balance=CurrencyAmount_from_json( requester, obj["channel_snapshot_local_balance"] ) @@ -116,11 +137,6 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot: ) 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, remote_balance=CurrencyAmount_from_json( requester, obj["channel_snapshot_remote_balance"] ) @@ -131,4 +147,11 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot: ) if obj["channel_snapshot_remote_unsettled_balance"] else None, + channel_id=obj["channel_snapshot_channel"]["id"], + local_channel_reserve=CurrencyAmount_from_json( + requester, obj["channel_snapshot_local_channel_reserve"] + ) + if obj["channel_snapshot_local_channel_reserve"] + else None, + timestamp=datetime.fromisoformat(obj["channel_snapshot_timestamp"]), ) diff --git a/lightspark/objects/Entity.py b/lightspark/objects/Entity.py index dbc552a..452fbdd 100644 --- a/lightspark/objects/Entity.py +++ b/lightspark/objects/Entity.py @@ -200,6 +200,56 @@ class Entity: id } } + ... on ChannelSnapshot { + __typename + channel_snapshot_id: id + channel_snapshot_created_at: created_at + channel_snapshot_updated_at: updated_at + 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_remote_balance: remote_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_remote_unsettled_balance: remote_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_channel: channel { + id + } + 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 + } + channel_snapshot_timestamp: timestamp + } ... on Deposit { __typename deposit_id: id @@ -288,6 +338,7 @@ class Entity: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -907,6 +958,7 @@ class Entity: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -1264,51 +1316,7 @@ class Entity: id } outgoing_payment_attempt_channel_snapshot: channel_snapshot { - __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp - 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 - } - channel_snapshot_remote_balance: remote_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_remote_unsettled_balance: remote_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 - } + id } } ... on RoutingTransaction { diff --git a/lightspark/objects/IncomingPayment.py b/lightspark/objects/IncomingPayment.py index dbca905..a1cb694 100644 --- a/lightspark/objects/IncomingPayment.py +++ b/lightspark/objects/IncomingPayment.py @@ -50,6 +50,9 @@ class IncomingPayment(LightningTransaction, Transaction, Entity): transaction_hash: Optional[str] """The hash of this transaction, so it can be uniquely identified on the Lightning Network.""" + is_uma: bool + """Whether this payment is an UMA payment or not. NOTE: this field is only set if the invoice that is being paid has been created using the recommended `create_uma_invoice` function.""" + destination_id: str """The recipient Lightspark node this payment was sent to.""" @@ -127,6 +130,7 @@ def to_json(self) -> Mapping[str, Any]: else None, "incoming_payment_amount": self.amount.to_json(), "incoming_payment_transaction_hash": self.transaction_hash, + "incoming_payment_is_uma": self.is_uma, "incoming_payment_destination": {"id": self.destination_id}, "incoming_payment_payment_request": {"id": self.payment_request_id} if self.payment_request_id @@ -156,6 +160,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -191,6 +196,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPayment: else None, amount=CurrencyAmount_from_json(requester, obj["incoming_payment_amount"]), transaction_hash=obj["incoming_payment_transaction_hash"], + is_uma=obj["incoming_payment_is_uma"], destination_id=obj["incoming_payment_destination"]["id"], payment_request_id=obj["incoming_payment_payment_request"]["id"] if obj["incoming_payment_payment_request"] diff --git a/lightspark/objects/LightningTransaction.py b/lightspark/objects/LightningTransaction.py index b0c26cb..d9d3bbf 100644 --- a/lightspark/objects/LightningTransaction.py +++ b/lightspark/objects/LightningTransaction.py @@ -85,6 +85,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -120,6 +121,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -504,6 +506,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact else None, amount=CurrencyAmount_from_json(requester, obj["incoming_payment_amount"]), transaction_hash=obj["incoming_payment_transaction_hash"], + is_uma=obj["incoming_payment_is_uma"], destination_id=obj["incoming_payment_destination"]["id"], payment_request_id=obj["incoming_payment_payment_request"]["id"] if obj["incoming_payment_payment_request"] @@ -534,6 +537,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact else None, amount=CurrencyAmount_from_json(requester, obj["outgoing_payment_amount"]), transaction_hash=obj["outgoing_payment_transaction_hash"], + is_uma=obj["outgoing_payment_is_uma"], origin_id=obj["outgoing_payment_origin"]["id"], destination_id=obj["outgoing_payment_destination"]["id"] if obj["outgoing_payment_destination"] diff --git a/lightspark/objects/OutgoingPayment.py b/lightspark/objects/OutgoingPayment.py index 154b021..c7309b2 100644 --- a/lightspark/objects/OutgoingPayment.py +++ b/lightspark/objects/OutgoingPayment.py @@ -55,6 +55,9 @@ class OutgoingPayment(LightningTransaction, Transaction, Entity): transaction_hash: Optional[str] """The hash of this transaction, so it can be uniquely identified on the Lightning Network.""" + is_uma: bool + """Whether this payment is an UMA payment or not. NOTE: this field is only set if the payment has been sent using the recommended `pay_uma_invoice` function.""" + origin_id: str """The Lightspark node this payment originated from.""" @@ -128,51 +131,7 @@ def get_attempts( id } outgoing_payment_attempt_channel_snapshot: channel_snapshot { - __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp - 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 - } - channel_snapshot_remote_balance: remote_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_remote_unsettled_balance: remote_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 - } + id } } } @@ -197,6 +156,7 @@ def to_json(self) -> Mapping[str, Any]: else None, "outgoing_payment_amount": self.amount.to_json(), "outgoing_payment_transaction_hash": self.transaction_hash, + "outgoing_payment_is_uma": self.is_uma, "outgoing_payment_origin": {"id": self.origin_id}, "outgoing_payment_destination": {"id": self.destination_id} if self.destination_id @@ -237,6 +197,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -580,6 +541,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPayment: else None, amount=CurrencyAmount_from_json(requester, obj["outgoing_payment_amount"]), transaction_hash=obj["outgoing_payment_transaction_hash"], + is_uma=obj["outgoing_payment_is_uma"], origin_id=obj["outgoing_payment_origin"]["id"], destination_id=obj["outgoing_payment_destination"]["id"] if obj["outgoing_payment_destination"] diff --git a/lightspark/objects/OutgoingPaymentAttempt.py b/lightspark/objects/OutgoingPaymentAttempt.py index 734001c..1a2261f 100644 --- a/lightspark/objects/OutgoingPaymentAttempt.py +++ b/lightspark/objects/OutgoingPaymentAttempt.py @@ -9,8 +9,6 @@ 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 @@ -63,7 +61,7 @@ class OutgoingPaymentAttempt(Entity): outgoing_payment_id: str """The outgoing payment for this attempt.""" - channel_snapshot: Optional[ChannelSnapshot] + channel_snapshot_id: Optional[str] """The channel snapshot at the time the outgoing payment attempt was made.""" typename: str @@ -147,8 +145,10 @@ def to_json(self) -> Mapping[str, Any]: "outgoing_payment_attempt_outgoing_payment": { "id": self.outgoing_payment_id }, - "outgoing_payment_attempt_channel_snapshot": self.channel_snapshot.to_json() - if self.channel_snapshot + "outgoing_payment_attempt_channel_snapshot": { + "id": self.channel_snapshot_id + } + if self.channel_snapshot_id else None, } @@ -184,51 +184,7 @@ def to_json(self) -> Mapping[str, Any]: id } outgoing_payment_attempt_channel_snapshot: channel_snapshot { - __typename - channel_snapshot_channel: channel { - id - } - channel_snapshot_timestamp: timestamp - 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 - } - channel_snapshot_remote_balance: remote_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_remote_unsettled_balance: remote_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 - } + id } } """ @@ -263,9 +219,7 @@ 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"] - ) + channel_snapshot_id=obj["outgoing_payment_attempt_channel_snapshot"]["id"] if obj["outgoing_payment_attempt_channel_snapshot"] else None, ) diff --git a/lightspark/objects/Transaction.py b/lightspark/objects/Transaction.py index c112ac9..713f923 100644 --- a/lightspark/objects/Transaction.py +++ b/lightspark/objects/Transaction.py @@ -180,6 +180,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -215,6 +216,7 @@ def to_json(self) -> Mapping[str, Any]: currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } @@ -743,6 +745,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Transaction: else None, amount=CurrencyAmount_from_json(requester, obj["incoming_payment_amount"]), transaction_hash=obj["incoming_payment_transaction_hash"], + is_uma=obj["incoming_payment_is_uma"], destination_id=obj["incoming_payment_destination"]["id"], payment_request_id=obj["incoming_payment_payment_request"]["id"] if obj["incoming_payment_payment_request"] @@ -773,6 +776,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Transaction: else None, amount=CurrencyAmount_from_json(requester, obj["outgoing_payment_amount"]), transaction_hash=obj["outgoing_payment_transaction_hash"], + is_uma=obj["outgoing_payment_is_uma"], origin_id=obj["outgoing_payment_origin"]["id"], destination_id=obj["outgoing_payment_destination"]["id"] if obj["outgoing_payment_destination"] diff --git a/lightspark/objects/Wallet.py b/lightspark/objects/Wallet.py index c600f33..5535cd0 100644 --- a/lightspark/objects/Wallet.py +++ b/lightspark/objects/Wallet.py @@ -201,6 +201,7 @@ def get_transactions( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } incoming_payment_transaction_hash: transaction_hash + incoming_payment_is_uma: is_uma incoming_payment_destination: destination { id } @@ -236,6 +237,7 @@ def get_transactions( currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } outgoing_payment_transaction_hash: transaction_hash + outgoing_payment_is_uma: is_uma outgoing_payment_origin: origin { id } diff --git a/lightspark/objects/all_entities.py b/lightspark/objects/all_entities.py index 076cbca..1c1197f 100644 --- a/lightspark/objects/all_entities.py +++ b/lightspark/objects/all_entities.py @@ -25,6 +25,9 @@ from lightspark.objects.ChannelOpeningTransaction import ( from_json as ChannelOpeningTransaction_from_json, ) +from lightspark.objects.ChannelSnapshot import FRAGMENT as ChannelSnapshotFragment +from lightspark.objects.ChannelSnapshot import ChannelSnapshot +from lightspark.objects.ChannelSnapshot import from_json as ChannelSnapshot_from_json from lightspark.objects.Deposit import FRAGMENT as DepositFragment from lightspark.objects.Deposit import Deposit from lightspark.objects.Deposit import from_json as Deposit_from_json @@ -155,6 +158,10 @@ ChannelOpeningTransaction: """ ... on ChannelOpeningTransaction { ...ChannelOpeningTransactionFragment } +""", + ChannelSnapshot: """ ... on ChannelSnapshot { + ...ChannelSnapshotFragment + } """, Deposit: """ ... on Deposit { ...DepositFragment @@ -263,6 +270,7 @@ Channel: ChannelFragment, ChannelClosingTransaction: ChannelClosingTransactionFragment, ChannelOpeningTransaction: ChannelOpeningTransactionFragment, + ChannelSnapshot: ChannelSnapshotFragment, Deposit: DepositFragment, Entity: EntityFragment, GraphNode: GraphNodeFragment, @@ -295,6 +303,7 @@ Channel: Channel_from_json, ChannelClosingTransaction: ChannelClosingTransaction_from_json, ChannelOpeningTransaction: ChannelOpeningTransaction_from_json, + ChannelSnapshot: ChannelSnapshot_from_json, Deposit: Deposit_from_json, GraphNode: GraphNode_from_json, Hop: Hop_from_json,