@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
@@ -1,15 +1,15 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  /** This is an object representing information about a page returned by the Lightspark API. For more information, please see the “Pagination” section of our API docs for more information about its usage. **/
4
- type PageInfo = {
5
- hasNextPage?: boolean;
4
+ interface PageInfo {
5
+ hasNextPage?: boolean | undefined;
6
6
 
7
- hasPreviousPage?: boolean;
7
+ hasPreviousPage?: boolean | undefined;
8
8
 
9
- startCursor?: string;
9
+ startCursor?: string | undefined;
10
10
 
11
- endCursor?: string;
12
- };
11
+ endCursor?: string | undefined;
12
+ }
13
13
 
14
14
  export const PageInfoFromJson = (obj: any): PageInfo => {
15
15
  return {
@@ -19,6 +19,14 @@ export const PageInfoFromJson = (obj: any): PageInfo => {
19
19
  endCursor: obj["page_info_end_cursor"],
20
20
  } as PageInfo;
21
21
  };
22
+ export const PageInfoToJson = (obj: PageInfo): any => {
23
+ return {
24
+ page_info_has_next_page: obj.hasNextPage,
25
+ page_info_has_previous_page: obj.hasPreviousPage,
26
+ page_info_start_cursor: obj.startCursor,
27
+ page_info_end_cursor: obj.endCursor,
28
+ };
29
+ };
22
30
 
23
31
  export const FRAGMENT = `
24
32
  fragment PageInfoFragment on PageInfo {
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type PayInvoiceInput = {
3
+ interface PayInvoiceInput {
4
4
  /** The node from where you want to send the payment. **/
5
5
  nodeId: string;
6
6
 
@@ -17,8 +17,8 @@ type PayInvoiceInput = {
17
17
  * The amount you will pay for this invoice, expressed in msats. It should ONLY be set when the
18
18
  * invoice amount is zero.
19
19
  **/
20
- amountMsats?: number;
21
- };
20
+ amountMsats?: number | undefined;
21
+ }
22
22
 
23
23
  export const PayInvoiceInputFromJson = (obj: any): PayInvoiceInput => {
24
24
  return {
@@ -29,5 +29,14 @@ export const PayInvoiceInputFromJson = (obj: any): PayInvoiceInput => {
29
29
  amountMsats: obj["pay_invoice_input_amount_msats"],
30
30
  } as PayInvoiceInput;
31
31
  };
32
+ export const PayInvoiceInputToJson = (obj: PayInvoiceInput): any => {
33
+ return {
34
+ pay_invoice_input_node_id: obj.nodeId,
35
+ pay_invoice_input_encoded_invoice: obj.encodedInvoice,
36
+ pay_invoice_input_timeout_secs: obj.timeoutSecs,
37
+ pay_invoice_input_maximum_fees_msats: obj.maximumFeesMsats,
38
+ pay_invoice_input_amount_msats: obj.amountMsats,
39
+ };
40
+ };
32
41
 
33
42
  export default PayInvoiceInput;
@@ -1,15 +1,20 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type PayInvoiceOutput = {
3
+ interface PayInvoiceOutput {
4
4
  /** The payment that has been sent. **/
5
5
  paymentId: string;
6
- };
6
+ }
7
7
 
8
8
  export const PayInvoiceOutputFromJson = (obj: any): PayInvoiceOutput => {
9
9
  return {
10
10
  paymentId: obj["pay_invoice_output_payment"].id,
11
11
  } as PayInvoiceOutput;
12
12
  };
13
+ export const PayInvoiceOutputToJson = (obj: PayInvoiceOutput): any => {
14
+ return {
15
+ pay_invoice_output_payment: { id: obj.paymentId },
16
+ };
17
+ };
13
18
 
14
19
  export const FRAGMENT = `
15
20
  fragment PayInvoiceOutputFragment on PayInvoiceOutput {
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type PayUmaInvoiceInput = {
3
+ interface PayUmaInvoiceInput {
4
4
  nodeId: string;
5
5
 
6
6
  encodedInvoice: string;
@@ -9,8 +9,8 @@ type PayUmaInvoiceInput = {
9
9
 
10
10
  maximumFeesMsats: number;
11
11
 
12
- amountMsats?: number;
13
- };
12
+ amountMsats?: number | undefined;
13
+ }
14
14
 
15
15
  export const PayUmaInvoiceInputFromJson = (obj: any): PayUmaInvoiceInput => {
16
16
  return {
@@ -21,5 +21,14 @@ export const PayUmaInvoiceInputFromJson = (obj: any): PayUmaInvoiceInput => {
21
21
  amountMsats: obj["pay_uma_invoice_input_amount_msats"],
22
22
  } as PayUmaInvoiceInput;
23
23
  };
24
+ export const PayUmaInvoiceInputToJson = (obj: PayUmaInvoiceInput): any => {
25
+ return {
26
+ pay_uma_invoice_input_node_id: obj.nodeId,
27
+ pay_uma_invoice_input_encoded_invoice: obj.encodedInvoice,
28
+ pay_uma_invoice_input_timeout_secs: obj.timeoutSecs,
29
+ pay_uma_invoice_input_maximum_fees_msats: obj.maximumFeesMsats,
30
+ pay_uma_invoice_input_amount_msats: obj.amountMsats,
31
+ };
32
+ };
24
33
 
25
34
  export default PayUmaInvoiceInput;
@@ -1,15 +1,17 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import { LightsparkException, type Query } from "@lightsparkdev/core";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
- import type Entity from "./Entity.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
6
8
  import type Invoice from "./Invoice.js";
7
- import { InvoiceDataFromJson } from "./InvoiceData.js";
9
+ import { InvoiceDataFromJson, InvoiceDataToJson } from "./InvoiceData.js";
8
10
  import type PaymentRequestData from "./PaymentRequestData.js";
9
11
  import PaymentRequestStatus from "./PaymentRequestStatus.js";
10
12
 
11
13
  /** This object contains information related to a payment request generated or received by a LightsparkNode. You can retrieve this object to receive payment information about a specific invoice. **/
12
- type PaymentRequest = Entity & {
14
+ interface PaymentRequest {
13
15
  /**
14
16
  * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
15
17
  * string.
@@ -30,7 +32,7 @@ type PaymentRequest = Entity & {
30
32
 
31
33
  /** The typename of the object **/
32
34
  typename: string;
33
- };
35
+ }
34
36
 
35
37
  export const PaymentRequestFromJson = (obj: any): PaymentRequest => {
36
38
  if (obj["__typename"] == "Invoice") {
@@ -53,6 +55,26 @@ export const PaymentRequestFromJson = (obj: any): PaymentRequest => {
53
55
  `Couldn't find a concrete type for interface PaymentRequest corresponding to the typename=${obj["__typename"]}`,
54
56
  );
55
57
  };
58
+ export const PaymentRequestToJson = (obj: PaymentRequest): any => {
59
+ if (obj.typename == "Invoice") {
60
+ const invoice = obj as Invoice;
61
+ return {
62
+ __typename: "Invoice",
63
+ invoice_id: invoice.id,
64
+ invoice_created_at: invoice.createdAt,
65
+ invoice_updated_at: invoice.updatedAt,
66
+ invoice_data: InvoiceDataToJson(invoice.data),
67
+ invoice_status: invoice.status,
68
+ invoice_amount_paid: invoice.amountPaid
69
+ ? CurrencyAmountToJson(invoice.amountPaid)
70
+ : undefined,
71
+ };
72
+ }
73
+ throw new LightsparkException(
74
+ "DeserializationError",
75
+ `Couldn't find a concrete type for interface PaymentRequest corresponding to the typename=${obj.typename}`,
76
+ );
77
+ };
56
78
 
57
79
  export const FRAGMENT = `
58
80
  fragment PaymentRequestFragment on PaymentRequest {
@@ -2,19 +2,22 @@
2
2
 
3
3
  import { LightsparkException } from "@lightsparkdev/core";
4
4
  import BitcoinNetwork from "./BitcoinNetwork.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
6
9
  import type InvoiceData from "./InvoiceData.js";
7
- import { NodeFromJson } from "./Node.js";
10
+ import { NodeFromJson, NodeToJson } from "./Node.js";
8
11
 
9
12
  /** This object is an interface of a payment request on the Lightning Network (i.e., a Lightning Invoice). It contains data related to parsing the payment details of a Lightning Invoice. **/
10
- type PaymentRequestData = {
13
+ interface PaymentRequestData {
11
14
  encodedPaymentRequest: string;
12
15
 
13
16
  bitcoinNetwork: BitcoinNetwork;
14
17
 
15
18
  /** The typename of the object **/
16
19
  typename: string;
17
- };
20
+ }
18
21
 
19
22
  export const PaymentRequestDataFromJson = (obj: any): PaymentRequestData => {
20
23
  if (obj["__typename"] == "InvoiceData") {
@@ -37,6 +40,26 @@ export const PaymentRequestDataFromJson = (obj: any): PaymentRequestData => {
37
40
  `Couldn't find a concrete type for interface PaymentRequestData corresponding to the typename=${obj["__typename"]}`,
38
41
  );
39
42
  };
43
+ export const PaymentRequestDataToJson = (obj: PaymentRequestData): any => {
44
+ if (obj.typename == "InvoiceData") {
45
+ const invoiceData = obj as InvoiceData;
46
+ return {
47
+ __typename: "InvoiceData",
48
+ invoice_data_encoded_payment_request: invoiceData.encodedPaymentRequest,
49
+ invoice_data_bitcoin_network: invoiceData.bitcoinNetwork,
50
+ invoice_data_payment_hash: invoiceData.paymentHash,
51
+ invoice_data_amount: CurrencyAmountToJson(invoiceData.amount),
52
+ invoice_data_created_at: invoiceData.createdAt,
53
+ invoice_data_expires_at: invoiceData.expiresAt,
54
+ invoice_data_memo: invoiceData.memo,
55
+ invoice_data_destination: NodeToJson(invoiceData.destination),
56
+ };
57
+ }
58
+ throw new LightsparkException(
59
+ "DeserializationError",
60
+ `Couldn't find a concrete type for interface PaymentRequestData corresponding to the typename=${obj.typename}`,
61
+ );
62
+ };
40
63
 
41
64
  export const FRAGMENT = `
42
65
  fragment PaymentRequestDataFragment on PaymentRequestData {
@@ -1,10 +1,13 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  import type CurrencyAmount from "./CurrencyAmount.js";
4
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
5
8
 
6
9
  /** This object represents post-transaction data that could be used to register payment for KYT. **/
7
- type PostTransactionData = {
10
+ interface PostTransactionData {
8
11
  /**
9
12
  * The utxo of the channel over which the payment went through in the format of
10
13
  * <transaction_hash>:<output_index>.
@@ -13,7 +16,7 @@ type PostTransactionData = {
13
16
 
14
17
  /** The amount of funds transferred in the payment. **/
15
18
  amount: CurrencyAmount;
16
- };
19
+ }
17
20
 
18
21
  export const PostTransactionDataFromJson = (obj: any): PostTransactionData => {
19
22
  return {
@@ -21,6 +24,12 @@ export const PostTransactionDataFromJson = (obj: any): PostTransactionData => {
21
24
  amount: CurrencyAmountFromJson(obj["post_transaction_data_amount"]),
22
25
  } as PostTransactionData;
23
26
  };
27
+ export const PostTransactionDataToJson = (obj: PostTransactionData): any => {
28
+ return {
29
+ post_transaction_data_utxo: obj.utxo,
30
+ post_transaction_data_amount: CurrencyAmountToJson(obj.amount),
31
+ };
32
+ };
24
33
 
25
34
  export const FRAGMENT = `
26
35
  fragment PostTransactionDataFragment on PostTransactionData {
@@ -3,7 +3,7 @@
3
3
  import ComplianceProvider from "./ComplianceProvider.js";
4
4
  import PaymentDirection from "./PaymentDirection.js";
5
5
 
6
- type RegisterPaymentInput = {
6
+ interface RegisterPaymentInput {
7
7
  /**
8
8
  * The compliance provider that is going to screen the node. You need to be a customer of the selected
9
9
  * provider and store the API key on the Lightspark account setting page.
@@ -25,7 +25,7 @@ type RegisterPaymentInput = {
25
25
 
26
26
  /** Indicates whether this payment is an OutgoingPayment or an IncomingPayment. **/
27
27
  direction: PaymentDirection;
28
- };
28
+ }
29
29
 
30
30
  export const RegisterPaymentInputFromJson = (
31
31
  obj: any,
@@ -41,5 +41,13 @@ export const RegisterPaymentInputFromJson = (
41
41
  PaymentDirection.FUTURE_VALUE,
42
42
  } as RegisterPaymentInput;
43
43
  };
44
+ export const RegisterPaymentInputToJson = (obj: RegisterPaymentInput): any => {
45
+ return {
46
+ register_payment_input_provider: obj.provider,
47
+ register_payment_input_payment_id: obj.paymentId,
48
+ register_payment_input_node_pubkey: obj.nodePubkey,
49
+ register_payment_input_direction: obj.direction,
50
+ };
51
+ };
44
52
 
45
53
  export default RegisterPaymentInput;
@@ -1,8 +1,8 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type RegisterPaymentOutput = {
3
+ interface RegisterPaymentOutput {
4
4
  paymentId: string;
5
- };
5
+ }
6
6
 
7
7
  export const RegisterPaymentOutputFromJson = (
8
8
  obj: any,
@@ -11,6 +11,13 @@ export const RegisterPaymentOutputFromJson = (
11
11
  paymentId: obj["register_payment_output_payment"].id,
12
12
  } as RegisterPaymentOutput;
13
13
  };
14
+ export const RegisterPaymentOutputToJson = (
15
+ obj: RegisterPaymentOutput,
16
+ ): any => {
17
+ return {
18
+ register_payment_output_payment: { id: obj.paymentId },
19
+ };
20
+ };
14
21
 
15
22
  export const FRAGMENT = `
16
23
  fragment RegisterPaymentOutputFragment on RegisterPaymentOutput {
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type ReleaseChannelPerCommitmentSecretInput = {
3
+ interface ReleaseChannelPerCommitmentSecretInput {
4
4
  /** The unique identifier of the channel. **/
5
5
  channelId: string;
6
6
 
@@ -9,7 +9,7 @@ type ReleaseChannelPerCommitmentSecretInput = {
9
9
 
10
10
  /** The index associated with the per-commitment secret. **/
11
11
  perCommitmentIndex: number;
12
- };
12
+ }
13
13
 
14
14
  export const ReleaseChannelPerCommitmentSecretInputFromJson = (
15
15
  obj: any,
@@ -22,5 +22,16 @@ export const ReleaseChannelPerCommitmentSecretInputFromJson = (
22
22
  obj["release_channel_per_commitment_secret_input_per_commitment_index"],
23
23
  } as ReleaseChannelPerCommitmentSecretInput;
24
24
  };
25
+ export const ReleaseChannelPerCommitmentSecretInputToJson = (
26
+ obj: ReleaseChannelPerCommitmentSecretInput,
27
+ ): any => {
28
+ return {
29
+ release_channel_per_commitment_secret_input_channel_id: obj.channelId,
30
+ release_channel_per_commitment_secret_input_per_commitment_secret:
31
+ obj.perCommitmentSecret,
32
+ release_channel_per_commitment_secret_input_per_commitment_index:
33
+ obj.perCommitmentIndex,
34
+ };
35
+ };
25
36
 
26
37
  export default ReleaseChannelPerCommitmentSecretInput;
@@ -1,9 +1,9 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type ReleaseChannelPerCommitmentSecretOutput = {
3
+ interface ReleaseChannelPerCommitmentSecretOutput {
4
4
  /** The channel object after the per-commitment secret release operation. **/
5
5
  channelId: string;
6
- };
6
+ }
7
7
 
8
8
  export const ReleaseChannelPerCommitmentSecretOutputFromJson = (
9
9
  obj: any,
@@ -12,6 +12,13 @@ export const ReleaseChannelPerCommitmentSecretOutputFromJson = (
12
12
  channelId: obj["release_channel_per_commitment_secret_output_channel"].id,
13
13
  } as ReleaseChannelPerCommitmentSecretOutput;
14
14
  };
15
+ export const ReleaseChannelPerCommitmentSecretOutputToJson = (
16
+ obj: ReleaseChannelPerCommitmentSecretOutput,
17
+ ): any => {
18
+ return {
19
+ release_channel_per_commitment_secret_output_channel: { id: obj.channelId },
20
+ };
21
+ };
15
22
 
16
23
  export const FRAGMENT = `
17
24
  fragment ReleaseChannelPerCommitmentSecretOutputFragment on ReleaseChannelPerCommitmentSecretOutput {
@@ -1,12 +1,12 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type ReleasePaymentPreimageInput = {
3
+ interface ReleasePaymentPreimageInput {
4
4
  /** The invoice the preimage belongs to. **/
5
5
  invoiceId: string;
6
6
 
7
7
  /** The preimage to release. **/
8
8
  paymentPreimage: string;
9
- };
9
+ }
10
10
 
11
11
  export const ReleasePaymentPreimageInputFromJson = (
12
12
  obj: any,
@@ -16,5 +16,13 @@ export const ReleasePaymentPreimageInputFromJson = (
16
16
  paymentPreimage: obj["release_payment_preimage_input_payment_preimage"],
17
17
  } as ReleasePaymentPreimageInput;
18
18
  };
19
+ export const ReleasePaymentPreimageInputToJson = (
20
+ obj: ReleasePaymentPreimageInput,
21
+ ): any => {
22
+ return {
23
+ release_payment_preimage_input_invoice_id: obj.invoiceId,
24
+ release_payment_preimage_input_payment_preimage: obj.paymentPreimage,
25
+ };
26
+ };
19
27
 
20
28
  export default ReleasePaymentPreimageInput;
@@ -1,9 +1,9 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type ReleasePaymentPreimageOutput = {
3
+ interface ReleasePaymentPreimageOutput {
4
4
  /** The invoice of the transaction. **/
5
5
  invoiceId: string;
6
- };
6
+ }
7
7
 
8
8
  export const ReleasePaymentPreimageOutputFromJson = (
9
9
  obj: any,
@@ -12,6 +12,13 @@ export const ReleasePaymentPreimageOutputFromJson = (
12
12
  invoiceId: obj["release_payment_preimage_output_invoice"].id,
13
13
  } as ReleasePaymentPreimageOutput;
14
14
  };
15
+ export const ReleasePaymentPreimageOutputToJson = (
16
+ obj: ReleasePaymentPreimageOutput,
17
+ ): any => {
18
+ return {
19
+ release_payment_preimage_output_invoice: { id: obj.invoiceId },
20
+ };
21
+ };
15
22
 
16
23
  export const FRAGMENT = `
17
24
  fragment ReleasePaymentPreimageOutputFragment on ReleasePaymentPreimageOutput {
@@ -2,7 +2,7 @@
2
2
 
3
3
  import WithdrawalMode from "./WithdrawalMode.js";
4
4
 
5
- type RequestWithdrawalInput = {
5
+ interface RequestWithdrawalInput {
6
6
  /** The node from which you'd like to make the withdrawal. **/
7
7
  nodeId: string;
8
8
 
@@ -17,7 +17,7 @@ type RequestWithdrawalInput = {
17
17
 
18
18
  /** The strategy that should be used to withdraw the funds from this node. **/
19
19
  withdrawalMode: WithdrawalMode;
20
- };
20
+ }
21
21
 
22
22
  export const RequestWithdrawalInputFromJson = (
23
23
  obj: any,
@@ -31,5 +31,15 @@ export const RequestWithdrawalInputFromJson = (
31
31
  WithdrawalMode.FUTURE_VALUE,
32
32
  } as RequestWithdrawalInput;
33
33
  };
34
+ export const RequestWithdrawalInputToJson = (
35
+ obj: RequestWithdrawalInput,
36
+ ): any => {
37
+ return {
38
+ request_withdrawal_input_node_id: obj.nodeId,
39
+ request_withdrawal_input_bitcoin_address: obj.bitcoinAddress,
40
+ request_withdrawal_input_amount_sats: obj.amountSats,
41
+ request_withdrawal_input_withdrawal_mode: obj.withdrawalMode,
42
+ };
43
+ };
34
44
 
35
45
  export default RequestWithdrawalInput;
@@ -1,9 +1,9 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type RequestWithdrawalOutput = {
3
+ interface RequestWithdrawalOutput {
4
4
  /** The request that is created for this withdrawal. **/
5
5
  requestId: string;
6
- };
6
+ }
7
7
 
8
8
  export const RequestWithdrawalOutputFromJson = (
9
9
  obj: any,
@@ -12,6 +12,13 @@ export const RequestWithdrawalOutputFromJson = (
12
12
  requestId: obj["request_withdrawal_output_request"].id,
13
13
  } as RequestWithdrawalOutput;
14
14
  };
15
+ export const RequestWithdrawalOutputToJson = (
16
+ obj: RequestWithdrawalOutput,
17
+ ): any => {
18
+ return {
19
+ request_withdrawal_output_request: { id: obj.requestId },
20
+ };
21
+ };
15
22
 
16
23
  export const FRAGMENT = `
17
24
  fragment RequestWithdrawalOutputFragment on RequestWithdrawalOutput {
@@ -1,14 +1,19 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- type RichText = {
3
+ interface RichText {
4
4
  text: string;
5
- };
5
+ }
6
6
 
7
7
  export const RichTextFromJson = (obj: any): RichText => {
8
8
  return {
9
9
  text: obj["rich_text_text"],
10
10
  } as RichText;
11
11
  };
12
+ export const RichTextToJson = (obj: RichText): any => {
13
+ return {
14
+ rich_text_text: obj.text,
15
+ };
16
+ };
12
17
 
13
18
  export const FRAGMENT = `
14
19
  fragment RichTextFragment on RichText {
@@ -2,64 +2,62 @@
2
2
 
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
- import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
6
- import type Entity from "./Entity.js";
7
- import type LightningTransaction from "./LightningTransaction.js";
5
+ import {
6
+ CurrencyAmountFromJson,
7
+ CurrencyAmountToJson,
8
+ } from "./CurrencyAmount.js";
8
9
  import type RichText from "./RichText.js";
9
- import { RichTextFromJson } from "./RichText.js";
10
+ import { RichTextFromJson, RichTextToJson } from "./RichText.js";
10
11
  import RoutingTransactionFailureReason from "./RoutingTransactionFailureReason.js";
11
- import type Transaction from "./Transaction.js";
12
12
  import TransactionStatus from "./TransactionStatus.js";
13
13
 
14
14
  /** This object represents a transaction that was forwarded through a Lightspark node on the Lightning Network, i.e., a routed transaction. You can retrieve this object to receive information about any transaction routed through your Lightspark Node. **/
15
- type RoutingTransaction = LightningTransaction &
16
- Transaction &
17
- Entity & {
18
- /**
19
- * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
20
- * string.
21
- **/
22
- id: string;
15
+ interface RoutingTransaction {
16
+ /**
17
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
18
+ * string.
19
+ **/
20
+ id: string;
23
21
 
24
- /** The date and time when this transaction was initiated. **/
25
- createdAt: string;
22
+ /** The date and time when this transaction was initiated. **/
23
+ createdAt: string;
26
24
 
27
- /** The date and time when the entity was last updated. **/
28
- updatedAt: string;
25
+ /** The date and time when the entity was last updated. **/
26
+ updatedAt: string;
29
27
 
30
- /** The current status of this transaction. **/
31
- status: TransactionStatus;
28
+ /** The current status of this transaction. **/
29
+ status: TransactionStatus;
32
30
 
33
- /** The amount of money involved in this transaction. **/
34
- amount: CurrencyAmount;
31
+ /** The amount of money involved in this transaction. **/
32
+ amount: CurrencyAmount;
35
33
 
36
- /** The typename of the object **/
37
- typename: string;
34
+ /** The typename of the object **/
35
+ typename: string;
38
36
 
39
- /** The date and time when this transaction was completed or failed. **/
40
- resolvedAt?: string;
37
+ /** The date and time when this transaction was completed or failed. **/
38
+ resolvedAt?: string | undefined;
41
39
 
42
- /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
43
- transactionHash?: string;
40
+ /** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
41
+ transactionHash?: string | undefined;
44
42
 
45
- /** If known, the channel this transaction was received from. **/
46
- incomingChannelId?: string;
43
+ /** If known, the channel this transaction was received from. **/
44
+ incomingChannelId?: string | undefined;
47
45
 
48
- /** If known, the channel this transaction was forwarded to. **/
49
- outgoingChannelId?: string;
46
+ /** If known, the channel this transaction was forwarded to. **/
47
+ outgoingChannelId?: string | undefined;
50
48
 
51
- /**
52
- * The fees collected by the node when routing this transaction. We subtract the outgoing amount to
53
- * the incoming amount to determine how much fees were collected.
54
- **/
55
- fees?: CurrencyAmount;
49
+ /**
50
+ * The fees collected by the node when routing this transaction. We subtract the outgoing amount to
51
+ * the incoming amount to determine how much fees were collected.
52
+ **/
53
+ fees?: CurrencyAmount | undefined;
56
54
 
57
- /** If applicable, user-facing error message describing why the routing failed. **/
58
- failureMessage?: RichText;
55
+ /** If applicable, user-facing error message describing why the routing failed. **/
56
+ failureMessage?: RichText | undefined;
59
57
 
60
- /** If applicable, the reason why the routing failed. **/
61
- failureReason?: RoutingTransactionFailureReason;
62
- };
58
+ /** If applicable, the reason why the routing failed. **/
59
+ failureReason?: RoutingTransactionFailureReason | undefined;
60
+ }
63
61
 
64
62
  export const RoutingTransactionFromJson = (obj: any): RoutingTransaction => {
65
63
  return {
@@ -90,6 +88,29 @@ export const RoutingTransactionFromJson = (obj: any): RoutingTransaction => {
90
88
  : null,
91
89
  } as RoutingTransaction;
92
90
  };
91
+ export const RoutingTransactionToJson = (obj: RoutingTransaction): any => {
92
+ return {
93
+ __typename: "RoutingTransaction",
94
+ routing_transaction_id: obj.id,
95
+ routing_transaction_created_at: obj.createdAt,
96
+ routing_transaction_updated_at: obj.updatedAt,
97
+ routing_transaction_status: obj.status,
98
+ routing_transaction_resolved_at: obj.resolvedAt,
99
+ routing_transaction_amount: CurrencyAmountToJson(obj.amount),
100
+ routing_transaction_transaction_hash: obj.transactionHash,
101
+ routing_transaction_incoming_channel:
102
+ { id: obj.incomingChannelId } ?? undefined,
103
+ routing_transaction_outgoing_channel:
104
+ { id: obj.outgoingChannelId } ?? undefined,
105
+ routing_transaction_fees: obj.fees
106
+ ? CurrencyAmountToJson(obj.fees)
107
+ : undefined,
108
+ routing_transaction_failure_message: obj.failureMessage
109
+ ? RichTextToJson(obj.failureMessage)
110
+ : undefined,
111
+ routing_transaction_failure_reason: obj.failureReason,
112
+ };
113
+ };
93
114
 
94
115
  export const FRAGMENT = `
95
116
  fragment RoutingTransactionFragment on RoutingTransaction {