@lightsparkdev/lightspark-sdk 1.0.7 → 1.1.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.
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-K2ZU5YQL.js → chunk-PZMOKVDK.js} +14 -10
- package/dist/{index-dbf06298.d.ts → index-95299cb4.d.ts} +116 -106
- package/dist/index.cjs +2939 -2883
- package/dist/index.d.ts +2 -2
- package/dist/index.js +74 -14
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +1 -1
- package/package.json +4 -2
- package/src/client.ts +39 -4
- package/src/graphql/CreateTestModePayment.ts +4 -4
- package/src/graphql/PaymentRequestsForNode.ts +33 -0
- package/src/tests/integration/client.test.ts +60 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthProvider } from '@lightsparkdev/core';
|
|
2
|
-
import { W as WebhookEventType, L as LightsparkClient } from './index-
|
|
3
|
-
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-
|
|
2
|
+
import { W as WebhookEventType, L as LightsparkClient } from './index-95299cb4.js';
|
|
3
|
+
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-95299cb4.js';
|
|
4
4
|
import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
|
|
5
5
|
import 'zen-observable';
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
CurrencyUnit_default,
|
|
15
15
|
FRAGMENT,
|
|
16
16
|
FRAGMENT10,
|
|
17
|
+
FRAGMENT11,
|
|
18
|
+
FRAGMENT12,
|
|
17
19
|
FRAGMENT2,
|
|
18
20
|
FRAGMENT3,
|
|
19
21
|
FRAGMENT4,
|
|
@@ -26,6 +28,7 @@ import {
|
|
|
26
28
|
GraphNode_default,
|
|
27
29
|
HtlcAttemptFailureCode_default,
|
|
28
30
|
IncomingPaymentAttemptStatus_default,
|
|
31
|
+
IncomingPaymentFromJson,
|
|
29
32
|
IncomingPayment_default,
|
|
30
33
|
InvoiceDataFromJson,
|
|
31
34
|
InvoiceFromJson,
|
|
@@ -42,6 +45,7 @@ import {
|
|
|
42
45
|
OutgoingPayment_default,
|
|
43
46
|
PaymentDirection_default,
|
|
44
47
|
PaymentFailureReason_default,
|
|
48
|
+
PaymentRequestFromJson,
|
|
45
49
|
PaymentRequestStatus_default,
|
|
46
50
|
Permission_default,
|
|
47
51
|
RemoteSigningSubEventType_default,
|
|
@@ -76,7 +80,7 @@ import {
|
|
|
76
80
|
getSignableQuery,
|
|
77
81
|
getTransactionQuery,
|
|
78
82
|
getWithdrawalQuery
|
|
79
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-PZMOKVDK.js";
|
|
80
84
|
import {
|
|
81
85
|
BitcoinNetwork_default
|
|
82
86
|
} from "./chunk-K6SAUSAX.js";
|
|
@@ -129,7 +133,7 @@ import {
|
|
|
129
133
|
// package.json
|
|
130
134
|
var package_default = {
|
|
131
135
|
name: "@lightsparkdev/lightspark-sdk",
|
|
132
|
-
version: "1.
|
|
136
|
+
version: "1.1.1",
|
|
133
137
|
description: "Lightspark JS SDK",
|
|
134
138
|
author: "Lightspark Inc.",
|
|
135
139
|
keywords: [
|
|
@@ -209,7 +213,9 @@ var package_default = {
|
|
|
209
213
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
210
214
|
lint: "eslint .",
|
|
211
215
|
postversion: "yarn build",
|
|
212
|
-
test: "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
216
|
+
"test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
217
|
+
test: "yarn test-cmd src/tests/*.test.ts",
|
|
218
|
+
"test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
|
|
213
219
|
"types:watch": "tsc-absolute --watch",
|
|
214
220
|
types: "tsc"
|
|
215
221
|
},
|
|
@@ -364,8 +370,8 @@ mutation CreateTestModePayment(
|
|
|
364
370
|
encoded_invoice: $encoded_invoice
|
|
365
371
|
amount_msats: $amount_msats
|
|
366
372
|
}) {
|
|
367
|
-
|
|
368
|
-
...
|
|
373
|
+
incoming_payment {
|
|
374
|
+
...IncomingPaymentFragment
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
377
|
}
|
|
@@ -575,7 +581,38 @@ var PayInvoice = `
|
|
|
575
581
|
}
|
|
576
582
|
}
|
|
577
583
|
|
|
578
|
-
${
|
|
584
|
+
${FRAGMENT8}
|
|
585
|
+
`;
|
|
586
|
+
|
|
587
|
+
// src/graphql/PaymentRequestsForNode.ts
|
|
588
|
+
var PaymentRequestsForNode = `
|
|
589
|
+
query PaymentRequestsForNode(
|
|
590
|
+
$network: BitcoinNetwork!,
|
|
591
|
+
$nodeId: ID!,
|
|
592
|
+
$numTransactions: Int,
|
|
593
|
+
$afterDate: DateTime,
|
|
594
|
+
) {
|
|
595
|
+
current_account {
|
|
596
|
+
id
|
|
597
|
+
name
|
|
598
|
+
recent_payment_requests: payment_requests(
|
|
599
|
+
first: $numTransactions
|
|
600
|
+
bitcoin_network: $network
|
|
601
|
+
lightning_node_id: $nodeId
|
|
602
|
+
after_date: $afterDate
|
|
603
|
+
) {
|
|
604
|
+
count
|
|
605
|
+
entities {
|
|
606
|
+
...PaymentRequestFragment
|
|
607
|
+
__typename
|
|
608
|
+
}
|
|
609
|
+
__typename
|
|
610
|
+
}
|
|
611
|
+
__typename
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
${FRAGMENT9}
|
|
579
616
|
`;
|
|
580
617
|
|
|
581
618
|
// src/graphql/PayUmaInvoice.ts
|
|
@@ -602,7 +639,7 @@ var PayUmaInvoice = `
|
|
|
602
639
|
}
|
|
603
640
|
}
|
|
604
641
|
|
|
605
|
-
${
|
|
642
|
+
${FRAGMENT8}
|
|
606
643
|
`;
|
|
607
644
|
|
|
608
645
|
// src/graphql/RequestWithdrawal.ts
|
|
@@ -625,7 +662,7 @@ var RequestWithdrawal = `
|
|
|
625
662
|
}
|
|
626
663
|
}
|
|
627
664
|
|
|
628
|
-
${
|
|
665
|
+
${FRAGMENT10}
|
|
629
666
|
`;
|
|
630
667
|
|
|
631
668
|
// src/graphql/SendPayment.ts
|
|
@@ -652,7 +689,7 @@ var SendPayment = `
|
|
|
652
689
|
}
|
|
653
690
|
}
|
|
654
691
|
|
|
655
|
-
${
|
|
692
|
+
${FRAGMENT8}
|
|
656
693
|
`;
|
|
657
694
|
|
|
658
695
|
// src/graphql/SingleNodeDashboard.ts
|
|
@@ -763,7 +800,7 @@ query SingleNodeDashboard(
|
|
|
763
800
|
}
|
|
764
801
|
}
|
|
765
802
|
|
|
766
|
-
${
|
|
803
|
+
${FRAGMENT11}
|
|
767
804
|
${FRAGMENT}
|
|
768
805
|
`;
|
|
769
806
|
|
|
@@ -802,7 +839,7 @@ query TransactionsForNode(
|
|
|
802
839
|
}
|
|
803
840
|
}
|
|
804
841
|
|
|
805
|
-
${
|
|
842
|
+
${FRAGMENT11}
|
|
806
843
|
${FRAGMENT}
|
|
807
844
|
`;
|
|
808
845
|
|
|
@@ -817,7 +854,7 @@ subscription TransactionSubscription(
|
|
|
817
854
|
}
|
|
818
855
|
}
|
|
819
856
|
|
|
820
|
-
${
|
|
857
|
+
${FRAGMENT12}
|
|
821
858
|
`;
|
|
822
859
|
|
|
823
860
|
// src/NodeKeyLoaderCache.ts
|
|
@@ -1112,6 +1149,29 @@ var LightsparkClient = class {
|
|
|
1112
1149
|
(transaction) => TransactionFromJson(transaction)
|
|
1113
1150
|
) ?? [];
|
|
1114
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Retrieves the most recent payment requests for a given node.
|
|
1154
|
+
*
|
|
1155
|
+
* @param nodeId The node ID for which to read transactions
|
|
1156
|
+
* @param numTransactions The maximum number of transactions to read. Defaults to 20.
|
|
1157
|
+
* @param bitcoinNetwork The bitcoin network on which to read transactions. Defaults to MAINNET.
|
|
1158
|
+
* @param afterDate Filters transactions to those after the given date. Defaults to undefined (no limit).
|
|
1159
|
+
* @returns An array of payment requests for the given node ID.
|
|
1160
|
+
*/
|
|
1161
|
+
async getRecentPaymentRequests(nodeId, numTransactions = 20, bitcoinNetwork = BitcoinNetwork_default.MAINNET, afterDate = void 0) {
|
|
1162
|
+
const response = await this.requester.makeRawRequest(
|
|
1163
|
+
PaymentRequestsForNode,
|
|
1164
|
+
{
|
|
1165
|
+
nodeId,
|
|
1166
|
+
numTransactions,
|
|
1167
|
+
network: bitcoinNetwork,
|
|
1168
|
+
afterDate
|
|
1169
|
+
}
|
|
1170
|
+
);
|
|
1171
|
+
return response.current_account?.recent_payment_requests.entities.map(
|
|
1172
|
+
(paymentRequest) => PaymentRequestFromJson(paymentRequest)
|
|
1173
|
+
) ?? [];
|
|
1174
|
+
}
|
|
1115
1175
|
/**
|
|
1116
1176
|
* Starts listening for new transactions or updates to existing transactions for a list of nodes.
|
|
1117
1177
|
*
|
|
@@ -1706,8 +1766,8 @@ var LightsparkClient = class {
|
|
|
1706
1766
|
amount_msats: amountMsats
|
|
1707
1767
|
},
|
|
1708
1768
|
constructObject: (responseJson) => {
|
|
1709
|
-
return
|
|
1710
|
-
responseJson.create_test_mode_payment?.
|
|
1769
|
+
return IncomingPaymentFromJson(
|
|
1770
|
+
responseJson.create_test_mode_payment?.incoming_payment
|
|
1711
1771
|
);
|
|
1712
1772
|
}
|
|
1713
1773
|
});
|
package/dist/objects/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-
|
|
1
|
+
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-95299cb4.js';
|
|
2
2
|
export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
|
|
3
3
|
import '@lightsparkdev/core';
|
|
4
4
|
import 'zen-observable';
|
package/dist/objects/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/lightspark-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -80,7 +80,9 @@
|
|
|
80
80
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
81
81
|
"lint": "eslint .",
|
|
82
82
|
"postversion": "yarn build",
|
|
83
|
-
"test": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
83
|
+
"test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
84
|
+
"test": "yarn test-cmd src/tests/*.test.ts",
|
|
85
|
+
"test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
|
|
84
86
|
"types:watch": "tsc-absolute --watch",
|
|
85
87
|
"types": "tsc"
|
|
86
88
|
},
|
package/src/client.ts
CHANGED
|
@@ -39,6 +39,7 @@ import { LightningFeeEstimateForNode } from "./graphql/LightningFeeEstimateForNo
|
|
|
39
39
|
import type { AccountDashboard } from "./graphql/MultiNodeDashboard.js";
|
|
40
40
|
import { MultiNodeDashboard } from "./graphql/MultiNodeDashboard.js";
|
|
41
41
|
import { PayInvoice } from "./graphql/PayInvoice.js";
|
|
42
|
+
import { PaymentRequestsForNode } from "./graphql/PaymentRequestsForNode.js";
|
|
42
43
|
import { PayUmaInvoice } from "./graphql/PayUmaInvoice.js";
|
|
43
44
|
import { RequestWithdrawal } from "./graphql/RequestWithdrawal.js";
|
|
44
45
|
import { SendPayment } from "./graphql/SendPayment.js";
|
|
@@ -54,6 +55,8 @@ import type CurrencyAmount from "./objects/CurrencyAmount.js";
|
|
|
54
55
|
import { CurrencyAmountFromJson } from "./objects/CurrencyAmount.js";
|
|
55
56
|
import type FeeEstimate from "./objects/FeeEstimate.js";
|
|
56
57
|
import { FeeEstimateFromJson } from "./objects/FeeEstimate.js";
|
|
58
|
+
import type IncomingPayment from "./objects/IncomingPayment.js";
|
|
59
|
+
import { IncomingPaymentFromJson } from "./objects/IncomingPayment.js";
|
|
57
60
|
import type Invoice from "./objects/Invoice.js";
|
|
58
61
|
import { InvoiceFromJson } from "./objects/Invoice.js";
|
|
59
62
|
import type InvoiceData from "./objects/InvoiceData.js";
|
|
@@ -61,6 +64,7 @@ import { InvoiceDataFromJson } from "./objects/InvoiceData.js";
|
|
|
61
64
|
import InvoiceType from "./objects/InvoiceType.js";
|
|
62
65
|
import type OutgoingPayment from "./objects/OutgoingPayment.js";
|
|
63
66
|
import { OutgoingPaymentFromJson } from "./objects/OutgoingPayment.js";
|
|
67
|
+
import { PaymentRequestFromJson } from "./objects/PaymentRequest.js";
|
|
64
68
|
import Permission from "./objects/Permission.js";
|
|
65
69
|
import type SingleNodeDashboard from "./objects/SingleNodeDashboard.js";
|
|
66
70
|
import type Transaction from "./objects/Transaction.js";
|
|
@@ -226,6 +230,37 @@ class LightsparkClient {
|
|
|
226
230
|
);
|
|
227
231
|
}
|
|
228
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Retrieves the most recent payment requests for a given node.
|
|
235
|
+
*
|
|
236
|
+
* @param nodeId The node ID for which to read transactions
|
|
237
|
+
* @param numTransactions The maximum number of transactions to read. Defaults to 20.
|
|
238
|
+
* @param bitcoinNetwork The bitcoin network on which to read transactions. Defaults to MAINNET.
|
|
239
|
+
* @param afterDate Filters transactions to those after the given date. Defaults to undefined (no limit).
|
|
240
|
+
* @returns An array of payment requests for the given node ID.
|
|
241
|
+
*/
|
|
242
|
+
public async getRecentPaymentRequests(
|
|
243
|
+
nodeId: string,
|
|
244
|
+
numTransactions: number = 20,
|
|
245
|
+
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
246
|
+
afterDate: Maybe<string> = undefined,
|
|
247
|
+
): Promise<Transaction[]> {
|
|
248
|
+
const response = await this.requester.makeRawRequest(
|
|
249
|
+
PaymentRequestsForNode,
|
|
250
|
+
{
|
|
251
|
+
nodeId,
|
|
252
|
+
numTransactions,
|
|
253
|
+
network: bitcoinNetwork,
|
|
254
|
+
afterDate,
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
return (
|
|
258
|
+
response.current_account?.recent_payment_requests.entities.map(
|
|
259
|
+
(paymentRequest) => PaymentRequestFromJson(paymentRequest),
|
|
260
|
+
) ?? []
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
229
264
|
/**
|
|
230
265
|
* Starts listening for new transactions or updates to existing transactions for a list of nodes.
|
|
231
266
|
*
|
|
@@ -956,7 +991,7 @@ class LightsparkClient {
|
|
|
956
991
|
localNodeId: string,
|
|
957
992
|
encodedInvoice: string,
|
|
958
993
|
amountMsats: number | undefined = undefined,
|
|
959
|
-
): Promise<
|
|
994
|
+
): Promise<IncomingPayment | null> {
|
|
960
995
|
return await this.executeRawQuery({
|
|
961
996
|
queryPayload: CreateTestModePayment,
|
|
962
997
|
variables: {
|
|
@@ -966,11 +1001,11 @@ class LightsparkClient {
|
|
|
966
1001
|
},
|
|
967
1002
|
constructObject: (responseJson: {
|
|
968
1003
|
create_test_mode_payment: {
|
|
969
|
-
|
|
1004
|
+
incoming_payment: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
970
1005
|
} | null;
|
|
971
1006
|
}) => {
|
|
972
|
-
return
|
|
973
|
-
responseJson.create_test_mode_payment?.
|
|
1007
|
+
return IncomingPaymentFromJson(
|
|
1008
|
+
responseJson.create_test_mode_payment?.incoming_payment,
|
|
974
1009
|
);
|
|
975
1010
|
},
|
|
976
1011
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
|
-
import { FRAGMENT as
|
|
3
|
+
import { FRAGMENT as IncomingPaymentFragment } from "../objects/IncomingPayment.js";
|
|
4
4
|
|
|
5
5
|
export const CreateTestModePayment = `
|
|
6
6
|
mutation CreateTestModePayment(
|
|
@@ -13,11 +13,11 @@ mutation CreateTestModePayment(
|
|
|
13
13
|
encoded_invoice: $encoded_invoice
|
|
14
14
|
amount_msats: $amount_msats
|
|
15
15
|
}) {
|
|
16
|
-
|
|
17
|
-
...
|
|
16
|
+
incoming_payment {
|
|
17
|
+
...IncomingPaymentFragment
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
${
|
|
22
|
+
${IncomingPaymentFragment}
|
|
23
23
|
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import { FRAGMENT as PaymentRequestFragment } from "../objects/PaymentRequest.js";
|
|
4
|
+
|
|
5
|
+
export const PaymentRequestsForNode = `
|
|
6
|
+
query PaymentRequestsForNode(
|
|
7
|
+
$network: BitcoinNetwork!,
|
|
8
|
+
$nodeId: ID!,
|
|
9
|
+
$numTransactions: Int,
|
|
10
|
+
$afterDate: DateTime,
|
|
11
|
+
) {
|
|
12
|
+
current_account {
|
|
13
|
+
id
|
|
14
|
+
name
|
|
15
|
+
recent_payment_requests: payment_requests(
|
|
16
|
+
first: $numTransactions
|
|
17
|
+
bitcoin_network: $network
|
|
18
|
+
lightning_node_id: $nodeId
|
|
19
|
+
after_date: $afterDate
|
|
20
|
+
) {
|
|
21
|
+
count
|
|
22
|
+
entities {
|
|
23
|
+
...PaymentRequestFragment
|
|
24
|
+
__typename
|
|
25
|
+
}
|
|
26
|
+
__typename
|
|
27
|
+
}
|
|
28
|
+
__typename
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
${PaymentRequestFragment}
|
|
33
|
+
`;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import LightsparkClient from "../../client.js";
|
|
2
|
+
import { getCredentialsFromEnvOrThrow } from "../../env.js";
|
|
3
|
+
import {
|
|
4
|
+
AccountTokenAuthProvider,
|
|
5
|
+
BitcoinNetwork,
|
|
6
|
+
PaymentRequestStatus,
|
|
7
|
+
} from "../../index.js";
|
|
8
|
+
|
|
9
|
+
describe("lightspark-sdk client", () => {
|
|
10
|
+
const { apiTokenClientId, apiTokenClientSecret, baseUrl } =
|
|
11
|
+
getCredentialsFromEnvOrThrow();
|
|
12
|
+
const accountAuthProvider = new AccountTokenAuthProvider(
|
|
13
|
+
apiTokenClientId,
|
|
14
|
+
apiTokenClientSecret,
|
|
15
|
+
);
|
|
16
|
+
let regtestNodeId: string | undefined;
|
|
17
|
+
|
|
18
|
+
function getRegtestNodeId() {
|
|
19
|
+
expect(regtestNodeId).toBeDefined();
|
|
20
|
+
if (!regtestNodeId) {
|
|
21
|
+
throw new Error("regtestNodeId is not set");
|
|
22
|
+
}
|
|
23
|
+
return regtestNodeId as string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
it("should get env vars and construct the client successfully", async () => {
|
|
27
|
+
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
28
|
+
expect(lightsparkClient).toBeDefined();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should successfully get the current account regtest node", async () => {
|
|
32
|
+
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
33
|
+
|
|
34
|
+
const account = await lightsparkClient.getCurrentAccount();
|
|
35
|
+
const nodesConnection = await account?.getNodes(lightsparkClient, 1, [
|
|
36
|
+
BitcoinNetwork.REGTEST,
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const regtestNode = nodesConnection?.entities[0];
|
|
40
|
+
expect(regtestNode).toBeDefined();
|
|
41
|
+
regtestNodeId = regtestNode?.id;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should successfully create an uma invoice", async () => {
|
|
45
|
+
const nodeId = getRegtestNodeId();
|
|
46
|
+
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
47
|
+
|
|
48
|
+
const metadata = JSON.stringify([
|
|
49
|
+
["text/plain", "Pay to vasp2.com user $bob"],
|
|
50
|
+
["text/identifier", "$bob@vasp2.com"],
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
const umaInvoice = await lightsparkClient.createUmaInvoice(
|
|
54
|
+
nodeId,
|
|
55
|
+
1000,
|
|
56
|
+
metadata,
|
|
57
|
+
);
|
|
58
|
+
expect(umaInvoice?.status).toEqual(PaymentRequestStatus.OPEN);
|
|
59
|
+
});
|
|
60
|
+
});
|