@lightsparkdev/lightspark-sdk 0.4.9 → 0.4.11
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 +14 -0
- package/dist/{chunk-YTXDF6SQ.js → chunk-NXUFC5J7.js} +950 -246
- package/dist/{index-adeff42d.d.ts → index-3ffe9e7b.d.ts} +194 -56
- package/dist/index.cjs +963 -254
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -9
- package/dist/objects/index.cjs +952 -246
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +5 -1
- package/package.json +4 -4
- package/src/__tests__/webhooks.test.ts +1 -1
- package/src/auth/AccountTokenAuthProvider.ts +4 -4
- package/src/client.ts +62 -63
- package/src/objects/Account.ts +46 -40
- package/src/objects/AccountToApiTokensConnection.ts +14 -9
- package/src/objects/AccountToChannelsConnection.ts +4 -4
- package/src/objects/AccountToNodesConnection.ts +13 -8
- package/src/objects/AccountToPaymentRequestsConnection.ts +22 -17
- package/src/objects/AccountToTransactionsConnection.ts +24 -19
- package/src/objects/AccountToWalletsConnection.ts +13 -8
- package/src/objects/ApiToken.ts +2 -1
- package/src/objects/Balances.ts +3 -2
- package/src/objects/BitcoinNetwork.ts +2 -1
- package/src/objects/BlockchainBalance.ts +1 -1
- package/src/objects/Channel.ts +6 -6
- package/src/objects/ChannelClosingTransaction.ts +4 -4
- package/src/objects/ChannelFees.ts +1 -0
- package/src/objects/ChannelOpeningTransaction.ts +4 -4
- package/src/objects/ChannelStatus.ts +1 -0
- package/src/objects/ChannelToTransactionsConnection.ts +4 -4
- package/src/objects/Connection.ts +387 -0
- package/src/objects/CreateApiTokenInput.ts +1 -1
- package/src/objects/CreateApiTokenOutput.ts +1 -1
- package/src/objects/CreateInvoiceInput.ts +12 -0
- package/src/objects/CreateLnurlInvoiceInput.ts +11 -1
- package/src/objects/CreateNodeWalletAddressInput.ts +1 -1
- package/src/objects/CreateNodeWalletAddressOutput.ts +1 -1
- package/src/objects/CreateTestModeInvoiceInput.ts +1 -1
- package/src/objects/CreateTestModeInvoiceOutput.ts +1 -1
- package/src/objects/CreateTestModePaymentInput.ts +1 -1
- package/src/objects/CreateTestModePaymentoutput.ts +2 -1
- package/src/objects/CryptoSanctionsScreeningProvider.ts +14 -0
- package/src/objects/CurrencyAmount.ts +1 -1
- package/src/objects/CurrencyUnit.ts +1 -0
- package/src/objects/DeleteApiTokenOutput.ts +1 -1
- package/src/objects/Deposit.ts +2 -2
- package/src/objects/Entity.ts +1 -1
- package/src/objects/FeeEstimate.ts +1 -0
- package/src/objects/GraphNode.ts +5 -5
- package/src/objects/Hop.ts +2 -2
- package/src/objects/HtlcAttemptFailureCode.ts +1 -0
- package/src/objects/IncomingPayment.ts +21 -8
- package/src/objects/IncomingPaymentAttempt.ts +4 -4
- package/src/objects/IncomingPaymentAttemptStatus.ts +1 -1
- package/src/objects/IncomingPaymentToAttemptsConnection.ts +23 -3
- package/src/objects/Invoice.ts +2 -2
- package/src/objects/InvoiceData.ts +1 -1
- package/src/objects/InvoiceType.ts +1 -0
- package/src/objects/LightningFeeEstimateForInvoiceInput.ts +1 -1
- package/src/objects/LightningFeeEstimateForNodeInput.ts +1 -1
- package/src/objects/LightningFeeEstimateOutput.ts +2 -2
- package/src/objects/LightningTransaction.ts +8 -8
- package/src/objects/LightsparkNode.ts +15 -9
- package/src/objects/LightsparkNodeOwner.ts +6 -6
- package/src/objects/LightsparkNodePurpose.ts +1 -0
- package/src/objects/LightsparkNodeToChannelsConnection.ts +14 -9
- package/src/objects/Node.ts +7 -8
- package/src/objects/NodeAddress.ts +1 -1
- package/src/objects/NodeAddressType.ts +1 -1
- package/src/objects/NodeToAddressesConnection.ts +2 -2
- package/src/objects/OnChainTransaction.ts +4 -5
- package/src/objects/OutgoingPayment.ts +16 -8
- package/src/objects/OutgoingPaymentAttempt.ts +18 -10
- package/src/objects/OutgoingPaymentAttemptStatus.ts +1 -1
- package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +23 -3
- package/src/objects/OutgoingPaymentToAttemptsConnection.ts +23 -3
- package/src/objects/PageInfo.ts +1 -0
- package/src/objects/PaymentFailureReason.ts +1 -0
- package/src/objects/PaymentRequest.ts +3 -3
- package/src/objects/PaymentRequestData.ts +2 -2
- package/src/objects/PaymentRequestStatus.ts +1 -0
- package/src/objects/Permission.ts +1 -0
- package/src/objects/RequestWithdrawalInput.ts +1 -1
- package/src/objects/RequestWithdrawalOutput.ts +1 -1
- package/src/objects/RiskRating.ts +18 -0
- package/src/objects/RoutingTransaction.ts +3 -3
- package/src/objects/RoutingTransactionFailureReason.ts +1 -0
- package/src/objects/ScreenBitcoinAddressesInput.ts +23 -0
- package/src/objects/ScreenBitcoinAddressesOutput.ts +25 -0
- package/src/objects/Transaction.ts +6 -6
- package/src/objects/TransactionFailures.ts +2 -1
- package/src/objects/TransactionStatus.ts +1 -0
- package/src/objects/TransactionType.ts +1 -0
- package/src/objects/Wallet.ts +636 -11
- package/src/objects/WalletStatus.ts +1 -0
- package/src/objects/WalletToPaymentRequestsConnection.ts +57 -0
- package/src/objects/WalletToTransactionsConnection.ts +57 -0
- package/src/objects/WebhookEventType.ts +3 -0
- package/src/objects/Withdrawal.ts +2 -2
- package/src/objects/WithdrawalMode.ts +1 -0
- package/src/objects/WithdrawalRequest.ts +8 -7
- package/src/objects/WithdrawalRequestStatus.ts +1 -0
- package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +2 -2
- package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +2 -2
- package/src/objects/index.ts +7 -0
- package/src/webhooks.ts +1 -1
- package/src/objects/.eslintrc.cjs +0 -5
package/dist/objects/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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 BitcoinNetwork, j as BlockchainBalance, C as Channel, k as ChannelClosingTransaction, m as ChannelFees, n as ChannelOpeningTransaction, p as ChannelStatus, q as ChannelToTransactionsConnection, r as
|
|
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 BitcoinNetwork, j as BlockchainBalance, C as Channel, k as ChannelClosingTransaction, m as ChannelFees, n as ChannelOpeningTransaction, p as ChannelStatus, q as ChannelToTransactionsConnection, 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 CryptoSanctionsScreeningProvider, H as CurrencyAmount, I as CurrencyUnit, J as DeleteApiTokenInput, K as DeleteApiTokenOutput, M as Deposit, O as Entity, P as FeeEstimate, Q as FundNodeInput, R as FundNodeOutput, S as GraphNode, T as Hop, V as HtlcAttemptFailureCode, X as IncomingPayment, Y as IncomingPaymentAttempt, _ as IncomingPaymentAttemptStatus, $ as IncomingPaymentToAttemptsConnection, a0 as Invoice, a2 as InvoiceData, a3 as InvoiceType, a4 as LightningFeeEstimateForInvoiceInput, a5 as LightningFeeEstimateForNodeInput, a6 as LightningFeeEstimateOutput, a7 as LightningTransaction, a9 as LightsparkNode, aa as LightsparkNodeOwner, ac as LightsparkNodePurpose, ad as LightsparkNodeStatus, ae as LightsparkNodeToChannelsConnection, af as Node, ag as NodeAddress, ah as NodeAddressType, ai as NodeToAddressesConnection, aj as OnChainTransaction, al as OutgoingPayment, am as OutgoingPaymentAttempt, an as OutgoingPaymentAttemptStatus, ao as OutgoingPaymentAttemptToHopsConnection, ap as OutgoingPaymentToAttemptsConnection, aq as PageInfo, ar as PayInvoiceInput, as as PayInvoiceOutput, at as PaymentFailureReason, au as PaymentRequest, aw as PaymentRequestData, ax as PaymentRequestStatus, ay as Permission, az as RequestWithdrawalInput, aA as RequestWithdrawalOutput, aB as RichText, aC as RiskRating, aD as RoutingTransaction, aF as RoutingTransactionFailureReason, aG as ScreenBitcoinAddressesInput, aH as ScreenBitcoinAddressesOutput, aI as Secret, aJ as SendPaymentInput, aK as SendPaymentOutput, aL as SingleNodeDashboard, aM as Transaction, aO as TransactionFailures, aP as TransactionStatus, aQ as TransactionType, aR as TransactionUpdate, aS as Wallet, aT as WalletStatus, aU as WalletToPaymentRequestsConnection, aV as WalletToTransactionsConnection, W as WebhookEventType, aW as Withdrawal, aY as WithdrawalMode, aZ as WithdrawalRequest, a_ as WithdrawalRequestStatus, a$ as WithdrawalRequestToChannelClosingTransactionsConnection, b0 as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, N as getDepositQuery, U as getHopQuery, Z as getIncomingPaymentAttemptQuery, a1 as getInvoiceQuery, a8 as getLightningTransactionQuery, ab as getLightsparkNodeOwnerQuery, ak as getOnChainTransactionQuery, av as getPaymentRequestQuery, aE as getRoutingTransactionQuery, aN as getTransactionQuery, aX as getWithdrawalQuery } from '../index-3ffe9e7b.js';
|
|
2
2
|
import '@lightsparkdev/core';
|
|
3
3
|
import 'zen-observable';
|
package/dist/objects/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
BitcoinNetwork_default,
|
|
5
5
|
ChannelStatus_default,
|
|
6
6
|
Channel_default,
|
|
7
|
+
CryptoSanctionsScreeningProvider_default,
|
|
7
8
|
CurrencyUnit_default,
|
|
8
9
|
GraphNode_default,
|
|
9
10
|
HtlcAttemptFailureCode_default,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
PaymentFailureReason_default,
|
|
22
23
|
PaymentRequestStatus_default,
|
|
23
24
|
Permission_default,
|
|
25
|
+
RiskRating_default,
|
|
24
26
|
RoutingTransactionFailureReason_default,
|
|
25
27
|
TransactionStatus_default,
|
|
26
28
|
TransactionType_default,
|
|
@@ -44,7 +46,7 @@ import {
|
|
|
44
46
|
getRoutingTransactionQuery,
|
|
45
47
|
getTransactionQuery,
|
|
46
48
|
getWithdrawalQuery
|
|
47
|
-
} from "../chunk-
|
|
49
|
+
} from "../chunk-NXUFC5J7.js";
|
|
48
50
|
import "../chunk-NIMBE7W3.js";
|
|
49
51
|
export {
|
|
50
52
|
Account_default as Account,
|
|
@@ -52,6 +54,7 @@ export {
|
|
|
52
54
|
BitcoinNetwork_default as BitcoinNetwork,
|
|
53
55
|
Channel_default as Channel,
|
|
54
56
|
ChannelStatus_default as ChannelStatus,
|
|
57
|
+
CryptoSanctionsScreeningProvider_default as CryptoSanctionsScreeningProvider,
|
|
55
58
|
CurrencyUnit_default as CurrencyUnit,
|
|
56
59
|
GraphNode_default as GraphNode,
|
|
57
60
|
HtlcAttemptFailureCode_default as HtlcAttemptFailureCode,
|
|
@@ -69,6 +72,7 @@ export {
|
|
|
69
72
|
PaymentFailureReason_default as PaymentFailureReason,
|
|
70
73
|
PaymentRequestStatus_default as PaymentRequestStatus,
|
|
71
74
|
Permission_default as Permission,
|
|
75
|
+
RiskRating_default as RiskRating,
|
|
72
76
|
RoutingTransactionFailureReason_default as RoutingTransactionFailureReason,
|
|
73
77
|
TransactionStatus_default as TransactionStatus,
|
|
74
78
|
TransactionType_default as TransactionType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/lightspark-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"format:fix": "prettier src --write",
|
|
64
64
|
"format": "prettier src --check",
|
|
65
65
|
"lint:fix": "eslint --fix .",
|
|
66
|
+
"lint:fix:continue": "eslint --fix . || exit 0",
|
|
66
67
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
67
68
|
"lint": "eslint .",
|
|
68
69
|
"postversion": "yarn build",
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
},
|
|
73
74
|
"license": "Apache-2.0",
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"@lightsparkdev/core": "0.3.
|
|
76
|
+
"@lightsparkdev/core": "0.3.11",
|
|
76
77
|
"auto-bind": "^5.0.1",
|
|
77
78
|
"crypto": "^1.0.1",
|
|
78
79
|
"crypto-browserify": "^3.12.0",
|
|
@@ -84,7 +85,6 @@
|
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@lightsparkdev/eslint-config": "*",
|
|
87
|
-
"@lightsparkdev/gql": "0.0.3",
|
|
88
88
|
"@lightsparkdev/tsconfig": "0.0.0",
|
|
89
89
|
"@types/crypto-js": "^4.1.1",
|
|
90
90
|
"@types/jest": "^29.5.2",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"eslint": "^8.3.0",
|
|
93
93
|
"eslint-watch": "^8.0.0",
|
|
94
94
|
"jest": "^29.4.1",
|
|
95
|
-
"prettier": "
|
|
95
|
+
"prettier": "3.0.2",
|
|
96
96
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
97
97
|
"ts-jest": "^29.0.5",
|
|
98
98
|
"ts-node": "^10.9.1",
|
|
@@ -9,16 +9,16 @@ class AccountTokenAuthProvider implements AuthProvider {
|
|
|
9
9
|
|
|
10
10
|
constructor(
|
|
11
11
|
private readonly apiTokenClientId: string,
|
|
12
|
-
private readonly apiTokenClientSecret: string
|
|
12
|
+
private readonly apiTokenClientSecret: string,
|
|
13
13
|
) {
|
|
14
14
|
this.utf8AuthBytes = new TextEncoder().encode(
|
|
15
|
-
`${apiTokenClientId}:${apiTokenClientSecret}
|
|
15
|
+
`${apiTokenClientId}:${apiTokenClientSecret}`,
|
|
16
16
|
);
|
|
17
17
|
autoBind(this);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async addWsConnectionParams(
|
|
21
|
-
params: Record<string, string
|
|
21
|
+
params: Record<string, string>,
|
|
22
22
|
): Promise<Record<string, string>> {
|
|
23
23
|
return Object.assign({}, params, {
|
|
24
24
|
client_id: this.apiTokenClientId,
|
|
@@ -27,7 +27,7 @@ class AccountTokenAuthProvider implements AuthProvider {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async addAuthHeaders(
|
|
30
|
-
headers: Record<string, string
|
|
30
|
+
headers: Record<string, string>,
|
|
31
31
|
): Promise<Record<string, string>> {
|
|
32
32
|
return Object.assign({}, headers, {
|
|
33
33
|
authorization: `Basic ${b64encode(this.utf8AuthBytes)}`,
|
package/src/client.ts
CHANGED
|
@@ -21,10 +21,6 @@ import {
|
|
|
21
21
|
Requester,
|
|
22
22
|
StubAuthProvider,
|
|
23
23
|
} from "@lightsparkdev/core";
|
|
24
|
-
import {
|
|
25
|
-
type OutgoingPayment as GQLOutgoingPayment,
|
|
26
|
-
type Subscription as GQLSubscription,
|
|
27
|
-
} from "@lightsparkdev/gql/generated/graphql.js";
|
|
28
24
|
import { createHash } from "crypto";
|
|
29
25
|
import packageJson from "../package.json";
|
|
30
26
|
import { BitcoinFeeEstimate as BitcoinFeeEstimateQuery } from "./graphql/BitcoinFeeEstimate.js";
|
|
@@ -114,7 +110,7 @@ class LightsparkClient {
|
|
|
114
110
|
constructor(
|
|
115
111
|
private authProvider: AuthProvider = new StubAuthProvider(),
|
|
116
112
|
private readonly serverUrl: string = "api.lightspark.com",
|
|
117
|
-
private readonly cryptoImpl: CryptoInterface = DefaultCrypto
|
|
113
|
+
private readonly cryptoImpl: CryptoInterface = DefaultCrypto,
|
|
118
114
|
) {
|
|
119
115
|
this.nodeKeyCache = new NodeKeyCache(this.cryptoImpl);
|
|
120
116
|
this.requester = new Requester(
|
|
@@ -123,7 +119,7 @@ class LightsparkClient {
|
|
|
123
119
|
`js-lightspark-sdk/${sdkVersion}`,
|
|
124
120
|
authProvider,
|
|
125
121
|
serverUrl,
|
|
126
|
-
this.cryptoImpl
|
|
122
|
+
this.cryptoImpl,
|
|
127
123
|
);
|
|
128
124
|
|
|
129
125
|
autoBind(this);
|
|
@@ -142,7 +138,7 @@ class LightsparkClient {
|
|
|
142
138
|
`js-lightspark-sdk/${sdkVersion}`,
|
|
143
139
|
authProvider,
|
|
144
140
|
this.serverUrl,
|
|
145
|
-
this.cryptoImpl
|
|
141
|
+
this.cryptoImpl,
|
|
146
142
|
);
|
|
147
143
|
this.authProvider = authProvider;
|
|
148
144
|
}
|
|
@@ -159,7 +155,7 @@ class LightsparkClient {
|
|
|
159
155
|
*/
|
|
160
156
|
public async getCurrentAccount(): Promise<Maybe<Account>> {
|
|
161
157
|
return await this.requester.executeQuery<Account>(
|
|
162
|
-
Account.getAccountQuery()
|
|
158
|
+
Account.getAccountQuery(),
|
|
163
159
|
);
|
|
164
160
|
}
|
|
165
161
|
|
|
@@ -176,7 +172,7 @@ class LightsparkClient {
|
|
|
176
172
|
nodeId: string,
|
|
177
173
|
numTransactions: number = 20,
|
|
178
174
|
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
179
|
-
afterDate: Maybe<string> = undefined
|
|
175
|
+
afterDate: Maybe<string> = undefined,
|
|
180
176
|
): Promise<Transaction[]> {
|
|
181
177
|
const response = await this.requester.makeRawRequest(TransactionsForNode, {
|
|
182
178
|
nodeId,
|
|
@@ -186,7 +182,7 @@ class LightsparkClient {
|
|
|
186
182
|
});
|
|
187
183
|
return (
|
|
188
184
|
response.current_account?.recent_transactions.entities.map(
|
|
189
|
-
(transaction) => TransactionFromJson(transaction)
|
|
185
|
+
(transaction) => TransactionFromJson(transaction),
|
|
190
186
|
) ?? []
|
|
191
187
|
);
|
|
192
188
|
}
|
|
@@ -198,18 +194,19 @@ class LightsparkClient {
|
|
|
198
194
|
* @returns A zen-observable that emits transaction updates for the given node IDs.
|
|
199
195
|
*/
|
|
200
196
|
public listenToTransactions(
|
|
201
|
-
nodeIds: string[]
|
|
197
|
+
nodeIds: string[],
|
|
202
198
|
): Observable<TransactionUpdate | undefined> {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
+
const response = this.requester.subscribe<{ transactions: any }>(
|
|
201
|
+
TransactionSubscription,
|
|
202
|
+
{
|
|
203
|
+
nodeIds,
|
|
204
|
+
},
|
|
205
|
+
);
|
|
208
206
|
return response.map(
|
|
209
207
|
(response) =>
|
|
210
|
-
response &&
|
|
211
|
-
response.data.transactions
|
|
212
|
-
TransactionUpdateFromJson(response.data.transactions)
|
|
208
|
+
response?.data?.transactions &&
|
|
209
|
+
TransactionUpdateFromJson(response.data.transactions),
|
|
213
210
|
);
|
|
214
211
|
}
|
|
215
212
|
|
|
@@ -224,7 +221,7 @@ class LightsparkClient {
|
|
|
224
221
|
*/
|
|
225
222
|
public async getAccountDashboard(
|
|
226
223
|
nodeIds: string[] | undefined = undefined,
|
|
227
|
-
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET
|
|
224
|
+
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
228
225
|
): Promise<AccountDashboard> {
|
|
229
226
|
const response = await this.requester.makeRawRequest(MultiNodeDashboard, {
|
|
230
227
|
nodeIds: nodeIds,
|
|
@@ -243,7 +240,7 @@ class LightsparkClient {
|
|
|
243
240
|
1. You are requesting MAINNET nodes, but you have no MAINNET nodes yet. In this case, request BitcoinNetwork.REGTEST instead.
|
|
244
241
|
2. You are specifying specific node IDs, but those IDs don't exist or are not on the bitcoid network you requested.
|
|
245
242
|
3. The api token or authentication mechanism you are using is not authorized to access the nodes you requested. If you're using
|
|
246
|
-
an API token, make sure it has the correct permissions for the desired network (only test tokens have access to REGTEST nodes)
|
|
243
|
+
an API token, make sure it has the correct permissions for the desired network (only test tokens have access to REGTEST nodes).`,
|
|
247
244
|
);
|
|
248
245
|
}
|
|
249
246
|
const account = response.current_account;
|
|
@@ -284,17 +281,17 @@ class LightsparkClient {
|
|
|
284
281
|
requiredReserve:
|
|
285
282
|
account.blockchain_balance.required_reserve &&
|
|
286
283
|
CurrencyAmountFromJson(
|
|
287
|
-
account.blockchain_balance.required_reserve
|
|
284
|
+
account.blockchain_balance.required_reserve,
|
|
288
285
|
),
|
|
289
286
|
availableBalance:
|
|
290
287
|
account.blockchain_balance.available_balance &&
|
|
291
288
|
CurrencyAmountFromJson(
|
|
292
|
-
account.blockchain_balance.available_balance
|
|
289
|
+
account.blockchain_balance.available_balance,
|
|
293
290
|
),
|
|
294
291
|
unconfirmedBalance:
|
|
295
292
|
account.blockchain_balance.unconfirmed_balance &&
|
|
296
293
|
CurrencyAmountFromJson(
|
|
297
|
-
account.blockchain_balance.unconfirmed_balance
|
|
294
|
+
account.blockchain_balance.unconfirmed_balance,
|
|
298
295
|
),
|
|
299
296
|
}
|
|
300
297
|
: null,
|
|
@@ -319,7 +316,7 @@ class LightsparkClient {
|
|
|
319
316
|
public async getSingleNodeDashboard(
|
|
320
317
|
nodeId: string,
|
|
321
318
|
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
322
|
-
transactionsAfterDate: Maybe<string> = undefined
|
|
319
|
+
transactionsAfterDate: Maybe<string> = undefined,
|
|
323
320
|
): Promise<SingleNodeDashboard> {
|
|
324
321
|
const response = await this.requester.makeRawRequest(
|
|
325
322
|
SingleNodeDashboardQuery,
|
|
@@ -328,7 +325,7 @@ class LightsparkClient {
|
|
|
328
325
|
network: bitcoinNetwork,
|
|
329
326
|
numTransactions: 20,
|
|
330
327
|
transactionsAfterDate,
|
|
331
|
-
}
|
|
328
|
+
},
|
|
332
329
|
);
|
|
333
330
|
if (!response.current_account) {
|
|
334
331
|
throw new LightsparkAuthException("No current account");
|
|
@@ -341,7 +338,7 @@ class LightsparkClient {
|
|
|
341
338
|
) {
|
|
342
339
|
throw new LightsparkException(
|
|
343
340
|
"InvalidOrMissingNode",
|
|
344
|
-
"No nodes found for node dashboard"
|
|
341
|
+
"No nodes found for node dashboard",
|
|
345
342
|
);
|
|
346
343
|
}
|
|
347
344
|
const node = account.dashboard_overview_nodes.entities[0];
|
|
@@ -368,16 +365,16 @@ class LightsparkClient {
|
|
|
368
365
|
remoteBalance: currencyAmountOrUndefined(node.remote_balance),
|
|
369
366
|
blockchainBalance: node.blockchain_balance && {
|
|
370
367
|
availableBalance: currencyAmountOrUndefined(
|
|
371
|
-
node.blockchain_balance.available_balance
|
|
368
|
+
node.blockchain_balance.available_balance,
|
|
372
369
|
),
|
|
373
370
|
confirmedBalance: currencyAmountOrUndefined(
|
|
374
|
-
node.blockchain_balance.confirmed_balance
|
|
371
|
+
node.blockchain_balance.confirmed_balance,
|
|
375
372
|
),
|
|
376
373
|
unconfirmedBalance: currencyAmountOrUndefined(
|
|
377
|
-
node.blockchain_balance.unconfirmed_balance
|
|
374
|
+
node.blockchain_balance.unconfirmed_balance,
|
|
378
375
|
),
|
|
379
376
|
totalBalance: currencyAmountOrUndefined(
|
|
380
|
-
node.blockchain_balance.total_balance
|
|
377
|
+
node.blockchain_balance.total_balance,
|
|
381
378
|
),
|
|
382
379
|
},
|
|
383
380
|
recentTransactions:
|
|
@@ -404,7 +401,7 @@ class LightsparkClient {
|
|
|
404
401
|
nodeId: string,
|
|
405
402
|
amountMsats: number,
|
|
406
403
|
memo: string,
|
|
407
|
-
type: InvoiceType | undefined = undefined
|
|
404
|
+
type: InvoiceType | undefined = undefined,
|
|
408
405
|
): Promise<string | undefined> {
|
|
409
406
|
const response = await this.requester.makeRawRequest(CreateInvoice, {
|
|
410
407
|
node_id: nodeId,
|
|
@@ -432,7 +429,7 @@ class LightsparkClient {
|
|
|
432
429
|
public async createLnurlInvoice(
|
|
433
430
|
nodeId: string,
|
|
434
431
|
amountMsats: number,
|
|
435
|
-
metadata: string
|
|
432
|
+
metadata: string,
|
|
436
433
|
): Promise<Invoice | undefined> {
|
|
437
434
|
const response = await this.requester.makeRawRequest(CreateLnurlInvoice, {
|
|
438
435
|
node_id: nodeId,
|
|
@@ -466,13 +463,13 @@ class LightsparkClient {
|
|
|
466
463
|
* @returns A fee estimate for the given bitcoin network including a minimum fee rate, and a max-speed fee rate.
|
|
467
464
|
*/
|
|
468
465
|
public async getBitcoinFeeEstimate(
|
|
469
|
-
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET
|
|
466
|
+
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
470
467
|
): Promise<FeeEstimate> {
|
|
471
468
|
const response = await this.requester.makeRawRequest(
|
|
472
469
|
BitcoinFeeEstimateQuery,
|
|
473
470
|
{
|
|
474
471
|
bitcoin_network: bitcoinNetwork,
|
|
475
|
-
}
|
|
472
|
+
},
|
|
476
473
|
);
|
|
477
474
|
return FeeEstimateFromJson(response.bitcoin_fee_estimate);
|
|
478
475
|
}
|
|
@@ -489,7 +486,7 @@ class LightsparkClient {
|
|
|
489
486
|
public async getLightningFeeEstimateForInvoice(
|
|
490
487
|
nodeId: string,
|
|
491
488
|
encodedPaymentRequest: string,
|
|
492
|
-
amountMsats: number | undefined = undefined
|
|
489
|
+
amountMsats: number | undefined = undefined,
|
|
493
490
|
): Promise<CurrencyAmount> {
|
|
494
491
|
const response = await this.requester.makeRawRequest(
|
|
495
492
|
LightningFeeEstimateForInvoice,
|
|
@@ -497,11 +494,11 @@ class LightsparkClient {
|
|
|
497
494
|
node_id: nodeId,
|
|
498
495
|
encoded_payment_request: encodedPaymentRequest,
|
|
499
496
|
amount_msats: amountMsats,
|
|
500
|
-
}
|
|
497
|
+
},
|
|
501
498
|
);
|
|
502
499
|
return CurrencyAmountFromJson(
|
|
503
500
|
response.lightning_fee_estimate_for_invoice
|
|
504
|
-
.lightning_fee_estimate_output_fee_estimate
|
|
501
|
+
.lightning_fee_estimate_output_fee_estimate,
|
|
505
502
|
);
|
|
506
503
|
}
|
|
507
504
|
|
|
@@ -516,7 +513,7 @@ class LightsparkClient {
|
|
|
516
513
|
public async getLightningFeeEstimateForNode(
|
|
517
514
|
nodeId: string,
|
|
518
515
|
destinationNodePublicKey: string,
|
|
519
|
-
amountMsats: number
|
|
516
|
+
amountMsats: number,
|
|
520
517
|
): Promise<CurrencyAmount> {
|
|
521
518
|
const response = await this.requester.makeRawRequest(
|
|
522
519
|
LightningFeeEstimateForNode,
|
|
@@ -524,11 +521,11 @@ class LightsparkClient {
|
|
|
524
521
|
node_id: nodeId,
|
|
525
522
|
destination_node_public_key: destinationNodePublicKey,
|
|
526
523
|
amount_msats: amountMsats,
|
|
527
|
-
}
|
|
524
|
+
},
|
|
528
525
|
);
|
|
529
526
|
return CurrencyAmountFromJson(
|
|
530
527
|
response.lightning_fee_estimate_for_node
|
|
531
|
-
.lightning_fee_estimate_output_fee_estimate
|
|
528
|
+
.lightning_fee_estimate_output_fee_estimate,
|
|
532
529
|
);
|
|
533
530
|
}
|
|
534
531
|
|
|
@@ -550,12 +547,12 @@ class LightsparkClient {
|
|
|
550
547
|
await this.cryptoImpl.decryptSecretWithNodePassword(
|
|
551
548
|
encryptedKey.cipher,
|
|
552
549
|
encryptedKey.encrypted_value,
|
|
553
|
-
password
|
|
550
|
+
password,
|
|
554
551
|
);
|
|
555
552
|
|
|
556
553
|
if (!signingPrivateKey) {
|
|
557
554
|
throw new LightsparkSigningException(
|
|
558
|
-
"Unable to decrypt signing key with provided password. Please try again."
|
|
555
|
+
"Unable to decrypt signing key with provided password. Please try again.",
|
|
559
556
|
);
|
|
560
557
|
}
|
|
561
558
|
|
|
@@ -570,17 +567,17 @@ class LightsparkClient {
|
|
|
570
567
|
|
|
571
568
|
await this.nodeKeyCache.loadKey(
|
|
572
569
|
nodeId,
|
|
573
|
-
KeyOrAlias.key(signingPrivateKeyPEM)
|
|
570
|
+
KeyOrAlias.key(signingPrivateKeyPEM),
|
|
574
571
|
);
|
|
575
572
|
return true;
|
|
576
573
|
}
|
|
577
574
|
|
|
578
575
|
private async recoverNodeSigningKey(
|
|
579
|
-
nodeId: string
|
|
576
|
+
nodeId: string,
|
|
580
577
|
): Promise<Maybe<{ encrypted_value: string; cipher: string }>> {
|
|
581
578
|
const response = await this.requester.makeRawRequest(
|
|
582
579
|
RecoverNodeSigningKey,
|
|
583
|
-
{ nodeId }
|
|
580
|
+
{ nodeId },
|
|
584
581
|
);
|
|
585
582
|
const nodeEntity = response.entity;
|
|
586
583
|
if (nodeEntity?.__typename === "LightsparkNode") {
|
|
@@ -597,7 +594,7 @@ class LightsparkClient {
|
|
|
597
594
|
*/
|
|
598
595
|
public async loadNodeKey(
|
|
599
596
|
nodeId: string,
|
|
600
|
-
signingPrivateKeyOrAlias: KeyOrAliasType
|
|
597
|
+
signingPrivateKeyOrAlias: KeyOrAliasType,
|
|
601
598
|
) {
|
|
602
599
|
await this.nodeKeyCache.loadKey(nodeId, signingPrivateKeyOrAlias);
|
|
603
600
|
}
|
|
@@ -623,7 +620,7 @@ class LightsparkClient {
|
|
|
623
620
|
encodedInvoice: string,
|
|
624
621
|
maximumFeesMsats: number,
|
|
625
622
|
timeoutSecs: number = 60,
|
|
626
|
-
amountMsats: number | undefined = undefined
|
|
623
|
+
amountMsats: number | undefined = undefined,
|
|
627
624
|
): Promise<OutgoingPayment | undefined> {
|
|
628
625
|
if (!this.nodeKeyCache.hasKey(payerNodeId)) {
|
|
629
626
|
throw new LightsparkSigningException("Paying node is not unlocked");
|
|
@@ -640,12 +637,13 @@ class LightsparkClient {
|
|
|
640
637
|
const response = await this.requester.makeRawRequest(
|
|
641
638
|
PayInvoice,
|
|
642
639
|
variables,
|
|
643
|
-
payerNodeId
|
|
640
|
+
payerNodeId,
|
|
644
641
|
);
|
|
645
642
|
if (response.pay_invoice?.payment.outgoing_payment_failure_message) {
|
|
646
643
|
throw new LightsparkException(
|
|
647
644
|
"PaymentError",
|
|
648
|
-
response.pay_invoice?.payment.outgoing_payment_failure_message
|
|
645
|
+
response.pay_invoice?.payment.outgoing_payment_failure_message
|
|
646
|
+
.rich_text_text,
|
|
649
647
|
);
|
|
650
648
|
}
|
|
651
649
|
return (
|
|
@@ -671,7 +669,7 @@ class LightsparkClient {
|
|
|
671
669
|
destinationPublicKey: string,
|
|
672
670
|
timeoutSecs: number = 60,
|
|
673
671
|
amountMsats: number,
|
|
674
|
-
maximumFeesMsats: number
|
|
672
|
+
maximumFeesMsats: number,
|
|
675
673
|
): Promise<OutgoingPayment | undefined> {
|
|
676
674
|
if (!this.nodeKeyCache.hasKey(payerNodeId)) {
|
|
677
675
|
throw new LightsparkSigningException("Paying node is not unlocked");
|
|
@@ -685,12 +683,13 @@ class LightsparkClient {
|
|
|
685
683
|
amount_msats: amountMsats,
|
|
686
684
|
maximum_fees_msats: maximumFeesMsats,
|
|
687
685
|
},
|
|
688
|
-
payerNodeId
|
|
686
|
+
payerNodeId,
|
|
689
687
|
);
|
|
690
688
|
if (response.send_payment?.payment.outgoing_payment_failure_message) {
|
|
691
689
|
throw new LightsparkException(
|
|
692
690
|
"PaymentError",
|
|
693
|
-
response.send_payment?.payment.outgoing_payment_failure_message
|
|
691
|
+
response.send_payment?.payment.outgoing_payment_failure_message
|
|
692
|
+
.rich_text_text,
|
|
694
693
|
);
|
|
695
694
|
}
|
|
696
695
|
return (
|
|
@@ -708,7 +707,7 @@ class LightsparkClient {
|
|
|
708
707
|
public async createNodeWalletAddress(nodeId: string): Promise<string> {
|
|
709
708
|
const response = await this.requester.makeRawRequest(
|
|
710
709
|
CreateNodeWalletAddress,
|
|
711
|
-
{ node_id: nodeId }
|
|
710
|
+
{ node_id: nodeId },
|
|
712
711
|
);
|
|
713
712
|
return response.create_node_wallet_address.wallet_address;
|
|
714
713
|
}
|
|
@@ -730,7 +729,7 @@ class LightsparkClient {
|
|
|
730
729
|
nodeId: string,
|
|
731
730
|
amountSats: number,
|
|
732
731
|
bitcoinAddress: string,
|
|
733
|
-
mode: WithdrawalMode
|
|
732
|
+
mode: WithdrawalMode,
|
|
734
733
|
): Promise<WithdrawalRequest> {
|
|
735
734
|
const response = await this.requester.makeRawRequest(
|
|
736
735
|
RequestWithdrawal,
|
|
@@ -740,7 +739,7 @@ class LightsparkClient {
|
|
|
740
739
|
bitcoin_address: bitcoinAddress,
|
|
741
740
|
withdrawal_mode: mode,
|
|
742
741
|
},
|
|
743
|
-
nodeId
|
|
742
|
+
nodeId,
|
|
744
743
|
);
|
|
745
744
|
return WithdrawalRequestFromJson(response.request_withdrawal.request);
|
|
746
745
|
}
|
|
@@ -756,7 +755,7 @@ class LightsparkClient {
|
|
|
756
755
|
*/
|
|
757
756
|
public async fundNode(
|
|
758
757
|
nodeId: string,
|
|
759
|
-
amountSats: number | undefined = undefined
|
|
758
|
+
amountSats: number | undefined = undefined,
|
|
760
759
|
): Promise<CurrencyAmount> {
|
|
761
760
|
const response = await this.requester.makeRawRequest(FundNode, {
|
|
762
761
|
node_id: nodeId,
|
|
@@ -778,7 +777,7 @@ class LightsparkClient {
|
|
|
778
777
|
public async createApiToken(
|
|
779
778
|
name: string,
|
|
780
779
|
transact: boolean = true,
|
|
781
|
-
testMode: boolean = true
|
|
780
|
+
testMode: boolean = true,
|
|
782
781
|
): Promise<CreateApiTokenOutput> {
|
|
783
782
|
let permissions: Permission[];
|
|
784
783
|
if (transact && testMode) {
|
|
@@ -823,7 +822,7 @@ class LightsparkClient {
|
|
|
823
822
|
localNodeId: string,
|
|
824
823
|
amountMsats: number,
|
|
825
824
|
memo: string | undefined = undefined,
|
|
826
|
-
invoiceType: InvoiceType = InvoiceType.STANDARD
|
|
825
|
+
invoiceType: InvoiceType = InvoiceType.STANDARD,
|
|
827
826
|
): Promise<string | null> {
|
|
828
827
|
return await this.executeRawQuery({
|
|
829
828
|
queryPayload: CreateTestModeInvoice,
|
|
@@ -843,7 +842,7 @@ class LightsparkClient {
|
|
|
843
842
|
if (!encodedPaymentRequest) {
|
|
844
843
|
throw new LightsparkException(
|
|
845
844
|
"CreateTestModeInvoiceError",
|
|
846
|
-
"Unable to create test mode invoice"
|
|
845
|
+
"Unable to create test mode invoice",
|
|
847
846
|
);
|
|
848
847
|
}
|
|
849
848
|
return encodedPaymentRequest;
|
|
@@ -863,7 +862,7 @@ class LightsparkClient {
|
|
|
863
862
|
public async createTestModePayment(
|
|
864
863
|
localNodeId: string,
|
|
865
864
|
encodedInvoice: string,
|
|
866
|
-
amountMsats: number | undefined = undefined
|
|
865
|
+
amountMsats: number | undefined = undefined,
|
|
867
866
|
): Promise<OutgoingPayment | null> {
|
|
868
867
|
return await this.executeRawQuery({
|
|
869
868
|
queryPayload: CreateTestModePayment,
|
|
@@ -874,11 +873,11 @@ class LightsparkClient {
|
|
|
874
873
|
},
|
|
875
874
|
constructObject: (responseJson: {
|
|
876
875
|
create_test_mode_payment: {
|
|
877
|
-
payment:
|
|
876
|
+
payment: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
878
877
|
} | null;
|
|
879
878
|
}) => {
|
|
880
879
|
return OutgoingPaymentFromJson(
|
|
881
|
-
responseJson.create_test_mode_payment?.payment
|
|
880
|
+
responseJson.create_test_mode_payment?.payment,
|
|
882
881
|
);
|
|
883
882
|
},
|
|
884
883
|
});
|