@lightsparkdev/lightspark-sdk 1.1.4 → 1.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 (34) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-PZMOKVDK.js → chunk-7UNNCH5S.js} +88 -6
  3. package/dist/{index-2ac27fbd.d.ts → index-5235e43b.d.ts} +57 -8
  4. package/dist/index.cjs +90 -10
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +3 -5
  7. package/dist/objects/index.cjs +88 -6
  8. package/dist/objects/index.d.ts +1 -1
  9. package/dist/objects/index.js +1 -1
  10. package/package.json +2 -4
  11. package/src/objects/Account.ts +1 -0
  12. package/src/objects/ChannelSnapshot.ts +57 -0
  13. package/src/objects/Entity.ts +28 -0
  14. package/src/objects/IdAndSignature.ts +2 -0
  15. package/src/objects/LightningTransaction.ts +2 -0
  16. package/src/objects/OutgoingPayment.ts +30 -0
  17. package/src/objects/OutgoingPaymentAttempt.ts +35 -0
  18. package/src/objects/RegisterPaymentInput.ts +14 -0
  19. package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +3 -0
  20. package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +1 -0
  21. package/src/objects/ReleasePaymentPreimageOutput.ts +1 -0
  22. package/src/objects/RemoteSigningSubEventType.ts +2 -0
  23. package/src/objects/ScreenNodeInput.ts +5 -0
  24. package/src/objects/SetInvoicePaymentHashInput.ts +5 -2
  25. package/src/objects/SignInvoiceInput.ts +3 -0
  26. package/src/objects/SignInvoiceOutput.ts +1 -0
  27. package/src/objects/SignMessagesInput.ts +1 -0
  28. package/src/objects/SignMessagesOutput.ts +1 -0
  29. package/src/objects/SignablePayloadStatus.ts +2 -0
  30. package/src/objects/Transaction.ts +2 -0
  31. package/src/objects/Wallet.ts +1 -0
  32. package/src/objects/WebhookEventType.ts +6 -0
  33. package/src/objects/WithdrawalRequestStatus.ts +2 -0
  34. package/src/objects/index.ts +1 -0
@@ -0,0 +1,57 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import type CurrencyAmount from "./CurrencyAmount.js";
4
+ import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
5
+
6
+ type ChannelSnapshot = {
7
+ localBalance?: CurrencyAmount;
8
+
9
+ localUnsettledBalance?: CurrencyAmount;
10
+
11
+ localChannelReserve?: CurrencyAmount;
12
+ };
13
+
14
+ export const ChannelSnapshotFromJson = (obj: any): ChannelSnapshot => {
15
+ return {
16
+ localBalance: !!obj["channel_snapshot_local_balance"]
17
+ ? CurrencyAmountFromJson(obj["channel_snapshot_local_balance"])
18
+ : undefined,
19
+ localUnsettledBalance: !!obj["channel_snapshot_local_unsettled_balance"]
20
+ ? CurrencyAmountFromJson(obj["channel_snapshot_local_unsettled_balance"])
21
+ : undefined,
22
+ localChannelReserve: !!obj["channel_snapshot_local_channel_reserve"]
23
+ ? CurrencyAmountFromJson(obj["channel_snapshot_local_channel_reserve"])
24
+ : undefined,
25
+ } as ChannelSnapshot;
26
+ };
27
+
28
+ export const FRAGMENT = `
29
+ fragment ChannelSnapshotFragment on ChannelSnapshot {
30
+ __typename
31
+ channel_snapshot_local_balance: local_balance {
32
+ __typename
33
+ currency_amount_original_value: original_value
34
+ currency_amount_original_unit: original_unit
35
+ currency_amount_preferred_currency_unit: preferred_currency_unit
36
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
37
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
38
+ }
39
+ channel_snapshot_local_unsettled_balance: local_unsettled_balance {
40
+ __typename
41
+ currency_amount_original_value: original_value
42
+ currency_amount_original_unit: original_unit
43
+ currency_amount_preferred_currency_unit: preferred_currency_unit
44
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
45
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
46
+ }
47
+ channel_snapshot_local_channel_reserve: local_channel_reserve {
48
+ __typename
49
+ currency_amount_original_value: original_value
50
+ currency_amount_original_unit: original_unit
51
+ currency_amount_preferred_currency_unit: preferred_currency_unit
52
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
53
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
54
+ }
55
+ }`;
56
+
57
+ export default ChannelSnapshot;
@@ -1065,6 +1065,7 @@ fragment EntityFragment on Entity {
1065
1065
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1066
1066
  }
