@lightsparkdev/lightspark-sdk 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/{chunk-7UNNCH5S.js → chunk-VTPDR6P4.js} +1270 -342
  3. package/dist/{index-5235e43b.d.ts → index-f040db9f.d.ts} +707 -407
  4. package/dist/index.cjs +1247 -319
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +7 -7
  7. package/dist/objects/index.cjs +1180 -306
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +5 -5
  10. package/package.json +2 -2
  11. package/src/objects/Account.ts +175 -2
  12. package/src/objects/AccountToApiTokensConnection.ts +16 -5
  13. package/src/objects/AccountToChannelsConnection.ts +9 -0
  14. package/src/objects/AccountToNodesConnection.ts +19 -5
  15. package/src/objects/AccountToPaymentRequestsConnection.ts +21 -5
  16. package/src/objects/AccountToTransactionsConnection.ts +33 -9
  17. package/src/objects/AccountToWalletsConnection.ts +13 -4
  18. package/src/objects/ApiToken.ts +13 -3
  19. package/src/objects/Balances.ts +17 -3
  20. package/src/objects/BlockchainBalance.ts +34 -9
  21. package/src/objects/Channel.ts +61 -16
  22. package/src/objects/ChannelClosingTransaction.ts +81 -61
  23. package/src/objects/ChannelFees.ts +16 -5
  24. package/src/objects/ChannelOpeningTransaction.ts +81 -61
  25. package/src/objects/ChannelSnapshot.ts +66 -6
  26. package/src/objects/ChannelToTransactionsConnection.ts +26 -6
  27. package/src/objects/Connection.ts +205 -10
  28. package/src/objects/CreateApiTokenInput.ts +8 -2
  29. package/src/objects/CreateApiTokenOutput.ts +9 -3
  30. package/src/objects/CreateInvoiceInput.ts +14 -5
  31. package/src/objects/CreateInvoiceOutput.ts +7 -2
  32. package/src/objects/CreateLnurlInvoiceInput.ts +13 -3
  33. package/src/objects/CreateNodeWalletAddressInput.ts +9 -2
  34. package/src/objects/CreateNodeWalletAddressOutput.ts +10 -2
  35. package/src/objects/CreateTestModeInvoiceInput.ts +14 -4
  36. package/src/objects/CreateTestModeInvoiceOutput.ts +10 -2
  37. package/src/objects/CreateTestModePaymentInput.ts +12 -3
  38. package/src/objects/CreateTestModePaymentoutput.ts +12 -2
  39. package/src/objects/CreateUmaInvoiceInput.ts +13 -3
  40. package/src/objects/CurrencyAmount.ts +13 -2
  41. package/src/objects/DeclineToSignMessagesInput.ts +9 -2
  42. package/src/objects/DeclineToSignMessagesOutput.ts +15 -3
  43. package/src/objects/DeleteApiTokenInput.ts +7 -2
  44. package/src/objects/DeleteApiTokenOutput.ts +7 -2
  45. package/src/objects/Deposit.ts +77 -61
  46. package/src/objects/Entity.ts +184 -2
  47. package/src/objects/FeeEstimate.ts +12 -3
  48. package/src/objects/FundNodeInput.ts +9 -3
  49. package/src/objects/FundNodeOutput.ts +11 -3
  50. package/src/objects/GraphNode.ts +21 -5
  51. package/src/objects/Hop.ts +27 -9
  52. package/src/objects/HtlcAttemptFailureCode.ts +2 -0
  53. package/src/objects/IdAndSignature.ts +8 -2
  54. package/src/objects/IncomingPayment.ts +33 -7
  55. package/src/objects/IncomingPaymentAttempt.ts +21 -5
  56. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
  57. package/src/objects/Invoice.ts +91 -24
  58. package/src/objects/InvoiceData.ts +75 -6
  59. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
  60. package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
  61. package/src/objects/LightningFeeEstimateOutput.ts +15 -3
  62. package/src/objects/LightningTransaction.ts +171 -28
  63. package/src/objects/LightsparkNode.ts +311 -208
  64. package/src/objects/LightsparkNodeOwner.ts +35 -4
  65. package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
  66. package/src/objects/LightsparkNodeWithOSK.ts +97 -15
  67. package/src/objects/LightsparkNodeWithRemoteSigning.ts +93 -13
  68. package/src/objects/Node.ts +269 -67
  69. package/src/objects/NodeAddress.ts +8 -2
  70. package/src/objects/NodeToAddressesConnection.ts +13 -3
  71. package/src/objects/OnChainTransaction.ts +156 -44
  72. package/src/objects/OutgoingPayment.ts +127 -14
  73. package/src/objects/OutgoingPaymentAttempt.ts +57 -8
  74. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
  75. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
  76. package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
  77. package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
  78. package/src/objects/PageInfo.ts +14 -6
  79. package/src/objects/PayInvoiceInput.ts +12 -3
  80. package/src/objects/PayInvoiceOutput.ts +7 -2
  81. package/src/objects/PayUmaInvoiceInput.ts +12 -3
  82. package/src/objects/PaymentRequest.ts +81 -5
  83. package/src/objects/PaymentRequestData.ts +81 -4
  84. package/src/objects/PostTransactionData.ts +12 -3
  85. package/src/objects/RegisterPaymentInput.ts +10 -2
  86. package/src/objects/RegisterPaymentOutput.ts +9 -2
  87. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
  88. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
  89. package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
  90. package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
  91. package/src/objects/RequestWithdrawalInput.ts +12 -2
  92. package/src/objects/RequestWithdrawalOutput.ts +9 -2
  93. package/src/objects/RichText.ts +7 -2
  94. package/src/objects/RoutingTransaction.ts +62 -41
  95. package/src/objects/ScreenNodeInput.ts +8 -2
  96. package/src/objects/ScreenNodeOutput.ts +7 -2
  97. package/src/objects/Secret.ts +8 -2
  98. package/src/objects/SendPaymentInput.ts +11 -2
  99. package/src/objects/SendPaymentOutput.ts +7 -2
  100. package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
  101. package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
  102. package/src/objects/SignInvoiceInput.ts +9 -2
  103. package/src/objects/SignInvoiceOutput.ts +7 -2
  104. package/src/objects/SignMessagesInput.ts +13 -3
  105. package/src/objects/SignMessagesOutput.ts +13 -3
  106. package/src/objects/Signable.ts +10 -3
  107. package/src/objects/SignablePayload.ts +18 -5
  108. package/src/objects/Transaction.ts +260 -9
  109. package/src/objects/TransactionFailures.ts +11 -4
  110. package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
  111. package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
  112. package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
  113. package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
  114. package/src/objects/Wallet.ts +130 -5
  115. package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
  116. package/src/objects/WalletToTransactionsConnection.ts +16 -5
  117. package/src/objects/Withdrawal.ts +77 -61
  118. package/src/objects/WithdrawalRequest.ts +25 -4
  119. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
  120. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
  121. package/src/objects/index.ts +5 -2
  122. package/src/tests/integration/client.test.ts +46 -7
  123. package/src/tests/serialization.test.ts +18 -0
