@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,10 +1,13 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
9
  /** This is an object representing the balance associated with your Lightspark account. You can retrieve this object to see your balance, which can be broken down into several different categorizations. **/
7
- type Balances = {
10
+ interface Balances {
8
11
  /**
9
12
  * This represents the balance that should be displayed when asked "how much do I own right now?". It
10
13
  * represents the amount currently owned, including things that may not be owned soon (e.g. in-flight
@@ -27,7 +30,7 @@ type Balances = {
27
30
  * likely succeed and therefore likely make your withdrawal fail).
28
31
  **/
29
32
  availableToWithdrawBalance: CurrencyAmount;
30
- };
33
+ }
31
34
 
32
35
  export const BalancesFromJson = (obj: any): Balances => {
33
36
  return {
@@ -40,6 +43,17 @@ export const BalancesFromJson = (obj: any): Balances => {
40
43
  ),
41
44
  } as Balances;
42
45
  };
46
+ export const BalancesToJson = (obj: Balances): any => {
47
+ return {
48
+ balances_owned_balance: CurrencyAmountToJson(obj.ownedBalance),
49
+ balances_available_to_send_balance: CurrencyAmountToJson(
50
+ obj.availableToSendBalance,
51
+ ),
52
+ balances_available_to_withdraw_balance: CurrencyAmountToJson(
53
+ obj.availableToWithdrawBalance,
54
+ ),
55
+ };
56
+ };
43
57
 
44
58
  export const FRAGMENT = `
45
59
  fragment BalancesFragment on Balances {
@@ -1,28 +1,31 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
9
  /** This is an object representing a detailed breakdown of the balance for a Lightspark Node. **/
7
- type BlockchainBalance = {
10
+ interface BlockchainBalance {
8
11
  /** The total wallet balance, including unconfirmed UTXOs. **/
9
- totalBalance?: CurrencyAmount;
12
+ totalBalance?: CurrencyAmount | undefined;
10
13
 
11
14
  /** The balance of confirmed UTXOs in the wallet. **/
12
- confirmedBalance?: CurrencyAmount;
15
+ confirmedBalance?: CurrencyAmount | undefined;
13
16
 
14
17
  /** The balance of unconfirmed UTXOs in the wallet. **/
15
- unconfirmedBalance?: CurrencyAmount;
18
+ unconfirmedBalance?: CurrencyAmount | undefined;
16
19
 
17
20
  /** The balance that's locked by an on-chain transaction. **/
18
- lockedBalance?: CurrencyAmount;
21
+ lockedBalance?: CurrencyAmount | undefined;
19
22
 
20
23
  /** Funds required to be held in reserve for channel bumping. **/
21
- requiredReserve?: CurrencyAmount;
24
+ requiredReserve?: CurrencyAmount | undefined;
22
25
 
23
26
  /** Funds available for creating channels or withdrawing. **/
24
- availableBalance?: CurrencyAmount;
25
- };
27
+ availableBalance?: CurrencyAmount | undefined;
28
+ }
26
29
 
27
30
  export const BlockchainBalanceFromJson = (obj: any): BlockchainBalance => {
28
31
  return {
@@ -46,6 +49,28 @@ export const BlockchainBalanceFromJson = (obj: any): BlockchainBalance => {
46
49
  : undefined,
47
50
  } as BlockchainBalance;
48
51
  };
52
+ export const BlockchainBalanceToJson = (obj: BlockchainBalance): any => {
53
+ return {
54
+ blockchain_balance_total_balance: obj.totalBalance
55
+ ? CurrencyAmountToJson(obj.totalBalance)
56
+ : undefined,
57
+ blockchain_balance_confirmed_balance: obj.confirmedBalance
58
+ ? CurrencyAmountToJson(obj.confirmedBalance)
59
+ : undefined,
60
+ blockchain_balance_unconfirmed_balance: obj.unconfirmedBalance
61
+ ? CurrencyAmountToJson(obj.unconfirmedBalance)
62
+ : undefined,
63
+ blockchain_balance_locked_balance: obj.lockedBalance
64
+ ? CurrencyAmountToJson(obj.lockedBalance)
65
+ : undefined,
66
+ blockchain_balance_required_reserve: obj.requiredReserve
67
+ ? CurrencyAmountToJson(obj.requiredReserve)
68
+ : undefined,
69
+ blockchain_balance_available_balance: obj.availableBalance
70
+ ? CurrencyAmountToJson(obj.availableBalance)
71
+ : undefined,
72
+ };
73
+ };
49
74
 
50
75
  export const FRAGMENT = `
