@lightsparkdev/lightspark-sdk 1.1.5 → 1.1.7
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.
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-7UNNCH5S.js → chunk-7UT6YX37.js} +833 -23
- package/dist/{index-5235e43b.d.ts → index-d31f4469.d.ts} +35 -27
- package/dist/index.cjs +835 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/objects/index.cjs +779 -23
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +1 -1
- package/package.json +2 -2
- package/src/objects/Account.ts +162 -0
- package/src/objects/ChannelSnapshot.ts +36 -0
- package/src/objects/Entity.ts +182 -0
- package/src/objects/HtlcAttemptFailureCode.ts +2 -0
- package/src/objects/Invoice.ts +54 -0
- package/src/objects/InvoiceData.ts +54 -0
- package/src/objects/LightningTransaction.ts +54 -0
- package/src/objects/LightsparkNode.ts +63 -0
- package/src/objects/LightsparkNodeWithOSK.ts +33 -0
- package/src/objects/LightsparkNodeWithRemoteSigning.ts +33 -0
- package/src/objects/Node.ts +61 -0
- package/src/objects/OutgoingPayment.ts +74 -0
- package/src/objects/OutgoingPaymentAttempt.ts +20 -0
- package/src/objects/PaymentRequest.ts +54 -0
- package/src/objects/PaymentRequestData.ts +54 -0
- package/src/objects/Transaction.ts +54 -0
- package/src/objects/Wallet.ts +108 -0
- package/src/tests/integration/client.test.ts +46 -7
|
@@ -170,6 +170,33 @@ fragment PaymentRequestDataFragment on PaymentRequestData {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
|
|
173
|
+
lightspark_node_with_o_s_k_balances: balances {
|
|
174
|
+
__typename
|
|
175
|
+
balances_owned_balance: owned_balance {
|
|
176
|
+
__typename
|
|
177
|
+
currency_amount_original_value: original_value
|
|
178
|
+
currency_amount_original_unit: original_unit
|
|
179
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
180
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
181
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
182
|
+
}
|
|
183
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
184
|
+
__typename
|
|
185
|
+
currency_amount_original_value: original_value
|
|
186
|
+
currency_amount_original_unit: original_unit
|
|
187
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
188
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
189
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
190
|
+
}
|
|
191
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
192
|
+
__typename
|
|
193
|
+
currency_amount_original_value: original_value
|
|
194
|
+
currency_amount_original_unit: original_unit
|
|
195
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
196
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
197
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
198
|
+
}
|
|
199
|
+
}
|
|
173
200
|
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
|
|
174
201
|
__typename
|
|
175
202
|
secret_encrypted_value: encrypted_value
|
|
@@ -275,6 +302,33 @@ fragment PaymentRequestDataFragment on PaymentRequestData {
|
|
|
275
302
|
}
|
|
276
303
|
}
|
|
277
304
|
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
|
|
305
|
+
lightspark_node_with_remote_signing_balances: balances {
|
|
306
|
+
__typename
|
|
307
|
+
balances_owned_balance: owned_balance {
|
|
308
|
+
__typename
|
|
309
|
+
currency_amount_original_value: original_value
|
|
310
|
+
currency_amount_original_unit: original_unit
|
|
311
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
312
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
313
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
314
|
+
}
|
|
315
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
316
|
+
__typename
|
|
317
|
+
currency_amount_original_value: original_value
|
|
318
|
+
currency_amount_original_unit: original_unit
|
|
319
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
320
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
321
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
322
|
+
}
|
|
323
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
324
|
+
__typename
|
|
325
|
+
currency_amount_original_value: original_value
|
|
326
|
+
currency_amount_original_unit: original_unit
|
|
327
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
328
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
329
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
330
|
+
}
|
|
331
|
+
}
|
|
278
332
|
}
|
|
279
333
|
}
|
|
280
334
|
}
|
|
@@ -521,6 +521,33 @@ fragment TransactionFragment on Transaction {
|
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
|
|
524
|
+
lightspark_node_with_o_s_k_balances: balances {
|
|
525
|
+
__typename
|
|
526
|
+
balances_owned_balance: owned_balance {
|
|
527
|
+
__typename
|
|
528
|
+
currency_amount_original_value: original_value
|
|
529
|
+
currency_amount_original_unit: original_unit
|
|
530
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
531
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
532
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
533
|
+
}
|
|
534
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
535
|
+
__typename
|
|
536
|
+
currency_amount_original_value: original_value
|
|
537
|
+
currency_amount_original_unit: original_unit
|
|
538
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
539
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
540
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
541
|
+
}
|
|
542
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
543
|
+
__typename
|
|
544
|
+
currency_amount_original_value: original_value
|
|
545
|
+
currency_amount_original_unit: original_unit
|
|
546
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
547
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
548
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
549
|
+
}
|
|
550
|
+
}
|
|
524
551
|
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
|
|
525
552
|
__typename
|
|
526
553
|
secret_encrypted_value: encrypted_value
|
|
@@ -626,6 +653,33 @@ fragment TransactionFragment on Transaction {
|
|
|
626
653
|
}
|
|
627
654
|
}
|
|
628
655
|
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
|
|
656
|
+
lightspark_node_with_remote_signing_balances: balances {
|
|
657
|
+
__typename
|
|
658
|
+
balances_owned_balance: owned_balance {
|
|
659
|
+
__typename
|
|
660
|
+
currency_amount_original_value: original_value
|
|
661
|
+
currency_amount_original_unit: original_unit
|
|
662
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
663
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
664
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
665
|
+
}
|
|
666
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
667
|
+
__typename
|
|
668
|
+
currency_amount_original_value: original_value
|
|
669
|
+
currency_amount_original_unit: original_unit
|
|
670
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
671
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
672
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
673
|
+
}
|
|
674
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
675
|
+
__typename
|
|
676
|
+
currency_amount_original_value: original_value
|
|
677
|
+
currency_amount_original_unit: original_unit
|
|
678
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
679
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
680
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
681
|
+
}
|
|
682
|
+
}
|
|
629
683
|
}
|
|
630
684
|
}
|
|
631
685
|
}
|
package/src/objects/Wallet.ts
CHANGED
|
@@ -350,6 +350,33 @@ query FetchWalletToTransactionsConnection($entity_id: ID!, $first: Int, $after:
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
|
|
353
|
+
lightspark_node_with_o_s_k_balances: balances {
|
|
354
|
+
__typename
|
|
355
|
+
balances_owned_balance: owned_balance {
|
|
356
|
+
__typename
|
|
357
|
+
currency_amount_original_value: original_value
|
|
358
|
+
currency_amount_original_unit: original_unit
|
|
359
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
360
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
361
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
362
|
+
}
|
|
363
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
364
|
+
__typename
|
|
365
|
+
currency_amount_original_value: original_value
|
|
366
|
+
currency_amount_original_unit: original_unit
|
|
367
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
368
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
369
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
370
|
+
}
|
|
371
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
372
|
+
__typename
|
|
373
|
+
currency_amount_original_value: original_value
|
|
374
|
+
currency_amount_original_unit: original_unit
|
|
375
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
376
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
377
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
378
|
+
}
|
|
379
|
+
}
|
|
353
380
|
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
|
|
354
381
|
__typename
|
|
355
382
|
secret_encrypted_value: encrypted_value
|
|
@@ -455,6 +482,33 @@ query FetchWalletToTransactionsConnection($entity_id: ID!, $first: Int, $after:
|
|
|
455
482
|
}
|
|
456
483
|
}
|
|
457
484
|
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
|
|
485
|
+
lightspark_node_with_remote_signing_balances: balances {
|
|
486
|
+
__typename
|
|
487
|
+
balances_owned_balance: owned_balance {
|
|
488
|
+
__typename
|
|
489
|
+
currency_amount_original_value: original_value
|
|
490
|
+
currency_amount_original_unit: original_unit
|
|
491
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
492
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
493
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
494
|
+
}
|
|
495
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
496
|
+
__typename
|
|
497
|
+
currency_amount_original_value: original_value
|
|
498
|
+
currency_amount_original_unit: original_unit
|
|
499
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
500
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
501
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
502
|
+
}
|
|
503
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
504
|
+
__typename
|
|
505
|
+
currency_amount_original_value: original_value
|
|
506
|
+
currency_amount_original_unit: original_unit
|
|
507
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
508
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
509
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
510
|
+
}
|
|
511
|
+
}
|
|
458
512
|
}
|
|
459
513
|
}
|
|
460
514
|
}
|
|
@@ -726,6 +780,33 @@ query FetchWalletToPaymentRequestsConnection($entity_id: ID!, $first: Int, $afte
|
|
|
726
780
|
}
|
|
727
781
|
}
|
|
728
782
|
lightspark_node_with_o_s_k_uma_prescreening_utxos: uma_prescreening_utxos
|
|
783
|
+
lightspark_node_with_o_s_k_balances: balances {
|
|
784
|
+
__typename
|
|
785
|
+
balances_owned_balance: owned_balance {
|
|
786
|
+
__typename
|
|
787
|
+
currency_amount_original_value: original_value
|
|
788
|
+
currency_amount_original_unit: original_unit
|
|
789
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
790
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
791
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
792
|
+
}
|
|
793
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
794
|
+
__typename
|
|
795
|
+
currency_amount_original_value: original_value
|
|
796
|
+
currency_amount_original_unit: original_unit
|
|
797
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
798
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
799
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
800
|
+
}
|
|
801
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
802
|
+
__typename
|
|
803
|
+
currency_amount_original_value: original_value
|
|
804
|
+
currency_amount_original_unit: original_unit
|
|
805
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
806
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
807
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
808
|
+
}
|
|
809
|
+
}
|
|
729
810
|
lightspark_node_with_o_s_k_encrypted_signing_private_key: encrypted_signing_private_key {
|
|
730
811
|
__typename
|
|
731
812
|
secret_encrypted_value: encrypted_value
|
|
@@ -831,6 +912,33 @@ query FetchWalletToPaymentRequestsConnection($entity_id: ID!, $first: Int, $afte
|
|
|
831
912
|
}
|
|
832
913
|
}
|
|
833
914
|
lightspark_node_with_remote_signing_uma_prescreening_utxos: uma_prescreening_utxos
|
|
915
|
+
lightspark_node_with_remote_signing_balances: balances {
|
|
916
|
+
__typename
|
|
917
|
+
balances_owned_balance: owned_balance {
|
|
918
|
+
__typename
|
|
919
|
+
currency_amount_original_value: original_value
|
|
920
|
+
currency_amount_original_unit: original_unit
|
|
921
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
922
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
923
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
924
|
+
}
|
|
925
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
926
|
+
__typename
|
|
927
|
+
currency_amount_original_value: original_value
|
|
928
|
+
currency_amount_original_unit: original_unit
|
|
929
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
930
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
931
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
932
|
+
}
|
|
933
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
934
|
+
__typename
|
|
935
|
+
currency_amount_original_value: original_value
|
|
936
|
+
currency_amount_original_unit: original_unit
|
|
937
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
938
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
939
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
940
|
+
}
|
|
941
|
+
}
|
|
834
942
|
}
|
|
835
943
|
}
|
|
836
944
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pollUntil } from "@lightsparkdev/core";
|
|
1
|
+
import { mapCurrencyAmount, pollUntil, round } from "@lightsparkdev/core";
|
|
2
2
|
import LightsparkClient from "../../client.js";
|
|
3
3
|
import { getCredentialsFromEnvOrThrow } from "../../env.js";
|
|
4
4
|
import {
|
|
@@ -83,7 +83,7 @@ describe("lightspark-sdk client", () => {
|
|
|
83
83
|
}, 10000);
|
|
84
84
|
|
|
85
85
|
const satsToFund = 50_000;
|
|
86
|
-
test("Should deposit funds to
|
|
86
|
+
test("Should deposit funds to node with a defined amount of sats", async () => {
|
|
87
87
|
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
88
88
|
const account = await lightsparkClient.getCurrentAccount();
|
|
89
89
|
|
|
@@ -95,9 +95,45 @@ describe("lightspark-sdk client", () => {
|
|
|
95
95
|
BitcoinNetwork.REGTEST,
|
|
96
96
|
]);
|
|
97
97
|
let regtestNode = nodesConnection?.entities[0];
|
|
98
|
-
const
|
|
98
|
+
const initialTotalBalance = mapCurrencyAmount(regtestNode?.totalBalance);
|
|
99
99
|
const nodeId = getRegtestNodeId();
|
|
100
100
|
|
|
101
|
+
/* Backend will error on fund_node if node balance is greater than 100,000,000 sats, so we should
|
|
102
|
+
adjust to a target balance less than that: */
|
|
103
|
+
const targetBalanceSats = 50_000_000;
|
|
104
|
+
if (initialTotalBalance.sats > targetBalanceSats) {
|
|
105
|
+
const invoiceAmount = initialTotalBalance.sats - targetBalanceSats;
|
|
106
|
+
|
|
107
|
+
await lightsparkClient.loadNodeSigningKey(getRegtestNodeId(), {
|
|
108
|
+
password: REGTEST_SIGNING_KEY_PASSWORD,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const invoice = await lightsparkClient.createTestModeInvoice(
|
|
112
|
+
nodeId,
|
|
113
|
+
round((initialTotalBalance.sats - targetBalanceSats) * 1000), // convert to msats
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (!invoice) {
|
|
117
|
+
throw new Error("Unable to create invoice for balance adjustment");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const feeRate = 0.0016;
|
|
121
|
+
const payment = await lightsparkClient.payInvoice(
|
|
122
|
+
nodeId,
|
|
123
|
+
invoice,
|
|
124
|
+
round(invoiceAmount * feeRate),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (!payment) {
|
|
128
|
+
throw new Error("Payment undefined for balance adjustment");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
await lightsparkClient.waitForTransactionComplete(
|
|
132
|
+
payment.id,
|
|
133
|
+
pollTimeoutSecs,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
101
137
|
await lightsparkClient.fundNode(nodeId, satsToFund);
|
|
102
138
|
|
|
103
139
|
regtestNode = await pollUntil(
|
|
@@ -107,8 +143,9 @@ describe("lightspark-sdk client", () => {
|
|
|
107
143
|
(current, response) => {
|
|
108
144
|
if (
|
|
109
145
|
current &&
|
|
110
|
-
current.entities[0]?.
|
|
111
|
-
|
|
146
|
+
!mapCurrencyAmount(current.entities[0]?.totalBalance).isEqualTo(
|
|
147
|
+
initialTotalBalance,
|
|
148
|
+
)
|
|
112
149
|
) {
|
|
113
150
|
return {
|
|
114
151
|
stopPolling: true,
|
|
@@ -124,8 +161,10 @@ describe("lightspark-sdk client", () => {
|
|
|
124
161
|
);
|
|
125
162
|
|
|
126
163
|
expect(
|
|
127
|
-
regtestNode.
|
|
128
|
-
|
|
164
|
+
mapCurrencyAmount(regtestNode.totalBalance).isEqualTo(
|
|
165
|
+
initialTotalBalance,
|
|
166
|
+
),
|
|
167
|
+
).toBe(false);
|
|
129
168
|
}, 120_000);
|
|
130
169
|
|
|
131
170
|
test("Should send test mode payment", async () => {
|