@lightsparkdev/lightspark-sdk 1.1.7 → 1.2.1

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 (136) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{chunk-5RDIWPBE.js → chunk-D32EWIPX.js} +3 -1
  3. package/dist/{chunk-7UT6YX37.js → chunk-VTPDR6P4.js} +393 -275
  4. package/dist/env.cjs +3 -1
  5. package/dist/env.d.cts +17 -0
  6. package/dist/env.js +2 -2
  7. package/dist/{index-d31f4469.d.ts → index-5acc6526.d.ts} +1403 -408
  8. package/dist/index.cjs +424 -296
  9. package/dist/index.d.cts +41 -0
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.js +32 -27
  12. package/dist/objects/index.cjs +395 -277
  13. package/dist/objects/index.d.cts +4 -0
  14. package/dist/objects/index.d.ts +1 -1
  15. package/dist/objects/index.js +6 -6
  16. package/dist/{text-encoding-MDIPJAHL.js → text-encoding-26SMKBAQ.js} +3 -1
  17. package/package.json +5 -5
  18. package/src/auth/AccountTokenAuthProvider.ts +15 -11
  19. package/src/client.ts +7 -6
  20. package/src/helpers.ts +3 -1
  21. package/src/objects/Account.ts +21 -2
  22. package/src/objects/AccountToApiTokensConnection.ts +16 -5
  23. package/src/objects/AccountToChannelsConnection.ts +14 -0
  24. package/src/objects/AccountToNodesConnection.ts +19 -5
  25. package/src/objects/AccountToPaymentRequestsConnection.ts +21 -5
  26. package/src/objects/AccountToTransactionsConnection.ts +33 -9
  27. package/src/objects/AccountToWalletsConnection.ts +13 -4
  28. package/src/objects/ApiToken.ts +13 -3
  29. package/src/objects/Balances.ts +17 -3
  30. package/src/objects/BlockchainBalance.ts +34 -9
  31. package/src/objects/Channel.ts +92 -16
  32. package/src/objects/ChannelClosingTransaction.ts +81 -61
  33. package/src/objects/ChannelFees.ts +16 -5
  34. package/src/objects/ChannelOpeningTransaction.ts +81 -61
  35. package/src/objects/ChannelSnapshot.ts +32 -8
  36. package/src/objects/ChannelToTransactionsConnection.ts +26 -6
  37. package/src/objects/Connection.ts +205 -10
  38. package/src/objects/CreateApiTokenInput.ts +8 -2
  39. package/src/objects/CreateApiTokenOutput.ts +9 -3
  40. package/src/objects/CreateInvoiceInput.ts +14 -5
  41. package/src/objects/CreateInvoiceOutput.ts +7 -2
  42. package/src/objects/CreateLnurlInvoiceInput.ts +13 -3
  43. package/src/objects/CreateNodeWalletAddressInput.ts +9 -2
  44. package/src/objects/CreateNodeWalletAddressOutput.ts +10 -2
  45. package/src/objects/CreateTestModeInvoiceInput.ts +14 -4
  46. package/src/objects/CreateTestModeInvoiceOutput.ts +10 -2
  47. package/src/objects/CreateTestModePaymentInput.ts +12 -3
  48. package/src/objects/CreateTestModePaymentoutput.ts +12 -2
  49. package/src/objects/CreateUmaInvoiceInput.ts +13 -3
  50. package/src/objects/CurrencyAmount.ts +13 -2
  51. package/src/objects/DeclineToSignMessagesInput.ts +9 -2
  52. package/src/objects/DeclineToSignMessagesOutput.ts +15 -3
  53. package/src/objects/DeleteApiTokenInput.ts +7 -2
  54. package/src/objects/DeleteApiTokenOutput.ts +7 -2
  55. package/src/objects/Deposit.ts +77 -61
  56. package/src/objects/Entity.ts +2 -2
  57. package/src/objects/FeeEstimate.ts +12 -3
  58. package/src/objects/FundNodeInput.ts +9 -3
  59. package/src/objects/FundNodeOutput.ts +11 -3
  60. package/src/objects/GraphNode.ts +49 -5
  61. package/src/objects/Hop.ts +27 -9
  62. package/src/objects/IdAndSignature.ts +8 -2
  63. package/src/objects/IncomingPayment.ts +50 -7
  64. package/src/objects/IncomingPaymentAttempt.ts +21 -5
  65. package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
  66. package/src/objects/Invoice.ts +37 -24
  67. package/src/objects/InvoiceData.ts +21 -6
  68. package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
  69. package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
  70. package/src/objects/LightningFeeEstimateOutput.ts +15 -3
  71. package/src/objects/LightningTransaction.ts +117 -28
  72. package/src/objects/LightsparkNode.ts +250 -210
  73. package/src/objects/LightsparkNodeOwner.ts +35 -4
  74. package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
  75. package/src/objects/LightsparkNodeWithOSK.ts +127 -17
  76. package/src/objects/LightsparkNodeWithRemoteSigning.ts +122 -15
  77. package/src/objects/Node.ts +209 -68
  78. package/src/objects/NodeAddress.ts +8 -2
  79. package/src/objects/NodeToAddressesConnection.ts +13 -3
  80. package/src/objects/OnChainTransaction.ts +156 -44
  81. package/src/objects/OutgoingPayment.ts +72 -14
  82. package/src/objects/OutgoingPaymentAttempt.ts +63 -8
  83. package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
  84. package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
  85. package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
  86. package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
  87. package/src/objects/PageInfo.ts +14 -6
  88. package/src/objects/PayInvoiceInput.ts +12 -3
  89. package/src/objects/PayInvoiceOutput.ts +7 -2
  90. package/src/objects/PayUmaInvoiceInput.ts +12 -3
  91. package/src/objects/PaymentRequest.ts +27 -5
  92. package/src/objects/PaymentRequestData.ts +27 -4
  93. package/src/objects/PostTransactionData.ts +12 -3
  94. package/src/objects/RegisterPaymentInput.ts +10 -2
  95. package/src/objects/RegisterPaymentOutput.ts +9 -2
  96. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
  97. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
  98. package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
  99. package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
  100. package/src/objects/RequestWithdrawalInput.ts +12 -2
  101. package/src/objects/RequestWithdrawalOutput.ts +9 -2
  102. package/src/objects/RichText.ts +7 -2
  103. package/src/objects/RoutingTransaction.ts +62 -41
  104. package/src/objects/ScreenNodeInput.ts +8 -2
  105. package/src/objects/ScreenNodeOutput.ts +7 -2
  106. package/src/objects/Secret.ts +8 -2
  107. package/src/objects/SendPaymentInput.ts +11 -2
  108. package/src/objects/SendPaymentOutput.ts +7 -2
  109. package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
  110. package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
  111. package/src/objects/SignInvoiceInput.ts +9 -2
  112. package/src/objects/SignInvoiceOutput.ts +7 -2
  113. package/src/objects/SignMessagesInput.ts +13 -3
  114. package/src/objects/SignMessagesOutput.ts +13 -3
  115. package/src/objects/Signable.ts +10 -3
  116. package/src/objects/SignablePayload.ts +18 -5
  117. package/src/objects/Transaction.ts +206 -9
  118. package/src/objects/TransactionFailures.ts +11 -4
  119. package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
  120. package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
  121. package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
  122. package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
  123. package/src/objects/Wallet.ts +34 -5
  124. package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
  125. package/src/objects/WalletToTransactionsConnection.ts +16 -5
  126. package/src/objects/Withdrawal.ts +77 -61
  127. package/src/objects/WithdrawalRequest.ts +42 -4
  128. package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
  129. package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
  130. package/src/objects/index.ts +5 -2
  131. package/src/tests/integration/constants.ts +13 -0
  132. package/src/tests/integration/general-regtest.test.ts +652 -0
  133. package/src/tests/serialization.test.ts +21 -0
  134. package/src/webhooks.ts +1 -1
  135. package/src/tests/integration/client.test.ts +0 -207
  136. /package/dist/{chunk-NIMBE7W3.js → chunk-BMTV3EA2.js} +0 -0