51
76
  fragment BlockchainBalanceFragment on BlockchainBalance {
@@ -4,12 +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 ChannelFees from "./ChannelFees.js";
7
- import { ChannelFeesFromJson } from "./ChannelFees.js";
7
+ import { ChannelFeesFromJson, ChannelFeesToJson } from "./ChannelFees.js";
8
8
  import ChannelStatus from "./ChannelStatus.js";
9
9
  import type ChannelToTransactionsConnection from "./ChannelToTransactionsConnection.js";
10
10
  import { ChannelToTransactionsConnectionFromJson } from "./ChannelToTransactionsConnection.js";
11
11
  import type CurrencyAmount from "./CurrencyAmount.js";
12
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
12
+ import {
13
+ CurrencyAmountFromJson,
14
+ CurrencyAmountToJson,
15
+ } from "./CurrencyAmount.js";
13
16
  import type Entity from "./Entity.js";
14
17
  import type TransactionType from "./TransactionType.js";
15
18
 
@@ -21,20 +24,20 @@ class Channel implements Entity {
21
24
  public readonly updatedAt: string,
22
25
  public readonly localNodeId: string,
23
26
  public readonly typename: string,
24
- public readonly fundingTransactionId?: string,
25
- public readonly capacity?: CurrencyAmount,
26
- public readonly localBalance?: CurrencyAmount,
27
- public readonly localUnsettledBalance?: CurrencyAmount,
28
- public readonly remoteBalance?: CurrencyAmount,
29
- public readonly remoteUnsettledBalance?: CurrencyAmount,
30
- public readonly unsettledBalance?: CurrencyAmount,
31
- public readonly totalBalance?: CurrencyAmount,
32
- public readonly status?: ChannelStatus,
33
- public readonly estimatedForceClosureWaitMinutes?: number,
34
- public readonly commitFee?: CurrencyAmount,
35
- public readonly fees?: ChannelFees,
36
- public readonly remoteNodeId?: string,
37
- public readonly shortChannelId?: string,
27
+ public readonly fundingTransactionId?: string | undefined,
28
+ public readonly capacity?: CurrencyAmount | undefined,
29
+ public readonly localBalance?: CurrencyAmount | undefined,
30
+ public readonly localUnsettledBalance?: CurrencyAmount | undefined,
31
+ public readonly remoteBalance?: CurrencyAmount | undefined,
32
+ public readonly remoteUnsettledBalance?: CurrencyAmount | undefined,
33
+ public readonly unsettledBalance?: CurrencyAmount | undefined,
34
+ public readonly totalBalance?: CurrencyAmount | undefined,
35
+ public readonly status?: ChannelStatus | undefined,
36
+ public readonly estimatedForceClosureWaitMinutes?: number | undefined,
37
+ public readonly commitFee?: CurrencyAmount | undefined,
38
+ public readonly fees?: ChannelFees | undefined,
39
+ public readonly remoteNodeId?: string | undefined,
40
+ public readonly shortChannelId?: string | undefined,
38
41
  ) {
39
42
  autoBind(this);
40
43
  }
@@ -139,6 +142,48 @@ ${FRAGMENT}
139
142
  constructObject: (data: any) => ChannelFromJson(data.entity),
140
143
  };
141
144
  }
145
+
146
+ public toJson() {
147
+ return {
148
+ __typename: "Channel",
149
+ channel_id: this.id,
150
+ channel_created_at: this.createdAt,
151
+ channel_updated_at: this.updatedAt,
152
+ channel_funding_transaction:
153
+ { id: this.fundingTransactionId } ?? undefined,
154
+ channel_capacity: this.capacity
155
+ ? CurrencyAmountToJson(this.capacity)
156
+ : undefined,
157
+ channel_local_balance: this.localBalance
158
+ ? CurrencyAmountToJson(this.localBalance)
159
+ : undefined,
160
+ channel_local_unsettled_balance: this.localUnsettledBalance
161
+ ? CurrencyAmountToJson(this.localUnsettledBalance)
162
+ : undefined,
163
+ channel_remote_balance: this.remoteBalance
164
+ ? CurrencyAmountToJson(this.remoteBalance)
165
+ : undefined,
166
+ channel_remote_unsettled_balance: this.remoteUnsettledBalance
167
+ ? CurrencyAmountToJson(this.remoteUnsettledBalance)
168
+ : undefined,
169
+ channel_unsettled_balance: this.unsettledBalance
170
+ ? CurrencyAmountToJson(this.unsettledBalance)
171
+ : undefined,
172
+ channel_total_balance: this.totalBalance
173
+ ? CurrencyAmountToJson(this.totalBalance)
174
+ : undefined,
175
+ channel_status: this.status,
176
+ channel_estimated_force_closure_wait_minutes:
177
+ this.estimatedForceClosureWaitMinutes,
178
+ channel_commit_fee: this.commitFee
179
+ ? CurrencyAmountToJson(this.commitFee)
180
+ : undefined,
181
+ channel_fees: this.fees ? ChannelFeesToJson(this.fees) : undefined,
182
+ channel_remote_node: { id: this.remoteNodeId } ?? undefined,
183
+ channel_local_node: { id: this.localNodeId },
184
+ channel_short_channel_id: this.shortChannelId,
185
+ };
186
+ }
142
187
  }
