@lightsparkdev/lightspark-sdk 0.1.6

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 (223) hide show
  1. package/.fossa.yml +6 -0
  2. package/.prettierrc +1 -0
  3. package/.turbo/turbo-build.log +19 -0
  4. package/.turbo/turbo-lint.log +3 -0
  5. package/CHANGELOG.md +49 -0
  6. package/LICENSE +201 -0
  7. package/README.md +137 -0
  8. package/dist/Withdrawal-17e1c8af.d.ts +1672 -0
  9. package/dist/Withdrawal-27a4d10d.d.ts +1672 -0
  10. package/dist/chunk-3VRI7CHE.js +5508 -0
  11. package/dist/chunk-AGEUDR2V.js +4498 -0
  12. package/dist/chunk-N27QHRE4.js +5508 -0
  13. package/dist/client-3bba3f64.d.ts +1302 -0
  14. package/dist/index.cjs +6633 -0
  15. package/dist/index.d.ts +15 -0
  16. package/dist/index.js +1177 -0
  17. package/dist/objects/index.cjs +5347 -0
  18. package/dist/objects/index.d.ts +3 -0
  19. package/dist/objects/index.js +88 -0
  20. package/examples/node-scripts/authHelpers.ts +20 -0
  21. package/examples/node-scripts/createInvoice.ts +64 -0
  22. package/examples/node-scripts/example.ts +288 -0
  23. package/examples/node-scripts/getAccountDashboard.ts +24 -0
  24. package/examples/node-scripts/getNodeChannels.ts +34 -0
  25. package/examples/node-scripts/internalAuthHelpers.ts +26 -0
  26. package/examples/node-scripts/internal_example.ts +296 -0
  27. package/examples/node-scripts/package-lock.json +887 -0
  28. package/examples/node-scripts/package.json +22 -0
  29. package/examples/node-scripts/prettyPrintJsonForDocs.ts +62 -0
  30. package/examples/node-scripts/tsconfig.json +27 -0
  31. package/examples/oauth-example/README.md +19 -0
  32. package/examples/oauth-example/package-lock.json +16071 -0
  33. package/examples/oauth-example/package.json +50 -0
  34. package/examples/oauth-example/public/favicon.ico +0 -0
  35. package/examples/oauth-example/public/index.html +43 -0
  36. package/examples/oauth-example/public/logo192.png +0 -0
  37. package/examples/oauth-example/public/logo512.png +0 -0
  38. package/examples/oauth-example/public/manifest.json +25 -0
  39. package/examples/oauth-example/public/robots.txt +3 -0
  40. package/examples/oauth-example/src/App.css +7 -0
  41. package/examples/oauth-example/src/App.test.tsx +12 -0
  42. package/examples/oauth-example/src/App.tsx +16 -0
  43. package/examples/oauth-example/src/auth/AuthContext.ts +8 -0
  44. package/examples/oauth-example/src/auth/AuthProvider.tsx +44 -0
  45. package/examples/oauth-example/src/auth/RequireAuth.tsx +19 -0
  46. package/examples/oauth-example/src/auth/oauthProvider.ts +35 -0
  47. package/examples/oauth-example/src/components/Button.tsx +39 -0
  48. package/examples/oauth-example/src/components/CurrencyAmount.tsx +117 -0
  49. package/examples/oauth-example/src/components/Dashboard.tsx +158 -0
  50. package/examples/oauth-example/src/components/Table.tsx +22 -0
  51. package/examples/oauth-example/src/hooks/useAccountInfo.tsx +31 -0
  52. package/examples/oauth-example/src/icons/BitcoinB.tsx +20 -0
  53. package/examples/oauth-example/src/icons/Icon.tsx +121 -0
  54. package/examples/oauth-example/src/icons/Satoshi.tsx +28 -0
  55. package/examples/oauth-example/src/index.css +13 -0
  56. package/examples/oauth-example/src/index.tsx +23 -0
  57. package/examples/oauth-example/src/lightsparkclient/LightsparkClientContext.ts +10 -0
  58. package/examples/oauth-example/src/lightsparkclient/LightsparkClientProvider.tsx +53 -0
  59. package/examples/oauth-example/src/logo.svg +1 -0
  60. package/examples/oauth-example/src/pages/DashboardPage.tsx +71 -0
  61. package/examples/oauth-example/src/pages/LoginPage.tsx +63 -0
  62. package/examples/oauth-example/src/react-app-env.d.ts +1 -0
  63. package/examples/oauth-example/src/reportWebVitals.ts +15 -0
  64. package/examples/oauth-example/src/routes/index.tsx +15 -0
  65. package/examples/oauth-example/src/setupTests.ts +5 -0
  66. package/examples/oauth-example/src/utils/currency.ts +483 -0
  67. package/examples/oauth-example/tsconfig.json +20 -0
  68. package/examples/streaming-wallet-extension/.fossa.yml +6 -0
  69. package/examples/streaming-wallet-extension/README.md +17 -0
  70. package/examples/streaming-wallet-extension/craco.config.js +58 -0
  71. package/examples/streaming-wallet-extension/package-lock.json +18260 -0
  72. package/examples/streaming-wallet-extension/package.json +77 -0
  73. package/examples/streaming-wallet-extension/public/index.html +24 -0
  74. package/examples/streaming-wallet-extension/public/lightspark_full.png +0 -0
  75. package/examples/streaming-wallet-extension/public/lightspark_icon_circle.png +0 -0
  76. package/examples/streaming-wallet-extension/public/manifest.json +43 -0
  77. package/examples/streaming-wallet-extension/public/robots.txt +3 -0
  78. package/examples/streaming-wallet-extension/src/App.css +53 -0
  79. package/examples/streaming-wallet-extension/src/App.tsx +425 -0
  80. package/examples/streaming-wallet-extension/src/auth/AccountStorage.ts +28 -0
  81. package/examples/streaming-wallet-extension/src/auth/DemoAccountProvider.ts +99 -0
  82. package/examples/streaming-wallet-extension/src/auth/StreamingDemoCredentials.ts +10 -0
  83. package/examples/streaming-wallet-extension/src/background/PaymentStrategy.ts +36 -0
  84. package/examples/streaming-wallet-extension/src/background/PlaybackRange.ts +31 -0
  85. package/examples/streaming-wallet-extension/src/background/StreamingInvoiceHolder.ts +33 -0
  86. package/examples/streaming-wallet-extension/src/background/TransactionObserver.ts +66 -0
  87. package/examples/streaming-wallet-extension/src/background/VideoPlaybackRanges.ts +38 -0
  88. package/examples/streaming-wallet-extension/src/background/VideoProgressCache.ts +87 -0
  89. package/examples/streaming-wallet-extension/src/background/background.ts +145 -0
  90. package/examples/streaming-wallet-extension/src/background/messageHandling.ts +185 -0
  91. package/examples/streaming-wallet-extension/src/common/datetimes.ts +28 -0
  92. package/examples/streaming-wallet-extension/src/common/settings.ts +12 -0
  93. package/examples/streaming-wallet-extension/src/common/storage.ts +8 -0
  94. package/examples/streaming-wallet-extension/src/common/streamingTabs.ts +27 -0
  95. package/examples/streaming-wallet-extension/src/common/types.tsx +23 -0
  96. package/examples/streaming-wallet-extension/src/components/CirclePlusIcon.tsx +19 -0
  97. package/examples/streaming-wallet-extension/src/components/CurrencyAmount.tsx +110 -0
  98. package/examples/streaming-wallet-extension/src/components/CurrencyAmountRaw.tsx +195 -0
  99. package/examples/streaming-wallet-extension/src/components/LeftArrow.tsx +21 -0
  100. package/examples/streaming-wallet-extension/src/components/Loading.tsx +151 -0
  101. package/examples/streaming-wallet-extension/src/components/StreamingTransactionChip.tsx +95 -0
  102. package/examples/streaming-wallet-extension/src/components/TransactionRow.tsx +93 -0
  103. package/examples/streaming-wallet-extension/src/contentscript/content.ts +123 -0
  104. package/examples/streaming-wallet-extension/src/contentscript/lightsparkDemoDom.tsx +113 -0
  105. package/examples/streaming-wallet-extension/src/contentscript/videoElementParsers.ts +92 -0
  106. package/examples/streaming-wallet-extension/src/index.css +16 -0
  107. package/examples/streaming-wallet-extension/src/index.tsx +11 -0
  108. package/examples/streaming-wallet-extension/src/lightsparkClientProvider.tsx +26 -0
  109. package/examples/streaming-wallet-extension/src/react-app-env.d.ts +1 -0
  110. package/examples/streaming-wallet-extension/src/types/Messages.ts +17 -0
  111. package/examples/streaming-wallet-extension/tsconfig.json +20 -0
  112. package/package.json +87 -0
  113. package/src/auth/AccountTokenAuthProvider.ts +37 -0
  114. package/src/auth/index.ts +3 -0
  115. package/src/client.ts +759 -0
  116. package/src/graphql/BitcoinFeeEstimate.ts +13 -0
  117. package/src/graphql/CreateApiToken.ts +22 -0
  118. package/src/graphql/CreateInvoice.ts +18 -0
  119. package/src/graphql/CreateNodeWalletAddress.ts +13 -0
  120. package/src/graphql/CurrentAccount.ts +13 -0
  121. package/src/graphql/DecodeInvoice.ts +16 -0
  122. package/src/graphql/DeleteApiToken.ts +13 -0
  123. package/src/graphql/FundNode.ts +18 -0
  124. package/src/graphql/LightningFeeEstimateForInvoice.ts +21 -0
  125. package/src/graphql/LightningFeeEstimateForNode.ts +21 -0
  126. package/src/graphql/MultiNodeDashboard.ts +118 -0
  127. package/src/graphql/PayInvoice.ts +29 -0
  128. package/src/graphql/RecoverNodeSigningKey.ts +15 -0
  129. package/src/graphql/RequestWithdrawal.ts +25 -0
  130. package/src/graphql/SendPayment.ts +29 -0
  131. package/src/graphql/SingleNodeDashboard.ts +116 -0
  132. package/src/graphql/TransactionSubscription.ts +16 -0
  133. package/src/graphql/TransactionsForNode.ts +42 -0
  134. package/src/index.ts +5 -0
  135. package/src/objects/Account.ts +1222 -0
  136. package/src/objects/AccountToApiTokensConnection.ts +50 -0
  137. package/src/objects/AccountToChannelsConnection.ts +35 -0
  138. package/src/objects/AccountToNodesConnection.ts +62 -0
  139. package/src/objects/AccountToPaymentRequestsConnection.ts +50 -0
  140. package/src/objects/AccountToTransactionsConnection.ts +112 -0
  141. package/src/objects/ApiToken.ts +80 -0
  142. package/src/objects/BitcoinNetwork.ts +19 -0
  143. package/src/objects/BlockchainBalance.ts +102 -0
  144. package/src/objects/Channel.ts +283 -0
  145. package/src/objects/ChannelClosingTransaction.ts +150 -0
  146. package/src/objects/ChannelFees.ts +34 -0
  147. package/src/objects/ChannelOpeningTransaction.ts +150 -0
  148. package/src/objects/ChannelStatus.ts +25 -0
  149. package/src/objects/ChannelToTransactionsConnection.ts +86 -0
  150. package/src/objects/CreateApiTokenInput.ts +22 -0
  151. package/src/objects/CreateApiTokenOutput.ts +41 -0
  152. package/src/objects/CreateInvoiceInput.ts +27 -0
  153. package/src/objects/CreateInvoiceOutput.ts +21 -0
  154. package/src/objects/CreateNodeWalletAddressInput.ts +15 -0
  155. package/src/objects/CreateNodeWalletAddressOutput.ts +27 -0
  156. package/src/objects/CurrencyAmount.ts +55 -0
  157. package/src/objects/CurrencyUnit.ts +25 -0
  158. package/src/objects/DeleteApiTokenInput.ts +13 -0
  159. package/src/objects/DeleteApiTokenOutput.ts +23 -0
  160. package/src/objects/Deposit.ts +144 -0
  161. package/src/objects/Entity.ts +868 -0
  162. package/src/objects/FeeEstimate.ts +39 -0
  163. package/src/objects/FundNodeInput.ts +16 -0
  164. package/src/objects/FundNodeOutput.ts +28 -0
  165. package/src/objects/GraphNode.ts +110 -0
  166. package/src/objects/Hop.ts +108 -0
  167. package/src/objects/HtlcAttemptFailureCode.ts +65 -0
  168. package/src/objects/IncomingPayment.ts +141 -0
  169. package/src/objects/IncomingPaymentAttempt.ts +96 -0
  170. package/src/objects/IncomingPaymentAttemptStatus.ts +20 -0
  171. package/src/objects/IncomingPaymentToAttemptsConnection.ts +39 -0
  172. package/src/objects/Invoice.ts +226 -0
  173. package/src/objects/InvoiceData.ts +185 -0
  174. package/src/objects/InvoiceType.ts +15 -0
  175. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +28 -0
  176. package/src/objects/LightningFeeEstimateForNodeInput.ts +25 -0
  177. package/src/objects/LightningFeeEstimateOutput.ts +33 -0
  178. package/src/objects/LightningTransaction.ts +393 -0
  179. package/src/objects/LightsparkNode.ts +377 -0
  180. package/src/objects/LightsparkNodePurpose.ts +17 -0
  181. package/src/objects/LightsparkNodeStatus.ts +29 -0
  182. package/src/objects/LightsparkNodeToChannelsConnection.ts +50 -0
  183. package/src/objects/Node.ts +273 -0
  184. package/src/objects/NodeAddress.ts +29 -0
  185. package/src/objects/NodeAddressType.ts +18 -0
  186. package/src/objects/NodeToAddressesConnection.ts +39 -0
  187. package/src/objects/OnChainTransaction.ts +318 -0
  188. package/src/objects/OutgoingPayment.ts +319 -0
  189. package/src/objects/OutgoingPaymentAttempt.ts +164 -0
  190. package/src/objects/OutgoingPaymentAttemptStatus.ts +18 -0
  191. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +37 -0
  192. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +39 -0
  193. package/src/objects/PageInfo.ts +31 -0
  194. package/src/objects/PayInvoiceInput.ts +33 -0
  195. package/src/objects/PayInvoiceOutput.ts +22 -0
  196. package/src/objects/PaymentFailureReason.ts +29 -0
  197. package/src/objects/PaymentRequest.ts +231 -0
  198. package/src/objects/PaymentRequestData.ts +183 -0
  199. package/src/objects/PaymentRequestStatus.ts +15 -0
  200. package/src/objects/Permission.ts +39 -0
  201. package/src/objects/RequestWithdrawalInput.ts +35 -0
  202. package/src/objects/RequestWithdrawalOutput.ts +24 -0
  203. package/src/objects/RichText.ts +19 -0
  204. package/src/objects/RoutingTransaction.ts +150 -0
  205. package/src/objects/RoutingTransactionFailureReason.ts +17 -0
  206. package/src/objects/Secret.ts +23 -0
  207. package/src/objects/SendPaymentInput.ts +30 -0
  208. package/src/objects/SendPaymentOutput.ts +22 -0
  209. package/src/objects/Transaction.ts +609 -0
  210. package/src/objects/TransactionFailures.ts +23 -0
  211. package/src/objects/TransactionStatus.ts +23 -0
  212. package/src/objects/TransactionType.ts +31 -0
  213. package/src/objects/TransactionUpdate.ts +67 -0
  214. package/src/objects/WalletDashboard.ts +32 -0
  215. package/src/objects/WebhookEventType.ts +15 -0
  216. package/src/objects/Withdrawal.ts +144 -0
  217. package/src/objects/WithdrawalMode.ts +15 -0
  218. package/src/objects/WithdrawalRequest.ts +224 -0
  219. package/src/objects/WithdrawalRequestStatus.ts +17 -0
  220. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +57 -0
  221. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +57 -0
  222. package/src/objects/index.ts +108 -0
  223. package/tsconfig.json +5 -0
