Skip to content

Commit 8cad613

Browse files
authored
Merge pull request #7 from lightsparkdev/feat/balances
Add the Balances object to wallets and nodes.
2 parents d4a3494 + e9072f8 commit 8cad613

17 files changed

Lines changed: 1120 additions & 0 deletions

lightspark/objects/Account.py

Lines changed: 162 additions & 0 deletions
Large diffs are not rendered by default.

lightspark/objects/ChannelSnapshot.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
22

33
from dataclasses import dataclass
4+
from datetime import datetime
45
from typing import Any, Mapping, Optional
56

67
from lightspark.requests.requester import Requester
@@ -13,16 +14,28 @@
1314
class ChannelSnapshot:
1415
requester: Requester
1516

17+
channel_id: str
18+
19+
timestamp: datetime
20+
1621
local_balance: Optional[CurrencyAmount]
1722

1823
local_unsettled_balance: Optional[CurrencyAmount]
1924

2025
local_channel_reserve: Optional[CurrencyAmount]
2126

27+
remote_balance: Optional[CurrencyAmount]
28+
29+
remote_unsettled_balance: Optional[CurrencyAmount]
30+
2231

2332
FRAGMENT = """
2433
fragment ChannelSnapshotFragment on ChannelSnapshot {
2534
__typename
35+
channel_snapshot_channel: channel {
36+
id
37+
}
38+
channel_snapshot_timestamp: timestamp
2639
channel_snapshot_local_balance: local_balance {
2740
__typename
2841
currency_amount_original_value: original_value
@@ -47,13 +60,31 @@ class ChannelSnapshot:
4760
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4861
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4962
}
63+
channel_snapshot_remote_balance: remote_balance {
64+
__typename
65+
currency_amount_original_value: original_value
66+
currency_amount_original_unit: original_unit
67+
currency_amount_preferred_currency_unit: preferred_currency_unit
68+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
69+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
70+
}
71+
channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
72+
__typename
73+
currency_amount_original_value: original_value
74+
currency_amount_original_unit: original_unit
75+
currency_amount_preferred_currency_unit: preferred_currency_unit
76+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
77+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
78+
}
5079
}
5180
"""
5281

5382

5483
def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot:
5584
return ChannelSnapshot(
5685
requester=requester,
86+
channel_id=obj["channel_snapshot_channel"]["id"],
87+
timestamp=datetime.fromisoformat(obj["channel_snapshot_timestamp"]),
5788
local_balance=CurrencyAmount_from_json(
5889
requester, obj["channel_snapshot_local_balance"]
5990
)
@@ -69,4 +100,14 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot:
69100
)
70101
if obj["channel_snapshot_local_channel_reserve"]
71102
else None,
103+
remote_balance=CurrencyAmount_from_json(
104+
requester, obj["channel_snapshot_remote_balance"]
105+
)
106+
if obj["channel_snapshot_remote_balance"]
107+
else None,
108+
remote_unsettled_balance=CurrencyAmount_from_json(
109+
requester, obj["channel_snapshot_remote_unsettled_balance"]
110+
)
111+
if obj["channel_snapshot_remote_unsettled_balance"]
112+
else None,
72113
)

