Skip to content

Commit 4e47bba

Browse files
committed
Forgot to git add
1 parent 93359ab commit 4e47bba

5 files changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, Mapping
5+
6+
7+
@dataclass
8+
class FailHtlcsInput:
9+
invoice_id: str
10+
"""The id of invoice which the pending HTLCs that need to be failed are paying for."""
11+
12+
cancel_invoice: bool
13+
"""Whether the invoice needs to be canceled after failing the htlcs. If yes, the invoice cannot be paid anymore."""
14+
15+
def to_json(self) -> Mapping[str, Any]:
16+
return {
17+
"fail_htlcs_input_invoice_id": self.invoice_id,
18+
"fail_htlcs_input_cancel_invoice": self.cancel_invoice,
19+
}
20+
21+
22+
def from_json(obj: Mapping[str, Any]) -> FailHtlcsInput:
23+
return FailHtlcsInput(
24+
invoice_id=obj["fail_htlcs_input_invoice_id"],
25+
cancel_invoice=obj["fail_htlcs_input_cancel_invoice"],
26+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, Mapping
5+
6+
from lightspark.requests.requester import Requester
7+
8+
9+
@dataclass
10+
class FailHtlcsOutput:
11+
requester: Requester
12+
13+
invoice_id: str
14+
15+
def to_json(self) -> Mapping[str, Any]:
16+
return {
17+
"fail_htlcs_output_invoice": {"id": self.invoice_id},
18+
}
19+
20+
21+
FRAGMENT = """
22+
fragment FailHtlcsOutputFragment on FailHtlcsOutput {
23+
__typename
24+
fail_htlcs_output_invoice: invoice {
25+
id
26+
}
27+
}
28+
"""
29+
30+
31+
def from_json(requester: Requester, obj: Mapping[str, Any]) -> FailHtlcsOutput:
32+
return FailHtlcsOutput(
33+
requester=requester,
34+
invoice_id=obj["fail_htlcs_output_invoice"]["id"],
35+
)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, List, Mapping
5+
6+
from lightspark.requests.requester import Requester
7+
8+
from .Withdrawal import Withdrawal
9+
from .Withdrawal import from_json as Withdrawal_from_json
10+
11+
12+
@dataclass
13+
class WithdrawalRequestToWithdrawalsConnection:
14+
requester: Requester
15+
16+
count: int
17+
"""The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field)."""
18+
19+
entities: List[Withdrawal]
20+
"""The withdrawals for the current page of this connection."""
21+
22+
def to_json(self) -> Mapping[str, Any]:
23+
return {
24+
"withdrawal_request_to_withdrawals_connection_count": self.count,
25+
"withdrawal_request_to_withdrawals_connection_entities": [
26+
e.to_json() for e in self.entities
27+
],
28+
}
29+
30+
31+
FRAGMENT = """
32+
fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestToWithdrawalsConnection {
33+
__typename
34+
withdrawal_request_to_withdrawals_connection_count: count
35+
withdrawal_request_to_withdrawals_connection_entities: entities {
36+
id
37+
}
38+
}
39+
"""
40+
41+
42+
def from_json(
43+
requester: Requester, obj: Mapping[str, Any]
44+
) -> WithdrawalRequestToWithdrawalsConnection:
45+
return WithdrawalRequestToWithdrawalsConnection(
46+
requester=requester,
47+
count=obj["withdrawal_request_to_withdrawals_connection_count"],
48+
entities=list(
49+
map(
50+
# pylint: disable=unnecessary-lambda
51+
lambda e: Withdrawal_from_json(requester, e),
52+
obj["withdrawal_request_to_withdrawals_connection_entities"],
53+
)
54+
),
55+
)

lightspark/scripts/fail_htlcs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
FAIL_HTLCS_MUTATION = f"""
4+
mutation FailHtlcs($invoice_id: ID!, $cancel_invoice: Boolean!) {{
5+
fail_htlcs(input: {{ invoice_id: $invoice_id, cancel_invoice: $cancel_invoice }}) {{
6+
invoice {{
7+
id
8+
}}
9+
}}
10+
}}
11+
"""
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from lightspark.objects.OutgoingPayment import FRAGMENT as OutgoingPaymentFragment
4+
5+
OUTGOING_PAYMENTS_FOR_PAYMENT_HASH_QUERY = f"""
6+
query OutgoingPaymentsForPaymentHash(
7+
$payment_hash: String!,
8+
$transaction_statuses: [TransactionStatus!] = null
9+
) {{
10+
outgoing_payments_for_payment_hash(input: {{
11+
payment_hash: $payment_hash,
12+
statuses: $transaction_statuses
13+
}}) {{
14+
payments {{
15+
...OutgoingPaymentFragment
16+
}}
17+
}}
18+
}}
19+
20+
{OutgoingPaymentFragment}
21+
"""

0 commit comments

Comments
 (0)