@@ -1,86 +1,80 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import { LightsparkException, type Query } from "@lightsparkdev/core";
4
- import autoBind from "auto-bind";
5
4
  import type LightsparkClient from "../client.js";
5
+ import { BalancesFromJson, BalancesToJson } from "./Balances.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
7
- import { BlockchainBalanceFromJson } from "./BlockchainBalance.js";
8
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
9
- import type Entity from "./Entity.js";
7
+ import {
8
+ BlockchainBalanceFromJson,
9
+ BlockchainBalanceToJson,
10
+ } from "./BlockchainBalance.js";
11
+ import {
12
+ CurrencyAmountFromJson,
13
+ CurrencyAmountToJson,
14
+ } from "./CurrencyAmount.js";
10
15
  import GraphNode from "./GraphNode.js";
11
16
  import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
12
17
  import LightsparkNodeWithOSK from "./LightsparkNodeWithOSK.js";
13
18
  import LightsparkNodeWithRemoteSigning from "./LightsparkNodeWithRemoteSigning.js";
14
19
  import type NodeAddressType from "./NodeAddressType.js";
15
20
  import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
16
- import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
17
- import { SecretFromJson } from "./Secret.js";
21
+ import { SecretFromJson, SecretToJson } from "./Secret.js";
18
22
 
19
23
  /** This object is an interface representing a Lightning Node on the Lightning Network, and could either be a Lightspark node or a node managed by a third party. **/