lightspark/objects/Entity.py

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,33 @@ class Entity:
460460
}
461461
}
462462
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
463+
lightspark_node_with_o_s_k_balances: balances {
464+
__typename
465+
balances_owned_balance: owned_balance {
466+
__typename
467+
currency_amount_original_value: original_value
468+
currency_amount_original_unit: original_unit
469+
currency_amount_preferred_currency_unit: preferred_currency_unit
470+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
471+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
472+
}
473+
balances_available_to_send_balance: available_to_send_balance {
474+
__typename
475+
currency_amount_original_value: original_value
476+
currency_amount_original_unit: original_unit
477+
currency_amount_preferred_currency_unit: preferred_currency_unit
478+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
479+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
480+
}
481+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
482+
__typename
483+
currency_amount_original_value: original_value
484+
currency_amount_original_unit: original_unit
485+
currency_amount_preferred_currency_unit: preferred_currency_unit
486+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
487+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
488+
}
489+
}
463490
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
464491
__typename
465492
secret_encrypted_value: encrypted_value
@@ -565,6 +592,33 @@ class Entity:
565592
}
566593
}
567594
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
595+
lightspark_node_with_remote_signing_balances: balances {
596+
__typename
597+
balances_owned_balance: owned_balance {
598+
__typename
599+
currency_amount_original_value: original_value
600+
currency_amount_original_unit: original_unit
601+
currency_amount_preferred_currency_unit: preferred_currency_unit
602+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
603+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
604+
}
605+
balances_available_to_send_balance: available_to_send_balance {
606+
__typename
607+
currency_amount_original_value: original_value
608+
currency_amount_original_unit: original_unit
609+
currency_amount_preferred_currency_unit: preferred_currency_unit
610+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
611+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
612+
}
613+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
614+
__typename
615+
currency_amount_original_value: original_value
616+
currency_amount_original_unit: original_unit
617+
currency_amount_preferred_currency_unit: preferred_currency_unit
618+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
619+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
620+
}
621+
}
568622
}
569623
}
570624
}
@@ -677,6 +731,33 @@ class Entity:
677731
}
678732
}
679733
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
734+
lightspark_node_with_o_s_k_balances: balances {
735+
__typename
736+
balances_owned_balance: owned_balance {
737+
__typename
738+
currency_amount_original_value: original_value
739+
currency_amount_original_unit: original_unit
740+
currency_amount_preferred_currency_unit: preferred_currency_unit
741+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
742+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
743+
}
744+
balances_available_to_send_balance: available_to_send_balance {
745+
__typename
746+
currency_amount_original_value: original_value
747+
currency_amount_original_unit: original_unit
748+
currency_amount_preferred_currency_unit: preferred_currency_unit
749+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
750+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
751+
}
752+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
753+
__typename
754+
currency_amount_original_value: original_value
755+
currency_amount_original_unit: original_unit
756+
currency_amount_preferred_currency_unit: preferred_currency_unit
757+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
758+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
759+
}
760+
}
680761
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
681762
__typename
682763
secret_encrypted_value: encrypted_value
@@ -782,6 +863,33 @@ class Entity:
782863
}
783864
}
784865
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
866+
lightspark_node_with_remote_signing_balances: balances {
867+
__typename
868+
balances_owned_balance: owned_balance {
869+
__typename
870+
currency_amount_original_value: original_value
871+
currency_amount_original_unit: original_unit
872+
currency_amount_preferred_currency_unit: preferred_currency_unit
873+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
874+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
875+
}
876+
balances_available_to_send_balance: available_to_send_balance {
877+
__typename
878+
currency_amount_original_value: original_value
879+
currency_amount_original_unit: original_unit
880+
currency_amount_preferred_currency_unit: preferred_currency_unit
881+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
882+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
883+
}
884+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
885+
__typename
886+
currency_amount_original_value: original_value
887+
currency_amount_original_unit: original_unit
888+
currency_amount_preferred_currency_unit: preferred_currency_unit
889+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
890+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
891+
}
892+
}
785893
}
786894
... on OutgoingPayment {
787895
__typename
@@ -944,6 +1052,33 @@ class Entity:
9441052
}
9451053
}
9461054
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
1055+
lightspark_node_with_o_s_k_balances: balances {
1056+
__typename
1057+
balances_owned_balance: owned_balance {
1058+
__typename
1059+
currency_amount_original_value: original_value
1060+
currency_amount_original_unit: original_unit
1061+
currency_amount_preferred_currency_unit: preferred_currency_unit
1062+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1063+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1064+
}
1065+
balances_available_to_send_balance: available_to_send_balance {
1066+
__typename
1067+
currency_amount_original_value: original_value
1068+
currency_amount_original_unit: original_unit
1069+
currency_amount_preferred_currency_unit: preferred_currency_unit
1070+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1071+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1072+
}
1073+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
1074+
__typename
1075+
currency_amount_original_value: original_value
1076+
currency_amount_original_unit: original_unit
1077+
currency_amount_preferred_currency_unit: preferred_currency_unit
1078+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1079+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1080+
}
1081+
}
9471082
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
9481083
__typename
9491084
secret_encrypted_value: encrypted_value
@@ -1049,6 +1184,33 @@ class Entity:
10491184
}
10501185
}
10511186
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
1187+
lightspark_node_with_remote_signing_balances: balances {
1188+
__typename
1189+
balances_owned_balance: owned_balance {
1190+
__typename
1191+
currency_amount_original_value: original_value
1192+
currency_amount_original_unit: original_unit
1193+
currency_amount_preferred_currency_unit: preferred_currency_unit
1194+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1195+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1196+
}
1197+
balances_available_to_send_balance: available_to_send_balance {
1198+
__typename
1199+
currency_amount_original_value: original_value
1200+
currency_amount_original_unit: original_unit
1201+
currency_amount_preferred_currency_unit: preferred_currency_unit
1202+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1203+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1204+
}
1205+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
1206+
__typename
1207+
currency_amount_original_value: original_value
1208+
currency_amount_original_unit: original_unit
1209+
currency_amount_preferred_currency_unit: preferred_currency_unit
1210+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1211+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1212+
}
1213+
}
10521214
}
10531215
}
10541216
}
@@ -1102,6 +1264,10 @@ class Entity:
11021264
}
11031265
outgoing_payment_attempt_channel_snapshot: channel_snapshot {
11041266
__typename
1267+
channel_snapshot_channel: channel {
1268+
id
1269+
}
1270+
channel_snapshot_timestamp: timestamp
11051271
channel_snapshot_local_balance: local_balance {
11061272
__typename
11071273
currency_amount_original_value: original_value
@@ -1126,6 +1292,22 @@ class Entity:
11261292
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
11271293
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
11281294
}
1295+
channel_snapshot_remote_balance: remote_balance {
1296+
__typename
1297+
currency_amount_original_value: original_value
1298+
currency_amount_original_unit: original_unit
1299+
currency_amount_preferred_currency_unit: preferred_currency_unit
1300+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1301+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1302+
}
1303+
channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
1304+
__typename
1305+
currency_amount_original_value: original_value
1306+
currency_amount_original_unit: original_unit
1307+
currency_amount_preferred_currency_unit: preferred_currency_unit
1308+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1309+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1310+
}
11291311
}
11301312
}
11311313
... on RoutingTransaction {

lightspark/objects/HtlcAttemptFailureCode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class HtlcAttemptFailureCode(Enum):
3232
EXPIRY_TOO_FAR = "EXPIRY_TOO_FAR"
3333
MPP_TIMEOUT = "MPP_TIMEOUT"
3434
INVALID_ONION_PAYLOAD = "INVALID_ONION_PAYLOAD"
35+
INVALID_ONION_BLINDING = "INVALID_ONION_BLINDING"
3536
INTERNAL_FAILURE = "INTERNAL_FAILURE"
3637
UNKNOWN_FAILURE = "UNKNOWN_FAILURE"
3738
UNREADABLE_FAILURE = "UNREADABLE_FAILURE"

0 commit comments

Comments
 (0)