@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
@@ -4,67 +4,67 @@ import { LightsparkException, type Query } from "@lightsparkdev/core";
4
4
  import type ChannelClosingTransaction from "./ChannelClosingTransaction.js";
5
5
  import type ChannelOpeningTransaction from "./ChannelOpeningTransaction.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
7
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import {
8
+ CurrencyAmountFromJson,
9
+ CurrencyAmountToJson,
10
+ } from "./CurrencyAmount.js";
8
11
  import type Deposit from "./Deposit.js";
9
- import type Entity from "./Entity.js";
10
- import type Transaction from "./Transaction.js";
11
12
  import TransactionStatus from "./TransactionStatus.js";
12
13
  import type Withdrawal from "./Withdrawal.js";
13
14
 
14
15
  /** This object represents an L1 transaction that occurred on the Bitcoin Network. You can retrieve this object to receive information about a specific on-chain transaction made on the Lightning Network associated with your Lightspark Node. **/
15
- type OnChainTransaction = Transaction &
16
- Entity & {
17
- /**
18
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
19
- * string.
20
- **/
21
- id: string;
16
+ interface OnChainTransaction {
17
+ /**
18
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
19
+ * string.
20
+ **/
21
+ id: string;
22
22
 
23
- /** The date and time when this transaction was initiated. **/
24
- createdAt: string;
23
+ /** The date and time when this transaction was initiated. **/
24
+ createdAt: string;
25
25
 
26
- /** The date and time when the entity was last updated. **/
27
- updatedAt: string;
26
+ /** The date and time when the entity was last updated. **/
27
+ updatedAt: string;
28
28
 
29
- /** The current status of this transaction. **/
30
- status: TransactionStatus;
29
+ /** The current status of this transaction. **/
30
+ status: TransactionStatus;
31
31
 
32
- /** The amount of money involved in this transaction. **/
33
- amount: CurrencyAmount;
32
+ /** The amount of money involved in this transaction. **/
33
+ amount: CurrencyAmount;
34
34
 
35
- /**
36
- * The height of the block that included this transaction. This will be zero for unconfirmed
37
- * transactions.
38
- **/
39
- blockHeight: number;
35
+ /**
36
+ * The height of the block that included this transaction. This will be zero for unconfirmed
37
+ * transactions.
38
+ **/
39
+ blockHeight: number;
40
40
 
41
- /** The Bitcoin blockchain addresses this transaction was sent to. **/
42
- destinationAddresses: string[];
41
+ /** The Bitcoin blockchain addresses this transaction was sent to. **/
42
+ destinationAddresses: string[];
43
43
 
44
- /** The typename of the object **/
45
- typename: string;
44
+ /** The typename of the object **/
45
+ typename: string;
46
46
 
47
- /** The date and time when this transaction was completed or failed. **/
48
- resolvedAt?: string;
47
+ /** The date and time when this transaction was completed or failed. **/
48
+ resolvedAt?: string | undefined;
49
49
 
50
- /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
51
- transactionHash?: string;
50
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
51
+ transactionHash?: string | undefined;
52
52
 
53
- /**
54
- * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
55
- * blockchain.
56
- **/
57
- fees?: CurrencyAmount;
53
+ /**
54
+ * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
55
+ * blockchain.
56
+ **/
57
+ fees?: CurrencyAmount | undefined;
58
58
 
59
- /**
60
- * The hash of the block that included this transaction. This will be null for unconfirmed
61
- * transactions.
62
- **/
63
- blockHash?: string;
59
+ /**
60
+ * The hash of the block that included this transaction. This will be null for unconfirmed
61
+ * transactions.
62
+ **/
63
+ blockHash?: string | undefined;
64
64
 
65
- /** The number of blockchain confirmations for this transaction in real time. **/
66
- numConfirmations?: number;
67
- };
65
+ /** The number of blockchain confirmations for this transaction in real time. **/
66
+ numConfirmations?: number | undefined;
67
+ }
68
68
 