@@ -4,29 +4,54 @@ import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
7
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
7
+ import {
8
+ CurrencyAmountFromJson,
9
+ CurrencyAmountToJson,
10
+ } from "./CurrencyAmount.js";
11
+ import type Entity from "./Entity.js";
8
12
  import type IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
9
13
  import type IncomingPaymentToAttemptsConnection from "./IncomingPaymentToAttemptsConnection.js";
10
14
  import { IncomingPaymentToAttemptsConnectionFromJson } from "./IncomingPaymentToAttemptsConnection.js";
11
15
  import type LightningTransaction from "./LightningTransaction.js";
12
16
  import type PostTransactionData from "./PostTransactionData.js";
13
- import { PostTransactionDataFromJson } from "./PostTransactionData.js";
17
+ import {
18
+ PostTransactionDataFromJson,
19
+ PostTransactionDataToJson,
20
+ } from "./PostTransactionData.js";
21
+ import type Transaction from "./Transaction.js";
14
22
  import TransactionStatus from "./TransactionStatus.js";
15
23
 
16
24
  /** This object represents any payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific payment received by a Lightspark node. **/
17
- class IncomingPayment implements LightningTransaction {
25
+ class IncomingPayment implements LightningTransaction, Transaction, Entity {
18
26
  constructor(
27
+ /**
28
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
29
+ * string.
30
+ **/
19
31
  public readonly id: string,
32
+ /** The date and time when this transaction was initiated. **/
20
33
  public readonly createdAt: string,
34
+ /** The date and time when the entity was last updated. **/
21
35
  public readonly updatedAt: string,
36
+ /** The current status of this transaction. **/
22
37
  public readonly status: TransactionStatus,
38
+ /** The amount of money involved in this transaction. **/
23
39
  public readonly amount: CurrencyAmount,
40
+ /** The recipient Lightspark node this payment was sent to. **/
24
41
  public readonly destinationId: string,
42
+ /** The typename of the object **/
25
43
  public readonly typename: string,
26
- public readonly resolvedAt?: string,
27
- public readonly transactionHash?: string,
28
- public readonly paymentRequestId?: string,
29
- public readonly umaPostTransactionData?: PostTransactionData[],
44
+ /** The date and time when this transaction was completed or failed. **/
45
+ public readonly resolvedAt?: string | undefined,
46
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
47
+ public readonly transactionHash?: string | undefined,
48
+ /**
49
+ * The optional payment request for this incoming payment, which will be null if the payment is sent
50
+ * through keysend.
51
+ **/
52
+ public readonly paymentRequestId?: string | undefined,
53
+ /** The post transaction data which can be used in KYT payment registration. **/
54
+ public readonly umaPostTransactionData?: PostTransactionData[] | undefined,
30
55
  ) {
31
56
  autoBind(this);
32
57
  }
@@ -106,6 +131,24 @@ ${FRAGMENT}
106
131
  constructObject: (data: any) => IncomingPaymentFromJson(data.entity),
107
132
  };
108
133
  }
134
+
135
+ public toJson() {
136
+ return {
137
+ __typename: "IncomingPayment",
138
+ incoming_payment_id: this.id,
139
+ incoming_payment_created_at: this.createdAt,
140
+ incoming_payment_updated_at: this.updatedAt,
141
+ incoming_payment_status: this.status,
142
+ incoming_payment_resolved_at: this.resolvedAt,
143
+ incoming_payment_amount: CurrencyAmountToJson(this.amount),
144
+ incoming_payment_transaction_hash: this.transactionHash,
145
+ incoming_payment_destination: { id: this.destinationId },
146
+ incoming_payment_payment_request:
147
+ { id: this.paymentRequestId } ?? undefined,
148
+ incoming_payment_uma_post_transaction_data:
149
+ this.umaPostTransactionData?.map((e) => PostTransactionDataToJson(e)),
150
+ };
151
+ }
109
152
  }
110
153
 
111
154
  export const IncomingPaymentFromJson = (obj: any): IncomingPayment => {
@@ -2,12 +2,14 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
  import IncomingPaymentAttemptStatus from "./IncomingPaymentAttemptStatus.js";
8
10
 
9
11
  /** This object represents any attempted payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific incoming payment attempt. **/
10
- type IncomingPaymentAttempt = Entity & {
12
+ interface IncomingPaymentAttempt {
11
13
  /**
12
14
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
13
15
  * string.
@@ -33,8 +35,8 @@ type IncomingPaymentAttempt = Entity & {
33
35
  typename: string;
34
36
 
35
37
  /** The time the incoming payment attempt failed or succeeded. **/
36
- resolvedAt?: string;
37
- };
38
+ resolvedAt?: string | undefined;
39
+ }
38
40
 
39
41
  export const IncomingPaymentAttemptFromJson = (
40
42
  obj: any,
@@ -52,6 +54,20 @@ export const IncomingPaymentAttemptFromJson = (
52
54
  resolvedAt: obj["incoming_payment_attempt_resolved_at"],
53
55
  } as IncomingPaymentAttempt;
54
56
  };
57
+ export const IncomingPaymentAttemptToJson = (
58
+ obj: IncomingPaymentAttempt,
59
+ ): any => {
60
+ return {
61
+ __typename: "IncomingPaymentAttempt",
62
+ incoming_payment_attempt_id: obj.id,
63
+ incoming_payment_attempt_created_at: obj.createdAt,
64
+ incoming_payment_attempt_updated_at: obj.updatedAt,
65
+ incoming_payment_attempt_status: obj.status,
66
+ incoming_payment_attempt_resolved_at: obj.resolvedAt,
67
+ incoming_payment_attempt_amount: CurrencyAmountToJson(obj.amount),
68
+ incoming_payment_attempt_channel: { id: obj.channelId },
69
+ };
70
+ };
55
71
 
56
72
  export const FRAGMENT = `
57
73
  fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt {
@@ -1,13 +1,15 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import type Connection from "./Connection.js";
4
3
  import type IncomingPaymentAttempt from "./IncomingPaymentAttempt.js";
5
- import { IncomingPaymentAttemptFromJson } from "./IncomingPaymentAttempt.js";
4
+ import {
5
+ IncomingPaymentAttemptFromJson,
6
+ IncomingPaymentAttemptToJson,
7
+ } from "./IncomingPaymentAttempt.js";
6
8
  import type PageInfo from "./PageInfo.js";
7
- import { PageInfoFromJson } from "./PageInfo.js";
9
+ import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
8
10
 
9
11
  /** The connection from incoming payment to all attempts. **/
10
- type IncomingPaymentToAttemptsConnection = Connection & {
12
+ interface IncomingPaymentToAttemptsConnection {
11
13
  /**
12
14
  * The total count of objects in this connection, using the current filters. It is different from the
13
15
  * number of objects returned in the current page (in the `entities` field).
@@ -22,7 +24,7 @@ type IncomingPaymentToAttemptsConnection = Connection & {
22
24
 
23
25
  /** The typename of the object **/
24
26
  typename: string;
25
- };
27
+ }
26
28
 
27
29
  export const IncomingPaymentToAttemptsConnectionFromJson = (
28
30
  obj: any,
@@ -38,6 +40,20 @@ export const IncomingPaymentToAttemptsConnectionFromJson = (
38
40
  typename: "IncomingPaymentToAttemptsConnection",
39
41
  } as IncomingPaymentToAttemptsConnection;
40
42
  };
43
+ export const IncomingPaymentToAttemptsConnectionToJson = (
44
+ obj: IncomingPaymentToAttemptsConnection,
45
+ ): any => {
46
+ return {
47
+ __typename: "IncomingPaymentToAttemptsConnection",
48
+ incoming_payment_to_attempts_connection_count: obj.count,
49
+ incoming_payment_to_attempts_connection_page_info: PageInfoToJson(
50
+ obj.pageInfo,
51
+ ),
52
+ incoming_payment_to_attempts_connection_entities: obj.entities.map((e) =>
53
+ IncomingPaymentAttemptToJson(e),
54
+ ),
55
+ };
56
+ };
41
57
 
42
58
  export const FRAGMENT = `
43
59
  fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttemptsConnection {
@@ -2,40 +2,40 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
  import type InvoiceData from "./InvoiceData.js";
8
- import { InvoiceDataFromJson } from "./InvoiceData.js";
9
- import type PaymentRequest from "./PaymentRequest.js";
10
+ import { InvoiceDataFromJson, InvoiceDataToJson } from "./InvoiceData.js";
10
11
  import PaymentRequestStatus from "./PaymentRequestStatus.js";
11
12
 
12
13
  /** This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) created by a Lightspark Node. You can retrieve this object to receive relevant payment information for a specific invoice generated by a Lightspark node. **/
13
- type Invoice = PaymentRequest &
14
- Entity & {
15
- /**
16
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
17
- * string.
18
- **/
19
- id: string;
14
+ interface Invoice {
15
+ /**
16
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
17
+ * string.
18
+ **/
19
+ id: string;
20
20
 
21
- /** The date and time when the entity was first created. **/
22
- createdAt: string;
21
+ /** The date and time when the entity was first created. **/
22
+ createdAt: string;
23
23
 
24
- /** The date and time when the entity was last updated. **/
25
- updatedAt: string;
24
+ /** The date and time when the entity was last updated. **/
25
+ updatedAt: string;
26
26
 
27
- /** The details of the invoice. **/
28
- data: InvoiceData;
27
+ /** The details of the invoice. **/
28
+ data: InvoiceData;
29
29
 
30
- /** The status of the payment request. **/
31
- status: PaymentRequestStatus;
30
+ /** The status of the payment request. **/
31
+ status: PaymentRequestStatus;
32
32
 
33
- /** The typename of the object **/
34
- typename: string;
33
+ /** The typename of the object **/
34
+ typename: string;
35
35
 
36
- /** The total amount that has been paid to this invoice. **/
37
- amountPaid?: CurrencyAmount;
38
- };
36
+ /** The total amount that has been paid to this invoice. **/
37
+ amountPaid?: CurrencyAmount | undefined;
38
+ }
39
39
 
40
40
  export const InvoiceFromJson = (obj: any): Invoice => {
41
41
  return {
@@ -52,6 +52,19 @@ export const InvoiceFromJson = (obj: any): Invoice => {
52
52
  : undefined,
53
53
  } as Invoice;
54
54
  };
55
+ export const InvoiceToJson = (obj: Invoice): any => {
56
+ return {
57
+ __typename: "Invoice",
58
+ invoice_id: obj.id,
59
+ invoice_created_at: obj.createdAt,
60
+ invoice_updated_at: obj.updatedAt,
61
+ invoice_data: InvoiceDataToJson(obj.data),
62
+ invoice_status: obj.status,
63
+ invoice_amount_paid: obj.amountPaid
64
+ ? CurrencyAmountToJson(obj.amountPaid)
65
+ : undefined,
66
+ };
67
+ };
55
68
 
56
69
  export const FRAGMENT = `
57
70
  fragment InvoiceFragment on Invoice {
@@ -2,13 +2,15 @@
2
2
 
3
3
  import BitcoinNetwork from "./BitcoinNetwork.js";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
6
9
  import type Node from "./Node.js";
7
- import { NodeFromJson } from "./Node.js";
8
- import type PaymentRequestData from "./PaymentRequestData.js";
10
+ import { NodeFromJson, NodeToJson } from "./Node.js";
9
11
 
10
12
  /** This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice. **/
11
- type InvoiceData = PaymentRequestData & {
13
+ interface InvoiceData {
12
14
  encodedPaymentRequest: string;
13
15
 
14
16
  bitcoinNetwork: BitcoinNetwork;
@@ -35,8 +37,8 @@ type InvoiceData = PaymentRequestData & {
35
37
  typename: string;
36
38
 
37
39
  /** A short, UTF-8 encoded, description of the purpose of this invoice. **/
38
- memo?: string;
39
- };
40
+ memo?: string | undefined;
41
+ }
40
42
 
41
43
  export const InvoiceDataFromJson = (obj: any): InvoiceData => {
42
44
  return {
@@ -53,6 +55,19 @@ export const InvoiceDataFromJson = (obj: any): InvoiceData => {
53
55
  memo: obj["invoice_data_memo"],
54
56
  } as InvoiceData;
55
57
  };
58
+ export const InvoiceDataToJson = (obj: InvoiceData): any => {
59
+ return {
60
+ __typename: "InvoiceData",
61
+ invoice_data_encoded_payment_request: obj.encodedPaymentRequest,
62
+ invoice_data_bitcoin_network: obj.bitcoinNetwork,
63
+ invoice_data_payment_hash: obj.paymentHash,
64
+ invoice_data_amount: CurrencyAmountToJson(obj.amount),
65
+ invoice_data_created_at: obj.createdAt,
66
+ invoice_data_expires_at: obj.expiresAt,
67
+ invoice_data_memo: obj.memo,
68
+ invoice_data_destination: NodeToJson(obj.destination),
69
+ };
70
+ };
56
71
 
57
72
  export const FRAGMENT = `
58
73
  fragment InvoiceDataFragment on InvoiceData {
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type LightningFeeEstimateForInvoiceInput = {
3
+ interface LightningFeeEstimateForInvoiceInput {
4
4
  /** The node from where you want to send the payment. **/
5
5
  nodeId: string;
6
6
 
@@ -11,8 +11,8 @@ type LightningFeeEstimateForInvoiceInput = {
11
11
  * If the invoice does not specify a payment amount, then the amount that you wish to pay, expressed
12
12
  * in msats.
13
13
  **/
14
- amountMsats?: number;
15
- };
14
+ amountMsats?: number | undefined;
15
+ }
16
16
 
17
17
  export const LightningFeeEstimateForInvoiceInputFromJson = (
18
18
  obj: any,
@@ -24,5 +24,15 @@ export const LightningFeeEstimateForInvoiceInputFromJson = (
24
24
  amountMsats: obj["lightning_fee_estimate_for_invoice_input_amount_msats"],
25
25
  } as LightningFeeEstimateForInvoiceInput;
26
26
  };
27
+ export const LightningFeeEstimateForInvoiceInputToJson = (
28
+ obj: LightningFeeEstimateForInvoiceInput,
29
+ ): any => {
30
+ return {
31
+ lightning_fee_estimate_for_invoice_input_node_id: obj.nodeId,
32
+ lightning_fee_estimate_for_invoice_input_encoded_payment_request:
33
+ obj.encodedPaymentRequest,
34
+ lightning_fee_estimate_for_invoice_input_amount_msats: obj.amountMsats,
35
+ };
36
+ };
27
37
 
28
38
  export default LightningFeeEstimateForInvoiceInput;
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type LightningFeeEstimateForNodeInput = {
3
+ interface LightningFeeEstimateForNodeInput {
4
4
  /** The node from where you want to send the payment. **/
5
5
  nodeId: string;
6
6
 
@@ -9,7 +9,7 @@ type LightningFeeEstimateForNodeInput = {
9
9
 
10
10
  /** The payment amount expressed in msats. **/
11
11
  amountMsats: number;
12
- };
12
+ }
13
13
 
14
14
  export const LightningFeeEstimateForNodeInputFromJson = (
15
15
  obj: any,
@@ -21,5 +21,15 @@ export const LightningFeeEstimateForNodeInputFromJson = (
21
21
  amountMsats: obj["lightning_fee_estimate_for_node_input_amount_msats"],
22
22
  } as LightningFeeEstimateForNodeInput;
23
23
  };
24
+ export const LightningFeeEstimateForNodeInputToJson = (
25
+ obj: LightningFeeEstimateForNodeInput,
26
+ ): any => {
27
+ return {
28
+ lightning_fee_estimate_for_node_input_node_id: obj.nodeId,
29
+ lightning_fee_estimate_for_node_input_destination_node_public_key:
30
+ obj.destinationNodePublicKey,
31
+ lightning_fee_estimate_for_node_input_amount_msats: obj.amountMsats,
32
+ };
33
+ };
24
34
 
25
35
  export default LightningFeeEstimateForNodeInput;
@@ -1,12 +1,15 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
- type LightningFeeEstimateOutput = {
9
+ interface LightningFeeEstimateOutput {
7
10
  /** The estimated fees for the payment. **/
8
11
  feeEstimate: CurrencyAmount;
9
- };
12
+ }
10
13
 
11
14
  export const LightningFeeEstimateOutputFromJson = (
12
15
  obj: any,
@@ -17,6 +20,15 @@ export const LightningFeeEstimateOutputFromJson = (
17
20
  ),
18
21
  } as LightningFeeEstimateOutput;
19
22
  };
23
+ export const LightningFeeEstimateOutputToJson = (
24
+ obj: LightningFeeEstimateOutput,
25
+ ): any => {
26
+ return {
27
+ lightning_fee_estimate_output_fee_estimate: CurrencyAmountToJson(
28
+ obj.feeEstimate,
29
+ ),
30
+ };
31
+ };
20
32
 
21
33
  export const FRAGMENT = `
22
34
  fragment LightningFeeEstimateOutputFragment on LightningFeeEstimateOutput {
@@ -2,49 +2,55 @@
2
2
 
3
3
  import { LightsparkException, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
7
9
  import IncomingPayment from "./IncomingPayment.js";
8
10
  import OutgoingPayment from "./OutgoingPayment.js";
9
11
  import PaymentFailureReason from "./PaymentFailureReason.js";
10
- import { PaymentRequestDataFromJson } from "./PaymentRequestData.js";
11
- import { PostTransactionDataFromJson } from "./PostTransactionData.js";
12
- import { RichTextFromJson } from "./RichText.js";
12
+ import {
13
+ PaymentRequestDataFromJson,
14
+ PaymentRequestDataToJson,
15
+ } from "./PaymentRequestData.js";
16
+ import {
17
+ PostTransactionDataFromJson,
18
+ PostTransactionDataToJson,
19
+ } from "./PostTransactionData.js";
20
+ import { RichTextFromJson, RichTextToJson } from "./RichText.js";
13
21
  import type RoutingTransaction from "./RoutingTransaction.js";
14
22
  import RoutingTransactionFailureReason from "./RoutingTransactionFailureReason.js";
15
- import type Transaction from "./Transaction.js";
16
23
  import TransactionStatus from "./TransactionStatus.js";
17
24
 
18
25
  /** This is an object representing a transaction made over the Lightning Network. You can retrieve this object to receive information about a specific transaction made over Lightning for a Lightspark node. **/
19
- type LightningTransaction = Transaction &
20
- Entity & {
21
- /**
22
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
23
- * string.
24
- **/
25
- id: string;
26
+ interface LightningTransaction {
27
+ /**
28
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
29
+ * string.
30
+ **/
31
+ id: string;
26
32
 
27
- /** The date and time when this transaction was initiated. **/
28
- createdAt: string;
33
+ /** The date and time when this transaction was initiated. **/
34
+ createdAt: string;
29
35
 
30
- /** The date and time when the entity was last updated. **/
31
- updatedAt: string;
36
+ /** The date and time when the entity was last updated. **/
37
+ updatedAt: string;
32
38
 
33
- /** The current status of this transaction. **/
34
- status: TransactionStatus;
39
+ /** The current status of this transaction. **/
40
+ status: TransactionStatus;
35
41
 
36
- /** The amount of money involved in this transaction. **/
37
- amount: CurrencyAmount;
42
+ /** The amount of money involved in this transaction. **/
43
+ amount: CurrencyAmount;
38
44
 
39
- /** The typename of the object **/
40
- typename: string;
45
+ /** The typename of the object **/
46
+ typename: string;
41
47
 
42
- /** The date and time when this transaction was completed or failed. **/
43
- resolvedAt?: string;
48
+ /** The date and time when this transaction was completed or failed. **/
49
+ resolvedAt?: string | undefined;
44
50
 
45
- /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
46
- transactionHash?: string;
47
- };
51
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
52
+ transactionHash?: string | undefined;
53
+ }
48
54
 
49
55
  export const LightningTransactionFromJson = (
50
56
  obj: any,
@@ -135,6 +141,89 @@ export const LightningTransactionFromJson = (
135
141
  `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj["__typename"]}`,
136
142
  );
137
143
  };
144
+ export const LightningTransactionToJson = (obj: LightningTransaction): any => {
145
+ if (obj.typename == "IncomingPayment") {
146
+ const incomingPayment = obj as IncomingPayment;
147
+ return {
148
+ __typename: "IncomingPayment",
149
+ incoming_payment_id: incomingPayment.id,
150
+ incoming_payment_created_at: incomingPayment.createdAt,
151
+ incoming_payment_updated_at: incomingPayment.updatedAt,
152
+ incoming_payment_status: incomingPayment.status,
153
+ incoming_payment_resolved_at: incomingPayment.resolvedAt,
154
+ incoming_payment_amount: CurrencyAmountToJson(incomingPayment.amount),
155
+ incoming_payment_transaction_hash: incomingPayment.transactionHash,
156
+ incoming_payment_destination: { id: incomingPayment.destinationId },
157
+ incoming_payment_payment_request:
158
+ { id: incomingPayment.paymentRequestId } ?? undefined,
159
+ incoming_payment_uma_post_transaction_data:
160
+ incomingPayment.umaPostTransactionData?.map((e) =>
161
+ PostTransactionDataToJson(e),
162
+ ),
163
+ };
164
+ }
165
+ if (obj.typename == "OutgoingPayment") {
166
+ const outgoingPayment = obj as OutgoingPayment;
167
+ return {
168
+ __typename: "OutgoingPayment",
169
+ outgoing_payment_id: outgoingPayment.id,
170
+ outgoing_payment_created_at: outgoingPayment.createdAt,
171
+ outgoing_payment_updated_at: outgoingPayment.updatedAt,
172
+ outgoing_payment_status: outgoingPayment.status,
173
+ outgoing_payment_resolved_at: outgoingPayment.resolvedAt,
174
+ outgoing_payment_amount: CurrencyAmountToJson(outgoingPayment.amount),
175
+ outgoing_payment_transaction_hash: outgoingPayment.transactionHash,
176
+ outgoing_payment_origin: { id: outgoingPayment.originId },
177
+ outgoing_payment_destination:
178
+ { id: outgoingPayment.destinationId } ?? undefined,
179
+ outgoing_payment_fees: outgoingPayment.fees
180
+ ? CurrencyAmountToJson(outgoingPayment.fees)
181
+ : undefined,
182
+ outgoing_payment_payment_request_data: outgoingPayment.paymentRequestData
183
+ ? PaymentRequestDataToJson(outgoingPayment.paymentRequestData)
184
+ : undefined,
185
+ outgoing_payment_failure_reason: outgoingPayment.failureReason,
186
+ outgoing_payment_failure_message: outgoingPayment.failureMessage
187
+ ? RichTextToJson(outgoingPayment.failureMessage)
188
+ : undefined,
189
+ outgoing_payment_uma_post_transaction_data:
190
+ outgoingPayment.umaPostTransactionData?.map((e) =>
191
+ PostTransactionDataToJson(e),
192
+ ),
193
+ outgoing_payment_payment_preimage: outgoingPayment.paymentPreimage,
194
+ };
195
+ }
196
+ if (obj.typename == "RoutingTransaction") {
197
+ const routingTransaction = obj as RoutingTransaction;
198
+ return {
199
+ __typename: "RoutingTransaction",
200
+ routing_transaction_id: routingTransaction.id,
201
+ routing_transaction_created_at: routingTransaction.createdAt,
202
+ routing_transaction_updated_at: routingTransaction.updatedAt,
203
+ routing_transaction_status: routingTransaction.status,
204
+ routing_transaction_resolved_at: routingTransaction.resolvedAt,
205
+ routing_transaction_amount: CurrencyAmountToJson(
206
+ routingTransaction.amount,
207
+ ),
208
+ routing_transaction_transaction_hash: routingTransaction.transactionHash,
209
+ routing_transaction_incoming_channel:
210
+ { id: routingTransaction.incomingChannelId } ?? undefined,
211
+ routing_transaction_outgoing_channel:
212
+ { id: routingTransaction.outgoingChannelId } ?? undefined,
213
+ routing_transaction_fees: routingTransaction.fees
214
+ ? CurrencyAmountToJson(routingTransaction.fees)
215
+ : undefined,
216
+ routing_transaction_failure_message: routingTransaction.failureMessage
217
+ ? RichTextToJson(routingTransaction.failureMessage)
218
+ : undefined,
219
+ routing_transaction_failure_reason: routingTransaction.failureReason,
220
+ };
221
+ }
222
+ throw new LightsparkException(
223
+ "DeserializationError",
224
+ `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj.typename}`,
225
+ );
226
+ };
138
227
 
139
228
  export const FRAGMENT = `
140
229
  fragment LightningTransactionFragment on LightningTransaction {