143
188
 
144
189
  export const ChannelFromJson = (obj: any): Channel => {
@@ -2,70 +2,68 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
7
- import type OnChainTransaction from "./OnChainTransaction.js";
8
- import type Transaction from "./Transaction.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
9
9
  import TransactionStatus from "./TransactionStatus.js";
10
10
 
11
11
  /** This is an object representing a transaction which closes a channel on the Lightning Network. This operation allocates balances back to the local and remote nodes. **/
12
- type ChannelClosingTransaction = OnChainTransaction &
13
- Transaction &
14
- Entity & {
15
- /**
16
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
17
- * string.
18
- **/
19
- id: string;
20
-
21
- /** The date and time when this transaction was initiated. **/
22
- createdAt: string;
23
-
24
- /** The date and time when the entity was last updated. **/
25
- updatedAt: string;
26
-
27
- /** The current status of this transaction. **/
28
- status: TransactionStatus;
29
-
30
- /** The amount of money involved in this transaction. **/
31
- amount: CurrencyAmount;
32
-
33
- /**
34
- * The height of the block that included this transaction. This will be zero for unconfirmed
35
- * transactions.
36
- **/
37
- blockHeight: number;
38
-
39
- /** The Bitcoin blockchain addresses this transaction was sent to. **/
40
- destinationAddresses: string[];
41
-
42
- /** The typename of the object **/
43
- typename: string;
44
-
45
- /** The date and time when this transaction was completed or failed. **/
46
- resolvedAt?: string;
47
-
48
- /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
49
- transactionHash?: string;
50
-
51
- /**
52
- * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
53
- * blockchain.
54
- **/
55
- fees?: CurrencyAmount;
56
-
57
- /**
58
- * The hash of the block that included this transaction. This will be null for unconfirmed
59
- * transactions.
60
- **/
61
- blockHash?: string;
62
-
63
- /** The number of blockchain confirmations for this transaction in real time. **/
64
- numConfirmations?: number;
65
-
66
- /** If known, the channel this transaction is closing. **/
67
- channelId?: string;
68
- };
12
+ interface ChannelClosingTransaction {
13
+ /**
14
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
15
+ * string.
16
+ **/
17
+ id: string;
18
+
19
+ /** The date and time when this transaction was initiated. **/
20
+ createdAt: string;
21
+
22
+ /** The date and time when the entity was last updated. **/
23
+ updatedAt: string;
24
+
25
+ /** The current status of this transaction. **/
26
+ status: TransactionStatus;
27
+
28
+ /** The amount of money involved in this transaction. **/
29
+ amount: CurrencyAmount;
30
+
31
+ /**
32
+ * The height of the block that included this transaction. This will be zero for unconfirmed
33
+ * transactions.
34
+ **/
35
+ blockHeight: number;
36
+
37
+ /** The Bitcoin blockchain addresses this transaction was sent to. **/
38
+ destinationAddresses: string[];
39
+
40
+ /** The typename of the object **/
41
+ typename: string;
42
+
43
+ /** The date and time when this transaction was completed or failed. **/
44
+ resolvedAt?: string | undefined;
45
+
46
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
47
+ transactionHash?: string | undefined;
48
+
49
+ /**
50
+ * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
51
+ * blockchain.
52
+ **/
53
+ fees?: CurrencyAmount | undefined;
54
+
55
+ /**
56
+ * The hash of the block that included this transaction. This will be null for unconfirmed
57
+ * transactions.
58
+ **/
59
+ blockHash?: string | undefined;
60
+
61
+ /** The number of blockchain confirmations for this transaction in real time. **/
62
+ numConfirmations?: number | undefined;
63
+
64
+ /** If known, the channel this transaction is closing. **/
65
+ channelId?: string | undefined;
66
+ }
69
67
 
70
68
  export const ChannelClosingTransactionFromJson = (
71
69
  obj: any,
@@ -92,6 +90,28 @@ export const ChannelClosingTransactionFromJson = (
92
90
  channelId: obj["channel_closing_transaction_channel"]?.id ?? undefined,
93
91
  } as ChannelClosingTransaction;
94
92
  };
93
+ export const ChannelClosingTransactionToJson = (
94
+ obj: ChannelClosingTransaction,
95
+ ): any => {
96
+ return {
97
+ __typename: "ChannelClosingTransaction",
98
+ channel_closing_transaction_id: obj.id,
99
+ channel_closing_transaction_created_at: obj.createdAt,
100
+ channel_closing_transaction_updated_at: obj.updatedAt,
101
+ channel_closing_transaction_status: obj.status,
102
+ channel_closing_transaction_resolved_at: obj.resolvedAt,
103
+ channel_closing_transaction_amount: CurrencyAmountToJson(obj.amount),
104
+ channel_closing_transaction_transaction_hash: obj.transactionHash,
105
+ channel_closing_transaction_fees: obj.fees
106
+ ? CurrencyAmountToJson(obj.fees)
107
+ : undefined,
108
+ channel_closing_transaction_block_hash: obj.blockHash,
109
+ channel_closing_transaction_block_height: obj.blockHeight,
110
+ channel_closing_transaction_destination_addresses: obj.destinationAddresses,
111
+ channel_closing_transaction_num_confirmations: obj.numConfirmations,
112
+ channel_closing_transaction_channel: { id: obj.channelId } ?? undefined,
113
+ };
114
+ };
95
115
 
96
116
  export const FRAGMENT = `
97
117
  fragment ChannelClosingTransactionFragment on ChannelClosingTransaction {
@@ -1,14 +1,17 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
9
  /** This represents the fee policies set for a channel on the Lightning Network. **/
7
- type ChannelFees = {
8
- baseFee?: CurrencyAmount;
10
+ interface ChannelFees {
11
+ baseFee?: CurrencyAmount | undefined;
9
12
 
10
- feeRatePerMil?: number;
11
- };
13
+ feeRatePerMil?: number | undefined;
14
+ }
12
15
 
13
16
  export const ChannelFeesFromJson = (obj: any): ChannelFees => {
14
17
  return {
@@ -18,6 +21,14 @@ export const ChannelFeesFromJson = (obj: any): ChannelFees => {
18
21
  feeRatePerMil: obj["channel_fees_fee_rate_per_mil"],
19
22
  } as ChannelFees;
20
23
  };
24
+ export const ChannelFeesToJson = (obj: ChannelFees): any => {
25
+ return {
26
+ channel_fees_base_fee: obj.baseFee
27
+ ? CurrencyAmountToJson(obj.baseFee)
28
+ : undefined,
29
+ channel_fees_fee_rate_per_mil: obj.feeRatePerMil,
30
+ };
31
+ };
21
32
 
22
33
  export const FRAGMENT = `
23
34
  fragment ChannelFeesFragment on ChannelFees {
@@ -2,70 +2,68 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
7
- import type OnChainTransaction from "./OnChainTransaction.js";
8
- import type Transaction from "./Transaction.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
9
9
  import TransactionStatus from "./TransactionStatus.js";
10
10
 
11
11
  /** This is an object representing a transaction which opens a channel on the Lightning Network. This object occurs only for channels funded by the local Lightspark node. **/
12
- type ChannelOpeningTransaction = OnChainTransaction &
13
- Transaction &
14
- Entity & {
15
- /**
16
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
17
- * string.
18
- **/
19
- id: string;
20
-
21
- /** The date and time when this transaction was initiated. **/
22
- createdAt: string;
23
-
24
- /** The date and time when the entity was last updated. **/
25
- updatedAt: string;
26
-
27
- /** The current status of this transaction. **/
28
- status: TransactionStatus;
29
-
30
- /** The amount of money involved in this transaction. **/
31
- amount: CurrencyAmount;
32
-
33
- /**
34
- * The height of the block that included this transaction. This will be zero for unconfirmed
35
- * transactions.
36
- **/
37
- blockHeight: number;
38
-
39
- /** The Bitcoin blockchain addresses this transaction was sent to. **/
40
- destinationAddresses: string[];
41
-
42
- /** The typename of the object **/
43
- typename: string;
44
-
45
- /** The date and time when this transaction was completed or failed. **/
46
- resolvedAt?: string;
47
-
48
- /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
49
- transactionHash?: string;
50
-
51
- /**
52
- * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
53
- * blockchain.
54
- **/
55
- fees?: CurrencyAmount;
56
-
57
- /**
58
- * The hash of the block that included this transaction. This will be null for unconfirmed
59
- * transactions.
60
- **/
61
- blockHash?: string;
62
-
63
- /** The number of blockchain confirmations for this transaction in real time. **/
64
- numConfirmations?: number;
65
-
66
- /** If known, the channel this transaction is opening. **/
67
- channelId?: string;
68
- };
12
+ interface ChannelOpeningTransaction {
13
+ /**
14
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
15
+ * string.
16
+ **/
17
+ id: string;
18
+
19
+ /** The date and time when this transaction was initiated. **/
20
+ createdAt: string;
21
+
22
+ /** The date and time when the entity was last updated. **/
23
+ updatedAt: string;
24
+
25
+ /** The current status of this transaction. **/
26
+ status: TransactionStatus;
27
+
28
+ /** The amount of money involved in this transaction. **/
29
+ amount: CurrencyAmount;
30
+
31
+ /**
32
+ * The height of the block that included this transaction. This will be zero for unconfirmed
33
+ * transactions.
34
+ **/
35
+ blockHeight: number;
36
+
37
+ /** The Bitcoin blockchain addresses this transaction was sent to. **/
38
+ destinationAddresses: string[];
39
+
40
+ /** The typename of the object **/
41
+ typename: string;
42
+
43
+ /** The date and time when this transaction was completed or failed. **/
44
+ resolvedAt?: string | undefined;
45
+
46
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
47
+ transactionHash?: string | undefined;
48
+
49
+ /**
50
+ * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
51
+ * blockchain.
52
+ **/
53
+ fees?: CurrencyAmount | undefined;
54
+
55
+ /**
56
+ * The hash of the block that included this transaction. This will be null for unconfirmed
57
+ * transactions.
58
+ **/
59
+ blockHash?: string | undefined;
60
+
61
+ /** The number of blockchain confirmations for this transaction in real time. **/
62
+ numConfirmations?: number | undefined;
63
+
64
+ /** If known, the channel this transaction is opening. **/
65
+ channelId?: string | undefined;
66
+ }
69
67
 
70
68
  export const ChannelOpeningTransactionFromJson = (
71
69
  obj: any,
@@ -92,6 +90,28 @@ export const ChannelOpeningTransactionFromJson = (
92
90
  channelId: obj["channel_opening_transaction_channel"]?.id ?? undefined,
93
91
  } as ChannelOpeningTransaction;
94
92
  };
93
+ export const ChannelOpeningTransactionToJson = (
94
+ obj: ChannelOpeningTransaction,
95
+ ): any => {
96
+ return {
97
+ __typename: "ChannelOpeningTransaction",
98
+ channel_opening_transaction_id: obj.id,
99
+ channel_opening_transaction_created_at: obj.createdAt,
100
+ channel_opening_transaction_updated_at: obj.updatedAt,
101
+ channel_opening_transaction_status: obj.status,
102
+ channel_opening_transaction_resolved_at: obj.resolvedAt,
103
+ channel_opening_transaction_amount: CurrencyAmountToJson(obj.amount),
104
+ channel_opening_transaction_transaction_hash: obj.transactionHash,
105
+ channel_opening_transaction_fees: obj.fees
106
+ ? CurrencyAmountToJson(obj.fees)
107
+ : undefined,
108
+ channel_opening_transaction_block_hash: obj.blockHash,
109
+ channel_opening_transaction_block_height: obj.blockHeight,
110
+ channel_opening_transaction_destination_addresses: obj.destinationAddresses,
111
+ channel_opening_transaction_num_confirmations: obj.numConfirmations,
112
+ channel_opening_transaction_channel: { id: obj.channelId } ?? undefined,
113
+ };
114
+ };
95
115
 
96
116
  export const FRAGMENT = `
97
117
  fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction {