@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,29 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum PaymentFailureReason {
4
+ /**
5
+ * This is an enum value that represents values that could be added in the future.
6
+ * Clients should support unknown values as more of them could be added without notice.
7
+ */
8
+ FUTURE_VALUE = "FUTURE_VALUE",
9
+
10
+ NONE = "NONE",
11
+
12
+ TIMEOUT = "TIMEOUT",
13
+
14
+ NO_ROUTE = "NO_ROUTE",
15
+
16
+ ERROR = "ERROR",
17
+
18
+ INCORRECT_PAYMENT_DETAILS = "INCORRECT_PAYMENT_DETAILS",
19
+
20
+ INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
21
+
22
+ INVOICE_ALREADY_PAID = "INVOICE_ALREADY_PAID",
23
+
24
+ SELF_PAYMENT = "SELF_PAYMENT",
25
+
26
+ INVOICE_EXPIRED = "INVOICE_EXPIRED",
27
+ }
28
+
29
+ export default PaymentFailureReason;
@@ -0,0 +1,231 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { LightsparkException, Query } from "@lightsparkdev/core";
4
+ import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
+ import Entity from "./Entity.js";
6
+ import Invoice from "./Invoice.js";
7
+ import { InvoiceDataFromJson } from "./InvoiceData.js";
8
+ import PaymentRequestData from "./PaymentRequestData.js";
9
+ import PaymentRequestStatus from "./PaymentRequestStatus.js";
10
+
11
+ type PaymentRequest = Entity & {
12
+ /**
13
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
14
+ * string.
15
+ **/
16
+ id: string;
17
+
18
+ /** The date and time when the entity was first created. **/
19
+ createdAt: string;
20
+
21
+ /** The date and time when the entity was last updated. **/
22
+ updatedAt: string;
23
+
24
+ /** The details of the payment request. **/
25
+ data: PaymentRequestData;
26
+
27
+ /** The status of the payment request. **/
28
+ status: PaymentRequestStatus;
29
+
30
+ /** The typename of the object **/
31
+ typename: string;
32
+ };
33
+
34
+ export const PaymentRequestFromJson = (obj: any): PaymentRequest => {
35
+ if (obj["__typename"] == "Invoice") {
36
+ return {
37
+ id: obj["invoice_id"],
38
+ createdAt: obj["invoice_created_at"],
39
+ updatedAt: obj["invoice_updated_at"],
40
+ data: InvoiceDataFromJson(obj["invoice_data"]),
41
+ status:
42
+ PaymentRequestStatus[obj["invoice_status"]] ??
43
+ PaymentRequestStatus.FUTURE_VALUE,
44
+ typename: "Invoice",
45
+ amountPaid: !!obj["invoice_amount_paid"]
46
+ ? CurrencyAmountFromJson(obj["invoice_amount_paid"])
47
+ : undefined,
48
+ } as Invoice;
49
+ }
50
+ throw new LightsparkException(
51
+ "DeserializationError",
52
+ `Couldn't find a concrete type for interface PaymentRequest corresponding to the typename=${obj["__typename"]}`
53
+ );
54
+ };
55
+
56
+ export const FRAGMENT = `
57
+ fragment PaymentRequestFragment on PaymentRequest {
58
+ __typename
59
+ ... on Invoice {
60
+ __typename
61
+ invoice_id: id
62
+ invoice_created_at: created_at
63
+ invoice_updated_at: updated_at
64
+ invoice_data: data {
65
+ __typename
66
+ invoice_data_encoded_payment_request: encoded_payment_request
67
+ invoice_data_bitcoin_network: bitcoin_network
68
+ invoice_data_payment_hash: payment_hash
69
+ invoice_data_amount: amount {
70
+ __typename
71
+ currency_amount_original_value: original_value
72
+ currency_amount_original_unit: original_unit
73
+ currency_amount_preferred_currency_unit: preferred_currency_unit
74
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
75
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
76
+ }
77
+ invoice_data_created_at: created_at
78
+ invoice_data_expires_at: expires_at
79
+ invoice_data_destination: destination {
80
+ __typename
81
+ ... on GraphNode {
82
+ __typename
83
+ graph_node_id: id
84
+ graph_node_created_at: created_at
85
+ graph_node_updated_at: updated_at
86
+ graph_node_alias: alias
87
+ graph_node_bitcoin_network: bitcoin_network
88
+ graph_node_color: color
89
+ graph_node_conductivity: conductivity
90
+ graph_node_display_name: display_name
91
+ graph_node_public_key: public_key
92
+ }
93
+ ... on LightsparkNode {
94
+ __typename
95
+ lightspark_node_id: id
96
+ lightspark_node_created_at: created_at
97
+ lightspark_node_updated_at: updated_at
98
+ lightspark_node_alias: alias
99
+ lightspark_node_bitcoin_network: bitcoin_network
100
+ lightspark_node_color: color
101
+ lightspark_node_conductivity: conductivity
102
+ lightspark_node_display_name: display_name
103
+ lightspark_node_public_key: public_key
104
+ lightspark_node_account: account {
105
+ id
106
+ }
107
+ lightspark_node_blockchain_balance: blockchain_balance {
108
+ __typename
109
+ blockchain_balance_total_balance: total_balance {
110
+ __typename
111
+ currency_amount_original_value: original_value
112
+ currency_amount_original_unit: original_unit
113
+ currency_amount_preferred_currency_unit: preferred_currency_unit
114
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
115
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
116
+ }
117
+ blockchain_balance_confirmed_balance: confirmed_balance {
118
+ __typename
119
+ currency_amount_original_value: original_value
120
+ currency_amount_original_unit: original_unit
121
+ currency_amount_preferred_currency_unit: preferred_currency_unit
122
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
123
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
124
+ }
125
+ blockchain_balance_unconfirmed_balance: unconfirmed_balance {
126
+ __typename
127
+ currency_amount_original_value: original_value
128
+ currency_amount_original_unit: original_unit
129
+ currency_amount_preferred_currency_unit: preferred_currency_unit
130
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
131
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
132
+ }
133
+ blockchain_balance_locked_balance: locked_balance {
134
+ __typename
135
+ currency_amount_original_value: original_value
136
+ currency_amount_original_unit: original_unit
137
+ currency_amount_preferred_currency_unit: preferred_currency_unit
138
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
139
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
140
+ }
141
+ blockchain_balance_required_reserve: required_reserve {
142
+ __typename
143
+ currency_amount_original_value: original_value
144
+ currency_amount_original_unit: original_unit
145
+ currency_amount_preferred_currency_unit: preferred_currency_unit
146
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
147
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
148
+ }
149
+ blockchain_balance_available_balance: available_balance {
150
+ __typename
151
+ currency_amount_original_value: original_value
152
+ currency_amount_original_unit: original_unit
153
+ currency_amount_preferred_currency_unit: preferred_currency_unit
154
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
155
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
156
+ }
157
+ }
158
+ lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
159
+ __typename
160
+ secret_encrypted_value: encrypted_value
161
+ secret_cipher: cipher
162
+ }
163
+ lightspark_node_total_balance: total_balance {
164
+ __typename
165
+ currency_amount_original_value: original_value
166
+ currency_amount_original_unit: original_unit
167
+ currency_amount_preferred_currency_unit: preferred_currency_unit
168
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
169
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
170
+ }
171
+ lightspark_node_total_local_balance: total_local_balance {
172
+ __typename
173
+ currency_amount_original_value: original_value
174
+ currency_amount_original_unit: original_unit
175
+ currency_amount_preferred_currency_unit: preferred_currency_unit
176
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
177
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
178
+ }
179
+ lightspark_node_local_balance: local_balance {
180
+ __typename
181
+ currency_amount_original_value: original_value
182
+ currency_amount_original_unit: original_unit
183
+ currency_amount_preferred_currency_unit: preferred_currency_unit
184
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
185
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
186
+ }
187
+ lightspark_node_purpose: purpose
188
+ lightspark_node_remote_balance: remote_balance {
189
+ __typename
190
+ currency_amount_original_value: original_value
191
+ currency_amount_original_unit: original_unit
192
+ currency_amount_preferred_currency_unit: preferred_currency_unit
193
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
194
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
195
+ }
196
+ lightspark_node_status: status
197
+ }
198
+ }
199
+ invoice_data_memo: memo
200
+ }
201
+ invoice_status: status
202
+ invoice_amount_paid: amount_paid {
203
+ __typename
204
+ currency_amount_original_value: original_value
205
+ currency_amount_original_unit: original_unit
206
+ currency_amount_preferred_currency_unit: preferred_currency_unit
207
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
208
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
209
+ }
210
+ }
211
+ }`;
212
+
213
+ export const getPaymentRequestQuery = (id: string): Query<PaymentRequest> => {
214
+ return {
215
+ queryPayload: `
216
+ query GetPaymentRequest($id: ID!) {
217
+ entity(id: $id) {
218
+ ... on PaymentRequest {
219
+ ...PaymentRequestFragment
220
+ }
221
+ }
222
+ }
223
+
224
+ ${FRAGMENT}
225
+ `,
226
+ variables: { id },
227
+ constructObject: (data: any) => PaymentRequestFromJson(data.entity),
228
+ };
229
+ };
230
+
231
+ export default PaymentRequest;
@@ -0,0 +1,183 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { LightsparkException } from "@lightsparkdev/core";
4
+ import BitcoinNetwork from "./BitcoinNetwork.js";
5
+ import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
+ import InvoiceData from "./InvoiceData.js";
7
+ import { NodeFromJson } from "./Node.js";
8
+
9
+ /** The interface of a payment request on the Lightning Network (a.k.a. Lightning Invoice). **/
10
+ type PaymentRequestData = {
11
+ encodedPaymentRequest: string;
12
+
13
+ bitcoinNetwork: BitcoinNetwork;
14
+
15
+ /** The typename of the object **/
16
+ typename: string;
17
+ };
18
+
19
+ export const PaymentRequestDataFromJson = (obj: any): PaymentRequestData => {
20
+ if (obj["__typename"] == "InvoiceData") {
21
+ return {
22
+ encodedPaymentRequest: obj["invoice_data_encoded_payment_request"],
23
+ bitcoinNetwork:
24
+ BitcoinNetwork[obj["invoice_data_bitcoin_network"]] ??
25
+ BitcoinNetwork.FUTURE_VALUE,
26
+ paymentHash: obj["invoice_data_payment_hash"],
27
+ amount: CurrencyAmountFromJson(obj["invoice_data_amount"]),
28
+ createdAt: obj["invoice_data_created_at"],
29
+ expiresAt: obj["invoice_data_expires_at"],
30
+ destination: NodeFromJson(obj["invoice_data_destination"]),
31
+ typename: "InvoiceData",
32
+ memo: obj["invoice_data_memo"],
33
+ } as InvoiceData;
34
+ }
35
+ throw new LightsparkException(
36
+ "DeserializationError",
37
+ `Couldn't find a concrete type for interface PaymentRequestData corresponding to the typename=${obj["__typename"]}`
38
+ );
39
+ };
40
+
41
+ export const FRAGMENT = `
42
+ fragment PaymentRequestDataFragment on PaymentRequestData {
43
+ __typename
44
+ ... on InvoiceData {
45
+ __typename
46
+ invoice_data_encoded_payment_request: encoded_payment_request
47
+ invoice_data_bitcoin_network: bitcoin_network
48
+ invoice_data_payment_hash: payment_hash
49
+ invoice_data_amount: amount {
50
+ __typename
51
+ currency_amount_original_value: original_value
52
+ currency_amount_original_unit: original_unit
53
+ currency_amount_preferred_currency_unit: preferred_currency_unit
54
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
55
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
56
+ }
57
+ invoice_data_created_at: created_at
58
+ invoice_data_expires_at: expires_at
59
+ invoice_data_destination: destination {
60
+ __typename
61
+ ... on GraphNode {
62
+ __typename
63
+ graph_node_id: id
64
+ graph_node_created_at: created_at
65
+ graph_node_updated_at: updated_at
66
+ graph_node_alias: alias
67
+ graph_node_bitcoin_network: bitcoin_network
68
+ graph_node_color: color
69
+ graph_node_conductivity: conductivity
70
+ graph_node_display_name: display_name
71
+ graph_node_public_key: public_key
72
+ }
73
+ ... on LightsparkNode {
74
+ __typename
75
+ lightspark_node_id: id
76
+ lightspark_node_created_at: created_at
77
+ lightspark_node_updated_at: updated_at
78
+ lightspark_node_alias: alias
79
+ lightspark_node_bitcoin_network: bitcoin_network
80
+ lightspark_node_color: color
81
+ lightspark_node_conductivity: conductivity
82
+ lightspark_node_display_name: display_name
83
+ lightspark_node_public_key: public_key
84
+ lightspark_node_account: account {
85
+ id
86
+ }
87
+ lightspark_node_blockchain_balance: blockchain_balance {
88
+ __typename
89
+ blockchain_balance_total_balance: total_balance {
90
+ __typename
91
+ currency_amount_original_value: original_value
92
+ currency_amount_original_unit: original_unit
93
+ currency_amount_preferred_currency_unit: preferred_currency_unit
94
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
95
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
96
+ }
97
+ blockchain_balance_confirmed_balance: confirmed_balance {
98
+ __typename
99
+ currency_amount_original_value: original_value
100
+ currency_amount_original_unit: original_unit
101
+ currency_amount_preferred_currency_unit: preferred_currency_unit
102
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
103
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
104
+ }
105
+ blockchain_balance_unconfirmed_balance: unconfirmed_balance {
106
+ __typename
107
+ currency_amount_original_value: original_value
108
+ currency_amount_original_unit: original_unit
109
+ currency_amount_preferred_currency_unit: preferred_currency_unit
110
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
111
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
112
+ }
113
+ blockchain_balance_locked_balance: locked_balance {
114
+ __typename
115
+ currency_amount_original_value: original_value
116
+ currency_amount_original_unit: original_unit
117
+ currency_amount_preferred_currency_unit: preferred_currency_unit
118
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
119
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
120
+ }
121
+ blockchain_balance_required_reserve: required_reserve {
122
+ __typename
123
+ currency_amount_original_value: original_value
124
+ currency_amount_original_unit: original_unit
125
+ currency_amount_preferred_currency_unit: preferred_currency_unit
126
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
127
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
128
+ }
129
+ blockchain_balance_available_balance: available_balance {
130
+ __typename
131
+ currency_amount_original_value: original_value
132
+ currency_amount_original_unit: original_unit
133
+ currency_amount_preferred_currency_unit: preferred_currency_unit
134
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
135
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
136
+ }
137
+ }
138
+ lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
139
+ __typename
140
+ secret_encrypted_value: encrypted_value
141
+ secret_cipher: cipher
142
+ }
143
+ lightspark_node_total_balance: total_balance {
144
+ __typename
145
+ currency_amount_original_value: original_value
146
+ currency_amount_original_unit: original_unit
147
+ currency_amount_preferred_currency_unit: preferred_currency_unit
148
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
149
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
150
+ }
151
+ lightspark_node_total_local_balance: total_local_balance {
152
+ __typename
153
+ currency_amount_original_value: original_value
154
+ currency_amount_original_unit: original_unit
155
+ currency_amount_preferred_currency_unit: preferred_currency_unit
156
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
157
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
158
+ }
159
+ lightspark_node_local_balance: local_balance {
160
+ __typename
161
+ currency_amount_original_value: original_value
162
+ currency_amount_original_unit: original_unit
163
+ currency_amount_preferred_currency_unit: preferred_currency_unit
164
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
165
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
166
+ }
167
+ lightspark_node_purpose: purpose
168
+ lightspark_node_remote_balance: remote_balance {
169
+ __typename
170
+ currency_amount_original_value: original_value
171
+ currency_amount_original_unit: original_unit
172
+ currency_amount_preferred_currency_unit: preferred_currency_unit
173
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
174
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
175
+ }
176
+ lightspark_node_status: status
177
+ }
178
+ }
179
+ invoice_data_memo: memo
180
+ }
181
+ }`;
182
+
183
+ export default PaymentRequestData;
@@ -0,0 +1,15 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum PaymentRequestStatus {
4
+ /**
5
+ * This is an enum value that represents values that could be added in the future.
6
+ * Clients should support unknown values as more of them could be added without notice.
7
+ */
8
+ FUTURE_VALUE = "FUTURE_VALUE",
9
+
10
+ OPEN = "OPEN",
11
+
12
+ CLOSED = "CLOSED",
13
+ }
14
+
15
+ export default PaymentRequestStatus;
@@ -0,0 +1,39 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum Permission {
4
+ /**
5
+ * This is an enum value that represents values that could be added in the future.
6
+ * Clients should support unknown values as more of them could be added without notice.
7
+ */
8
+ FUTURE_VALUE = "FUTURE_VALUE",
9
+
10
+ ALL = "ALL",
11
+
12
+ MAINNET_VIEW = "MAINNET_VIEW",
13
+
14
+ MAINNET_TRANSACT = "MAINNET_TRANSACT",
15
+
16
+ MAINNET_MANAGE = "MAINNET_MANAGE",
17
+
18
+ TESTNET_VIEW = "TESTNET_VIEW",
19
+
20
+ TESTNET_TRANSACT = "TESTNET_TRANSACT",
21
+
22
+ TESTNET_MANAGE = "TESTNET_MANAGE",
23
+
24
+ REGTEST_VIEW = "REGTEST_VIEW",
25
+
26
+ REGTEST_TRANSACT = "REGTEST_TRANSACT",
27
+
28
+ REGTEST_MANAGE = "REGTEST_MANAGE",
29
+
30
+ USER_VIEW = "USER_VIEW",
31
+
32
+ USER_MANAGE = "USER_MANAGE",
33
+
34
+ ACCOUNT_VIEW = "ACCOUNT_VIEW",
35
+
36
+ ACCOUNT_MANAGE = "ACCOUNT_MANAGE",
37
+ }
38
+
39
+ export default Permission;
@@ -0,0 +1,35 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import WithdrawalMode from "./WithdrawalMode.js";
4
+
5
+ type RequestWithdrawalInput = {
6
+ /** The node from which you'd like to make the withdrawal. **/
7
+ nodeId: string;
8
+
9
+ /** The bitcoin address where the withdrawal should be sent. **/
10
+ bitcoinAddress: string;
11
+
12
+ /**
13
+ * The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal
14
+ * all funds from this node.
15
+ **/
16
+ amountSats: number;
17
+
18
+ /** The strategy that should be used to withdraw the funds from this node. **/
19
+ withdrawalMode: WithdrawalMode;
20
+ };
21
+
22
+ export const RequestWithdrawalInputFromJson = (
23
+ obj: any
24
+ ): RequestWithdrawalInput => {
25
+ return {
26
+ nodeId: obj["request_withdrawal_input_node_id"],
27
+ bitcoinAddress: obj["request_withdrawal_input_bitcoin_address"],
28
+ amountSats: obj["request_withdrawal_input_amount_sats"],
29
+ withdrawalMode:
30
+ WithdrawalMode[obj["request_withdrawal_input_withdrawal_mode"]] ??
31
+ WithdrawalMode.FUTURE_VALUE,
32
+ } as RequestWithdrawalInput;
33
+ };
34
+
35
+ export default RequestWithdrawalInput;
@@ -0,0 +1,24 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ type RequestWithdrawalOutput = {
4
+ /** The request that is created for this withdrawal. **/
5
+ requestId: string;
6
+ };
7
+
8
+ export const RequestWithdrawalOutputFromJson = (
9
+ obj: any
10
+ ): RequestWithdrawalOutput => {
11
+ return {
12
+ requestId: obj["request_withdrawal_output_request"].id,
13
+ } as RequestWithdrawalOutput;
14
+ };
15
+
16
+ export const FRAGMENT = `
17
+ fragment RequestWithdrawalOutputFragment on RequestWithdrawalOutput {
18
+ __typename
19
+ request_withdrawal_output_request: request {
20
+ id
21
+ }
22
+ }`;
23
+
24
+ export default RequestWithdrawalOutput;
@@ -0,0 +1,19 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ type RichText = {
4
+ text: string;
5
+ };
6
+
7
+ export const RichTextFromJson = (obj: any): RichText => {
8
+ return {
9
+ text: obj["rich_text_text"],
10
+ } as RichText;
11
+ };
12
+
13
+ export const FRAGMENT = `
14
+ fragment RichTextFragment on RichText {
15
+ __typename
16
+ rich_text_text: text
17
+ }`;
18
+
19
+ export default RichText;