1067
1067
  }
1068
+ outgoing_payment_payment_preimage: payment_preimage
1068
1069
  }
1069
1070
  ... on OutgoingPaymentAttempt {
1070
1071
  __typename
@@ -1094,6 +1095,33 @@ fragment EntityFragment on Entity {
1094
1095
  outgoing_payment_attempt_outgoing_payment: outgoing_payment {
1095
1096
  id
1096
1097
  }
1098
+ outgoing_payment_attempt_channel_snapshot: channel_snapshot {
1099
+ __typename
1100
+ channel_snapshot_local_balance: local_balance {
1101
+ __typename
1102
+ currency_amount_original_value: original_value
1103
+ currency_amount_original_unit: original_unit
1104
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1105
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1106
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1107
+ }
1108
+ channel_snapshot_local_unsettled_balance: local_unsettled_balance {
1109
+ __typename
1110
+ currency_amount_original_value: original_value
1111
+ currency_amount_original_unit: original_unit
1112
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1113
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1114
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1115
+ }
1116
+ channel_snapshot_local_channel_reserve: local_channel_reserve {
1117
+ __typename
1118
+ currency_amount_original_value: original_value
1119
+ currency_amount_original_unit: original_unit
1120
+ currency_amount_preferred_currency_unit: preferred_currency_unit
1121
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
1122
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
1123
+ }
1124
+ }
1097
1125
  }
1098
1126
  ... on RoutingTransaction {
1099
1127
  __typename
@@ -1,8 +1,10 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  type IdAndSignature = {
4
+ /** The id of the message. **/
4
5
  id: string;
5
6
 
7
+ /** The signature of the message. **/
6
8
  signature: string;
7
9
  };
8
10
 
@@ -98,6 +98,7 @@ export const LightningTransactionFromJson = (
98
98
  obj["outgoing_payment_uma_post_transaction_data"]?.map((e) =>
99
99
  PostTransactionDataFromJson(e),
100
100
  ),
101
+ obj["outgoing_payment_payment_preimage"],
101
102
  );
102
103
  }
103
104
  if (obj["__typename"] == "RoutingTransaction") {
@@ -460,6 +461,7 @@ fragment LightningTransactionFragment on LightningTransaction {
460
461
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
461
462
  }
462
463
  }
464
+ outgoing_payment_payment_preimage: payment_preimage
463
465
  }
464
466
  ... on RoutingTransaction {
465
467
  __typename
@@ -35,6 +35,7 @@ class OutgoingPayment implements LightningTransaction {
35
35
  public readonly failureReason?: PaymentFailureReason,
36
36
  public readonly failureMessage?: RichText,
37
37
  public readonly umaPostTransactionData?: PostTransactionData[],
38
+ public readonly paymentPreimage?: string,
38
39
  ) {
39
40
  autoBind(this);
40
41
  }
@@ -87,6 +88,33 @@ query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $af
87
88
  outgoing_payment_attempt_outgoing_payment: outgoing_payment {
88
89
  id
89
90
  }
91
+ outgoing_payment_attempt_channel_snapshot: channel_snapshot {
92
+ __typename
93
+ channel_snapshot_local_balance: local_balance {
94
+ __typename
95
+ currency_amount_original_value: original_value
96
+ currency_amount_original_unit: original_unit
97
+ currency_amount_preferred_currency_unit: preferred_currency_unit
98
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
99
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
100
+ }
101
+ channel_snapshot_local_unsettled_balance: local_unsettled_balance {
102
+ __typename
103
+ currency_amount_original_value: original_value
104
+ currency_amount_original_unit: original_unit
105
+ currency_amount_preferred_currency_unit: preferred_currency_unit
106
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
107
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
108
+ }
109
+ channel_snapshot_local_channel_reserve: local_channel_reserve {
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
+ }
90
118
  }
91
119
  }