@@ -0,0 +1,1222 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { Query } from "@lightsparkdev/core";
4
+ import autoBind from "auto-bind";
5
+ import LightsparkClient from "../client.js";
6
+ import AccountToApiTokensConnection, {
7
+ AccountToApiTokensConnectionFromJson,
8
+ } from "./AccountToApiTokensConnection.js";
9
+ import AccountToChannelsConnection, {
10
+ AccountToChannelsConnectionFromJson,
11
+ } from "./AccountToChannelsConnection.js";
12
+ import AccountToNodesConnection, {
13
+ AccountToNodesConnectionFromJson,
14
+ } from "./AccountToNodesConnection.js";
15
+ import AccountToPaymentRequestsConnection, {
16
+ AccountToPaymentRequestsConnectionFromJson,
17
+ } from "./AccountToPaymentRequestsConnection.js";
18
+ import AccountToTransactionsConnection, {
19
+ AccountToTransactionsConnectionFromJson,
20
+ } from "./AccountToTransactionsConnection.js";
21
+ import BitcoinNetwork from "./BitcoinNetwork.js";
22
+ import BlockchainBalance, {
23
+ BlockchainBalanceFromJson,
24
+ } from "./BlockchainBalance.js";
25
+ import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
26
+ import Entity from "./Entity.js";
27
+ import TransactionFailures from "./TransactionFailures.js";
28
+ import TransactionStatus from "./TransactionStatus.js";
29
+ import TransactionType from "./TransactionType.js";
30
+
31
+ class Account implements Entity {
32
+ constructor(
33
+ public readonly id: string,
34
+ public readonly createdAt: string,
35
+ public readonly updatedAt: string,
36
+ public readonly typename: string,
37
+ public readonly name?: string
38
+ ) {
39
+ autoBind(this);
40
+ }
41
+
42
+ public async getApiTokens(
43
+ client: LightsparkClient,
44
+ first: number | undefined = undefined
45
+ ): Promise<AccountToApiTokensConnection> {
46
+ return (await client.executeRawQuery({
47
+ queryPayload: `
48
+ query FetchAccountToApiTokensConnection($first: Int) {
49
+ current_account {
50
+ ... on Account {
51
+ api_tokens(, first: $first) {
52
+ __typename
53
+ account_to_api_tokens_connection_page_info: page_info {
54
+ __typename
55
+ page_info_has_next_page: has_next_page
56
+ page_info_has_previous_page: has_previous_page
57
+ page_info_start_cursor: start_cursor
58
+ page_info_end_cursor: end_cursor
59
+ }
60
+ account_to_api_tokens_connection_count: count
61
+ account_to_api_tokens_connection_entities: entities {
62
+ __typename
63
+ api_token_id: id
64
+ api_token_created_at: created_at
65
+ api_token_updated_at: updated_at
66
+ api_token_client_id: client_id
67
+ api_token_name: name
68
+ api_token_permissions: permissions
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ `,
75
+ variables: { first: first },
76
+ constructObject: (json) => {
77
+ const connection = json["current_account"]["api_tokens"];
78
+ return AccountToApiTokensConnectionFromJson(connection);
79
+ },
80
+ }))!;
81
+ }
82
+
83
+ public async getBlockchainBalance(
84
+ client: LightsparkClient,
85
+ bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
86
+ nodeIds: string[] | undefined = undefined
87
+ ): Promise<BlockchainBalance | null> {
88
+ return await client.executeRawQuery({
89
+ queryPayload: `
90
+ query FetchAccountBlockchainBalance($bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) {
91
+ current_account {
92
+ ... on Account {
93
+ blockchain_balance(, bitcoin_networks: $bitcoin_networks, node_ids: $node_ids) {
94
+ __typename
95
+ blockchain_balance_total_balance: total_balance {
96
+ __typename
97
+ currency_amount_original_value: original_value
98
+ currency_amount_original_unit: original_unit
99
+ currency_amount_preferred_currency_unit: preferred_currency_unit
100
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
101
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
102
+ }
103
+ blockchain_balance_confirmed_balance: confirmed_balance {
104
+ __typename
105
+ currency_amount_original_value: original_value
106
+ currency_amount_original_unit: original_unit
107
+ currency_amount_preferred_currency_unit: preferred_currency_unit
108
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
109
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
110
+ }
111
+ blockchain_balance_unconfirmed_balance: unconfirmed_balance {
112
+ __typename
113
+ currency_amount_original_value: original_value
114
+ currency_amount_original_unit: original_unit
115
+ currency_amount_preferred_currency_unit: preferred_currency_unit
116
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
117
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
118
+ }
119
+ blockchain_balance_locked_balance: locked_balance {
120
+ __typename
121
+ currency_amount_original_value: original_value
122
+ currency_amount_original_unit: original_unit
123
+ currency_amount_preferred_currency_unit: preferred_currency_unit
124
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
125
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
126
+ }
127
+ blockchain_balance_required_reserve: required_reserve {
128
+ __typename
129
+ currency_amount_original_value: original_value
130
+ currency_amount_original_unit: original_unit
131
+ currency_amount_preferred_currency_unit: preferred_currency_unit
132
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
133
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
134
+ }
135
+ blockchain_balance_available_balance: available_balance {
136
+ __typename
137
+ currency_amount_original_value: original_value
138
+ currency_amount_original_unit: original_unit
139
+ currency_amount_preferred_currency_unit: preferred_currency_unit
140
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
141
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ `,
148
+ variables: { bitcoin_networks: bitcoinNetworks, node_ids: nodeIds },
149
+ constructObject: (json) => {
150
+ const connection = json["current_account"]["blockchain_balance"];
151
+ return !!connection ? BlockchainBalanceFromJson(connection) : null;
152
+ },
153
+ });
154
+ }
155
+
156
+ public async getConductivity(
157
+ client: LightsparkClient,
158
+ bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
159
+ nodeIds: string[] | undefined = undefined
160
+ ): Promise<number> {
161
+ return await client.executeRawQuery({
162
+ queryPayload: `
163
+ query FetchAccountConductivity($bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) {
164
+ current_account {
165
+ ... on Account {
166
+ conductivity(, bitcoin_networks: $bitcoin_networks, node_ids: $node_ids)
167
+ }
168
+ }
169
+ }
170
+ `,
171
+ variables: { bitcoin_networks: bitcoinNetworks, node_ids: nodeIds },
172
+ constructObject: (json) => {
173
+ const connection = json["current_account"]["conductivity"];
174
+ return connection;
175
+ },
176
+ });
177
+ }
178
+
179
+ public async getLocalBalance(
180
+ client: LightsparkClient,
181
+ bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
182
+ nodeIds: string[] | undefined = undefined
183
+ ): Promise<CurrencyAmount | null> {
184
+ return await client.executeRawQuery({
185
+ queryPayload: `
186
+ query FetchAccountLocalBalance($bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) {
187
+ current_account {
188
+ ... on Account {
189
+ local_balance(, bitcoin_networks: $bitcoin_networks, node_ids: $node_ids) {
190
+ __typename
191
+ currency_amount_original_value: original_value
192
+ currency_amount_original_unit: original_unit
193
+ currency_amount_preferred_currency_unit: preferred_currency_unit
194
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
195
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
196
+ }
197
+ }
198
+ }
199
+ }
200
+ `,
201
+ variables: { bitcoin_networks: bitcoinNetworks, node_ids: nodeIds },
202
+ constructObject: (json) => {
203
+ const connection = json["current_account"]["local_balance"];
204
+ return !!connection ? CurrencyAmountFromJson(connection) : null;
205
+ },
206
+ });
207
+ }
208
+
209
+ public async getNodes(
210
+ client: LightsparkClient,
211
+ first: number | undefined = undefined,
212
+ bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
213
+ nodeIds: string[] | undefined = undefined
214
+ ): Promise<AccountToNodesConnection> {
215
+ return (await client.executeRawQuery({
216
+ queryPayload: `
217
+ query FetchAccountToNodesConnection($first: Int, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) {
218
+ current_account {
219
+ ... on Account {
220
+ nodes(, first: $first, bitcoin_networks: $bitcoin_networks, node_ids: $node_ids) {
221
+ __typename
222
+ account_to_nodes_connection_page_info: page_info {
223
+ __typename
224
+ page_info_has_next_page: has_next_page
225
+ page_info_has_previous_page: has_previous_page
226
+ page_info_start_cursor: start_cursor
227
+ page_info_end_cursor: end_cursor
228
+ }
229
+ account_to_nodes_connection_count: count
230
+ account_to_nodes_connection_purpose: purpose
231
+ account_to_nodes_connection_entities: entities {
232
+ __typename
233
+ lightspark_node_id: id
234
+ lightspark_node_created_at: created_at
235
+ lightspark_node_updated_at: updated_at
236
+ lightspark_node_alias: alias
237
+ lightspark_node_bitcoin_network: bitcoin_network
238
+ lightspark_node_color: color
239
+ lightspark_node_conductivity: conductivity
240
+ lightspark_node_display_name: display_name
241
+ lightspark_node_public_key: public_key
242
+ lightspark_node_account: account {
243
+ id
244
+ }
245
+ lightspark_node_blockchain_balance: blockchain_balance {
246
+ __typename
247
+ blockchain_balance_total_balance: total_balance {
248
+ __typename
249
+ currency_amount_original_value: original_value
250
+ currency_amount_original_unit: original_unit
251
+ currency_amount_preferred_currency_unit: preferred_currency_unit
252
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
253
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
254
+ }
255
+ blockchain_balance_confirmed_balance: confirmed_balance {
256
+ __typename
257
+ currency_amount_original_value: original_value
258
+ currency_amount_original_unit: original_unit
259
+ currency_amount_preferred_currency_unit: preferred_currency_unit
260
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
261
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
262
+ }
263
+ blockchain_balance_unconfirmed_balance: unconfirmed_balance {
264
+ __typename
265
+ currency_amount_original_value: original_value
266
+ currency_amount_original_unit: original_unit
267
+ currency_amount_preferred_currency_unit: preferred_currency_unit
268
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
269
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
270
+ }
271
+ blockchain_balance_locked_balance: locked_balance {
272
+ __typename
273
+ currency_amount_original_value: original_value
274
+ currency_amount_original_unit: original_unit
275
+ currency_amount_preferred_currency_unit: preferred_currency_unit
276
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
277
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
278
+ }
279
+ blockchain_balance_required_reserve: required_reserve {
280
+ __typename
281
+ currency_amount_original_value: original_value
282
+ currency_amount_original_unit: original_unit
283
+ currency_amount_preferred_currency_unit: preferred_currency_unit
284
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
285
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
286
+ }
287
+ blockchain_balance_available_balance: available_balance {
288
+ __typename
289
+ currency_amount_original_value: original_value
290
+ currency_amount_original_unit: original_unit
291
+ currency_amount_preferred_currency_unit: preferred_currency_unit
292
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
293
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
294
+ }
295
+ }
296
+ lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
297
+ __typename
298
+ secret_encrypted_value: encrypted_value
299
+ secret_cipher: cipher
300
+ }
301
+ lightspark_node_total_balance: total_balance {
302
+ __typename
303
+ currency_amount_original_value: original_value
304
+ currency_amount_original_unit: original_unit
305
+ currency_amount_preferred_currency_unit: preferred_currency_unit
306
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
307
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
308
+ }
309
+ lightspark_node_total_local_balance: total_local_balance {
310
+ __typename
311
+ currency_amount_original_value: original_value
312
+ currency_amount_original_unit: original_unit
313
+ currency_amount_preferred_currency_unit: preferred_currency_unit
314
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
315
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
316
+ }
317
+ lightspark_node_local_balance: local_balance {
318
+ __typename
319
+ currency_amount_original_value: original_value
320
+ currency_amount_original_unit: original_unit
321
+ currency_amount_preferred_currency_unit: preferred_currency_unit
322
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
323
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
324
+ }
325
+ lightspark_node_purpose: purpose
326
+ lightspark_node_remote_balance: remote_balance {
327
+ __typename
328
+ currency_amount_original_value: original_value
329
+ currency_amount_original_unit: original_unit
330
+ currency_amount_preferred_currency_unit: preferred_currency_unit
331
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
332
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
333
+ }
334
+ lightspark_node_status: status
335
+ }
336
+ }
337
+ }
338
+ }
339
+ }
340
+ `,
341
+ variables: {
342
+ first: first,
343
+ bitcoin_networks: bitcoinNetworks,
344
+ node_ids: nodeIds,
345
+ },
346
+ constructObject: (json) => {
347
+ const connection = json["current_account"]["nodes"];
348
+ return AccountToNodesConnectionFromJson(connection);
349
+ },
350
+ }))!;
351
+ }
352
+
353
+ public async getRemoteBalance(
354
+ client: LightsparkClient,
355
+ bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
356
+ nodeIds: string[] | undefined = undefined
357
+ ): Promise<CurrencyAmount | null> {
358
+ return await client.executeRawQuery({
359
+ queryPayload: `
360
+ query FetchAccountRemoteBalance($bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) {
361
+ current_account {
362
+ ... on Account {
363
+ remote_balance(, bitcoin_networks: $bitcoin_networks, node_ids: $node_ids) {
364
+ __typename
365
+ currency_amount_original_value: original_value
366
+ currency_amount_original_unit: original_unit
367
+ currency_amount_preferred_currency_unit: preferred_currency_unit
368
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
369
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
370
+ }
371
+ }
372
+ }
373
+ }
374
+ `,
375
+ variables: { bitcoin_networks: bitcoinNetworks, node_ids: nodeIds },
376
+ constructObject: (json) => {
377
+ const connection = json["current_account"]["remote_balance"];
378
+ return !!connection ? CurrencyAmountFromJson(connection) : null;
379
+ },
380
+ });
381
+ }
382
+
383
+ public async getUptimePercentage(
384
+ client: LightsparkClient,
385
+ afterDate: string | undefined = undefined,
386
+ beforeDate: string | undefined = undefined,
387
+ bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
388
+ nodeIds: string[] | undefined = undefined
389
+ ): Promise<number> {
390
+ return await client.executeRawQuery({
391
+ queryPayload: `
392
+ query FetchAccountUptimePercentage($after_date: DateTime, $before_date: DateTime, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) {
393
+ current_account {
394
+ ... on Account {
395
+ uptime_percentage(, after_date: $after_date, before_date: $before_date, bitcoin_networks: $bitcoin_networks, node_ids: $node_ids)
396
+ }
397
+ }
398
+ }
399
+ `,
400
+ variables: {
401
+ after_date: afterDate,
402
+ before_date: beforeDate,
403
+ bitcoin_networks: bitcoinNetworks,
404
+ node_ids: nodeIds,
405
+ },
406
+ constructObject: (json) => {
407
+ const connection = json["current_account"]["uptime_percentage"];
408
+ return connection;
409
+ },
410
+ });
411
+ }
412
+
413
+ public async getChannels(
414
+ client: LightsparkClient,
415
+ bitcoinNetwork: BitcoinNetwork,
416
+ lightningNodeId: string | undefined = undefined,
417
+ afterDate: string | undefined = undefined,
418
+ beforeDate: string | undefined = undefined,
419
+ first: number | undefined = undefined
420
+ ): Promise<AccountToChannelsConnection> {
421
+ return (await client.executeRawQuery({
422
+ queryPayload: `
423
+ query FetchAccountToChannelsConnection($bitcoin_network: BitcoinNetwork!, $lightning_node_id: ID, $after_date: DateTime, $before_date: DateTime, $first: Int) {
424
+ current_account {
425
+ ... on Account {
426
+ channels(, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, after_date: $after_date, before_date: $before_date, first: $first) {
427
+ __typename
428
+ account_to_channels_connection_count: count
429
+ account_to_channels_connection_entities: entities {
430
+ __typename
431
+ channel_id: id
432
+ channel_created_at: created_at
433
+ channel_updated_at: updated_at
434
+ channel_funding_transaction: funding_transaction {
435
+ id
436
+ }
437
+ channel_capacity: capacity {
438
+ __typename
439
+ currency_amount_original_value: original_value
440
+ currency_amount_original_unit: original_unit
441
+ currency_amount_preferred_currency_unit: preferred_currency_unit
442
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
443
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
444
+ }
445
+ channel_local_balance: local_balance {
446
+ __typename
447
+ currency_amount_original_value: original_value
448
+ currency_amount_original_unit: original_unit
449
+ currency_amount_preferred_currency_unit: preferred_currency_unit
450
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
451
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
452
+ }
453
+ channel_local_unsettled_balance: local_unsettled_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
+ channel_remote_balance: remote_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
+ channel_remote_unsettled_balance: remote_unsettled_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
+ channel_unsettled_balance: unsettled_balance {
478
+ __typename
479
+ currency_amount_original_value: original_value
480
+ currency_amount_original_unit: original_unit
481
+ currency_amount_preferred_currency_unit: preferred_currency_unit
482
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
483
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
484
+ }
485
+ channel_total_balance: total_balance {
486
+ __typename
487
+ currency_amount_original_value: original_value
488
+ currency_amount_original_unit: original_unit
489
+ currency_amount_preferred_currency_unit: preferred_currency_unit
490
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
491
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
492
+ }
493
+ channel_status: status
494
+ channel_estimated_force_closure_wait_minutes: estimated_force_closure_wait_minutes
495
+ channel_commit_fee: commit_fee {
496
+ __typename
497
+ currency_amount_original_value: original_value
498
+ currency_amount_original_unit: original_unit
499
+ currency_amount_preferred_currency_unit: preferred_currency_unit
500
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
501
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
502
+ }
503
+ channel_fees: fees {
504
+ __typename
505
+ channel_fees_base_fee: base_fee {
506
+ __typename
507
+ currency_amount_original_value: original_value
508
+ currency_amount_original_unit: original_unit
509
+ currency_amount_preferred_currency_unit: preferred_currency_unit
510
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
511
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
512
+ }
513
+ channel_fees_fee_rate_per_mil: fee_rate_per_mil
514
+ }
515
+ channel_remote_node: remote_node {
516
+ id
517
+ }
518
+ channel_local_node: local_node {
519
+ id
520
+ }
521
+ channel_short_channel_id: short_channel_id
522
+ }
523
+ }
524
+ }
525
+ }
526
+ }
527
+ `,
528
+ variables: {
529
+ bitcoin_network: bitcoinNetwork,
530
+ lightning_node_id: lightningNodeId,
531
+ after_date: afterDate,
532
+ before_date: beforeDate,
533
+ first: first,
534
+ },
535
+ constructObject: (json) => {
536
+ const connection = json["current_account"]["channels"];
537
+ return AccountToChannelsConnectionFromJson(connection);
538
+ },
539
+ }))!;
540
+ }
541
+
542
+ public async getTransactions(
543
+ client: LightsparkClient,
544
+ first: number | undefined = undefined,
545
+ after: string | undefined = undefined,
546
+ types: TransactionType[] | undefined = undefined,
547
+ afterDate: string | undefined = undefined,
548
+ beforeDate: string | undefined = undefined,
549
+ bitcoinNetwork: BitcoinNetwork | undefined = undefined,
550
+ lightningNodeId: string | undefined = undefined,
551
+ statuses: TransactionStatus[] | undefined = undefined,
552
+ excludeFailures: TransactionFailures | undefined = undefined
553
+ ): Promise<AccountToTransactionsConnection> {
554
+ return (await client.executeRawQuery({
555
+ queryPayload: `
556
+ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures) {
557
+ current_account {
558
+ ... on Account {
559
+ transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures) {
560
+ __typename
561
+ account_to_transactions_connection_profit_loss: profit_loss {
562
+ __typename
563
+ currency_amount_original_value: original_value
564
+ currency_amount_original_unit: original_unit
565
+ currency_amount_preferred_currency_unit: preferred_currency_unit
566
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
567
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
568
+ }
569
+ account_to_transactions_connection_average_fee_earned: average_fee_earned {
570
+ __typename
571
+ currency_amount_original_value: original_value
572
+ currency_amount_original_unit: original_unit
573
+ currency_amount_preferred_currency_unit: preferred_currency_unit
574
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
575
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
576
+ }
577
+ account_to_transactions_connection_count: count
578
+ account_to_transactions_connection_total_amount_transacted: total_amount_transacted {
579
+ __typename
580
+ currency_amount_original_value: original_value
581
+ currency_amount_original_unit: original_unit
582
+ currency_amount_preferred_currency_unit: preferred_currency_unit
583
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
584
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
585
+ }
586
+ account_to_transactions_connection_entities: entities {
587
+ __typename
588
+ ... on ChannelClosingTransaction {
589
+ __typename
590
+ channel_closing_transaction_id: id
591
+ channel_closing_transaction_created_at: created_at
592
+ channel_closing_transaction_updated_at: updated_at
593
+ channel_closing_transaction_status: status
594
+ channel_closing_transaction_resolved_at: resolved_at
595
+ channel_closing_transaction_amount: amount {
596
+ __typename
597
+ currency_amount_original_value: original_value
598
+ currency_amount_original_unit: original_unit
599
+ currency_amount_preferred_currency_unit: preferred_currency_unit
600
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
601
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
602
+ }
603
+ channel_closing_transaction_transaction_hash: transaction_hash
604
+ channel_closing_transaction_fees: fees {
605
+ __typename
606
+ currency_amount_original_value: original_value
607
+ currency_amount_original_unit: original_unit
608
+ currency_amount_preferred_currency_unit: preferred_currency_unit
609
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
610
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
611
+ }
612
+ channel_closing_transaction_block_hash: block_hash
613
+ channel_closing_transaction_block_height: block_height
614
+ channel_closing_transaction_destination_addresses: destination_addresses
615
+ channel_closing_transaction_num_confirmations: num_confirmations
616
+ channel_closing_transaction_channel: channel {
617
+ id
618
+ }
619
+ }
620
+ ... on ChannelOpeningTransaction {
621
+ __typename
622
+ channel_opening_transaction_id: id
623
+ channel_opening_transaction_created_at: created_at
624
+ channel_opening_transaction_updated_at: updated_at
625
+ channel_opening_transaction_status: status
626
+ channel_opening_transaction_resolved_at: resolved_at
627
+ channel_opening_transaction_amount: amount {
628
+ __typename
629
+ currency_amount_original_value: original_value
630
+ currency_amount_original_unit: original_unit
631
+ currency_amount_preferred_currency_unit: preferred_currency_unit
632
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
633
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
634
+ }
635
+ channel_opening_transaction_transaction_hash: transaction_hash
636
+ channel_opening_transaction_fees: fees {
637
+ __typename
638
+ currency_amount_original_value: original_value
639
+ currency_amount_original_unit: original_unit
640
+ currency_amount_preferred_currency_unit: preferred_currency_unit
641
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
642
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
643
+ }
644
+ channel_opening_transaction_block_hash: block_hash
645
+ channel_opening_transaction_block_height: block_height
646
+ channel_opening_transaction_destination_addresses: destination_addresses
647
+ channel_opening_transaction_num_confirmations: num_confirmations
648
+ channel_opening_transaction_channel: channel {
649
+ id
650
+ }
651
+ }
652
+ ... on Deposit {
653
+ __typename
654
+ deposit_id: id
655
+ deposit_created_at: created_at
656
+ deposit_updated_at: updated_at
657
+ deposit_status: status
658
+ deposit_resolved_at: resolved_at
659
+ deposit_amount: amount {
660
+ __typename
661
+ currency_amount_original_value: original_value
662
+ currency_amount_original_unit: original_unit
663
+ currency_amount_preferred_currency_unit: preferred_currency_unit
664
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
665
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
666
+ }
667
+ deposit_transaction_hash: transaction_hash
668
+ deposit_fees: fees {
669
+ __typename
670
+ currency_amount_original_value: original_value
671
+ currency_amount_original_unit: original_unit
672
+ currency_amount_preferred_currency_unit: preferred_currency_unit
673
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
674
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
675
+ }
676
+ deposit_block_hash: block_hash
677
+ deposit_block_height: block_height
678
+ deposit_destination_addresses: destination_addresses
679
+ deposit_num_confirmations: num_confirmations
680
+ deposit_destination: destination {
681
+ id
682
+ }
683
+ }
684
+ ... on IncomingPayment {
685
+ __typename
686
+ incoming_payment_id: id
687
+ incoming_payment_created_at: created_at
688
+ incoming_payment_updated_at: updated_at
689
+ incoming_payment_status: status
690
+ incoming_payment_resolved_at: resolved_at
691
+ incoming_payment_amount: amount {
692
+ __typename
693
+ currency_amount_original_value: original_value
694
+ currency_amount_original_unit: original_unit
695
+ currency_amount_preferred_currency_unit: preferred_currency_unit
696
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
697
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
698
+ }
699
+ incoming_payment_transaction_hash: transaction_hash
700
+ incoming_payment_origin: origin {
701
+ id
702
+ }
703
+ incoming_payment_destination: destination {
704
+ id
705
+ }
706
+ incoming_payment_payment_request: payment_request {
707
+ id
708
+ }
709
+ }
710
+ ... on OutgoingPayment {
711
+ __typename
712
+ outgoing_payment_id: id
713
+ outgoing_payment_created_at: created_at
714
+ outgoing_payment_updated_at: updated_at
715
+ outgoing_payment_status: status
716
+ outgoing_payment_resolved_at: resolved_at
717
+ outgoing_payment_amount: amount {
718
+ __typename
719
+ currency_amount_original_value: original_value
720
+ currency_amount_original_unit: original_unit
721
+ currency_amount_preferred_currency_unit: preferred_currency_unit
722
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
723
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
724
+ }
725
+ outgoing_payment_transaction_hash: transaction_hash
726
+ outgoing_payment_origin: origin {
727
+ id
728
+ }
729
+ outgoing_payment_destination: destination {
730
+ id
731
+ }
732
+ outgoing_payment_fees: fees {
733
+ __typename
734
+ currency_amount_original_value: original_value
735
+ currency_amount_original_unit: original_unit
736
+ currency_amount_preferred_currency_unit: preferred_currency_unit
737
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
738
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
739
+ }
740
+ outgoing_payment_payment_request_data: payment_request_data {
741
+ __typename
742
+ ... on InvoiceData {
743
+ __typename
744
+ invoice_data_encoded_payment_request: encoded_payment_request
745
+ invoice_data_bitcoin_network: bitcoin_network
746
+ invoice_data_payment_hash: payment_hash
747
+ invoice_data_amount: amount {
748
+ __typename
749
+ currency_amount_original_value: original_value
750
+ currency_amount_original_unit: original_unit
751
+ currency_amount_preferred_currency_unit: preferred_currency_unit
752
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
753
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
754
+ }
755
+ invoice_data_created_at: created_at
756
+ invoice_data_expires_at: expires_at
757
+ invoice_data_destination: destination {
758
+ __typename
759
+ ... on GraphNode {
760
+ __typename
761
+ graph_node_id: id
762
+ graph_node_created_at: created_at
763
+ graph_node_updated_at: updated_at
764
+ graph_node_alias: alias
765
+ graph_node_bitcoin_network: bitcoin_network
766
+ graph_node_color: color
767
+ graph_node_conductivity: conductivity
768
+ graph_node_display_name: display_name
769
+ graph_node_public_key: public_key
770
+ }
771
+ ... on LightsparkNode {
772
+ __typename
773
+ lightspark_node_id: id
774
+ lightspark_node_created_at: created_at
775
+ lightspark_node_updated_at: updated_at
776
+ lightspark_node_alias: alias
777
+ lightspark_node_bitcoin_network: bitcoin_network
778
+ lightspark_node_color: color
779
+ lightspark_node_conductivity: conductivity
780
+ lightspark_node_display_name: display_name
781
+ lightspark_node_public_key: public_key
782
+ lightspark_node_account: account {
783
+ id
784
+ }
785
+ lightspark_node_blockchain_balance: blockchain_balance {
786
+ __typename
787
+ blockchain_balance_total_balance: total_balance {
788
+ __typename
789
+ currency_amount_original_value: original_value
790
+ currency_amount_original_unit: original_unit
791
+ currency_amount_preferred_currency_unit: preferred_currency_unit
792
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
793
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
794
+ }
795
+ blockchain_balance_confirmed_balance: confirmed_balance {
796
+ __typename
797
+ currency_amount_original_value: original_value
798
+ currency_amount_original_unit: original_unit
799
+ currency_amount_preferred_currency_unit: preferred_currency_unit
800
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
801
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
802
+ }
803
+ blockchain_balance_unconfirmed_balance: unconfirmed_balance {
804
+ __typename
805
+ currency_amount_original_value: original_value
806
+ currency_amount_original_unit: original_unit
807
+ currency_amount_preferred_currency_unit: preferred_currency_unit
808
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
809
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
810
+ }
811
+ blockchain_balance_locked_balance: locked_balance {
812
+ __typename
813
+ currency_amount_original_value: original_value
814
+ currency_amount_original_unit: original_unit
815
+ currency_amount_preferred_currency_unit: preferred_currency_unit
816
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
817
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
818
+ }
819
+ blockchain_balance_required_reserve: required_reserve {
820
+ __typename
821
+ currency_amount_original_value: original_value
822
+ currency_amount_original_unit: original_unit
823
+ currency_amount_preferred_currency_unit: preferred_currency_unit
824
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
825
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
826
+ }
827
+ blockchain_balance_available_balance: available_balance {
828
+ __typename
829
+ currency_amount_original_value: original_value
830
+ currency_amount_original_unit: original_unit
831
+ currency_amount_preferred_currency_unit: preferred_currency_unit
832
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
833
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
834
+ }
835
+ }
836
+ lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
837
+ __typename
838
+ secret_encrypted_value: encrypted_value
839
+ secret_cipher: cipher
840
+ }
841
+ lightspark_node_total_balance: total_balance {
842
+ __typename
843
+ currency_amount_original_value: original_value
844
+ currency_amount_original_unit: original_unit
845
+ currency_amount_preferred_currency_unit: preferred_currency_unit
846
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
847
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
848
+ }
849
+ lightspark_node_total_local_balance: total_local_balance {
850
+ __typename
851
+ currency_amount_original_value: original_value
852
+ currency_amount_original_unit: original_unit
853
+ currency_amount_preferred_currency_unit: preferred_currency_unit
854
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
855
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
856
+ }
857
+ lightspark_node_local_balance: local_balance {
858
+ __typename
859
+ currency_amount_original_value: original_value
860
+ currency_amount_original_unit: original_unit
861
+ currency_amount_preferred_currency_unit: preferred_currency_unit
862
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
863
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
864
+ }
865
+ lightspark_node_purpose: purpose
866
+ lightspark_node_remote_balance: remote_balance {
867
+ __typename
868
+ currency_amount_original_value: original_value
869
+ currency_amount_original_unit: original_unit
870
+ currency_amount_preferred_currency_unit: preferred_currency_unit
871
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
872
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
873
+ }
874
+ lightspark_node_status: status
875
+ }
876
+ }
877
+ invoice_data_memo: memo
878
+ }
879
+ }
880
+ outgoing_payment_failure_reason: failure_reason
881
+ outgoing_payment_failure_message: failure_message {
882
+ __typename
883
+ rich_text_text: text
884
+ }
885
+ }
886
+ ... on RoutingTransaction {
887
+ __typename
888
+ routing_transaction_id: id
889
+ routing_transaction_created_at: created_at
890
+ routing_transaction_updated_at: updated_at
891
+ routing_transaction_status: status
892
+ routing_transaction_resolved_at: resolved_at
893
+ routing_transaction_amount: amount {
894
+ __typename
895
+ currency_amount_original_value: original_value
896
+ currency_amount_original_unit: original_unit
897
+ currency_amount_preferred_currency_unit: preferred_currency_unit
898
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
899
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
900
+ }
901
+ routing_transaction_transaction_hash: transaction_hash
902
+ routing_transaction_incoming_channel: incoming_channel {
903
+ id
904
+ }
905
+ routing_transaction_outgoing_channel: outgoing_channel {
906
+ id
907
+ }
908
+ routing_transaction_fees: fees {
909
+ __typename
910
+ currency_amount_original_value: original_value
911
+ currency_amount_original_unit: original_unit
912
+ currency_amount_preferred_currency_unit: preferred_currency_unit
913
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
914
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
915
+ }
916
+ routing_transaction_failure_message: failure_message {
917
+ __typename
918
+ rich_text_text: text
919
+ }
920
+ routing_transaction_failure_reason: failure_reason
921
+ }
922
+ ... on Withdrawal {
923
+ __typename
924
+ withdrawal_id: id
925
+ withdrawal_created_at: created_at
926
+ withdrawal_updated_at: updated_at
927
+ withdrawal_status: status
928
+ withdrawal_resolved_at: resolved_at
929
+ withdrawal_amount: amount {
930
+ __typename
931
+ currency_amount_original_value: original_value
932
+ currency_amount_original_unit: original_unit
933
+ currency_amount_preferred_currency_unit: preferred_currency_unit
934
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
935
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
936
+ }
937
+ withdrawal_transaction_hash: transaction_hash
938
+ withdrawal_fees: fees {
939
+ __typename
940
+ currency_amount_original_value: original_value
941
+ currency_amount_original_unit: original_unit
942
+ currency_amount_preferred_currency_unit: preferred_currency_unit
943
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
944
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
945
+ }
946
+ withdrawal_block_hash: block_hash
947
+ withdrawal_block_height: block_height
948
+ withdrawal_destination_addresses: destination_addresses
949
+ withdrawal_num_confirmations: num_confirmations
950
+ withdrawal_origin: origin {
951
+ id
952
+ }
953
+ }
954
+ }
955
+ account_to_transactions_connection_page_info: page_info {
956
+ __typename
957
+ page_info_has_next_page: has_next_page
958
+ page_info_has_previous_page: has_previous_page
959
+ page_info_start_cursor: start_cursor
960
+ page_info_end_cursor: end_cursor
961
+ }
962
+ }
963
+ }
964
+ }
965
+ }
966
+ `,
967
+ variables: {
968
+ first: first,
969
+ after: after,
970
+ types: types,
971
+ after_date: afterDate,
972
+ before_date: beforeDate,
973
+ bitcoin_network: bitcoinNetwork,
974
+ lightning_node_id: lightningNodeId,
975
+ statuses: statuses,
976
+ exclude_failures: excludeFailures,
977
+ },
978
+ constructObject: (json) => {
979
+ const connection = json["current_account"]["transactions"];
980
+ return AccountToTransactionsConnectionFromJson(connection);
981
+ },
982
+ }))!;
983
+ }
984
+
985
+ public async getPaymentRequests(
986
+ client: LightsparkClient,
987
+ first: number | undefined = undefined,
988
+ after: string | undefined = undefined,
989
+ afterDate: string | undefined = undefined,
990
+ beforeDate: string | undefined = undefined,
991
+ bitcoinNetwork: BitcoinNetwork | undefined = undefined,
992
+ lightningNodeId: string | undefined = undefined
993
+ ): Promise<AccountToPaymentRequestsConnection> {
994
+ return (await client.executeRawQuery({
995
+ queryPayload: `
996
+ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID) {
997
+ current_account {
998
+ ... on Account {
999
+ payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id) {
1000
+ __typename
1001
+ account_to_payment_requests_connection_count: count
1002
+ account_to_payment_requests_connection_entities: entities {
1003
+ __typename
1004
+ ... on Invoice {
1005
+ __typename
1006
+ invoice_id: id
1007
+ invoice_created_at: created_at
1008
+ invoice_updated_at: updated_at
1009
+ invoice_data: data {
1010
+ __typename
1011
+ invoice_data_encoded_payment_request: encoded_payment_request
1012
+ invoice_data_bitcoin_network: bitcoin_network
1013
+ invoice_data_payment_hash: payment_hash
1014
+ invoice_data_amount: amount {
1015
+ __typename
1016
+ currency_amount_original_value: original_value
1017
+ currency_amount_original_unit: original_unit
1018
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1019
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1020
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1021
+ }
1022
+ invoice_data_created_at: created_at
1023
+ invoice_data_expires_at: expires_at
1024
+ invoice_data_destination: destination {
1025
+ __typename
1026
+ ... on GraphNode {
1027
+ __typename
1028
+ graph_node_id: id
1029
+ graph_node_created_at: created_at
1030
+ graph_node_updated_at: updated_at
1031
+ graph_node_alias: alias
1032
+ graph_node_bitcoin_network: bitcoin_network
1033
+ graph_node_color: color
1034
+ graph_node_conductivity: conductivity
1035
+ graph_node_display_name: display_name
1036
+ graph_node_public_key: public_key
1037
+ }
1038
+ ... on LightsparkNode {
1039
+ __typename
1040
+ lightspark_node_id: id
1041
+ lightspark_node_created_at: created_at
1042
+ lightspark_node_updated_at: updated_at
1043
+ lightspark_node_alias: alias
1044
+ lightspark_node_bitcoin_network: bitcoin_network
1045
+ lightspark_node_color: color
1046
+ lightspark_node_conductivity: conductivity
1047
+ lightspark_node_display_name: display_name
1048
+ lightspark_node_public_key: public_key
1049
+ lightspark_node_account: account {
1050
+ id
1051
+ }
1052
+ lightspark_node_blockchain_balance: blockchain_balance {
1053
+ __typename
1054
+ blockchain_balance_total_balance: total_balance {
1055
+ __typename
1056
+ currency_amount_original_value: original_value
1057
+ currency_amount_original_unit: original_unit
1058
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1059
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1060
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1061
+ }
1062
+ blockchain_balance_confirmed_balance: confirmed_balance {
1063
+ __typename
1064
+ currency_amount_original_value: original_value
1065
+ currency_amount_original_unit: original_unit
1066
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1067
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1068
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1069
+ }
1070
+ blockchain_balance_unconfirmed_balance: unconfirmed_balance {
1071
+ __typename
1072
+ currency_amount_original_value: original_value
1073
+ currency_amount_original_unit: original_unit
1074
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1075
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1076
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1077
+ }
1078
+ blockchain_balance_locked_balance: locked_balance {
1079
+ __typename
1080
+ currency_amount_original_value: original_value
1081
+ currency_amount_original_unit: original_unit
1082
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1083
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1084
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1085
+ }
1086
+ blockchain_balance_required_reserve: required_reserve {
1087
+ __typename
1088
+ currency_amount_original_value: original_value
1089
+ currency_amount_original_unit: original_unit
1090
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1091
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1092
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1093
+ }
1094
+ blockchain_balance_available_balance: available_balance {
1095
+ __typename
1096
+ currency_amount_original_value: original_value
1097
+ currency_amount_original_unit: original_unit
1098
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1099
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1100
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1101
+ }
1102
+ }
1103
+ lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
1104
+ __typename
1105
+ secret_encrypted_value: encrypted_value
1106
+ secret_cipher: cipher
1107
+ }
1108
+ lightspark_node_total_balance: total_balance {
1109
+ __typename
1110
+ currency_amount_original_value: original_value
1111
+ currency_amount_original_unit: original_unit
1112
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1113
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1114
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1115
+ }
1116
+ lightspark_node_total_local_balance: total_local_balance {
1117
+ __typename
1118
+ currency_amount_original_value: original_value
1119
+ currency_amount_original_unit: original_unit
1120
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1121
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1122
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1123
+ }
1124
+ lightspark_node_local_balance: local_balance {
1125
+ __typename
1126
+ currency_amount_original_value: original_value
1127
+ currency_amount_original_unit: original_unit
1128
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1129
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1130
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1131
+ }
1132
+ lightspark_node_purpose: purpose
1133
+ lightspark_node_remote_balance: remote_balance {
1134
+ __typename
1135
+ currency_amount_original_value: original_value
1136
+ currency_amount_original_unit: original_unit
1137
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1138
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1139
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1140
+ }
1141
+ lightspark_node_status: status
1142
+ }
1143
+ }
1144
+ invoice_data_memo: memo
1145
+ }
1146
+ invoice_status: status
1147
+ invoice_amount_paid: amount_paid {
1148
+ __typename
1149
+ currency_amount_original_value: original_value
1150
+ currency_amount_original_unit: original_unit
1151
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1152
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1153
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1154
+ }
1155
+ }
1156
+ }
1157
+ account_to_payment_requests_connection_page_info: page_info {
1158
+ __typename
1159
+ page_info_has_next_page: has_next_page
1160
+ page_info_has_previous_page: has_previous_page
1161
+ page_info_start_cursor: start_cursor
1162
+ page_info_end_cursor: end_cursor
1163
+ }
1164
+ }
1165
+ }
1166
+ }
1167
+ }
1168
+ `,
1169
+ variables: {
1170
+ first: first,
1171
+ after: after,
1172
+ after_date: afterDate,
1173
+ before_date: beforeDate,
1174
+ bitcoin_network: bitcoinNetwork,
1175
+ lightning_node_id: lightningNodeId,
1176
+ },
1177
+ constructObject: (json) => {
1178
+ const connection = json["current_account"]["payment_requests"];
1179
+ return AccountToPaymentRequestsConnectionFromJson(connection);
1180
+ },
1181
+ }))!;
1182
+ }
1183
+
1184
+ static getAccountQuery(): Query<Account> {
1185
+ return {
1186
+ queryPayload: `
1187
+ query GetAccount {
1188
+ current_account {
1189
+ ... on Account {
1190
+ ...AccountFragment
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ ${FRAGMENT}
1196
+ `,
1197
+ variables: {},
1198
+ constructObject: (data: any) => AccountFromJson(data.current_account),
1199
+ };
1200
+ }
1201
+ }
1202
+
1203
+ export const AccountFromJson = (obj: any): Account => {
1204
+ return new Account(
1205
+ obj["account_id"],
1206
+ obj["account_created_at"],
1207
+ obj["account_updated_at"],
1208
+ "Account",
1209
+ obj["account_name"]
1210
+ );
1211
+ };
1212
+
1213
+ export const FRAGMENT = `
1214
+ fragment AccountFragment on Account {
1215
+ __typename
1216
+ account_id: id
1217
+ account_created_at: created_at
1218
+ account_updated_at: updated_at
1219
+ account_name: name
1220
+ }`;
1221
+
1222
+ export default Account;