69
69
  export const OnChainTransactionFromJson = (obj: any): OnChainTransaction => {
70
70
  if (obj["__typename"] == "ChannelClosingTransaction") {
@@ -162,6 +162,118 @@ export const OnChainTransactionFromJson = (obj: any): OnChainTransaction => {
162
162
  `Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename=${obj["__typename"]}`,
163
163
  );
164
164
  };
165
+ export const OnChainTransactionToJson = (obj: OnChainTransaction): any => {
166
+ if (obj.typename == "ChannelClosingTransaction") {
167
+ const channelClosingTransaction = obj as ChannelClosingTransaction;
168
+ return {
169
+ __typename: "ChannelClosingTransaction",
170
+ channel_closing_transaction_id: channelClosingTransaction.id,
171
+ channel_closing_transaction_created_at:
172
+ channelClosingTransaction.createdAt,
173
+ channel_closing_transaction_updated_at:
174
+ channelClosingTransaction.updatedAt,
175
+ channel_closing_transaction_status: channelClosingTransaction.status,
176
+ channel_closing_transaction_resolved_at:
177
+ channelClosingTransaction.resolvedAt,
178
+ channel_closing_transaction_amount: CurrencyAmountToJson(
179
+ channelClosingTransaction.amount,
180
+ ),
181
+ channel_closing_transaction_transaction_hash:
182
+ channelClosingTransaction.transactionHash,
183
+ channel_closing_transaction_fees: channelClosingTransaction.fees
184
+ ? CurrencyAmountToJson(channelClosingTransaction.fees)
185
+ : undefined,
186
+ channel_closing_transaction_block_hash:
187
+ channelClosingTransaction.blockHash,
188
+ channel_closing_transaction_block_height:
189
+ channelClosingTransaction.blockHeight,
190
+ channel_closing_transaction_destination_addresses:
191
+ channelClosingTransaction.destinationAddresses,
192
+ channel_closing_transaction_num_confirmations:
193
+ channelClosingTransaction.numConfirmations,
194
+ channel_closing_transaction_channel:
195
+ { id: channelClosingTransaction.channelId } ?? undefined,
196
+ };
197
+ }
198
+ if (obj.typename == "ChannelOpeningTransaction") {
199
+ const channelOpeningTransaction = obj as ChannelOpeningTransaction;
200
+ return {
201
+ __typename: "ChannelOpeningTransaction",
202
+ channel_opening_transaction_id: channelOpeningTransaction.id,
203
+ channel_opening_transaction_created_at:
204
+ channelOpeningTransaction.createdAt,
205
+ channel_opening_transaction_updated_at:
206
+ channelOpeningTransaction.updatedAt,
207
+ channel_opening_transaction_status: channelOpeningTransaction.status,
208
+ channel_opening_transaction_resolved_at:
209
+ channelOpeningTransaction.resolvedAt,
210
+ channel_opening_transaction_amount: CurrencyAmountToJson(
211
+ channelOpeningTransaction.amount,
212
+ ),
213
+ channel_opening_transaction_transaction_hash:
214
+ channelOpeningTransaction.transactionHash,
215
+ channel_opening_transaction_fees: channelOpeningTransaction.fees
216
+ ? CurrencyAmountToJson(channelOpeningTransaction.fees)
217
+ : undefined,
218
+ channel_opening_transaction_block_hash:
219
+ channelOpeningTransaction.blockHash,
220
+ channel_opening_transaction_block_height:
221
+ channelOpeningTransaction.blockHeight,
222
+ channel_opening_transaction_destination_addresses:
223
+ channelOpeningTransaction.destinationAddresses,
224
+ channel_opening_transaction_num_confirmations:
225
+ channelOpeningTransaction.numConfirmations,
226
+ channel_opening_transaction_channel:
227
+ { id: channelOpeningTransaction.channelId } ?? undefined,
228
+ };
229
+ }
230
+ if (obj.typename == "Deposit") {
231
+ const deposit = obj as Deposit;
232
+ return {
233
+ __typename: "Deposit",
234
+ deposit_id: deposit.id,
235
+ deposit_created_at: deposit.createdAt,
236
+ deposit_updated_at: deposit.updatedAt,
237
+ deposit_status: deposit.status,
238
+ deposit_resolved_at: deposit.resolvedAt,
239
+ deposit_amount: CurrencyAmountToJson(deposit.amount),
240
+ deposit_transaction_hash: deposit.transactionHash,
241
+ deposit_fees: deposit.fees
242
+ ? CurrencyAmountToJson(deposit.fees)
243
+ : undefined,
244
+ deposit_block_hash: deposit.blockHash,
245
+ deposit_block_height: deposit.blockHeight,
246
+ deposit_destination_addresses: deposit.destinationAddresses,
247
+ deposit_num_confirmations: deposit.numConfirmations,
248
+ deposit_destination: { id: deposit.destinationId },
249
+ };
250
+ }
251
+ if (obj.typename == "Withdrawal") {
252
+ const withdrawal = obj as Withdrawal;
253
+ return {
254
+ __typename: "Withdrawal",
255
+ withdrawal_id: withdrawal.id,
256
+ withdrawal_created_at: withdrawal.createdAt,
257
+ withdrawal_updated_at: withdrawal.updatedAt,
258
+ withdrawal_status: withdrawal.status,
259
+ withdrawal_resolved_at: withdrawal.resolvedAt,
260
+ withdrawal_amount: CurrencyAmountToJson(withdrawal.amount),
261
+ withdrawal_transaction_hash: withdrawal.transactionHash,
262
+ withdrawal_fees: withdrawal.fees
263
+ ? CurrencyAmountToJson(withdrawal.fees)
264
+ : undefined,
265
+ withdrawal_block_hash: withdrawal.blockHash,
266
+ withdrawal_block_height: withdrawal.blockHeight,
267
+ withdrawal_destination_addresses: withdrawal.destinationAddresses,
268
+ withdrawal_num_confirmations: withdrawal.numConfirmations,
269
+ withdrawal_origin: { id: withdrawal.originId },
270
+ };
271
+ }
272
+ throw new LightsparkException(
273
+ "DeserializationError",
274
+ `Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename=${obj.typename}`,
275
+ );
276
+ };
165
277
 
166
278
  export const FRAGMENT = `
167
279
  fragment OnChainTransactionFragment on OnChainTransaction {
@@ -4,21 +4,32 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
7
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import {
8
+ CurrencyAmountFromJson,
9
+ CurrencyAmountToJson,
10
+ } from "./CurrencyAmount.js";
11
+ import type Entity from "./Entity.js";
8
12
  import type LightningTransaction from "./LightningTransaction.js";
9
13
  import type OutgoingPaymentToAttemptsConnection from "./OutgoingPaymentToAttemptsConnection.js";
10
14
  import { OutgoingPaymentToAttemptsConnectionFromJson } from "./OutgoingPaymentToAttemptsConnection.js";
11
15
  import PaymentFailureReason from "./PaymentFailureReason.js";
12
16
  import type PaymentRequestData from "./PaymentRequestData.js";
13
- import { PaymentRequestDataFromJson } from "./PaymentRequestData.js";
17
+ import {
18
+ PaymentRequestDataFromJson,
19
+ PaymentRequestDataToJson,
20
+ } from "./PaymentRequestData.js";
14
21
  import type PostTransactionData from "./PostTransactionData.js";
15
- import { PostTransactionDataFromJson } from "./PostTransactionData.js";
22
+ import {
23
+ PostTransactionDataFromJson,
24
+ PostTransactionDataToJson,
25
+ } from "./PostTransactionData.js";
16
26
  import type RichText from "./RichText.js";
17
- import { RichTextFromJson } from "./RichText.js";
27
+ import { RichTextFromJson, RichTextToJson } from "./RichText.js";
28
+ import type Transaction from "./Transaction.js";
18
29
  import TransactionStatus from "./TransactionStatus.js";
19
30
 
20
31
  /** This object represents a Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment sent from your Lightspark Node on the Lightning Network. **/
21
- class OutgoingPayment implements LightningTransaction {
32
+ class OutgoingPayment implements LightningTransaction, Transaction, Entity {
22
33
  constructor(
23
34
  public readonly id: string,
24
35
  public readonly createdAt: string,
@@ -27,15 +38,15 @@ class OutgoingPayment implements LightningTransaction {
27
38
  public readonly amount: CurrencyAmount,
28
39
  public readonly originId: string,
29
40
  public readonly typename: string,
30
- public readonly resolvedAt?: string,
31
- public readonly transactionHash?: string,
32
- public readonly destinationId?: string,
33
- public readonly fees?: CurrencyAmount,
34
- public readonly paymentRequestData?: PaymentRequestData,
35
- public readonly failureReason?: PaymentFailureReason,
36
- public readonly failureMessage?: RichText,
37
- public readonly umaPostTransactionData?: PostTransactionData[],
38
- public readonly paymentPreimage?: string,
41
+ public readonly resolvedAt?: string | undefined,
42
+ public readonly transactionHash?: string | undefined,
43
+ public readonly destinationId?: string | undefined,
44
+ public readonly fees?: CurrencyAmount | undefined,
45
+ public readonly paymentRequestData?: PaymentRequestData | undefined,
46
+ public readonly failureReason?: PaymentFailureReason | undefined,
47
+ public readonly failureMessage?: RichText | undefined,
48
+ public readonly umaPostTransactionData?: PostTransactionData[] | undefined,
49
+ public readonly paymentPreimage?: string | undefined,
39
50
  ) {
40
51
  autoBind(this);
41
52
  }
@@ -90,6 +101,10 @@ query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $af
90
101
  }
91
102
  outgoing_payment_attempt_channel_snapshot: channel_snapshot {
92
103
  __typename
104
+ channel_snapshot_channel: channel {
105
+ id
106
+ }
107
+ channel_snapshot_timestamp: timestamp
93
108
  channel_snapshot_local_balance: local_balance {
94
109
  __typename
95
110
  currency_amount_original_value: original_value
@@ -114,6 +129,22 @@ query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $af
114
129
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
115
130
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
116
131
  }
132
+ channel_snapshot_remote_balance: remote_balance {
133
+ __typename
134
+ currency_amount_original_value: original_value
135
+ currency_amount_original_unit: original_unit
136
+ currency_amount_preferred_currency_unit: preferred_currency_unit
137
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
138
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
139
+ }
140
+ channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
141
+ __typename
142
+ currency_amount_original_value: original_value
143
+ currency_amount_original_unit: original_unit
144
+ currency_amount_preferred_currency_unit: preferred_currency_unit
145
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
146
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
147
+ }
117
148
  }
118
149
  }
119
150
  }
@@ -146,6 +177,34 @@ ${FRAGMENT}
146
177
  constructObject: (data: any) => OutgoingPaymentFromJson(data.entity),
147
178
  };
148
179
  }
180
+
181
+ public toJson() {
182
+ return {
183
+ __typename: "OutgoingPayment",
184
+ outgoing_payment_id: this.id,
185
+ outgoing_payment_created_at: this.createdAt,
186
+ outgoing_payment_updated_at: this.updatedAt,
187
+ outgoing_payment_status: this.status,
188
+ outgoing_payment_resolved_at: this.resolvedAt,
189
+ outgoing_payment_amount: CurrencyAmountToJson(this.amount),
190
+ outgoing_payment_transaction_hash: this.transactionHash,
191
+ outgoing_payment_origin: { id: this.originId },
192
+ outgoing_payment_destination: { id: this.destinationId } ?? undefined,
193
+ outgoing_payment_fees: this.fees
194
+ ? CurrencyAmountToJson(this.fees)
195
+ : undefined,
196
+ outgoing_payment_payment_request_data: this.paymentRequestData
197
+ ? PaymentRequestDataToJson(this.paymentRequestData)
198
+ : undefined,
199
+ outgoing_payment_failure_reason: this.failureReason,
200
+ outgoing_payment_failure_message: this.failureMessage
201
+ ? RichTextToJson(this.failureMessage)
202
+ : undefined,
203
+ outgoing_payment_uma_post_transaction_data:
204
+ this.umaPostTransactionData?.map((e) => PostTransactionDataToJson(e)),
205
+ outgoing_payment_payment_preimage: this.paymentPreimage,
206
+ };
207
+ }
149
208
  }
150
209
 
151
210
  export const OutgoingPaymentFromJson = (obj: any): OutgoingPayment => {
@@ -343,6 +402,33 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
343
402
  }
344
403
  }
345
404
  lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
405
+ lightspark_node_with_o_s_k_balances: balances {
406
+ __typename
407
+ balances_owned_balance: owned_balance {
408
+ __typename
409
+ currency_amount_original_value: original_value
410
+ currency_amount_original_unit: original_unit
411
+ currency_amount_preferred_currency_unit: preferred_currency_unit
412
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
413
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
414
+ }
415
+ balances_available_to_send_balance: available_to_send_balance {
416
+ __typename
417
+ currency_amount_original_value: original_value
418
+ currency_amount_original_unit: original_unit
419
+ currency_amount_preferred_currency_unit: preferred_currency_unit
420
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
421
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
422
+ }
423
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
424
+ __typename
425
+ currency_amount_original_value: original_value
426
+ currency_amount_original_unit: original_unit
427
+ currency_amount_preferred_currency_unit: preferred_currency_unit
428
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
429
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
430
+ }
431
+ }
346
432
  lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
347
433
  __typename
348
434
  secret_encrypted_value: encrypted_value
@@ -448,6 +534,33 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
448
534
  }
449
535
  }
450
536
  lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
537
+ lightspark_node_with_remote_signing_balances: balances {
538
+ __typename
539
+ balances_owned_balance: owned_balance {
540
+ __typename
541
+ currency_amount_original_value: original_value
542
+ currency_amount_original_unit: original_unit
543
+ currency_amount_preferred_currency_unit: preferred_currency_unit
544
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
545
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
546
+ }
547
+ balances_available_to_send_balance: available_to_send_balance {
548
+ __typename
549
+ currency_amount_original_value: original_value
550
+ currency_amount_original_unit: original_unit
551
+ currency_amount_preferred_currency_unit: preferred_currency_unit
552
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
553
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
554
+ }
555
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
556
+ __typename
557
+ currency_amount_original_value: original_value
558
+ currency_amount_original_unit: original_unit
559
+ currency_amount_preferred_currency_unit: preferred_currency_unit
560
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
561
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
562
+ }
563
+ }
451
564
  }
452
565
  }
453
566
  }
@@ -4,9 +4,15 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type ChannelSnapshot from "./ChannelSnapshot.js";
7
- import { ChannelSnapshotFromJson } from "./ChannelSnapshot.js";
7
+ import {
8
+ ChannelSnapshotFromJson,
9
+ ChannelSnapshotToJson,
10
+ } from "./ChannelSnapshot.js";
8
11
  import type CurrencyAmount from "./CurrencyAmount.js";
9
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
12
+ import {
13
+ CurrencyAmountFromJson,
14
+ CurrencyAmountToJson,
15
+ } from "./CurrencyAmount.js";
10
16
  import type Entity from "./Entity.js";
11
17
  import HtlcAttemptFailureCode from "./HtlcAttemptFailureCode.js";
12
18
  import OutgoingPaymentAttemptStatus from "./OutgoingPaymentAttemptStatus.js";
@@ -22,12 +28,12 @@ class OutgoingPaymentAttempt implements Entity {
22
28
  public readonly status: OutgoingPaymentAttemptStatus,
23
29
  public readonly outgoingPaymentId: string,
24
30
  public readonly typename: string,
25
- public readonly failureCode?: HtlcAttemptFailureCode,
26
- public readonly failureSourceIndex?: number,
27
- public readonly resolvedAt?: string,
28
- public readonly amount?: CurrencyAmount,
29
- public readonly fees?: CurrencyAmount,
30
- public readonly channelSnapshot?: ChannelSnapshot,
31
+ public readonly failureCode?: HtlcAttemptFailureCode | undefined,
32
+ public readonly failureSourceIndex?: number | undefined,
33
+ public readonly resolvedAt?: string | undefined,
34
+ public readonly amount?: CurrencyAmount | undefined,
35
+ public readonly fees?: CurrencyAmount | undefined,
36
+ public readonly channelSnapshot?: ChannelSnapshot | undefined,
31
37
  ) {
32
38
  autoBind(this);
33
39
  }
@@ -113,6 +119,29 @@ ${FRAGMENT}
113
119
  OutgoingPaymentAttemptFromJson(data.entity),
114
120
  };
115
121
  }
122
+
123
+ public toJson() {
124
+ return {
125
+ __typename: "OutgoingPaymentAttempt",
126
+ outgoing_payment_attempt_id: this.id,
127
+ outgoing_payment_attempt_created_at: this.createdAt,
128
+ outgoing_payment_attempt_updated_at: this.updatedAt,
129
+ outgoing_payment_attempt_status: this.status,
130
+ outgoing_payment_attempt_failure_code: this.failureCode,
131
+ outgoing_payment_attempt_failure_source_index: this.failureSourceIndex,
132
+ outgoing_payment_attempt_resolved_at: this.resolvedAt,
133
+ outgoing_payment_attempt_amount: this.amount
134
+ ? CurrencyAmountToJson(this.amount)
135
+ : undefined,
136
+ outgoing_payment_attempt_fees: this.fees
137
+ ? CurrencyAmountToJson(this.fees)
138
+ : undefined,
139
+ outgoing_payment_attempt_outgoing_payment: { id: this.outgoingPaymentId },
140
+ outgoing_payment_attempt_channel_snapshot: this.channelSnapshot
141
+ ? ChannelSnapshotToJson(this.channelSnapshot)
142
+ : undefined,
143
+ };
144
+ }
116
145
  }
117
146
 
118
147
  export const OutgoingPaymentAttemptFromJson = (
@@ -177,6 +206,10 @@ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt {
177
206
  }
178
207
  outgoing_payment_attempt_channel_snapshot: channel_snapshot {
179
208
  __typename
209
+ channel_snapshot_channel: channel {
210
+ id
211
+ }
212
+ channel_snapshot_timestamp: timestamp
180
213
  channel_snapshot_local_balance: local_balance {
181
214
  __typename
182
215
  currency_amount_original_value: original_value
@@ -201,6 +234,22 @@ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt {
201
234
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
202
235
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
203
236
  }
237
+ channel_snapshot_remote_balance: remote_balance {
238
+ __typename
239
+ currency_amount_original_value: original_value
240
+ currency_amount_original_unit: original_unit
241
+ currency_amount_preferred_currency_unit: preferred_currency_unit
242
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
243
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
244
+ }
245
+ channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
246
+ __typename
247
+ currency_amount_original_value: original_value
248
+ currency_amount_original_unit: original_unit
249
+ currency_amount_preferred_currency_unit: preferred_currency_unit
250
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
251
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
252
+ }
204
253
  }
205
254
  }`;
206
255
 
@@ -1,13 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type Connection from "./Connection.js";
4
3
  import type Hop from "./Hop.js";
5
- import { HopFromJson } from "./Hop.js";
4
+ import { HopFromJson, HopToJson } from "./Hop.js";
6
5
  import type PageInfo from "./PageInfo.js";
7
- import { PageInfoFromJson } from "./PageInfo.js";
6
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
8
7
 
9
8
  /** The connection from an outgoing payment attempt to the list of sequential hops that define the path from sender node to recipient node. **/
10
- type OutgoingPaymentAttemptToHopsConnection = Connection & {
9
+ interface OutgoingPaymentAttemptToHopsConnection {
11
10
  /**
12
11
  * The total count of objects in this connection, using the current filters. It is different from the
13
12
  * number of objects returned in the current page (in the `entities` field).
@@ -22,7 +21,7 @@ type OutgoingPaymentAttemptToHopsConnection = Connection & {
22
21
 
23
22
  /** The typename of the object **/
24
23
  typename: string;
25
- };
24
+ }
26
25
 
27
26
  export const OutgoingPaymentAttemptToHopsConnectionFromJson = (
28
27
  obj: any,
@@ -38,6 +37,20 @@ export const OutgoingPaymentAttemptToHopsConnectionFromJson = (
38
37
  typename: "OutgoingPaymentAttemptToHopsConnection",
39
38
  } as OutgoingPaymentAttemptToHopsConnection;
40
39
  };
40
+ export const OutgoingPaymentAttemptToHopsConnectionToJson = (
41
+ obj: OutgoingPaymentAttemptToHopsConnection,
42
+ ): any => {
43
+ return {
44
+ __typename: "OutgoingPaymentAttemptToHopsConnection",
45
+ outgoing_payment_attempt_to_hops_connection_count: obj.count,
46
+ outgoing_payment_attempt_to_hops_connection_page_info: PageInfoToJson(
47
+ obj.pageInfo,
48
+ ),
49
+ outgoing_payment_attempt_to_hops_connection_entities: obj.entities.map(
50
+ (e) => HopToJson(e),
51
+ ),
52
+ };
53
+ };
41
54
 
42
55
  export const FRAGMENT = `
43
56
  fragment OutgoingPaymentAttemptToHopsConnectionFragment on OutgoingPaymentAttemptToHopsConnection {
@@ -1,13 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type Connection from "./Connection.js";
4
3
  import type OutgoingPaymentAttempt from "./OutgoingPaymentAttempt.js";
5
4
  import { OutgoingPaymentAttemptFromJson } from "./OutgoingPaymentAttempt.js";
6
5
  import type PageInfo from "./PageInfo.js";
7
- import { PageInfoFromJson } from "./PageInfo.js";
6
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
8
7
 
9
8
  /** The connection from outgoing payment to all attempts. **/
10
- type OutgoingPaymentToAttemptsConnection = Connection & {
9
+ interface OutgoingPaymentToAttemptsConnection {
11
10
  /**
12
11
  * The total count of objects in this connection, using the current filters. It is different from the
13
12
  * number of objects returned in the current page (in the `entities` field).
@@ -22,7 +21,7 @@ type OutgoingPaymentToAttemptsConnection = Connection & {
22
21
 
23
22
  /** The typename of the object **/
24
23
  typename: string;
25
- };
24
+ }
26
25
 
27
26
  export const OutgoingPaymentToAttemptsConnectionFromJson = (
28
27
  obj: any,
@@ -38,6 +37,20 @@ export const OutgoingPaymentToAttemptsConnectionFromJson = (
38
37
  typename: "OutgoingPaymentToAttemptsConnection",
39
38
  } as OutgoingPaymentToAttemptsConnection;
40
39
  };
40
+ export const OutgoingPaymentToAttemptsConnectionToJson = (
41
+ obj: OutgoingPaymentToAttemptsConnection,
42
+ ): any => {
43
+ return {
44
+ __typename: "OutgoingPaymentToAttemptsConnection",
45
+ outgoing_payment_to_attempts_connection_count: obj.count,
46
+ outgoing_payment_to_attempts_connection_page_info: PageInfoToJson(
47
+ obj.pageInfo,
48
+ ),
49
+ outgoing_payment_to_attempts_connection_entities: obj.entities.map((e) =>
50
+ e.toJson(),
51
+ ),
52
+ };
53
+ };
41
54
 
42
55
  export const FRAGMENT = `
43
56
  fragment OutgoingPaymentToAttemptsConnectionFragment on OutgoingPaymentToAttemptsConnection {
@@ -2,13 +2,13 @@
2
2
 
3
3
  import TransactionStatus from "./TransactionStatus.js";
4
4
 
5
- type OutgoingPaymentsForInvoiceQueryInput = {
5
+ interface OutgoingPaymentsForInvoiceQueryInput {
6
6
  /** The encoded invoice that the outgoing payments paid to. **/
7
7
  encodedInvoice: string;
8
8
 
9
9
  /** An optional filter to only query outgoing payments of given statuses. **/
10
- statuses?: TransactionStatus[];
11
- };
10
+ statuses?: TransactionStatus[] | undefined;
11
+ }
12
12
 
13
13
  export const OutgoingPaymentsForInvoiceQueryInputFromJson = (
14
14
  obj: any,
@@ -21,5 +21,14 @@ export const OutgoingPaymentsForInvoiceQueryInputFromJson = (
21
21
  ),
22
22
  } as OutgoingPaymentsForInvoiceQueryInput;
23
23
  };
24
+ export const OutgoingPaymentsForInvoiceQueryInputToJson = (
25
+ obj: OutgoingPaymentsForInvoiceQueryInput,
26
+ ): any => {
27
+ return {
28
+ outgoing_payments_for_invoice_query_input_encoded_invoice:
29
+ obj.encodedInvoice,
30
+ outgoing_payments_for_invoice_query_input_statuses: obj.statuses,
31
+ };
32
+ };
24
33
 
25
34
  export default OutgoingPaymentsForInvoiceQueryInput;