92
120
  }
@@ -149,6 +177,7 @@ export const OutgoingPaymentFromJson = (obj: any): OutgoingPayment => {
149
177
  obj["outgoing_payment_uma_post_transaction_data"]?.map((e) =>
150
178
  PostTransactionDataFromJson(e),
151
179
  ),
180
+ obj["outgoing_payment_payment_preimage"],
152
181
  );
153
182
  };
154
183
 
@@ -440,6 +469,7 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
440
469
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
441
470
  }
442
471
  }
472
+ outgoing_payment_payment_preimage: payment_preimage
443
473
  }`;
444
474
 
445
475
  export default OutgoingPayment;
@@ -3,6 +3,8 @@
3
3
  import { type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
+ import type ChannelSnapshot from "./ChannelSnapshot.js";
7
+ import { ChannelSnapshotFromJson } from "./ChannelSnapshot.js";
6
8
  import type CurrencyAmount from "./CurrencyAmount.js";
7
9
  import { CurrencyAmountFromJson } from "./CurrencyAmount.js";
8
10
  import type Entity from "./Entity.js";
@@ -25,6 +27,7 @@ class OutgoingPaymentAttempt implements Entity {
25
27
  public readonly resolvedAt?: string,
26
28
  public readonly amount?: CurrencyAmount,
27
29
  public readonly fees?: CurrencyAmount,
30
+ public readonly channelSnapshot?: ChannelSnapshot,
28
31
  ) {
29
32
  autoBind(this);
30
33
  }
@@ -135,6 +138,11 @@ export const OutgoingPaymentAttemptFromJson = (
135
138
  !!obj["outgoing_payment_attempt_fees"]
136
139
  ? CurrencyAmountFromJson(obj["outgoing_payment_attempt_fees"])
137
140
  : undefined,
141
+ !!obj["outgoing_payment_attempt_channel_snapshot"]
142
+ ? ChannelSnapshotFromJson(
143
+ obj["outgoing_payment_attempt_channel_snapshot"],
144
+ )
145
+ : undefined,
138
146
  );
139
147
  };
140
148
 
@@ -167,6 +175,33 @@ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt {
167
175
  outgoing_payment_attempt_outgoing_payment: outgoing_payment {
168
176
  id
169
177
  }
178
+ outgoing_payment_attempt_channel_snapshot: channel_snapshot {
179
+ __typename
180
+ channel_snapshot_local_balance: local_balance {
181
+ __typename
182
+ currency_amount_original_value: original_value
183
+ currency_amount_original_unit: original_unit
184
+ currency_amount_preferred_currency_unit: preferred_currency_unit
185
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
186
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
187
+ }
188
+ channel_snapshot_local_unsettled_balance: local_unsettled_balance {
189
+ __typename
190
+ currency_amount_original_value: original_value
191
+ currency_amount_original_unit: original_unit
192
+ currency_amount_preferred_currency_unit: preferred_currency_unit
193
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
194
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
195
+ }
196
+ channel_snapshot_local_channel_reserve: local_channel_reserve {
197
+ __typename
198
+ currency_amount_original_value: original_value
199
+ currency_amount_original_unit: original_unit
200
+ currency_amount_preferred_currency_unit: preferred_currency_unit
201
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
202
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
203
+ }
204
+ }
170
205
  }`;
171
206
 
172
207
  export default OutgoingPaymentAttempt;
@@ -4,12 +4,26 @@ import ComplianceProvider from "./ComplianceProvider.js";
4
4
  import PaymentDirection from "./PaymentDirection.js";
5
5
 
