@lightsparkdev/lightspark-sdk 0.4.10 → 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 +8 -0
- package/dist/index.cjs +4 -3
- package/dist/index.js +4 -3
- package/package.json +4 -3
- package/src/__tests__/webhooks.test.ts +1 -1
- package/src/auth/AccountTokenAuthProvider.ts +4 -4
- package/src/client.ts +54 -52
- package/src/objects/Account.ts +13 -13
- package/src/objects/AccountToApiTokensConnection.ts +3 -3
- package/src/objects/AccountToChannelsConnection.ts +4 -4
- package/src/objects/AccountToNodesConnection.ts +2 -2
- package/src/objects/AccountToPaymentRequestsConnection.ts +3 -3
- package/src/objects/AccountToTransactionsConnection.ts +6 -6
- package/src/objects/AccountToWalletsConnection.ts +2 -2
- package/src/objects/Balances.ts +2 -2
- package/src/objects/Channel.ts +4 -4
- package/src/objects/ChannelClosingTransaction.ts +2 -2
- package/src/objects/ChannelOpeningTransaction.ts +2 -2
- package/src/objects/ChannelToTransactionsConnection.ts +4 -4
- package/src/objects/Connection.ts +25 -25
- package/src/objects/CreateApiTokenInput.ts +1 -1
- package/src/objects/CreateApiTokenOutput.ts +1 -1
- package/src/objects/CreateLnurlInvoiceInput.ts +1 -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 +1 -1
- package/src/objects/DeleteApiTokenOutput.ts +1 -1
- package/src/objects/GraphNode.ts +3 -3
- package/src/objects/IncomingPayment.ts +3 -3
- package/src/objects/IncomingPaymentAttempt.ts +2 -2
- package/src/objects/IncomingPaymentToAttemptsConnection.ts +3 -3
- 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 +6 -6
- package/src/objects/LightsparkNode.ts +4 -4
- package/src/objects/LightsparkNodeOwner.ts +4 -4
- package/src/objects/LightsparkNodeToChannelsConnection.ts +3 -3
- package/src/objects/Node.ts +5 -5
- package/src/objects/NodeToAddressesConnection.ts +2 -2
- package/src/objects/OnChainTransaction.ts +2 -2
- package/src/objects/OutgoingPayment.ts +3 -3
- package/src/objects/OutgoingPaymentAttempt.ts +5 -5
- package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +3 -3
- package/src/objects/OutgoingPaymentToAttemptsConnection.ts +3 -3
- package/src/objects/PaymentRequest.ts +1 -1
- package/src/objects/PaymentRequestData.ts +1 -1
- package/src/objects/RequestWithdrawalInput.ts +1 -1
- package/src/objects/RequestWithdrawalOutput.ts +1 -1
- package/src/objects/RoutingTransaction.ts +1 -1
- package/src/objects/ScreenBitcoinAddressesInput.ts +1 -1
- package/src/objects/ScreenBitcoinAddressesOutput.ts +2 -2
- package/src/objects/Transaction.ts +4 -4
- package/src/objects/TransactionFailures.ts +1 -1
- package/src/objects/Wallet.ts +6 -6
- package/src/objects/WalletToPaymentRequestsConnection.ts +3 -3
- package/src/objects/WalletToTransactionsConnection.ts +3 -3
- package/src/objects/WithdrawalRequest.ts +6 -6
- package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +2 -2
- package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +2 -2
- package/src/webhooks.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lightsparkdev/lightspark-sdk
|
|
2
2
|
|
|
3
|
+
## 0.4.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4ffd9a1: Upgrade prettier, fix lint configs, move ls-react-native-crypto-app to examples
|
|
8
|
+
- Updated dependencies [4ffd9a1]
|
|
9
|
+
- @lightsparkdev/core@0.3.11
|
|
10
|
+
|
|
3
11
|
## 0.4.10
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1929,7 +1929,7 @@ var import_crypto = require("crypto");
|
|
|
1929
1929
|
// package.json
|
|
1930
1930
|
var package_default = {
|
|
1931
1931
|
name: "@lightsparkdev/lightspark-sdk",
|
|
1932
|
-
version: "0.4.
|
|
1932
|
+
version: "0.4.11",
|
|
1933
1933
|
description: "Lightspark JS SDK",
|
|
1934
1934
|
author: "Lightspark Inc.",
|
|
1935
1935
|
keywords: [
|
|
@@ -1992,6 +1992,7 @@ var package_default = {
|
|
|
1992
1992
|
"format:fix": "prettier src --write",
|
|
1993
1993
|
format: "prettier src --check",
|
|
1994
1994
|
"lint:fix": "eslint --fix .",
|
|
1995
|
+
"lint:fix:continue": "eslint --fix . || exit 0",
|
|
1995
1996
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
1996
1997
|
lint: "eslint .",
|
|
1997
1998
|
postversion: "yarn build",
|
|
@@ -2001,7 +2002,7 @@ var package_default = {
|
|
|
2001
2002
|
},
|
|
2002
2003
|
license: "Apache-2.0",
|
|
2003
2004
|
dependencies: {
|
|
2004
|
-
"@lightsparkdev/core": "0.3.
|
|
2005
|
+
"@lightsparkdev/core": "0.3.11",
|
|
2005
2006
|
"auto-bind": "^5.0.1",
|
|
2006
2007
|
crypto: "^1.0.1",
|
|
2007
2008
|
"crypto-browserify": "^3.12.0",
|
|
@@ -2020,7 +2021,7 @@ var package_default = {
|
|
|
2020
2021
|
eslint: "^8.3.0",
|
|
2021
2022
|
"eslint-watch": "^8.0.0",
|
|
2022
2023
|
jest: "^29.4.1",
|
|
2023
|
-
prettier: "
|
|
2024
|
+
prettier: "3.0.2",
|
|
2024
2025
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
2025
2026
|
"ts-jest": "^29.0.5",
|
|
2026
2027
|
"ts-node": "^10.9.1",
|
package/dist/index.js
CHANGED
|
@@ -117,7 +117,7 @@ import { createHash } from "crypto";
|
|
|
117
117
|
// package.json
|
|
118
118
|
var package_default = {
|
|
119
119
|
name: "@lightsparkdev/lightspark-sdk",
|
|
120
|
-
version: "0.4.
|
|
120
|
+
version: "0.4.11",
|
|
121
121
|
description: "Lightspark JS SDK",
|
|
122
122
|
author: "Lightspark Inc.",
|
|
123
123
|
keywords: [
|
|
@@ -180,6 +180,7 @@ var package_default = {
|
|
|
180
180
|
"format:fix": "prettier src --write",
|
|
181
181
|
format: "prettier src --check",
|
|
182
182
|
"lint:fix": "eslint --fix .",
|
|
183
|
+
"lint:fix:continue": "eslint --fix . || exit 0",
|
|
183
184
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
184
185
|
lint: "eslint .",
|
|
185
186
|
postversion: "yarn build",
|
|
@@ -189,7 +190,7 @@ var package_default = {
|
|
|
189
190
|
},
|
|
190
191
|
license: "Apache-2.0",
|
|
191
192
|
dependencies: {
|
|
192
|
-
"@lightsparkdev/core": "0.3.
|
|
193
|
+
"@lightsparkdev/core": "0.3.11",
|
|
193
194
|
"auto-bind": "^5.0.1",
|
|
194
195
|
crypto: "^1.0.1",
|
|
195
196
|
"crypto-browserify": "^3.12.0",
|
|
@@ -208,7 +209,7 @@ var package_default = {
|
|
|
208
209
|
eslint: "^8.3.0",
|
|
209
210
|
"eslint-watch": "^8.0.0",
|
|
210
211
|
jest: "^29.4.1",
|
|
211
|
-
prettier: "
|
|
212
|
+
prettier: "3.0.2",
|
|
212
213
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
213
214
|
"ts-jest": "^29.0.5",
|
|
214
215
|
"ts-node": "^10.9.1",
|
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",
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
"eslint": "^8.3.0",
|
|
92
93
|
"eslint-watch": "^8.0.0",
|
|
93
94
|
"jest": "^29.4.1",
|
|
94
|
-
"prettier": "
|
|
95
|
+
"prettier": "3.0.2",
|
|
95
96
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
96
97
|
"ts-jest": "^29.0.5",
|
|
97
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
|
@@ -110,7 +110,7 @@ class LightsparkClient {
|
|
|
110
110
|
constructor(
|
|
111
111
|
private authProvider: AuthProvider = new StubAuthProvider(),
|
|
112
112
|
private readonly serverUrl: string = "api.lightspark.com",
|
|
113
|
-
private readonly cryptoImpl: CryptoInterface = DefaultCrypto
|
|
113
|
+
private readonly cryptoImpl: CryptoInterface = DefaultCrypto,
|
|
114
114
|
) {
|
|
115
115
|
this.nodeKeyCache = new NodeKeyCache(this.cryptoImpl);
|
|
116
116
|
this.requester = new Requester(
|
|
@@ -119,7 +119,7 @@ class LightsparkClient {
|
|
|
119
119
|
`js-lightspark-sdk/${sdkVersion}`,
|
|
120
120
|
authProvider,
|
|
121
121
|
serverUrl,
|
|
122
|
-
this.cryptoImpl
|
|
122
|
+
this.cryptoImpl,
|
|
123
123
|
);
|
|
124
124
|
|
|
125
125
|
autoBind(this);
|
|
@@ -138,7 +138,7 @@ class LightsparkClient {
|
|
|
138
138
|
`js-lightspark-sdk/${sdkVersion}`,
|
|
139
139
|
authProvider,
|
|
140
140
|
this.serverUrl,
|
|
141
|
-
this.cryptoImpl
|
|
141
|
+
this.cryptoImpl,
|
|
142
142
|
);
|
|
143
143
|
this.authProvider = authProvider;
|
|
144
144
|
}
|
|
@@ -155,7 +155,7 @@ class LightsparkClient {
|
|
|
155
155
|
*/
|
|
156
156
|
public async getCurrentAccount(): Promise<Maybe<Account>> {
|
|
157
157
|
return await this.requester.executeQuery<Account>(
|
|
158
|
-
Account.getAccountQuery()
|
|
158
|
+
Account.getAccountQuery(),
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -172,7 +172,7 @@ class LightsparkClient {
|
|
|
172
172
|
nodeId: string,
|
|
173
173
|
numTransactions: number = 20,
|
|
174
174
|
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
175
|
-
afterDate: Maybe<string> = undefined
|
|
175
|
+
afterDate: Maybe<string> = undefined,
|
|
176
176
|
): Promise<Transaction[]> {
|
|
177
177
|
const response = await this.requester.makeRawRequest(TransactionsForNode, {
|
|
178
178
|
nodeId,
|
|
@@ -182,7 +182,7 @@ class LightsparkClient {
|
|
|
182
182
|
});
|
|
183
183
|
return (
|
|
184
184
|
response.current_account?.recent_transactions.entities.map(
|
|
185
|
-
(transaction) => TransactionFromJson(transaction)
|
|
185
|
+
(transaction) => TransactionFromJson(transaction),
|
|
186
186
|
) ?? []
|
|
187
187
|
);
|
|
188
188
|
}
|
|
@@ -194,19 +194,19 @@ class LightsparkClient {
|
|
|
194
194
|
* @returns A zen-observable that emits transaction updates for the given node IDs.
|
|
195
195
|
*/
|
|
196
196
|
public listenToTransactions(
|
|
197
|
-
nodeIds: string[]
|
|
197
|
+
nodeIds: string[],
|
|
198
198
|
): Observable<TransactionUpdate | undefined> {
|
|
199
199
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
200
|
const response = this.requester.subscribe<{ transactions: any }>(
|
|
201
201
|
TransactionSubscription,
|
|
202
202
|
{
|
|
203
203
|
nodeIds,
|
|
204
|
-
}
|
|
204
|
+
},
|
|
205
205
|
);
|
|
206
206
|
return response.map(
|
|
207
207
|
(response) =>
|
|
208
208
|
response?.data?.transactions &&
|
|
209
|
-
TransactionUpdateFromJson(response.data.transactions)
|
|
209
|
+
TransactionUpdateFromJson(response.data.transactions),
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
212
|
|
|
@@ -221,7 +221,7 @@ class LightsparkClient {
|
|
|
221
221
|
*/
|
|
222
222
|
public async getAccountDashboard(
|
|
223
223
|
nodeIds: string[] | undefined = undefined,
|
|
224
|
-
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET
|
|
224
|
+
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
225
225
|
): Promise<AccountDashboard> {
|
|
226
226
|
const response = await this.requester.makeRawRequest(MultiNodeDashboard, {
|
|
227
227
|
nodeIds: nodeIds,
|
|
@@ -240,7 +240,7 @@ class LightsparkClient {
|
|
|
240
240
|
1. You are requesting MAINNET nodes, but you have no MAINNET nodes yet. In this case, request BitcoinNetwork.REGTEST instead.
|
|
241
241
|
2. You are specifying specific node IDs, but those IDs don't exist or are not on the bitcoid network you requested.
|
|
242
242
|
3. The api token or authentication mechanism you are using is not authorized to access the nodes you requested. If you're using
|
|
243
|
-
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).`,
|
|
244
244
|
);
|
|
245
245
|
}
|
|
246
246
|
const account = response.current_account;
|
|
@@ -281,17 +281,17 @@ class LightsparkClient {
|
|
|
281
281
|
requiredReserve:
|
|
282
282
|
account.blockchain_balance.required_reserve &&
|
|
283
283
|
CurrencyAmountFromJson(
|
|
284
|
-
account.blockchain_balance.required_reserve
|
|
284
|
+
account.blockchain_balance.required_reserve,
|
|
285
285
|
),
|
|
286
286
|
availableBalance:
|
|
287
287
|
account.blockchain_balance.available_balance &&
|
|
288
288
|
CurrencyAmountFromJson(
|
|
289
|
-
account.blockchain_balance.available_balance
|
|
289
|
+
account.blockchain_balance.available_balance,
|
|
290
290
|
),
|
|
291
291
|
unconfirmedBalance:
|
|
292
292
|
account.blockchain_balance.unconfirmed_balance &&
|
|
293
293
|
CurrencyAmountFromJson(
|
|
294
|
-
account.blockchain_balance.unconfirmed_balance
|
|
294
|
+
account.blockchain_balance.unconfirmed_balance,
|
|
295
295
|
),
|
|
296
296
|
}
|
|
297
297
|
: null,
|
|
@@ -316,7 +316,7 @@ class LightsparkClient {
|
|
|
316
316
|
public async getSingleNodeDashboard(
|
|
317
317
|
nodeId: string,
|
|
318
318
|
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
319
|
-
transactionsAfterDate: Maybe<string> = undefined
|
|
319
|
+
transactionsAfterDate: Maybe<string> = undefined,
|
|
320
320
|
): Promise<SingleNodeDashboard> {
|
|
321
321
|
const response = await this.requester.makeRawRequest(
|
|
322
322
|
SingleNodeDashboardQuery,
|
|
@@ -325,7 +325,7 @@ class LightsparkClient {
|
|
|
325
325
|
network: bitcoinNetwork,
|
|
326
326
|
numTransactions: 20,
|
|
327
327
|
transactionsAfterDate,
|
|
328
|
-
}
|
|
328
|
+
},
|
|
329
329
|
);
|
|
330
330
|
if (!response.current_account) {
|
|
331
331
|
throw new LightsparkAuthException("No current account");
|
|
@@ -338,7 +338,7 @@ class LightsparkClient {
|
|
|
338
338
|
) {
|
|
339
339
|
throw new LightsparkException(
|
|
340
340
|
"InvalidOrMissingNode",
|
|
341
|
-
"No nodes found for node dashboard"
|
|
341
|
+
"No nodes found for node dashboard",
|
|
342
342
|
);
|
|
343
343
|
}
|
|
344
344
|
const node = account.dashboard_overview_nodes.entities[0];
|
|
@@ -365,16 +365,16 @@ class LightsparkClient {
|
|
|
365
365
|
remoteBalance: currencyAmountOrUndefined(node.remote_balance),
|
|
366
366
|
blockchainBalance: node.blockchain_balance && {
|
|
367
367
|
availableBalance: currencyAmountOrUndefined(
|
|
368
|
-
node.blockchain_balance.available_balance
|
|
368
|
+
node.blockchain_balance.available_balance,
|
|
369
369
|
),
|
|
370
370
|
confirmedBalance: currencyAmountOrUndefined(
|
|
371
|
-
node.blockchain_balance.confirmed_balance
|
|
371
|
+
node.blockchain_balance.confirmed_balance,
|
|
372
372
|
),
|
|
373
373
|
unconfirmedBalance: currencyAmountOrUndefined(
|
|
374
|
-
node.blockchain_balance.unconfirmed_balance
|
|
374
|
+
node.blockchain_balance.unconfirmed_balance,
|
|
375
375
|
),
|
|
376
376
|
totalBalance: currencyAmountOrUndefined(
|
|
377
|
-
node.blockchain_balance.total_balance
|
|
377
|
+
node.blockchain_balance.total_balance,
|
|
378
378
|
),
|
|
379
379
|
},
|
|
380
380
|
recentTransactions:
|
|
@@ -401,7 +401,7 @@ class LightsparkClient {
|
|
|
401
401
|
nodeId: string,
|
|
402
402
|
amountMsats: number,
|
|
403
403
|
memo: string,
|
|
404
|
-
type: InvoiceType | undefined = undefined
|
|
404
|
+
type: InvoiceType | undefined = undefined,
|
|
405
405
|
): Promise<string | undefined> {
|
|
406
406
|
const response = await this.requester.makeRawRequest(CreateInvoice, {
|
|
407
407
|
node_id: nodeId,
|
|
@@ -429,7 +429,7 @@ class LightsparkClient {
|
|
|
429
429
|
public async createLnurlInvoice(
|
|
430
430
|
nodeId: string,
|
|
431
431
|
amountMsats: number,
|
|
432
|
-
metadata: string
|
|
432
|
+
metadata: string,
|
|
433
433
|
): Promise<Invoice | undefined> {
|
|
434
434
|
const response = await this.requester.makeRawRequest(CreateLnurlInvoice, {
|
|
435
435
|
node_id: nodeId,
|
|
@@ -463,13 +463,13 @@ class LightsparkClient {
|
|
|
463
463
|
* @returns A fee estimate for the given bitcoin network including a minimum fee rate, and a max-speed fee rate.
|
|
464
464
|
*/
|
|
465
465
|
public async getBitcoinFeeEstimate(
|
|
466
|
-
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET
|
|
466
|
+
bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
|
|
467
467
|
): Promise<FeeEstimate> {
|
|
468
468
|
const response = await this.requester.makeRawRequest(
|
|
469
469
|
BitcoinFeeEstimateQuery,
|
|
470
470
|
{
|
|
471
471
|
bitcoin_network: bitcoinNetwork,
|
|
472
|
-
}
|
|
472
|
+
},
|
|
473
473
|
);
|
|
474
474
|
return FeeEstimateFromJson(response.bitcoin_fee_estimate);
|
|
475
475
|
}
|
|
@@ -486,7 +486,7 @@ class LightsparkClient {
|
|
|
486
486
|
public async getLightningFeeEstimateForInvoice(
|
|
487
487
|
nodeId: string,
|
|
488
488
|
encodedPaymentRequest: string,
|
|
489
|
-
amountMsats: number | undefined = undefined
|
|
489
|
+
amountMsats: number | undefined = undefined,
|
|
490
490
|
): Promise<CurrencyAmount> {
|
|
491
491
|
const response = await this.requester.makeRawRequest(
|
|
492
492
|
LightningFeeEstimateForInvoice,
|
|
@@ -494,11 +494,11 @@ class LightsparkClient {
|
|
|
494
494
|
node_id: nodeId,
|
|
495
495
|
encoded_payment_request: encodedPaymentRequest,
|
|
496
496
|
amount_msats: amountMsats,
|
|
497
|
-
}
|
|
497
|
+
},
|
|
498
498
|
);
|
|
499
499
|
return CurrencyAmountFromJson(
|
|
500
500
|
response.lightning_fee_estimate_for_invoice
|
|
501
|
-
.lightning_fee_estimate_output_fee_estimate
|
|
501
|
+
.lightning_fee_estimate_output_fee_estimate,
|
|
502
502
|
);
|
|
503
503
|
}
|
|
504
504
|
|
|
@@ -513,7 +513,7 @@ class LightsparkClient {
|
|
|
513
513
|
public async getLightningFeeEstimateForNode(
|
|
514
514
|
nodeId: string,
|
|
515
515
|
destinationNodePublicKey: string,
|
|
516
|
-
amountMsats: number
|
|
516
|
+
amountMsats: number,
|
|
517
517
|
): Promise<CurrencyAmount> {
|
|
518
518
|
const response = await this.requester.makeRawRequest(
|
|
519
519
|
LightningFeeEstimateForNode,
|
|
@@ -521,11 +521,11 @@ class LightsparkClient {
|
|
|
521
521
|
node_id: nodeId,
|
|
522
522
|
destination_node_public_key: destinationNodePublicKey,
|
|
523
523
|
amount_msats: amountMsats,
|
|
524
|
-
}
|
|
524
|
+
},
|
|
525
525
|
);
|
|
526
526
|
return CurrencyAmountFromJson(
|
|
527
527
|
response.lightning_fee_estimate_for_node
|
|
528
|
-
.lightning_fee_estimate_output_fee_estimate
|
|
528
|
+
.lightning_fee_estimate_output_fee_estimate,
|
|
529
529
|
);
|
|
530
530
|
}
|
|
531
531
|
|
|
@@ -547,12 +547,12 @@ class LightsparkClient {
|
|
|
547
547
|
await this.cryptoImpl.decryptSecretWithNodePassword(
|
|
548
548
|
encryptedKey.cipher,
|
|
549
549
|
encryptedKey.encrypted_value,
|
|
550
|
-
password
|
|
550
|
+
password,
|
|
551
551
|
);
|
|
552
552
|
|
|
553
553
|
if (!signingPrivateKey) {
|
|
554
554
|
throw new LightsparkSigningException(
|
|
555
|
-
"Unable to decrypt signing key with provided password. Please try again."
|
|
555
|
+
"Unable to decrypt signing key with provided password. Please try again.",
|
|
556
556
|
);
|
|
557
557
|
}
|
|
558
558
|
|
|
@@ -567,17 +567,17 @@ class LightsparkClient {
|
|
|
567
567
|
|
|
568
568
|
await this.nodeKeyCache.loadKey(
|
|
569
569
|
nodeId,
|
|
570
|
-
KeyOrAlias.key(signingPrivateKeyPEM)
|
|
570
|
+
KeyOrAlias.key(signingPrivateKeyPEM),
|
|
571
571
|
);
|
|
572
572
|
return true;
|
|
573
573
|
}
|
|
574
574
|
|
|
575
575
|
private async recoverNodeSigningKey(
|
|
576
|
-
nodeId: string
|
|
576
|
+
nodeId: string,
|
|
577
577
|
): Promise<Maybe<{ encrypted_value: string; cipher: string }>> {
|
|
578
578
|
const response = await this.requester.makeRawRequest(
|
|
579
579
|
RecoverNodeSigningKey,
|
|
580
|
-
{ nodeId }
|
|
580
|
+
{ nodeId },
|
|
581
581
|
);
|
|
582
582
|
const nodeEntity = response.entity;
|
|
583
583
|
if (nodeEntity?.__typename === "LightsparkNode") {
|
|
@@ -594,7 +594,7 @@ class LightsparkClient {
|
|
|
594
594
|
*/
|
|
595
595
|
public async loadNodeKey(
|
|
596
596
|
nodeId: string,
|
|
597
|
-
signingPrivateKeyOrAlias: KeyOrAliasType
|
|
597
|
+
signingPrivateKeyOrAlias: KeyOrAliasType,
|
|
598
598
|
) {
|
|
599
599
|
await this.nodeKeyCache.loadKey(nodeId, signingPrivateKeyOrAlias);
|
|
600
600
|
}
|
|
@@ -620,7 +620,7 @@ class LightsparkClient {
|
|
|
620
620
|
encodedInvoice: string,
|
|
621
621
|
maximumFeesMsats: number,
|
|
622
622
|
timeoutSecs: number = 60,
|
|
623
|
-
amountMsats: number | undefined = undefined
|
|
623
|
+
amountMsats: number | undefined = undefined,
|
|
624
624
|
): Promise<OutgoingPayment | undefined> {
|
|
625
625
|
if (!this.nodeKeyCache.hasKey(payerNodeId)) {
|
|
626
626
|
throw new LightsparkSigningException("Paying node is not unlocked");
|
|
@@ -637,12 +637,13 @@ class LightsparkClient {
|
|
|
637
637
|
const response = await this.requester.makeRawRequest(
|
|
638
638
|
PayInvoice,
|
|
639
639
|
variables,
|
|
640
|
-
payerNodeId
|
|
640
|
+
payerNodeId,
|
|
641
641
|
);
|
|
642
642
|
if (response.pay_invoice?.payment.outgoing_payment_failure_message) {
|
|
643
643
|
throw new LightsparkException(
|
|
644
644
|
"PaymentError",
|
|
645
|
-
response.pay_invoice?.payment.outgoing_payment_failure_message
|
|
645
|
+
response.pay_invoice?.payment.outgoing_payment_failure_message
|
|
646
|
+
.rich_text_text,
|
|
646
647
|
);
|
|
647
648
|
}
|
|
648
649
|
return (
|
|
@@ -668,7 +669,7 @@ class LightsparkClient {
|
|
|
668
669
|
destinationPublicKey: string,
|
|
669
670
|
timeoutSecs: number = 60,
|
|
670
671
|
amountMsats: number,
|
|
671
|
-
maximumFeesMsats: number
|
|
672
|
+
maximumFeesMsats: number,
|
|
672
673
|
): Promise<OutgoingPayment | undefined> {
|
|
673
674
|
if (!this.nodeKeyCache.hasKey(payerNodeId)) {
|
|
674
675
|
throw new LightsparkSigningException("Paying node is not unlocked");
|
|
@@ -682,12 +683,13 @@ class LightsparkClient {
|
|
|
682
683
|
amount_msats: amountMsats,
|
|
683
684
|
maximum_fees_msats: maximumFeesMsats,
|
|
684
685
|
},
|
|
685
|
-
payerNodeId
|
|
686
|
+
payerNodeId,
|
|
686
687
|
);
|
|
687
688
|
if (response.send_payment?.payment.outgoing_payment_failure_message) {
|
|
688
689
|
throw new LightsparkException(
|
|
689
690
|
"PaymentError",
|
|
690
|
-
response.send_payment?.payment.outgoing_payment_failure_message
|
|
691
|
+
response.send_payment?.payment.outgoing_payment_failure_message
|
|
692
|
+
.rich_text_text,
|
|
691
693
|
);
|
|
692
694
|
}
|
|
693
695
|
return (
|
|
@@ -705,7 +707,7 @@ class LightsparkClient {
|
|
|
705
707
|
public async createNodeWalletAddress(nodeId: string): Promise<string> {
|
|
706
708
|
const response = await this.requester.makeRawRequest(
|
|
707
709
|
CreateNodeWalletAddress,
|
|
708
|
-
{ node_id: nodeId }
|
|
710
|
+
{ node_id: nodeId },
|
|
709
711
|
);
|
|
710
712
|
return response.create_node_wallet_address.wallet_address;
|
|
711
713
|
}
|
|
@@ -727,7 +729,7 @@ class LightsparkClient {
|
|
|
727
729
|
nodeId: string,
|
|
728
730
|
amountSats: number,
|
|
729
731
|
bitcoinAddress: string,
|
|
730
|
-
mode: WithdrawalMode
|
|
732
|
+
mode: WithdrawalMode,
|
|
731
733
|
): Promise<WithdrawalRequest> {
|
|
732
734
|
const response = await this.requester.makeRawRequest(
|
|
733
735
|
RequestWithdrawal,
|
|
@@ -737,7 +739,7 @@ class LightsparkClient {
|
|
|
737
739
|
bitcoin_address: bitcoinAddress,
|
|
738
740
|
withdrawal_mode: mode,
|
|
739
741
|
},
|
|
740
|
-
nodeId
|
|
742
|
+
nodeId,
|
|
741
743
|
);
|
|
742
744
|
return WithdrawalRequestFromJson(response.request_withdrawal.request);
|
|
743
745
|
}
|
|
@@ -753,7 +755,7 @@ class LightsparkClient {
|
|
|
753
755
|
*/
|
|
754
756
|
public async fundNode(
|
|
755
757
|
nodeId: string,
|
|
756
|
-
amountSats: number | undefined = undefined
|
|
758
|
+
amountSats: number | undefined = undefined,
|
|
757
759
|
): Promise<CurrencyAmount> {
|
|
758
760
|
const response = await this.requester.makeRawRequest(FundNode, {
|
|
759
761
|
node_id: nodeId,
|
|
@@ -775,7 +777,7 @@ class LightsparkClient {
|
|
|
775
777
|
public async createApiToken(
|
|
776
778
|
name: string,
|
|
777
779
|
transact: boolean = true,
|
|
778
|
-
testMode: boolean = true
|
|
780
|
+
testMode: boolean = true,
|
|
779
781
|
): Promise<CreateApiTokenOutput> {
|
|
780
782
|
let permissions: Permission[];
|
|
781
783
|
if (transact && testMode) {
|
|
@@ -820,7 +822,7 @@ class LightsparkClient {
|
|
|
820
822
|
localNodeId: string,
|
|
821
823
|
amountMsats: number,
|
|
822
824
|
memo: string | undefined = undefined,
|
|
823
|
-
invoiceType: InvoiceType = InvoiceType.STANDARD
|
|
825
|
+
invoiceType: InvoiceType = InvoiceType.STANDARD,
|
|
824
826
|
): Promise<string | null> {
|
|
825
827
|
return await this.executeRawQuery({
|
|
826
828
|
queryPayload: CreateTestModeInvoice,
|
|
@@ -840,7 +842,7 @@ class LightsparkClient {
|
|
|
840
842
|
if (!encodedPaymentRequest) {
|
|
841
843
|
throw new LightsparkException(
|
|
842
844
|
"CreateTestModeInvoiceError",
|
|
843
|
-
"Unable to create test mode invoice"
|
|
845
|
+
"Unable to create test mode invoice",
|
|
844
846
|
);
|
|
845
847
|
}
|
|
846
848
|
return encodedPaymentRequest;
|
|
@@ -860,7 +862,7 @@ class LightsparkClient {
|
|
|
860
862
|
public async createTestModePayment(
|
|
861
863
|
localNodeId: string,
|
|
862
864
|
encodedInvoice: string,
|
|
863
|
-
amountMsats: number | undefined = undefined
|
|
865
|
+
amountMsats: number | undefined = undefined,
|
|
864
866
|
): Promise<OutgoingPayment | null> {
|
|
865
867
|
return await this.executeRawQuery({
|
|
866
868
|
queryPayload: CreateTestModePayment,
|
|
@@ -875,7 +877,7 @@ class LightsparkClient {
|
|
|
875
877
|
} | null;
|
|
876
878
|
}) => {
|
|
877
879
|
return OutgoingPaymentFromJson(
|
|
878
|
-
responseJson.create_test_mode_payment?.payment
|
|
880
|
+
responseJson.create_test_mode_payment?.payment,
|
|
879
881
|
);
|
|
880
882
|
},
|
|
881
883
|
});
|
package/src/objects/Account.ts
CHANGED
|
@@ -32,7 +32,7 @@ class Account implements LightsparkNodeOwner {
|
|
|
32
32
|
public readonly createdAt: string,
|
|
33
33
|
public readonly updatedAt: string,
|
|
34
34
|
public readonly typename: string,
|
|
35
|
-
public readonly name?: string
|
|
35
|
+
public readonly name?: string,
|
|
36
36
|
) {
|
|
37
37
|
autoBind(this);
|
|
38
38
|
}
|
|
@@ -40,7 +40,7 @@ class Account implements LightsparkNodeOwner {
|
|
|
40
40
|
public async getApiTokens(
|
|
41
41
|
client: LightsparkClient,
|
|
42
42
|
first: number | undefined = undefined,
|
|
43
|
-
after: string | undefined = undefined
|
|
43
|
+
after: string | undefined = undefined,
|
|
44
44
|
): Promise<AccountToApiTokensConnection> {
|
|
45
45
|
return (await client.executeRawQuery({
|
|
46
46
|
queryPayload: `
|
|
@@ -82,7 +82,7 @@ query FetchAccountToApiTokensConnection($first: Int, $after: String) {
|
|
|
82
82
|
public async getBlockchainBalance(
|
|
83
83
|
client: LightsparkClient,
|
|
84
84
|
bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
|
|
85
|
-
nodeIds: string[] | undefined = undefined
|
|
85
|
+
nodeIds: string[] | undefined = undefined,
|
|
86
86
|
): Promise<BlockchainBalance | null> {
|
|
87
87
|
return await client.executeRawQuery({
|
|
88
88
|
queryPayload: `
|
|
@@ -155,7 +155,7 @@ query FetchAccountBlockchainBalance($bitcoin_networks: [BitcoinNetwork!], $node_
|
|
|
155
155
|
public async getConductivity(
|
|
156
156
|
client: LightsparkClient,
|
|
157
157
|
bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
|
|
158
|
-
nodeIds: string[] | undefined = undefined
|
|
158
|
+
nodeIds: string[] | undefined = undefined,
|
|
159
159
|
): Promise<number> {
|
|
160
160
|
return await client.executeRawQuery({
|
|
161
161
|
queryPayload: `
|
|
@@ -178,7 +178,7 @@ query FetchAccountConductivity($bitcoin_networks: [BitcoinNetwork!], $node_ids:
|
|
|
178
178
|
public async getLocalBalance(
|
|
179
179
|
client: LightsparkClient,
|
|
180
180
|
bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
|
|
181
|
-
nodeIds: string[] | undefined = undefined
|
|
181
|
+
nodeIds: string[] | undefined = undefined,
|
|
182
182
|
): Promise<CurrencyAmount | null> {
|
|
183
183
|
return await client.executeRawQuery({
|
|
184
184
|
queryPayload: `
|
|
@@ -210,7 +210,7 @@ query FetchAccountLocalBalance($bitcoin_networks: [BitcoinNetwork!], $node_ids:
|
|
|
210
210
|
first: number | undefined = undefined,
|
|
211
211
|
bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
|
|
212
212
|
nodeIds: string[] | undefined = undefined,
|
|
213
|
-
after: string | undefined = undefined
|
|
213
|
+
after: string | undefined = undefined,
|
|
214
214
|
): Promise<AccountToNodesConnection> {
|
|
215
215
|
return (await client.executeRawQuery({
|
|
216
216
|
queryPayload: `
|
|
@@ -357,7 +357,7 @@ query FetchAccountToNodesConnection($first: Int, $bitcoin_networks: [BitcoinNetw
|
|
|
357
357
|
public async getRemoteBalance(
|
|
358
358
|
client: LightsparkClient,
|
|
359
359
|
bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
|
|
360
|
-
nodeIds: string[] | undefined = undefined
|
|
360
|
+
nodeIds: string[] | undefined = undefined,
|
|
361
361
|
): Promise<CurrencyAmount | null> {
|
|
362
362
|
return await client.executeRawQuery({
|
|
363
363
|
queryPayload: `
|
|
@@ -389,7 +389,7 @@ query FetchAccountRemoteBalance($bitcoin_networks: [BitcoinNetwork!], $node_ids:
|
|
|
389
389
|
afterDate: string | undefined = undefined,
|
|
390
390
|
beforeDate: string | undefined = undefined,
|
|
391
391
|
bitcoinNetworks: BitcoinNetwork[] | undefined = undefined,
|
|
392
|
-
nodeIds: string[] | undefined = undefined
|
|
392
|
+
nodeIds: string[] | undefined = undefined,
|
|
393
393
|
): Promise<number> {
|
|
394
394
|
return await client.executeRawQuery({
|
|
395
395
|
queryPayload: `
|
|
@@ -420,7 +420,7 @@ query FetchAccountUptimePercentage($after_date: DateTime, $before_date: DateTime
|
|
|
420
420
|
lightningNodeId: string | undefined = undefined,
|
|
421
421
|
afterDate: string | undefined = undefined,
|
|
422
422
|
beforeDate: string | undefined = undefined,
|
|
423
|
-
first: number | undefined = undefined
|
|
423
|
+
first: number | undefined = undefined,
|
|
424
424
|
): Promise<AccountToChannelsConnection> {
|
|
425
425
|
return (await client.executeRawQuery({
|
|
426
426
|
queryPayload: `
|
|
@@ -553,7 +553,7 @@ query FetchAccountToChannelsConnection($bitcoin_network: BitcoinNetwork!, $light
|
|
|
553
553
|
bitcoinNetwork: BitcoinNetwork | undefined = undefined,
|
|
554
554
|
lightningNodeId: string | undefined = undefined,
|
|
555
555
|
statuses: TransactionStatus[] | undefined = undefined,
|
|
556
|
-
excludeFailures: TransactionFailures | undefined = undefined
|
|
556
|
+
excludeFailures: TransactionFailures | undefined = undefined,
|
|
557
557
|
): Promise<AccountToTransactionsConnection> {
|
|
558
558
|
return (await client.executeRawQuery({
|
|
559
559
|
queryPayload: `
|
|
@@ -996,7 +996,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
|
|
|
996
996
|
afterDate: string | undefined = undefined,
|
|
997
997
|
beforeDate: string | undefined = undefined,
|
|
998
998
|
bitcoinNetwork: BitcoinNetwork | undefined = undefined,
|
|
999
|
-
lightningNodeId: string | undefined = undefined
|
|
999
|
+
lightningNodeId: string | undefined = undefined,
|
|
1000
1000
|
): Promise<AccountToPaymentRequestsConnection> {
|
|
1001
1001
|
return (await client.executeRawQuery({
|
|
1002
1002
|
queryPayload: `
|
|
@@ -1195,7 +1195,7 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
|
|
|
1195
1195
|
client: LightsparkClient,
|
|
1196
1196
|
first: number | undefined = undefined,
|
|
1197
1197
|
after: string | undefined = undefined,
|
|
1198
|
-
thirdPartyIds: string[] | undefined = undefined
|
|
1198
|
+
thirdPartyIds: string[] | undefined = undefined,
|
|
1199
1199
|
): Promise<AccountToWalletsConnection> {
|
|
1200
1200
|
return (await client.executeRawQuery({
|
|
1201
1201
|
queryPayload: `
|
|
@@ -1286,7 +1286,7 @@ export const AccountFromJson = (obj: any): Account => {
|
|
|
1286
1286
|
obj["account_created_at"],
|
|
1287
1287
|
obj["account_updated_at"],
|
|
1288
1288
|
"Account",
|
|
1289
|
-
obj["account_name"]
|
|
1289
|
+
obj["account_name"],
|
|
1290
1290
|
);
|
|
1291
1291
|
};
|
|
1292
1292
|
|