Skip to content
Closed
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
2 changes: 2 additions & 0 deletions lightspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from lightspark.objects.CreateUmaInvitationOutput import CreateUmaInvitationOutput
from lightspark.objects.CreateUmaInvoiceInput import CreateUmaInvoiceInput
from lightspark.objects.CurrencyAmount import CurrencyAmount
from lightspark.objects.CurrencyAmountInput import CurrencyAmountInput
from lightspark.objects.CurrencyUnit import CurrencyUnit
from lightspark.objects.DailyLiquidityForecast import DailyLiquidityForecast
from lightspark.objects.DeclineToSignMessagesInput import DeclineToSignMessagesInput
Expand Down Expand Up @@ -175,6 +176,7 @@
from lightspark.objects.PaymentRequest import PaymentRequest
from lightspark.objects.PaymentRequestData import PaymentRequestData
from lightspark.objects.PaymentRequestStatus import PaymentRequestStatus
from lightspark.objects.PayTestModeInvoiceInput import PayTestModeInvoiceInput
from lightspark.objects.PayUmaInvoiceInput import PayUmaInvoiceInput
from lightspark.objects.Permission import Permission
from lightspark.objects.PostTransactionData import PostTransactionData
Expand Down
25 changes: 19 additions & 6 deletions lightspark/objects/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .BlockchainBalance import from_json as BlockchainBalance_from_json
from .CurrencyAmount import CurrencyAmount
from .CurrencyAmount import from_json as CurrencyAmount_from_json
from .CurrencyAmountInput import CurrencyAmountInput
from .Entity import Entity
from .LightsparkNodeOwner import LightsparkNodeOwner
from .TransactionFailures import TransactionFailures
Expand Down Expand Up @@ -745,13 +746,15 @@ def get_transactions(
lightning_node_id: Optional[str] = None,
statuses: Optional[List[TransactionStatus]] = None,
exclude_failures: Optional[TransactionFailures] = None,
max_amount: Optional[CurrencyAmountInput] = None,
min_amount: Optional[CurrencyAmountInput] = None,
) -> AccountToTransactionsConnection:
json = self.requester.execute_graphql(
"""
query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures) {
query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) {
entity(id: $entity_id) {
... on Account {
transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures) {
transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures, max_amount: $max_amount, min_amount: $min_amount) {
__typename
account_to_transactions_connection_count: count
account_to_transactions_connection_page_info: page_info {
Expand Down Expand Up @@ -1351,6 +1354,8 @@ def get_transactions(
"lightning_node_id": lightning_node_id,
"statuses": statuses,
"exclude_failures": exclude_failures,
"max_amount": max_amount,
"min_amount": min_amount,
},
)
connection = json["entity"]["transactions"]
Expand All @@ -1364,13 +1369,15 @@ def get_payment_requests(
before_date: Optional[datetime] = None,
bitcoin_network: Optional[BitcoinNetwork] = None,
lightning_node_id: Optional[str] = None,
max_amount: Optional[CurrencyAmountInput] = None,
min_amount: Optional[CurrencyAmountInput] = None,
) -> AccountToPaymentRequestsConnection:
json = self.requester.execute_graphql(
"""
query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID) {
query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) {
entity(id: $entity_id) {
... on Account {
payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id) {
payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, max_amount: $max_amount, min_amount: $min_amount) {
__typename
account_to_payment_requests_connection_count: count
account_to_payment_requests_connection_page_info: page_info {
Expand Down Expand Up @@ -1704,6 +1711,8 @@ def get_payment_requests(
"before_date": before_date,
"bitcoin_network": bitcoin_network,
"lightning_node_id": lightning_node_id,
"max_amount": max_amount,
"min_amount": min_amount,
},
)
connection = json["entity"]["payment_requests"]
Expand All @@ -1719,13 +1728,15 @@ def get_withdrawal_requests(
idempotency_keys: Optional[List[str]] = None,
after_date: Optional[datetime] = None,
before_date: Optional[datetime] = None,
max_amount: Optional[CurrencyAmountInput] = None,
min_amount: Optional[CurrencyAmountInput] = None,
) -> AccountToWithdrawalRequestsConnection:
json = self.requester.execute_graphql(
"""
query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime) {
query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) {
entity(id: $entity_id) {
... on Account {
withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date) {
withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date, max_amount: $max_amount, min_amount: $min_amount) {
__typename
account_to_withdrawal_requests_connection_count: count
account_to_withdrawal_requests_connection_page_info: page_info {
Expand Down Expand Up @@ -1805,6 +1816,8 @@ def get_withdrawal_requests(
"idempotency_keys": idempotency_keys,
"after_date": after_date,
"before_date": before_date,
"max_amount": max_amount,
"min_amount": min_amount,
},
)
connection = json["entity"]["withdrawal_requests"]
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/AccountToApiTokensConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@dataclass
class AccountToApiTokensConnection(Connection):

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra blank line between @DataClass class declaration and first attribute 'requester'. This pattern needs to be fixed in all 98 affected files by running the code formatter to ensure consistent formatting.

Spotted by Graphite Reviewer (based on CI logs)

Is this helpful? React 👍 or 👎 to let us know.

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/AccountToChannelsConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@dataclass
class AccountToChannelsConnection(Connection):

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra blank line after class declaration to match Black formatting

Spotted by Graphite Reviewer (based on CI logs)

Is this helpful? React 👍 or 👎 to let us know.

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/AccountToPaymentRequestsConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@dataclass
class AccountToPaymentRequestsConnection(Connection):

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/AccountToTransactionsConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@dataclass
class AccountToTransactionsConnection(Connection):

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/AccountToWalletsConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

@dataclass
class AccountToWalletsConnection(Connection):

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/ChannelSnapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@dataclass
class ChannelSnapshot(Entity):

requester: Requester

id: str
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/ChannelToTransactionsConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

@dataclass
class ChannelToTransactionsConnection:

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/ClaimUmaInvitationInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@dataclass
class ClaimUmaInvitationInput:

invitation_code: str
"""The unique code that identifies this invitation and was shared by the inviter."""

Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/ClaimUmaInvitationOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@dataclass
class ClaimUmaInvitationOutput:

requester: Requester

invitation_id: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@dataclass
class ClaimUmaInvitationWithIncentivesInput:

invitation_code: str
"""The unique code that identifies this invitation and was shared by the inviter."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@dataclass
class ClaimUmaInvitationWithIncentivesOutput:

requester: Requester

invitation_id: str
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

@dataclass
class Connection:

requester: Requester

count: int
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateApiTokenInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@dataclass
class CreateApiTokenInput:

name: str
"""An arbitrary name that the user can choose to identify the API token in a list."""

Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateApiTokenOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

@dataclass
class CreateApiTokenOutput:

requester: Requester

api_token: ApiToken
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateInvitationWithIncentivesInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@dataclass
class CreateInvitationWithIncentivesInput:

inviter_uma: str
"""The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation."""

Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateInvitationWithIncentivesOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@dataclass
class CreateInvitationWithIncentivesOutput:

requester: Requester

invitation_id: str
Expand Down
8 changes: 7 additions & 1 deletion lightspark/objects/CreateInvoiceInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@dataclass
class CreateInvoiceInput:

node_id: str
"""The node from which to create the invoice."""

Expand All @@ -21,7 +22,10 @@ class CreateInvoiceInput:
invoice_type: Optional[InvoiceType]

expiry_secs: Optional[int]
"""The expiry of the invoice in seconds. Default value is 86400 (1 day)."""
"""The expiry of the invoice in seconds. Default value is 86400 (1 day) for AMP invoice, or 3600 (1 hour) for STANDARD invoice."""

payment_hash: Optional[str]
"""The payment hash of the invoice. It should only be set if your node is a remote signing node. If not set, it will be requested through REMOTE_SIGNING webhooks with sub event type REQUEST_INVOICE_PAYMENT_HASH."""

def to_json(self) -> Mapping[str, Any]:
return {
Expand All @@ -32,6 +36,7 @@ def to_json(self) -> Mapping[str, Any]:
self.invoice_type.value if self.invoice_type else None
),
"create_invoice_input_expiry_secs": self.expiry_secs,
"create_invoice_input_payment_hash": self.payment_hash,
}


Expand All @@ -44,4 +49,5 @@ def from_json(obj: Mapping[str, Any]) -> CreateInvoiceInput:
InvoiceType, obj["create_invoice_input_invoice_type"]
),
expiry_secs=obj["create_invoice_input_expiry_secs"],
payment_hash=obj["create_invoice_input_payment_hash"],
)
1 change: 1 addition & 0 deletions lightspark/objects/CreateInvoiceOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@dataclass
class CreateInvoiceOutput:

requester: Requester

invoice_id: str
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateLnurlInvoiceInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@dataclass
class CreateLnurlInvoiceInput:

node_id: str
"""The node from which to create the invoice."""

Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateNodeWalletAddressInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@dataclass
class CreateNodeWalletAddressInput:

node_id: str

def to_json(self) -> Mapping[str, Any]:
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateNodeWalletAddressOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@dataclass
class CreateNodeWalletAddressOutput:

requester: Requester

node_id: str
Expand Down
5 changes: 5 additions & 0 deletions lightspark/objects/CreateTestModeInvoiceInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@

@dataclass
class CreateTestModeInvoiceInput:

local_node_id: str
"""The local node from which to create the invoice."""

amount_msats: int
"""The amount for which the invoice should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount."""

memo: Optional[str]
"""An optional memo to include in the invoice."""

invoice_type: Optional[InvoiceType]
"""The type of invoice to create."""

def to_json(self) -> Mapping[str, Any]:
return {
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateTestModeInvoiceOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@dataclass
class CreateTestModeInvoiceOutput:

requester: Requester

encoded_payment_request: str
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateTestModePaymentInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@dataclass
class CreateTestModePaymentInput:

local_node_id: str
"""The node to where you want to send the payment."""

Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateUmaInvitationInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@dataclass
class CreateUmaInvitationInput:

inviter_uma: str
"""The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation."""

Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateUmaInvitationOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

@dataclass
class CreateUmaInvitationOutput:

requester: Requester

invitation_id: str
Expand Down
1 change: 1 addition & 0 deletions lightspark/objects/CreateUmaInvoiceInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

@dataclass
class CreateUmaInvoiceInput:

node_id: str
"""The node from which to create the invoice."""

Expand Down
29 changes: 29 additions & 0 deletions lightspark/objects/CurrencyAmountInput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved

from dataclasses import dataclass
from typing import Any, Mapping

from lightspark.utils.enums import parse_enum

from .CurrencyUnit import CurrencyUnit


@dataclass
class CurrencyAmountInput:

value: int

unit: CurrencyUnit

def to_json(self) -> Mapping[str, Any]:
return {
"currency_amount_input_value": self.value,
"currency_amount_input_unit": self.unit.value,
}


def from_json(obj: Mapping[str, Any]) -> CurrencyAmountInput:
return CurrencyAmountInput(
value=obj["currency_amount_input_value"],
unit=parse_enum(CurrencyUnit, obj["currency_amount_input_unit"]),
)
2 changes: 2 additions & 0 deletions lightspark/objects/CurrencyUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class CurrencyUnit(Enum):
"""United States Dollar."""
MXN = "MXN"
"""Mexican Peso."""
PHP = "PHP"
"""Philippine Peso."""
NANOBITCOIN = "NANOBITCOIN"
"""0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible."""
MICROBITCOIN = "MICROBITCOIN"
Expand Down
Loading
Loading