6
6
  type RegisterPaymentInput = {
7
+ /**
8
+ * The compliance provider that is going to screen the node. You need to be a customer of the selected
9
+ * provider and store the API key on the Lightspark account setting page.
10
+ **/
7
11
  provider: ComplianceProvider;
8
12
 
13
+ /**
14
+ * The Lightspark ID of the lightning payment you want to register. It can be the id of either an
15
+ * OutgoingPayment or an IncomingPayment.
16
+ **/
9
17
  paymentId: string;
10
18
 
19
+ /**
20
+ * The public key of the counterparty lightning node, which would be the public key of the recipient
21
+ * node if it is to register an outgoing payment, or the public key of the sender node if it is to
22
+ * register an incoming payment.
23
+ **/
11
24
  nodePubkey: string;
12
25
 
26
+ /** Indicates whether this payment is an OutgoingPayment or an IncomingPayment. **/
13
27
  direction: PaymentDirection;
14
28
  };
15
29
 
@@ -1,10 +1,13 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  type ReleaseChannelPerCommitmentSecretInput = {
4
+ /** The unique identifier of the channel. **/
4
5
  channelId: string;
5
6
 
7
+ /** The per-commitment secret to be released. **/
6
8
  perCommitmentSecret: string;
7
9
 
10
+ /** The index associated with the per-commitment secret. **/
8
11
  perCommitmentIndex: number;
9
12
  };
10
13
 
@@ -1,6 +1,7 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  type ReleaseChannelPerCommitmentSecretOutput = {
4
+ /** The channel object after the per-commitment secret release operation. **/
4
5
  channelId: string;
5
6
  };
6
7
 
@@ -1,6 +1,7 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  type ReleasePaymentPreimageOutput = {
4
+ /** The invoice of the transaction. **/
4
5
  invoiceId: string;
5
6
  };
6
7
 
@@ -21,6 +21,8 @@ export enum RemoteSigningSubEventType {
21
21
  RELEASE_PAYMENT_PREIMAGE = "RELEASE_PAYMENT_PREIMAGE",
22
22
 
23
23
  REQUEST_INVOICE_PAYMENT_HASH = "REQUEST_INVOICE_PAYMENT_HASH",
24
+
25
+ REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET = "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET",
24
26
  }
25
27
 
26
28
  export default RemoteSigningSubEventType;
@@ -3,8 +3,13 @@
3
3
  import ComplianceProvider from "./ComplianceProvider.js";
4
4
 
5
5
  type ScreenNodeInput = {
6
+ /**
7
+ * The compliance provider that is going to screen the node. You need to be a customer of the selected
8
+ * provider and store the API key on the Lightspark account setting page.
9
+ **/
6
10
  provider: ComplianceProvider;
7
11
 
12
+ /** The public key of the lightning node that needs to be screened. **/
8
13
  nodePubkey: string;
9
14
  };
10
15
 
@@ -7,8 +7,11 @@ type SetInvoicePaymentHashInput = {
7
7
  /** The 32-byte hash of the payment preimage. **/
8
8
  paymentHash: string;
9
9
 
10
- /** The 32-byte nonce used to generate the invoice preimage. **/
11
- preimageNonce: string;
10
+ /**
11
+ * The 32-byte nonce used to generate the invoice preimage if applicable. It will later be included in
12
+ * RELEASE_PAYMENT_PREIMAGE webhook to help recover the raw preimage.
13
+ **/
14
+ preimageNonce?: string;
12
15
  };
13
16
 
