@lightsparkdev/lightspark-sdk 1.1.2 → 1.1.3
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 +10 -0
- package/dist/{index-95299cb4.d.ts → index-827d336f.d.ts} +1 -0
- package/dist/index.cjs +9 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -4
- package/dist/objects/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/client.ts +10 -1
- package/src/graphql/FundNode.ts +2 -2
- package/src/logger.ts +3 -0
- package/src/tests/integration/client.test.ts +126 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lightsparkdev/lightspark-sdk
|
|
2
2
|
|
|
3
|
+
## 1.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- baeb7a1: [lightspark-sdk] Fix improper fundNode var ref and add tests
|
|
8
|
+
- Updated dependencies [ffcedbe]
|
|
9
|
+
- Updated dependencies [d9f6d5b]
|
|
10
|
+
- Updated dependencies [baeb7a1]
|
|
11
|
+
- @lightsparkdev/core@1.0.6
|
|
12
|
+
|
|
3
13
|
## 1.1.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1420,6 +1420,7 @@ declare class LightsparkClient {
|
|
|
1420
1420
|
* @returns An array of transactions for the given node ID.
|
|
1421
1421
|
*/
|
|
1422
1422
|
getRecentTransactions(nodeId: string, numTransactions?: number, bitcoinNetwork?: BitcoinNetwork, afterDate?: Maybe<string>): Promise<Transaction[]>;
|
|
1423
|
+
getTransaction(transactionId: string): Promise<Maybe<Transaction>>;
|
|
1423
1424
|
/**
|
|
1424
1425
|
* Retrieves the most recent payment requests for a given node.
|
|
1425
1426
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -1938,7 +1938,7 @@ var import_core9 = require("@lightsparkdev/core");
|
|
|
1938
1938
|
// package.json
|
|
1939
1939
|
var package_default = {
|
|
1940
1940
|
name: "@lightsparkdev/lightspark-sdk",
|
|
1941
|
-
version: "1.1.
|
|
1941
|
+
version: "1.1.3",
|
|
1942
1942
|
description: "Lightspark JS SDK",
|
|
1943
1943
|
author: "Lightspark Inc.",
|
|
1944
1944
|
keywords: [
|
|
@@ -2026,7 +2026,7 @@ var package_default = {
|
|
|
2026
2026
|
},
|
|
2027
2027
|
license: "Apache-2.0",
|
|
2028
2028
|
dependencies: {
|
|
2029
|
-
"@lightsparkdev/core": "1.0.
|
|
2029
|
+
"@lightsparkdev/core": "1.0.6",
|
|
2030
2030
|
"@lightsparkdev/crypto-wasm": "0.1.2",
|
|
2031
2031
|
"auto-bind": "^5.0.1",
|
|
2032
2032
|
crypto: "^1.0.1",
|
|
@@ -4650,9 +4650,9 @@ var DeleteApiToken = `
|
|
|
4650
4650
|
var FundNode = `
|
|
4651
4651
|
mutation FundNode(
|
|
4652
4652
|
$node_id: ID!,
|
|
4653
|
-
$
|
|
4653
|
+
$amount_sats: Long
|
|
4654
4654
|
) {
|
|
4655
|
-
fund_node(input: { node_id: $node_id, amount_sats: $
|
|
4655
|
+
fund_node(input: { node_id: $node_id, amount_sats: $amount_sats }) {
|
|
4656
4656
|
amount {
|
|
4657
4657
|
...CurrencyAmountFragment
|
|
4658
4658
|
}
|
|
@@ -10595,6 +10595,11 @@ var LightsparkClient = class {
|
|
|
10595
10595
|
(transaction) => TransactionFromJson(transaction)
|
|
10596
10596
|
) ?? [];
|
|
10597
10597
|
}
|
|
10598
|
+
getTransaction(transactionId) {
|
|
10599
|
+
return this.requester.executeQuery(
|
|
10600
|
+
getTransactionQuery(transactionId)
|
|
10601
|
+
);
|
|
10602
|
+
}
|
|
10598
10603
|
/**
|
|
10599
10604
|
* Retrieves the most recent payment requests for a given node.
|
|
10600
10605
|
*
|
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-827d336f.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-827d336f.js';
|
|
4
4
|
import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
|
|
5
5
|
import 'zen-observable';
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -133,7 +133,7 @@ import {
|
|
|
133
133
|
// package.json
|
|
134
134
|
var package_default = {
|
|
135
135
|
name: "@lightsparkdev/lightspark-sdk",
|
|
136
|
-
version: "1.1.
|
|
136
|
+
version: "1.1.3",
|
|
137
137
|
description: "Lightspark JS SDK",
|
|
138
138
|
author: "Lightspark Inc.",
|
|
139
139
|
keywords: [
|
|
@@ -221,7 +221,7 @@ var package_default = {
|
|
|
221
221
|
},
|
|
222
222
|
license: "Apache-2.0",
|
|
223
223
|
dependencies: {
|
|
224
|
-
"@lightsparkdev/core": "1.0.
|
|
224
|
+
"@lightsparkdev/core": "1.0.6",
|
|
225
225
|
"@lightsparkdev/crypto-wasm": "0.1.2",
|
|
226
226
|
"auto-bind": "^5.0.1",
|
|
227
227
|
crypto: "^1.0.1",
|
|
@@ -432,9 +432,9 @@ var DeleteApiToken = `
|
|
|
432
432
|
var FundNode = `
|
|
433
433
|
mutation FundNode(
|
|
434
434
|
$node_id: ID!,
|
|
435
|
-
$
|
|
435
|
+
$amount_sats: Long
|
|
436
436
|
) {
|
|
437
|
-
fund_node(input: { node_id: $node_id, amount_sats: $
|
|
437
|
+
fund_node(input: { node_id: $node_id, amount_sats: $amount_sats }) {
|
|
438
438
|
amount {
|
|
439
439
|
...CurrencyAmountFragment
|
|
440
440
|
}
|
|
@@ -1149,6 +1149,11 @@ var LightsparkClient = class {
|
|
|
1149
1149
|
(transaction) => TransactionFromJson(transaction)
|
|
1150
1150
|
) ?? [];
|
|
1151
1151
|
}
|
|
1152
|
+
getTransaction(transactionId) {
|
|
1153
|
+
return this.requester.executeQuery(
|
|
1154
|
+
getTransactionQuery(transactionId)
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1152
1157
|
/**
|
|
1153
1158
|
* Retrieves the most recent payment requests for a given node.
|
|
1154
1159
|
*
|
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-827d336f.js';
|
|
2
2
|
export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
|
|
3
3
|
import '@lightsparkdev/core';
|
|
4
4
|
import 'zen-observable';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/lightspark-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"license": "Apache-2.0",
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@lightsparkdev/core": "1.0.
|
|
91
|
+
"@lightsparkdev/core": "1.0.6",
|
|
92
92
|
"@lightsparkdev/crypto-wasm": "0.1.2",
|
|
93
93
|
"auto-bind": "^5.0.1",
|
|
94
94
|
"crypto": "^1.0.1",
|
package/src/client.ts
CHANGED
|
@@ -68,7 +68,10 @@ import { PaymentRequestFromJson } from "./objects/PaymentRequest.js";
|
|
|
68
68
|
import Permission from "./objects/Permission.js";
|
|
69
69
|
import type SingleNodeDashboard from "./objects/SingleNodeDashboard.js";
|
|
70
70
|
import type Transaction from "./objects/Transaction.js";
|
|
71
|
-
import {
|
|
71
|
+
import {
|
|
72
|
+
getTransactionQuery,
|
|
73
|
+
TransactionFromJson,
|
|
74
|
+
} from "./objects/Transaction.js";
|
|
72
75
|
import type TransactionUpdate from "./objects/TransactionUpdate.js";
|
|
73
76
|
import { TransactionUpdateFromJson } from "./objects/TransactionUpdate.js";
|
|
74
77
|
import type WithdrawalMode from "./objects/WithdrawalMode.js";
|
|
@@ -230,6 +233,12 @@ class LightsparkClient {
|
|
|
230
233
|
);
|
|
231
234
|
}
|
|
232
235
|
|
|
236
|
+
public getTransaction(transactionId: string): Promise<Maybe<Transaction>> {
|
|
237
|
+
return this.requester.executeQuery<Transaction>(
|
|
238
|
+
getTransactionQuery(transactionId),
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
233
242
|
/**
|
|
234
243
|
* Retrieves the most recent payment requests for a given node.
|
|
235
244
|
*
|
package/src/graphql/FundNode.ts
CHANGED
|
@@ -5,9 +5,9 @@ import { FRAGMENT as CurrencyAmountFragment } from "../objects/CurrencyAmount.js
|
|
|
5
5
|
export const FundNode = `
|
|
6
6
|
mutation FundNode(
|
|
7
7
|
$node_id: ID!,
|
|
8
|
-
$
|
|
8
|
+
$amount_sats: Long
|
|
9
9
|
) {
|
|
10
|
-
fund_node(input: { node_id: $node_id, amount_sats: $
|
|
10
|
+
fund_node(input: { node_id: $node_id, amount_sats: $amount_sats }) {
|
|
11
11
|
amount {
|
|
12
12
|
...CurrencyAmountFragment
|
|
13
13
|
}
|
package/src/logger.ts
ADDED
|
@@ -1,10 +1,34 @@
|
|
|
1
|
+
import { pollUntil } from "@lightsparkdev/core";
|
|
1
2
|
import LightsparkClient from "../../client.js";
|
|
2
3
|
import { getCredentialsFromEnvOrThrow } from "../../env.js";
|
|
3
4
|
import {
|
|
4
5
|
AccountTokenAuthProvider,
|
|
5
6
|
BitcoinNetwork,
|
|
6
7
|
PaymentRequestStatus,
|
|
8
|
+
TransactionStatus,
|
|
9
|
+
type Transaction,
|
|
7
10
|
} from "../../index.js";
|
|
11
|
+
import { logger } from "../../logger.js";
|
|
12
|
+
|
|
13
|
+
const REGTEST_SIGNING_KEY_PASSWORD = "1234!@#$";
|
|
14
|
+
const pollIntervalMs = 250;
|
|
15
|
+
const pollTimeoutSecs = 20;
|
|
16
|
+
const pollMaxTimeouts = (pollTimeoutSecs * 1000) / pollIntervalMs;
|
|
17
|
+
const pollIgnoreErrors = false;
|
|
18
|
+
|
|
19
|
+
const suiteName = "lightspark-sdk client";
|
|
20
|
+
|
|
21
|
+
function log(msg: string, ...args: unknown[]) {
|
|
22
|
+
logger.info(
|
|
23
|
+
`${expect
|
|
24
|
+
.getState()
|
|
25
|
+
.currentTestName?.replace(
|
|
26
|
+
new RegExp(`^(${suiteName})\\s`, "g"),
|
|
27
|
+
"",
|
|
28
|
+
)}: ${msg}`,
|
|
29
|
+
...args,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
8
32
|
|
|
9
33
|
describe("lightspark-sdk client", () => {
|
|
10
34
|
const { apiTokenClientId, apiTokenClientSecret, baseUrl } =
|
|
@@ -23,12 +47,12 @@ describe("lightspark-sdk client", () => {
|
|
|
23
47
|
return regtestNodeId as string;
|
|
24
48
|
}
|
|
25
49
|
|
|
26
|
-
it("
|
|
50
|
+
it("Should get env vars and construct the client successfully", async () => {
|
|
27
51
|
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
28
52
|
expect(lightsparkClient).toBeDefined();
|
|
29
53
|
});
|
|
30
54
|
|
|
31
|
-
it("
|
|
55
|
+
it("Should successfully get the current account regtest node", async () => {
|
|
32
56
|
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
33
57
|
|
|
34
58
|
const account = await lightsparkClient.getCurrentAccount();
|
|
@@ -38,10 +62,11 @@ describe("lightspark-sdk client", () => {
|
|
|
38
62
|
|
|
39
63
|
const regtestNode = nodesConnection?.entities[0];
|
|
40
64
|
expect(regtestNode).toBeDefined();
|
|
65
|
+
log("regtestNodeId", regtestNode?.id);
|
|
41
66
|
regtestNodeId = regtestNode?.id;
|
|
42
67
|
});
|
|
43
68
|
|
|
44
|
-
it("
|
|
69
|
+
it("Should successfully create an uma invoice", async () => {
|
|
45
70
|
const nodeId = getRegtestNodeId();
|
|
46
71
|
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
47
72
|
|
|
@@ -56,5 +81,102 @@ describe("lightspark-sdk client", () => {
|
|
|
56
81
|
metadata,
|
|
57
82
|
);
|
|
58
83
|
expect(umaInvoice?.status).toEqual(PaymentRequestStatus.OPEN);
|
|
59
|
-
});
|
|
84
|
+
}, 10000);
|
|
85
|
+
|
|
86
|
+
const satsToFund = 50_000;
|
|
87
|
+
test("Should deposit funds to wallet with a defined amount of sats", async () => {
|
|
88
|
+
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
89
|
+
const account = await lightsparkClient.getCurrentAccount();
|
|
90
|
+
|
|
91
|
+
if (!account) {
|
|
92
|
+
throw new Error("No account");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const nodesConnection = await account?.getNodes(lightsparkClient, 1, [
|
|
96
|
+
BitcoinNetwork.REGTEST,
|
|
97
|
+
]);
|
|
98
|
+
let regtestNode = nodesConnection?.entities[0];
|
|
99
|
+
const initialLocalBalance = regtestNode?.localBalance?.originalValue;
|
|
100
|
+
const nodeId = getRegtestNodeId();
|
|
101
|
+
|
|
102
|
+
await lightsparkClient.fundNode(nodeId, satsToFund);
|
|
103
|
+
|
|
104
|
+
regtestNode = await pollUntil(
|
|
105
|
+
() => {
|
|
106
|
+
return account?.getNodes(lightsparkClient, 1, [BitcoinNetwork.REGTEST]);
|
|
107
|
+
},
|
|
108
|
+
(current, response) => {
|
|
109
|
+
if (
|
|
110
|
+
current &&
|
|
111
|
+
current.entities[0]?.localBalance?.originalValue !==
|
|
112
|
+
initialLocalBalance
|
|
113
|
+
) {
|
|
114
|
+
return {
|
|
115
|
+
stopPolling: true,
|
|
116
|
+
value: current.entities[0],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return response;
|
|
120
|
+
},
|
|
121
|
+
pollIntervalMs,
|
|
122
|
+
pollMaxTimeouts,
|
|
123
|
+
pollIgnoreErrors,
|
|
124
|
+
() => new Error("Timeout waiting for payment to be received"),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
expect(
|
|
128
|
+
regtestNode.localBalance?.originalValue !== initialLocalBalance,
|
|
129
|
+
).toBe(true);
|
|
130
|
+
}, 120_000);
|
|
131
|
+
|
|
132
|
+
test("Should send test mode payment", async () => {
|
|
133
|
+
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
|
|
134
|
+
const account = await lightsparkClient.getCurrentAccount();
|
|
135
|
+
|
|
136
|
+
if (!account) {
|
|
137
|
+
throw new Error("No account");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const nodeId = getRegtestNodeId();
|
|
141
|
+
|
|
142
|
+
const invoice = await lightsparkClient.createTestModeInvoice(
|
|
143
|
+
nodeId,
|
|
144
|
+
satsToFund * 1000, // convert to msats
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
await lightsparkClient.loadNodeSigningKey(nodeId, {
|
|
148
|
+
password: REGTEST_SIGNING_KEY_PASSWORD,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (!invoice) {
|
|
152
|
+
throw new Error("No invoice");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const payment = await lightsparkClient.payInvoice(nodeId, invoice, 60);
|
|
156
|
+
log("payment.id", payment?.id);
|
|
157
|
+
|
|
158
|
+
const transaction = (await pollUntil(
|
|
159
|
+
() => {
|
|
160
|
+
if (!payment) {
|
|
161
|
+
throw new Error("No payment");
|
|
162
|
+
}
|
|
163
|
+
return lightsparkClient.getTransaction(payment.id);
|
|
164
|
+
},
|
|
165
|
+
(current, response) => {
|
|
166
|
+
if (current && current.status === TransactionStatus.SUCCESS) {
|
|
167
|
+
return {
|
|
168
|
+
stopPolling: true,
|
|
169
|
+
value: current,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return response;
|
|
173
|
+
},
|
|
174
|
+
pollIntervalMs,
|
|
175
|
+
pollMaxTimeouts,
|
|
176
|
+
pollIgnoreErrors,
|
|
177
|
+
() => new Error("Timeout waiting for payment to be received"),
|
|
178
|
+
)) as Transaction;
|
|
179
|
+
|
|
180
|
+
expect(transaction.status).toEqual(TransactionStatus.SUCCESS);
|
|
181
|
+
}, 30_000);
|
|
60
182
|
});
|