20
- class Node implements Entity {
21
- constructor(
22
- public readonly id: string,
23
- public readonly createdAt: string,
24
- public readonly updatedAt: string,
25
- public readonly bitcoinNetwork: BitcoinNetwork,
26
- public readonly displayName: string,
27
- public readonly typename: string,
28
- public readonly alias?: string,
29
- public readonly color?: string,
30
- public readonly conductivity?: number,
31
- public readonly publicKey?: string,
32
- ) {
33
- autoBind(this);
34
- }
24
+ interface Node {
25
+ /**
26
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
27
+ * string.
28
+ **/
29
+ id: string;
35
30
 
36
- public async getAddresses(
37
- client: LightsparkClient,
38
- first: number | undefined = undefined,
39
- types: NodeAddressType[] | undefined = undefined,
40
- ): Promise<NodeToAddressesConnection> {
41
- return (await client.executeRawQuery({
42
- queryPayload: `
43
- query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) {
44
- entity(id: $entity_id) {
45
- ... on Node {
46
- addresses(, first: $first, types: $types) {
47
- __typename
48
- node_to_addresses_connection_count: count
49
- node_to_addresses_connection_entities: entities {
50
- __typename
51
- node_address_address: address
52
- node_address_type: type
53
- }
54
- }
55
- }
56
- }
57
- }
58
- `,
59
- variables: { entity_id: this.id, first: first, types: types },
60
- constructObject: (json) => {
61
- const connection = json["entity"]["addresses"];
62
- return NodeToAddressesConnectionFromJson(connection);
63
- },
64
- }))!;
65
- }
31
+ /** The date and time when the entity was first created. **/
32
+ createdAt: string;
66
33
 
67
- static getNodeQuery(id: string): Query<Node> {
68
- return {
69
- queryPayload: `
70
- query GetNode($id: ID!) {
71
- entity(id: $id) {
72
- ... on Node {
73
- ...NodeFragment
74
- }
75
- }
76
- }
34
+ /** The date and time when the entity was last updated. **/
35
+ updatedAt: string;
77
36
 
78
- ${FRAGMENT}
79
- `,
80
- variables: { id },
81
- constructObject: (data: any) => NodeFromJson(data.entity),
82
- };
83
- }
37
+ /** The Bitcoin Network this node is deployed in. **/
38
+ bitcoinNetwork: BitcoinNetwork;
39
+
40
+ /**
41
+ * The name of this node in the network. It will be the most human-readable option possible, depending
42
+ * on the data available for this node.
43
+ **/
44
+ displayName: string;
45
+
46
+ /** The typename of the object **/
47
+ typename: string;
48
+
49
+ /**
50
+ * A name that identifies the node. It has no importance in terms of operating the node, it is just a
51
+ * way to identify and search for commercial services or popular nodes. This alias can be changed at
52
+ * any time by the node operator.
53
+ **/
54
+ alias?: string | undefined;
55
+
56
+ /**
57
+ * A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It
58
+ * has no importance in terms of operating the node, it is just a way to visually differentiate nodes.
59
+ * That color can be changed at any time by the node operator.
60
+ **/
61
+ color?: string | undefined;
62
+
63
+ /**
64
+ * A summary metric used to capture how well positioned a node is to send, receive, or route
65
+ * transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be
66
+ * capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
67
+ **/
68
+ conductivity?: number | undefined;
69
+
70
+ /** The public key of this node. It acts as a unique identifier of this node in the Lightning Network. **/
71
+ publicKey?: string | undefined;
72
+
73
+ getAddresses(
74
+ client: LightsparkClient,
75
+ first?: number | undefined,
76
+ types?: NodeAddressType[] | undefined,
77
+ ): Promise<NodeToAddressesConnection>;
84
78
  }
85
79
 
86
80
  export const NodeFromJson = (obj: any): Node => {
@@ -143,6 +137,9 @@ export const NodeFromJson = (obj: any): Node => {
143
137
  obj["lightspark_node_with_o_s_k_blockchain_balance"],
144
138
  )
145
139
  : undefined,
140
+ !!obj["lightspark_node_with_o_s_k_balances"]
141
+ ? BalancesFromJson(obj["lightspark_node_with_o_s_k_balances"])
142
+ : undefined,
146
143
  !!obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"]
147
144
  ? SecretFromJson(
148
145
  obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"],
@@ -196,6 +193,9 @@ export const NodeFromJson = (obj: any): Node => {
196
193
  obj["lightspark_node_with_remote_signing_blockchain_balance"],
197
194
  )
198
195
  : undefined,
196
+ !!obj["lightspark_node_with_remote_signing_balances"]
197
+ ? BalancesFromJson(obj["lightspark_node_with_remote_signing_balances"])
198
+ : undefined,
199
199
  );
200
200
  }
201
201
  throw new LightsparkException(
@@ -203,6 +203,136 @@ export const NodeFromJson = (obj: any): Node => {
203
203
  `Couldn't find a concrete type for interface Node corresponding to the typename=${obj["__typename"]}`,
204
204
  );
205
205
  };
206
+ export const NodeToJson = (obj: Node): any => {
207
+ if (obj.typename == "GraphNode") {
208
+ const graphNode = obj as GraphNode;
209
+ return {
210
+ __typename: "GraphNode",
211
+ graph_node_id: graphNode.id,
212
+ graph_node_created_at: graphNode.createdAt,
213
+ graph_node_updated_at: graphNode.updatedAt,
214
+ graph_node_alias: graphNode.alias,
215
+ graph_node_bitcoin_network: graphNode.bitcoinNetwork,
216
+ graph_node_color: graphNode.color,
217
+ graph_node_conductivity: graphNode.conductivity,
218
+ graph_node_display_name: graphNode.displayName,
219
+ graph_node_public_key: graphNode.publicKey,
220
+ };
221
+ }
222
+ if (obj.typename == "LightsparkNodeWithOSK") {
223
+ const lightsparkNodeWithOSK = obj as LightsparkNodeWithOSK;
224
+ return {
225
+ __typename: "LightsparkNodeWithOSK",
226
+ lightspark_node_with_o_s_k_id: lightsparkNodeWithOSK.id,
227
+ lightspark_node_with_o_s_k_created_at: lightsparkNodeWithOSK.createdAt,
228
+ lightspark_node_with_o_s_k_updated_at: lightsparkNodeWithOSK.updatedAt,
229
+ lightspark_node_with_o_s_k_alias: lightsparkNodeWithOSK.alias,
230
+ lightspark_node_with_o_s_k_bitcoin_network:
231
+ lightsparkNodeWithOSK.bitcoinNetwork,
232
+ lightspark_node_with_o_s_k_color: lightsparkNodeWithOSK.color,
233
+ lightspark_node_with_o_s_k_conductivity:
234
+ lightsparkNodeWithOSK.conductivity,
235
+ lightspark_node_with_o_s_k_display_name:
236
+ lightsparkNodeWithOSK.displayName,
237
+ lightspark_node_with_o_s_k_public_key: lightsparkNodeWithOSK.publicKey,
238
+ lightspark_node_with_o_s_k_owner: { id: lightsparkNodeWithOSK.ownerId },
239
+ lightspark_node_with_o_s_k_status: lightsparkNodeWithOSK.status,
240
+ lightspark_node_with_o_s_k_total_balance:
241
+ lightsparkNodeWithOSK.totalBalance
242
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.totalBalance)
243
+ : undefined,
244
+ lightspark_node_with_o_s_k_total_local_balance:
245
+ lightsparkNodeWithOSK.totalLocalBalance
246
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.totalLocalBalance)
247
+ : undefined,
248
+ lightspark_node_with_o_s_k_local_balance:
249
+ lightsparkNodeWithOSK.localBalance
250
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.localBalance)
251
+ : undefined,
252
+ lightspark_node_with_o_s_k_remote_balance:
253
+ lightsparkNodeWithOSK.remoteBalance
254
+ ? CurrencyAmountToJson(lightsparkNodeWithOSK.remoteBalance)
255
+ : undefined,
256
+ lightspark_node_with_o_s_k_blockchain_balance:
257
+ lightsparkNodeWithOSK.blockchainBalance
258
+ ? BlockchainBalanceToJson(lightsparkNodeWithOSK.blockchainBalance)
259
+ : undefined,
260
+ lightspark_node_with_o_s_k_uma_prescreening_utxos:
261
+ lightsparkNodeWithOSK.umaPrescreeningUtxos,
262
+ lightspark_node_with_o_s_k_balances: lightsparkNodeWithOSK.balances
263
+ ? BalancesToJson(lightsparkNodeWithOSK.balances)
264
+ : undefined,
265
+ lightspark_node_with_o_s_k_encrypted_signing_private_key:
266
+ lightsparkNodeWithOSK.encryptedSigningPrivateKey
267
+ ? SecretToJson(lightsparkNodeWithOSK.encryptedSigningPrivateKey)
268
+ : undefined,
269
+ };
270
+ }
271
+ if (obj.typename == "LightsparkNodeWithRemoteSigning") {
272
+ const lightsparkNodeWithRemoteSigning =
273
+ obj as LightsparkNodeWithRemoteSigning;
274
+ return {
275
+ __typename: "LightsparkNodeWithRemoteSigning",
276
+ lightspark_node_with_remote_signing_id:
277
+ lightsparkNodeWithRemoteSigning.id,
278
+ lightspark_node_with_remote_signing_created_at:
279
+ lightsparkNodeWithRemoteSigning.createdAt,
280
+ lightspark_node_with_remote_signing_updated_at:
281
+ lightsparkNodeWithRemoteSigning.updatedAt,
282
+ lightspark_node_with_remote_signing_alias:
283
+ lightsparkNodeWithRemoteSigning.alias,
284
+ lightspark_node_with_remote_signing_bitcoin_network:
285
+ lightsparkNodeWithRemoteSigning.bitcoinNetwork,
286
+ lightspark_node_with_remote_signing_color:
287
+ lightsparkNodeWithRemoteSigning.color,
288
+ lightspark_node_with_remote_signing_conductivity:
289
+ lightsparkNodeWithRemoteSigning.conductivity,
290
+ lightspark_node_with_remote_signing_display_name:
291
+ lightsparkNodeWithRemoteSigning.displayName,
292
+ lightspark_node_with_remote_signing_public_key:
293
+ lightsparkNodeWithRemoteSigning.publicKey,
294
+ lightspark_node_with_remote_signing_owner: {
295
+ id: lightsparkNodeWithRemoteSigning.ownerId,
296
+ },
297
+ lightspark_node_with_remote_signing_status:
298
+ lightsparkNodeWithRemoteSigning.status,
299
+ lightspark_node_with_remote_signing_total_balance:
300
+ lightsparkNodeWithRemoteSigning.totalBalance
301
+ ? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.totalBalance)
302
+ : undefined,
303
+ lightspark_node_with_remote_signing_total_local_balance:
304
+ lightsparkNodeWithRemoteSigning.totalLocalBalance
305
+ ? CurrencyAmountToJson(
306
+ lightsparkNodeWithRemoteSigning.totalLocalBalance,
307
+ )
308
+ : undefined,
309
+ lightspark_node_with_remote_signing_local_balance:
310
+ lightsparkNodeWithRemoteSigning.localBalance
311
+ ? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.localBalance)
312
+ : undefined,
313
+ lightspark_node_with_remote_signing_remote_balance:
314
+ lightsparkNodeWithRemoteSigning.remoteBalance
315
+ ? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.remoteBalance)
316
+ : undefined,
317
+ lightspark_node_with_remote_signing_blockchain_balance:
318
+ lightsparkNodeWithRemoteSigning.blockchainBalance
319
+ ? BlockchainBalanceToJson(
320
+ lightsparkNodeWithRemoteSigning.blockchainBalance,
321
+ )
322
+ : undefined,
323
+ lightspark_node_with_remote_signing_uma_prescreening_utxos:
324
+ lightsparkNodeWithRemoteSigning.umaPrescreeningUtxos,
325
+ lightspark_node_with_remote_signing_balances:
326
+ lightsparkNodeWithRemoteSigning.balances
327
+ ? BalancesToJson(lightsparkNodeWithRemoteSigning.balances)
328
+ : undefined,
329
+ };
330
+ }
331
+ throw new LightsparkException(
332
+ "DeserializationError",
333
+ `Couldn't find a concrete type for interface Node corresponding to the typename=${obj.typename}`,
334
+ );
335
+ };
206
336
 