14
17
  export const SetInvoicePaymentHashInputFromJson = (
@@ -1,10 +1,13 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  type SignInvoiceInput = {
4
+ /** The unique identifier of the invoice to be signed. **/
4
5
  invoiceId: string;
5
6
 
7
+ /** The cryptographic signature for the invoice. **/
6
8
  signature: string;
7
9
 
10
+ /** The recovery identifier for the signature. **/
8
11
  recoveryId: number;
9
12
  };
10
13
 
@@ -1,6 +1,7 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
3
  type SignInvoiceOutput = {
4
+ /** The signed invoice object. **/
4
5
  invoiceId: string;
5
6
  };
6
7
 
@@ -4,6 +4,7 @@ import type IdAndSignature from "./IdAndSignature.js";
4
4
  import { IdAndSignatureFromJson } from "./IdAndSignature.js";
5
5
 
6
6
  type SignMessagesInput = {
7
+ /** The list of the message ids and signatures. **/
7
8
  signatures: IdAndSignature[];
8
9
  };
9
10
 
@@ -4,6 +4,7 @@ import type SignablePayload from "./SignablePayload.js";
4
4
  import { SignablePayloadFromJson } from "./SignablePayload.js";
5
5
 
6
6
  type SignMessagesOutput = {
7
+ /** The list of signed payloads. **/
7
8
  signedPayloads: SignablePayload[];
8
9
  };
9
10
 
@@ -12,6 +12,8 @@ export enum SignablePayloadStatus {
12
12
  SIGNED = "SIGNED",
13
13
 
14
14
  VALIDATION_FAILED = "VALIDATION_FAILED",
15
+
16
+ INVALID_SIGNATURE = "INVALID_SIGNATURE",
15
17
  }
16
18
 
17
19
  export default SignablePayloadStatus;
@@ -166,6 +166,7 @@ export const TransactionFromJson = (obj: any): Transaction => {
166
166
  obj["outgoing_payment_uma_post_transaction_data"]?.map((e) =>
167
167
  PostTransactionDataFromJson(e),
168
168
  ),
169
+ obj["outgoing_payment_payment_preimage"],
169
170
  );
170
171
  }
171
172
  if (obj["__typename"] == "RoutingTransaction") {
@@ -646,6 +647,7 @@ fragment TransactionFragment on Transaction {
646
647
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
647
648
  }
648
649
  }
650
+ outgoing_payment_payment_preimage: payment_preimage
649
651
  }
650
652
  ... on RoutingTransaction {
651
653
  __typename
@@ -476,6 +476,7 @@ query FetchWalletToTransactionsConnection($entity_id: ID!, $first: Int, $after:
476
476
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
477
477
  }
478
478
  }
479
+ outgoing_payment_payment_preimage: payment_preimage
479
480
  }
480
481
  ... on RoutingTransaction {
481
482
  __typename
@@ -10,6 +10,10 @@ export enum WebhookEventType {
10
10
 
11
11
  PAYMENT_FINISHED = "PAYMENT_FINISHED",
12
12
 
13
+ WITHDRAWAL_FINISHED = "WITHDRAWAL_FINISHED",
14
+
15
+ FUNDS_RECEIVED = "FUNDS_RECEIVED",
16
+
13
17
  NODE_STATUS = "NODE_STATUS",
14
18
 
15
19
  WALLET_STATUS = "WALLET_STATUS",
@@ -23,6 +27,8 @@ export enum WebhookEventType {
23
27
  WALLET_FUNDS_RECEIVED = "WALLET_FUNDS_RECEIVED",
24
28
 
25
29
  REMOTE_SIGNING = "REMOTE_SIGNING",
30
+
31
+ LOW_BALANCE = "LOW_BALANCE",
26
32
  }
27
33
 
28
34
  export default WebhookEventType;
@@ -8,6 +8,8 @@ export enum WithdrawalRequestStatus {
8
8
  */
9
9
  FUTURE_VALUE = "FUTURE_VALUE",
10
10
 
11
+ CREATED = "CREATED",
12
+
11
13
  FAILED = "FAILED",
12
14
 
13
15
  IN_PROGRESS = "IN_PROGRESS",
@@ -19,6 +19,7 @@ export {
19
19
  default as ChannelOpeningTransaction,
20
20
  getChannelOpeningTransactionQuery,
21
21
  } from "./ChannelOpeningTransaction.js";
22
+ export { default as ChannelSnapshot } from "./ChannelSnapshot.js";
22
23
  export { default as ChannelStatus } from "./ChannelStatus.js";
23
24
  export { default as ChannelToTransactionsConnection } from "./ChannelToTransactionsConnection.js";
24
25
  export { default as ComplianceProvider } from "./ComplianceProvider.js";