@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,31 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum TransactionType {
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
+ /** Transactions initiated from a Lightspark node on Lightning Network. **/
10
+ OUTGOING_PAYMENT = "OUTGOING_PAYMENT",
11
+ /** Transactions received by a Lightspark node on Lightning Network. **/
12
+ INCOMING_PAYMENT = "INCOMING_PAYMENT",
13
+ /** Transactions that forwarded payments through Lightspark nodes on Lightning Network. **/
14
+ ROUTED = "ROUTED",
15
+ /** Transactions on the Bitcoin blockchain to withdraw funds from a Lightspark node to a Bitcoin wallet. **/
16
+ L1_WITHDRAW = "L1_WITHDRAW",
17
+ /** Transactions on Bitcoin blockchain to fund a Lightspark node's wallet. **/
18
+ L1_DEPOSIT = "L1_DEPOSIT",
19
+ /** Transactions on Bitcoin blockchain to open a channel on Lightning Network funded by the local Lightspark node. **/
20
+ CHANNEL_OPEN = "CHANNEL_OPEN",
21
+ /** Transactions on Bitcoin blockchain to close a channel on Lightning Network where the balances are allocated back to local and remote nodes. **/
22
+ CHANNEL_CLOSE = "CHANNEL_CLOSE",
23
+ /** Transactions initiated from a Lightspark node on Lightning Network. **/
24
+ PAYMENT = "PAYMENT",
25
+ /** Payment requests from a Lightspark node on Lightning Network **/
26
+ PAYMENT_REQUEST = "PAYMENT_REQUEST",
27
+ /** Transactions that forwarded payments through Lightspark nodes on Lightning Network. **/
28
+ ROUTE = "ROUTE",
29
+ }
30
+
31
+ export default TransactionType;
@@ -0,0 +1,67 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import TransactionStatus from "./TransactionStatus.js";
5
+
6
+ type TransactionUpdate = {
7
+ /**
8
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
9
+ * string.
10
+ **/
11
+ id: string;
12
+
13
+ /** The date and time when this transaction was initiated. **/
14
+ createdAt: string;
15
+
16
+ /** The date and time when the entity was last updated. **/
17
+ updatedAt: string;
18
+
19
+ /** The current status of this transaction. **/
20
+ status: TransactionStatus;
21
+
22
+ /** The amount of money involved in this transaction. **/
23
+ amount: CurrencyAmount;
24
+
25
+ /** The typename of the object **/
26
+ typename: string;
27
+
28
+ /** The date and time when this transaction was completed or failed. **/
29
+ resolvedAt?: string;
30
+
31
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
32
+ transactionHash?: string;
33
+ };
34
+
35
+ export const TransactionUpdateFromJson = (obj: any): TransactionUpdate => {
36
+ return {
37
+ id: obj["id"],
38
+ createdAt: obj["created_at"],
39
+ updatedAt: obj["updated_at"],
40
+ status: TransactionStatus[obj["status"]] ?? TransactionStatus.FUTURE_VALUE,
41
+ amount: CurrencyAmountFromJson(obj["amount"]),
42
+ typename: obj["__typename"] ?? "TransactionUpdate",
43
+ resolvedAt: obj["resolved_at"],
44
+ transactionHash: obj["transaction_hash"],
45
+ };
46
+ };
47
+
48
+ export const FRAGMENT = `
49
+ fragment TransactionUpdateFragment on Transaction {
50
+ __typename
51
+ id
52
+ created_at
53
+ updated_at
54
+ status
55
+ resolved_at
56
+ amount {
57
+ __typename
58
+ currency_amount_original_value: original_value
59
+ currency_amount_original_unit: original_unit
60
+ currency_amount_preferred_currency_unit: preferred_currency_unit
61
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
62
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
63
+ }
64
+ transaction_hash
65
+ }`;
66
+
67
+ export default TransactionUpdate;
@@ -0,0 +1,32 @@
1
+ import { Maybe } from "@lightsparkdev/core";
2
+ import CurrencyAmount from "./CurrencyAmount.js";
3
+ import LightsparkNodePurpose from "./LightsparkNodePurpose.js";
4
+ import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
5
+ import NodeAddressType from "./NodeAddressType.js";
6
+ import Transaction from "./Transaction.js";
7
+
8
+ type WalletDashboard = {
9
+ id: string;
10
+ displayName: string;
11
+ purpose: Maybe<LightsparkNodePurpose>;
12
+ color: Maybe<string>;
13
+ publicKey: Maybe<string>;
14
+ status: Maybe<LightsparkNodeStatus>;
15
+ addresses: {
16
+ address: string;
17
+ type: NodeAddressType;
18
+ }[];
19
+ totalBalance: Maybe<CurrencyAmount>;
20
+ totalLocalBalance: Maybe<CurrencyAmount>;
21
+ onlineLocalBalance: Maybe<CurrencyAmount>;
22
+ remoteBalance: Maybe<CurrencyAmount>;
23
+ blockchainBalance: {
24
+ availableBalance: Maybe<CurrencyAmount>;
25
+ totalBalance: Maybe<CurrencyAmount>;
26
+ confirmedBalance: Maybe<CurrencyAmount>;
27
+ unconfirmedBalance: Maybe<CurrencyAmount>;
28
+ } | null;
29
+ recentTransactions: Transaction[];
30
+ };
31
+
32
+ export default WalletDashboard;
@@ -0,0 +1,15 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum WebhookEventType {
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
+ PAYMENT_FINISHED = "PAYMENT_FINISHED",
11
+
12
+ NODE_STATUS = "NODE_STATUS",
13
+ }
14
+
15
+ export default WebhookEventType;
@@ -0,0 +1,144 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { Query } from "@lightsparkdev/core";
4
+ import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
+ import Entity from "./Entity.js";
6
+ import OnChainTransaction from "./OnChainTransaction.js";
7
+ import Transaction from "./Transaction.js";
8
+ import TransactionStatus from "./TransactionStatus.js";
9
+
10
+ /** The transaction on the Bitcoin blockchain to withdraw funds from the Lightspark node to a Bitcoin wallet. **/
11
+ type Withdrawal = OnChainTransaction &
12
+ Transaction &
13
+ Entity & {
14
+ /**
15
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
16
+ * string.
17
+ **/
18
+ id: string;
19
+
20
+ /** The date and time when this transaction was initiated. **/
21
+ createdAt: string;
22
+
23
+ /** The date and time when the entity was last updated. **/
24
+ updatedAt: string;
25
+
26
+ /** The current status of this transaction. **/
27
+ status: TransactionStatus;
28
+
29
+ /** The amount of money involved in this transaction. **/
30
+ amount: CurrencyAmount;
31
+
32
+ /**
33
+ * The height of the block that included this transaction. This will be zero for unconfirmed
34
+ * transactions.
35
+ **/
36
+ blockHeight: number;
37
+
38
+ /** The Bitcoin blockchain addresses this transaction was sent to. **/
39
+ destinationAddresses: string[];
40
+
41
+ /** The Lightspark node this withdrawal originated from. **/
42
+ originId: string;
43
+
44
+ /** The typename of the object **/
45
+ typename: string;
46
+
47
+ /** The date and time when this transaction was completed or failed. **/
48
+ resolvedAt?: string;
49
+
50
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
51
+ transactionHash?: string;
52
+
53
+ /**
54
+ * The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
55
+ * blockchain.
56
+ **/
57
+ fees?: CurrencyAmount;
58
+
59
+ /**
60
+ * The hash of the block that included this transaction. This will be null for unconfirmed
61
+ * transactions.
62
+ **/
63
+ blockHash?: string;
64
+
65
+ /** The number of blockchain confirmations for this transaction in real time. **/
66
+ numConfirmations?: number;
67
+ };
68
+
69
+ export const WithdrawalFromJson = (obj: any): Withdrawal => {
70
+ return {
71
+ id: obj["withdrawal_id"],
72
+ createdAt: obj["withdrawal_created_at"],
73
+ updatedAt: obj["withdrawal_updated_at"],
74
+ status:
75
+ TransactionStatus[obj["withdrawal_status"]] ??
76
+ TransactionStatus.FUTURE_VALUE,
77
+ amount: CurrencyAmountFromJson(obj["withdrawal_amount"]),
78
+ blockHeight: obj["withdrawal_block_height"],
79
+ destinationAddresses: obj["withdrawal_destination_addresses"],
80
+ originId: obj["withdrawal_origin"].id,
81
+ typename: "Withdrawal",
82
+ resolvedAt: obj["withdrawal_resolved_at"],
83
+ transactionHash: obj["withdrawal_transaction_hash"],
84
+ fees: !!obj["withdrawal_fees"]
85
+ ? CurrencyAmountFromJson(obj["withdrawal_fees"])
86
+ : undefined,
87
+ blockHash: obj["withdrawal_block_hash"],
88
+ numConfirmations: obj["withdrawal_num_confirmations"],
89
+ } as Withdrawal;
90
+ };
91
+
92
+ export const FRAGMENT = `
93
+ fragment WithdrawalFragment on Withdrawal {
94
+ __typename
95
+ withdrawal_id: id
96
+ withdrawal_created_at: created_at
97
+ withdrawal_updated_at: updated_at
98
+ withdrawal_status: status
99
+ withdrawal_resolved_at: resolved_at
100
+ withdrawal_amount: amount {
101
+ __typename
102
+ currency_amount_original_value: original_value
103
+ currency_amount_original_unit: original_unit
104
+ currency_amount_preferred_currency_unit: preferred_currency_unit
105
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
106
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
107
+ }
108
+ withdrawal_transaction_hash: transaction_hash
109
+ withdrawal_fees: fees {
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
+ withdrawal_block_hash: block_hash
118
+ withdrawal_block_height: block_height
119
+ withdrawal_destination_addresses: destination_addresses
120
+ withdrawal_num_confirmations: num_confirmations
121
+ withdrawal_origin: origin {
122
+ id
123
+ }
124
+ }`;
125
+
126
+ export const getWithdrawalQuery = (id: string): Query<Withdrawal> => {
127
+ return {
128
+ queryPayload: `
129
+ query GetWithdrawal($id: ID!) {
130
+ entity(id: $id) {
131
+ ... on Withdrawal {
132
+ ...WithdrawalFragment
133
+ }
134
+ }
135
+ }
136
+
137
+ ${FRAGMENT}
138
+ `,
139
+ variables: { id },
140
+ constructObject: (data: any) => WithdrawalFromJson(data.entity),
141
+ };
142
+ };
143
+
144
+ export default Withdrawal;
@@ -0,0 +1,15 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum WithdrawalMode {
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
+ WALLET_ONLY = "WALLET_ONLY",
11
+
12
+ WALLET_THEN_CHANNELS = "WALLET_THEN_CHANNELS",
13
+ }
14
+
15
+ export default WithdrawalMode;
@@ -0,0 +1,224 @@
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 CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import Entity from "./Entity.js";
8
+ import WithdrawalMode from "./WithdrawalMode.js";
9
+ import WithdrawalRequestStatus from "./WithdrawalRequestStatus.js";
10
+ import WithdrawalRequestToChannelClosingTransactionsConnection, {
11
+ WithdrawalRequestToChannelClosingTransactionsConnectionFromJson,
12
+ } from "./WithdrawalRequestToChannelClosingTransactionsConnection.js";
13
+ import WithdrawalRequestToChannelOpeningTransactionsConnection, {
14
+ WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson,
15
+ } from "./WithdrawalRequestToChannelOpeningTransactionsConnection.js";
16
+
17
+ class WithdrawalRequest implements Entity {
18
+ constructor(
19
+ public readonly id: string,
20
+ public readonly createdAt: string,
21
+ public readonly updatedAt: string,
22
+ public readonly amount: CurrencyAmount,
23
+ public readonly bitcoinAddress: string,
24
+ public readonly withdrawalMode: WithdrawalMode,
25
+ public readonly status: WithdrawalRequestStatus,
26
+ public readonly typename: string,
27
+ public readonly completedAt?: string,
28
+ public readonly withdrawalId?: string
29
+ ) {
30
+ autoBind(this);
31
+ }
32
+
33
+ public async getChannelClosingTransactions(
34
+ client: LightsparkClient,
35
+ first: number | undefined = undefined
36
+ ): Promise<WithdrawalRequestToChannelClosingTransactionsConnection> {
37
+ return (await client.executeRawQuery({
38
+ queryPayload: `
39
+ query FetchWithdrawalRequestToChannelClosingTransactionsConnection($entity_id: ID!, $first: Int) {
40
+ entity(id: $entity_id) {
41
+ ... on WithdrawalRequest {
42
+ channel_closing_transactions(, first: $first) {
43
+ __typename
44
+ withdrawal_request_to_channel_closing_transactions_connection_page_info: page_info {
45
+ __typename
46
+ page_info_has_next_page: has_next_page
47
+ page_info_has_previous_page: has_previous_page
48
+ page_info_start_cursor: start_cursor
49
+ page_info_end_cursor: end_cursor
50
+ }
51
+ withdrawal_request_to_channel_closing_transactions_connection_count: count
52
+ withdrawal_request_to_channel_closing_transactions_connection_entities: entities {
53
+ __typename
54
+ channel_closing_transaction_id: id
55
+ channel_closing_transaction_created_at: created_at
56
+ channel_closing_transaction_updated_at: updated_at
57
+ channel_closing_transaction_status: status
58
+ channel_closing_transaction_resolved_at: resolved_at
59
+ channel_closing_transaction_amount: amount {
60
+ __typename
61
+ currency_amount_original_value: original_value
62
+ currency_amount_original_unit: original_unit
63
+ currency_amount_preferred_currency_unit: preferred_currency_unit
64
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
65
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
66
+ }
67
+ channel_closing_transaction_transaction_hash: transaction_hash
68
+ channel_closing_transaction_fees: fees {
69
+ __typename
70
+ currency_amount_original_value: original_value
71
+ currency_amount_original_unit: original_unit
72
+ currency_amount_preferred_currency_unit: preferred_currency_unit
73
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
74
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
75
+ }
76
+ channel_closing_transaction_block_hash: block_hash
77
+ channel_closing_transaction_block_height: block_height
78
+ channel_closing_transaction_destination_addresses: destination_addresses
79
+ channel_closing_transaction_num_confirmations: num_confirmations
80
+ channel_closing_transaction_channel: channel {
81
+ id
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ `,
89
+ variables: { entity_id: this.id, first: first },
90
+ constructObject: (json) => {
91
+ const connection = json["entity"]["channel_closing_transactions"];
92
+ return WithdrawalRequestToChannelClosingTransactionsConnectionFromJson(
93
+ connection
94
+ );
95
+ },
96
+ }))!;
97
+ }
98
+
99
+ public async getChannelOpeningTransactions(
100
+ client: LightsparkClient,
101
+ first: number | undefined = undefined
102
+ ): Promise<WithdrawalRequestToChannelOpeningTransactionsConnection> {
103
+ return (await client.executeRawQuery({
104
+ queryPayload: `
105
+ query FetchWithdrawalRequestToChannelOpeningTransactionsConnection($entity_id: ID!, $first: Int) {
106
+ entity(id: $entity_id) {
107
+ ... on WithdrawalRequest {
108
+ channel_opening_transactions(, first: $first) {
109
+ __typename
110
+ withdrawal_request_to_channel_opening_transactions_connection_page_info: page_info {
111
+ __typename
112
+ page_info_has_next_page: has_next_page
113
+ page_info_has_previous_page: has_previous_page
114
+ page_info_start_cursor: start_cursor
115
+ page_info_end_cursor: end_cursor
116
+ }
117
+ withdrawal_request_to_channel_opening_transactions_connection_count: count
118
+ withdrawal_request_to_channel_opening_transactions_connection_entities: entities {
119
+ __typename
120
+ channel_opening_transaction_id: id
121
+ channel_opening_transaction_created_at: created_at
122
+ channel_opening_transaction_updated_at: updated_at
123
+ channel_opening_transaction_status: status
124
+ channel_opening_transaction_resolved_at: resolved_at
125
+ channel_opening_transaction_amount: amount {
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
+ channel_opening_transaction_transaction_hash: transaction_hash
134
+ channel_opening_transaction_fees: fees {
135
+ __typename
136
+ currency_amount_original_value: original_value
137
+ currency_amount_original_unit: original_unit
138
+ currency_amount_preferred_currency_unit: preferred_currency_unit
139
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
140
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
141
+ }
142
+ channel_opening_transaction_block_hash: block_hash
143
+ channel_opening_transaction_block_height: block_height
144
+ channel_opening_transaction_destination_addresses: destination_addresses
145
+ channel_opening_transaction_num_confirmations: num_confirmations
146
+ channel_opening_transaction_channel: channel {
147
+ id
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ `,
155
+ variables: { entity_id: this.id, first: first },
156
+ constructObject: (json) => {
157
+ const connection = json["entity"]["channel_opening_transactions"];
158
+ return WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson(
159
+ connection
160
+ );
161
+ },
162
+ }))!;
163
+ }
164
+
165
+ static getWithdrawalRequestQuery(id: string): Query<WithdrawalRequest> {
166
+ return {
167
+ queryPayload: `
168
+ query GetWithdrawalRequest($id: ID!) {
169
+ entity(id: $id) {
170
+ ... on WithdrawalRequest {
171
+ ...WithdrawalRequestFragment
172
+ }
173
+ }
174
+ }
175
+
176
+ ${FRAGMENT}
177
+ `,
178
+ variables: { id },
179
+ constructObject: (data: any) => WithdrawalRequestFromJson(data.entity),
180
+ };
181
+ }
182
+ }
183
+
184
+ export const WithdrawalRequestFromJson = (obj: any): WithdrawalRequest => {
185
+ return new WithdrawalRequest(
186
+ obj["withdrawal_request_id"],
187
+ obj["withdrawal_request_created_at"],
188
+ obj["withdrawal_request_updated_at"],
189
+ CurrencyAmountFromJson(obj["withdrawal_request_amount"]),
190
+ obj["withdrawal_request_bitcoin_address"],
191
+ WithdrawalMode[obj["withdrawal_request_withdrawal_mode"]] ??
192
+ WithdrawalMode.FUTURE_VALUE,
193
+ WithdrawalRequestStatus[obj["withdrawal_request_status"]] ??
194
+ WithdrawalRequestStatus.FUTURE_VALUE,
195
+ "WithdrawalRequest",
196
+ obj["withdrawal_request_completed_at"],
197
+ obj["withdrawal_request_withdrawal"]?.id ?? undefined
198
+ );
199
+ };
200
+
201
+ export const FRAGMENT = `
202
+ fragment WithdrawalRequestFragment on WithdrawalRequest {
203
+ __typename
204
+ withdrawal_request_id: id
205
+ withdrawal_request_created_at: created_at
206
+ withdrawal_request_updated_at: updated_at
207
+ withdrawal_request_amount: amount {
208
+ __typename
209
+ currency_amount_original_value: original_value
210
+ currency_amount_original_unit: original_unit
211
+ currency_amount_preferred_currency_unit: preferred_currency_unit
212
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
213
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
214
+ }
215
+ withdrawal_request_bitcoin_address: bitcoin_address
216
+ withdrawal_request_withdrawal_mode: withdrawal_mode
217
+ withdrawal_request_status: status
218
+ withdrawal_request_completed_at: completed_at
219
+ withdrawal_request_withdrawal: withdrawal {
220
+ id
221
+ }
222
+ }`;
223
+
224
+ export default WithdrawalRequest;
@@ -0,0 +1,17 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ export enum WithdrawalRequestStatus {
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
+ FAILED = "FAILED",
11
+
12
+ IN_PROGRESS = "IN_PROGRESS",
13
+
14
+ SUCCESSFUL = "SUCCESSFUL",
15
+ }
16
+
17
+ export default WithdrawalRequestStatus;
@@ -0,0 +1,57 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import ChannelClosingTransaction, {
4
+ ChannelClosingTransactionFromJson,
5
+ } from "./ChannelClosingTransaction.js";
6
+ import PageInfo, { PageInfoFromJson } from "./PageInfo.js";
7
+
8
+ type WithdrawalRequestToChannelClosingTransactionsConnection = {
9
+ /** An object that holds pagination information about the objects in this connection. **/
10
+ pageInfo: PageInfo;
11
+
12
+ /**
13
+ * The total count of objects in this connection, using the current filters. It is different from the
14
+ * number of objects returned in the current page (in the `entities` field).
15
+ **/
16
+ count: number;
17
+
18
+ /** The channel closing transactions for the current page of this connection. **/
19
+ entities: ChannelClosingTransaction[];
20
+ };
21
+
22
+ export const WithdrawalRequestToChannelClosingTransactionsConnectionFromJson = (
23
+ obj: any
24
+ ): WithdrawalRequestToChannelClosingTransactionsConnection => {
25
+ return {
26
+ pageInfo: PageInfoFromJson(
27
+ obj[
28
+ "withdrawal_request_to_channel_closing_transactions_connection_page_info"
29
+ ]
30
+ ),
31
+ count:
32
+ obj[
33
+ "withdrawal_request_to_channel_closing_transactions_connection_count"
34
+ ],
35
+ entities: obj[
36
+ "withdrawal_request_to_channel_closing_transactions_connection_entities"
37
+ ].map((e) => ChannelClosingTransactionFromJson(e)),
38
+ } as WithdrawalRequestToChannelClosingTransactionsConnection;
39
+ };
40
+
41
+ export const FRAGMENT = `
42
+ fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on WithdrawalRequestToChannelClosingTransactionsConnection {
43
+ __typename
44
+ withdrawal_request_to_channel_closing_transactions_connection_page_info: page_info {
45
+ __typename
46
+ page_info_has_next_page: has_next_page
47
+ page_info_has_previous_page: has_previous_page
48
+ page_info_start_cursor: start_cursor
49
+ page_info_end_cursor: end_cursor
50
+ }
51
+ withdrawal_request_to_channel_closing_transactions_connection_count: count
52
+ withdrawal_request_to_channel_closing_transactions_connection_entities: entities {
53
+ id
54
+ }
55
+ }`;
56
+
57
+ export default WithdrawalRequestToChannelClosingTransactionsConnection;
@@ -0,0 +1,57 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import ChannelOpeningTransaction, {
4
+ ChannelOpeningTransactionFromJson,
5
+ } from "./ChannelOpeningTransaction.js";
6
+ import PageInfo, { PageInfoFromJson } from "./PageInfo.js";
7
+
8
+ type WithdrawalRequestToChannelOpeningTransactionsConnection = {
9
+ /** An object that holds pagination information about the objects in this connection. **/
10
+ pageInfo: PageInfo;
11
+
12
+ /**
13
+ * The total count of objects in this connection, using the current filters. It is different from the
14
+ * number of objects returned in the current page (in the `entities` field).
15
+ **/
16
+ count: number;
17
+
18
+ /** The channel opening transactions for the current page of this connection. **/
19
+ entities: ChannelOpeningTransaction[];
20
+ };
21
+
22
+ export const WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson = (
23
+ obj: any
24
+ ): WithdrawalRequestToChannelOpeningTransactionsConnection => {
25
+ return {
26
+ pageInfo: PageInfoFromJson(
27
+ obj[
28
+ "withdrawal_request_to_channel_opening_transactions_connection_page_info"
29
+ ]
30
+ ),
31
+ count:
32
+ obj[
33
+ "withdrawal_request_to_channel_opening_transactions_connection_count"
34
+ ],
35
+ entities: obj[
36
+ "withdrawal_request_to_channel_opening_transactions_connection_entities"
37
+ ].map((e) => ChannelOpeningTransactionFromJson(e)),
38
+ } as WithdrawalRequestToChannelOpeningTransactionsConnection;
39
+ };
40
+
41
+ export const FRAGMENT = `
42
+ fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on WithdrawalRequestToChannelOpeningTransactionsConnection {
43
+ __typename
44
+ withdrawal_request_to_channel_opening_transactions_connection_page_info: page_info {
45
+ __typename
46
+ page_info_has_next_page: has_next_page
47
+ page_info_has_previous_page: has_previous_page
48
+ page_info_start_cursor: start_cursor
49
+ page_info_end_cursor: end_cursor
50
+ }
51
+ withdrawal_request_to_channel_opening_transactions_connection_count: count
52
+ withdrawal_request_to_channel_opening_transactions_connection_entities: entities {
53
+ id
54
+ }
55
+ }`;
56
+
57
+ export default WithdrawalRequestToChannelOpeningTransactionsConnection;