207
337
  export const FRAGMENT = `
208
338
  fragment NodeFragment on Node {
@@ -318,6 +448,33 @@ fragment NodeFragment on Node {
318
448
  }
319
449
  }
320
450
  lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
451
+ lightspark_node_with_o_s_k_balances: balances {
452
+ __typename
453
+ balances_owned_balance: owned_balance {
454
+ __typename
455
+ currency_amount_original_value: original_value
456
+ currency_amount_original_unit: original_unit
457
+ currency_amount_preferred_currency_unit: preferred_currency_unit
458
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
459
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
460
+ }
461
+ balances_available_to_send_balance: available_to_send_balance {
462
+ __typename
463
+ currency_amount_original_value: original_value
464
+ currency_amount_original_unit: original_unit
465
+ currency_amount_preferred_currency_unit: preferred_currency_unit
466
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
467
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
468
+ }
469
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
470
+ __typename
471
+ currency_amount_original_value: original_value
472
+ currency_amount_original_unit: original_unit
473
+ currency_amount_preferred_currency_unit: preferred_currency_unit
474
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
475
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
476
+ }
477
+ }
321
478
  lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
322
479
  __typename
323
480
  secret_encrypted_value: encrypted_value
@@ -423,7 +580,52 @@ fragment NodeFragment on Node {
423
580
  }
424
581
  }
425
582
  lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
583
+ lightspark_node_with_remote_signing_balances: balances {
584
+ __typename
585
+ balances_owned_balance: owned_balance {
586
+ __typename
587
+ currency_amount_original_value: original_value
588
+ currency_amount_original_unit: original_unit
589
+ currency_amount_preferred_currency_unit: preferred_currency_unit
590
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
591
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
592
+ }
593
+ balances_available_to_send_balance: available_to_send_balance {
594
+ __typename
595
+ currency_amount_original_value: original_value
596
+ currency_amount_original_unit: original_unit
597
+ currency_amount_preferred_currency_unit: preferred_currency_unit
598
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
599
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
600
+ }
601
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
602
+ __typename
603
+ currency_amount_original_value: original_value
604
+ currency_amount_original_unit: original_unit
605
+ currency_amount_preferred_currency_unit: preferred_currency_unit
606
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
607
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
608
+ }
609
+ }
426
610
  }
427
611
  }`;
428
612
 
613
+ export const getNodeQuery = (id: string): Query<Node> => {
614
+ return {
615
+ queryPayload: `
616
+ query GetNode($id: ID!) {
617
+ entity(id: $id) {
618
+ ... on Node {
619
+ ...NodeFragment
620
+ }
621
+ }
622
+ }
623
+
624
+ ${FRAGMENT}
625
+ `,
626
+ variables: { id },
627
+ constructObject: (data: any) => NodeFromJson(data.entity),
628
+ };
629
+ };
630
+
429
631
  export default Node;
@@ -3,13 +3,13 @@
3
3
  import NodeAddressType from "./NodeAddressType.js";
4
4
 
5
5
  /** This object represents the address of a node on the Lightning Network. **/
6
- type NodeAddress = {
6
+ interface NodeAddress {
7
7
  /** The string representation of the address. **/
8
8
  address: string;
9
9
 
10
10
  /** The type, or protocol, of this address. **/
11
11
  type: NodeAddressType;
12
- };
12
+ }
13
13
 
14
14
  export const NodeAddressFromJson = (obj: any): NodeAddress => {
15
15
  return {
@@ -18,6 +18,12 @@ export const NodeAddressFromJson = (obj: any): NodeAddress => {
18
18
  NodeAddressType[obj["node_address_type"]] ?? NodeAddressType.FUTURE_VALUE,
19
19
  } as NodeAddress;
20
20
  };
21
+ export const NodeAddressToJson = (obj: NodeAddress): any => {
22
+ return {
23
+ node_address_address: obj.address,
24
+ node_address_type: obj.type,
25
+ };
26
+ };
21
27
 
22
28
  export const FRAGMENT = `
23
29
  fragment NodeAddressFragment on NodeAddress {
@@ -1,10 +1,10 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type NodeAddress from "./NodeAddress.js";
4
- import { NodeAddressFromJson } from "./NodeAddress.js";
4
+ import { NodeAddressFromJson, NodeAddressToJson } from "./NodeAddress.js";
5
5
 
6
6
  /** A connection between a node and the addresses it has announced for itself on Lightning Network. **/
7
- type NodeToAddressesConnection = {
7
+ interface NodeToAddressesConnection {
8
8
  /**
9
9
  * The total count of objects in this connection, using the current filters. It is different from the
10
10
  * number of objects returned in the current page (in the `entities` field).
@@ -13,7 +13,7 @@ type NodeToAddressesConnection = {
13
13
 
14
14
  /** The addresses for the current page of this connection. **/
15
15
  entities: NodeAddress[];
16
- };
16
+ }
17
17
 
18
18
  export const NodeToAddressesConnectionFromJson = (
19
19
  obj: any,
@@ -25,6 +25,16 @@ export const NodeToAddressesConnectionFromJson = (
25
25
  ),
26
26
  } as NodeToAddressesConnection;
27
27
  };
28
+ export const NodeToAddressesConnectionToJson = (
29
+ obj: NodeToAddressesConnection,
30
+ ): any => {
31
+ return {
32
+ node_to_addresses_connection_count: obj.count,
33
+ node_to_addresses_connection_entities: obj.entities.map((e) =>
34
+ NodeAddressToJson(e),
35
+ ),
36
+ };
37
+ };
28
38
 
29
39
  export const FRAGMENT = `
30
40
  fragment NodeToAddressesConnectionFragment on NodeToAddressesConnection {