@lightsparkdev/lightspark-sdk 1.1.7 → 1.2.0
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/{chunk-7UT6YX37.js → chunk-VTPDR6P4.js} +393 -275
- package/dist/{index-d31f4469.d.ts → index-f040db9f.d.ts} +678 -386
- package/dist/index.cjs +396 -278
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/objects/index.cjs +395 -277
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +5 -5
- package/package.json +2 -2
- package/src/objects/Account.ts +13 -2
- package/src/objects/AccountToApiTokensConnection.ts +16 -5
- package/src/objects/AccountToChannelsConnection.ts +9 -0
- package/src/objects/AccountToNodesConnection.ts +19 -5
- package/src/objects/AccountToPaymentRequestsConnection.ts +21 -5
- package/src/objects/AccountToTransactionsConnection.ts +33 -9
- package/src/objects/AccountToWalletsConnection.ts +13 -4
- package/src/objects/ApiToken.ts +13 -3
- package/src/objects/Balances.ts +17 -3
- package/src/objects/BlockchainBalance.ts +34 -9
- package/src/objects/Channel.ts +61 -16
- package/src/objects/ChannelClosingTransaction.ts +81 -61
- package/src/objects/ChannelFees.ts +16 -5
- package/src/objects/ChannelOpeningTransaction.ts +81 -61
- package/src/objects/ChannelSnapshot.ts +32 -8
- package/src/objects/ChannelToTransactionsConnection.ts +26 -6
- package/src/objects/Connection.ts +205 -10
- package/src/objects/CreateApiTokenInput.ts +8 -2
- package/src/objects/CreateApiTokenOutput.ts +9 -3
- package/src/objects/CreateInvoiceInput.ts +14 -5
- package/src/objects/CreateInvoiceOutput.ts +7 -2
- package/src/objects/CreateLnurlInvoiceInput.ts +13 -3
- package/src/objects/CreateNodeWalletAddressInput.ts +9 -2
- package/src/objects/CreateNodeWalletAddressOutput.ts +10 -2
- package/src/objects/CreateTestModeInvoiceInput.ts +14 -4
- package/src/objects/CreateTestModeInvoiceOutput.ts +10 -2
- package/src/objects/CreateTestModePaymentInput.ts +12 -3
- package/src/objects/CreateTestModePaymentoutput.ts +12 -2
- package/src/objects/CreateUmaInvoiceInput.ts +13 -3
- package/src/objects/CurrencyAmount.ts +13 -2
- package/src/objects/DeclineToSignMessagesInput.ts +9 -2
- package/src/objects/DeclineToSignMessagesOutput.ts +15 -3
- package/src/objects/DeleteApiTokenInput.ts +7 -2
- package/src/objects/DeleteApiTokenOutput.ts +7 -2
- package/src/objects/Deposit.ts +77 -61
- package/src/objects/Entity.ts +2 -2
- package/src/objects/FeeEstimate.ts +12 -3
- package/src/objects/FundNodeInput.ts +9 -3
- package/src/objects/FundNodeOutput.ts +11 -3
- package/src/objects/GraphNode.ts +21 -5
- package/src/objects/Hop.ts +27 -9
- package/src/objects/IdAndSignature.ts +8 -2
- package/src/objects/IncomingPayment.ts +33 -7
- package/src/objects/IncomingPaymentAttempt.ts +21 -5
- package/src/objects/IncomingPaymentToAttemptsConnection.ts +21 -5
- package/src/objects/Invoice.ts +37 -24
- package/src/objects/InvoiceData.ts +21 -6
- package/src/objects/LightningFeeEstimateForInvoiceInput.ts +13 -3
- package/src/objects/LightningFeeEstimateForNodeInput.ts +12 -2
- package/src/objects/LightningFeeEstimateOutput.ts +15 -3
- package/src/objects/LightningTransaction.ts +117 -28
- package/src/objects/LightsparkNode.ts +250 -210
- package/src/objects/LightsparkNodeOwner.ts +35 -4
- package/src/objects/LightsparkNodeToChannelsConnection.ts +17 -4
- package/src/objects/LightsparkNodeWithOSK.ts +66 -17
- package/src/objects/LightsparkNodeWithRemoteSigning.ts +62 -15
- package/src/objects/Node.ts +209 -68
- package/src/objects/NodeAddress.ts +8 -2
- package/src/objects/NodeToAddressesConnection.ts +13 -3
- package/src/objects/OnChainTransaction.ts +156 -44
- package/src/objects/OutgoingPayment.ts +53 -14
- package/src/objects/OutgoingPaymentAttempt.ts +37 -8
- package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +18 -5
- package/src/objects/OutgoingPaymentToAttemptsConnection.ts +17 -4
- package/src/objects/OutgoingPaymentsForInvoiceQueryInput.ts +12 -3
- package/src/objects/OutgoingPaymentsForInvoiceQueryOutput.ts +11 -2
- package/src/objects/PageInfo.ts +14 -6
- package/src/objects/PayInvoiceInput.ts +12 -3
- package/src/objects/PayInvoiceOutput.ts +7 -2
- package/src/objects/PayUmaInvoiceInput.ts +12 -3
- package/src/objects/PaymentRequest.ts +27 -5
- package/src/objects/PaymentRequestData.ts +27 -4
- package/src/objects/PostTransactionData.ts +12 -3
- package/src/objects/RegisterPaymentInput.ts +10 -2
- package/src/objects/RegisterPaymentOutput.ts +9 -2
- package/src/objects/ReleaseChannelPerCommitmentSecretInput.ts +13 -2
- package/src/objects/ReleaseChannelPerCommitmentSecretOutput.ts +9 -2
- package/src/objects/ReleasePaymentPreimageInput.ts +10 -2
- package/src/objects/ReleasePaymentPreimageOutput.ts +9 -2
- package/src/objects/RequestWithdrawalInput.ts +12 -2
- package/src/objects/RequestWithdrawalOutput.ts +9 -2
- package/src/objects/RichText.ts +7 -2
- package/src/objects/RoutingTransaction.ts +62 -41
- package/src/objects/ScreenNodeInput.ts +8 -2
- package/src/objects/ScreenNodeOutput.ts +7 -2
- package/src/objects/Secret.ts +8 -2
- package/src/objects/SendPaymentInput.ts +11 -2
- package/src/objects/SendPaymentOutput.ts +7 -2
- package/src/objects/SetInvoicePaymentHashInput.ts +12 -3
- package/src/objects/SetInvoicePaymentHashOutput.ts +9 -2
- package/src/objects/SignInvoiceInput.ts +9 -2
- package/src/objects/SignInvoiceOutput.ts +7 -2
- package/src/objects/SignMessagesInput.ts +13 -3
- package/src/objects/SignMessagesOutput.ts +13 -3
- package/src/objects/Signable.ts +10 -3
- package/src/objects/SignablePayload.ts +18 -5
- package/src/objects/Transaction.ts +206 -9
- package/src/objects/TransactionFailures.ts +11 -4
- package/src/objects/UpdateChannelPerCommitmentPointInput.ts +13 -2
- package/src/objects/UpdateChannelPerCommitmentPointOutput.ts +9 -2
- package/src/objects/UpdateNodeSharedSecretInput.ts +10 -2
- package/src/objects/UpdateNodeSharedSecretOutput.ts +9 -2
- package/src/objects/Wallet.ts +22 -5
- package/src/objects/WalletToPaymentRequestsConnection.ts +21 -5
- package/src/objects/WalletToTransactionsConnection.ts +16 -5
- package/src/objects/Withdrawal.ts +77 -61
- package/src/objects/WithdrawalRequest.ts +25 -4
- package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +19 -4
- package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +19 -4
- package/src/objects/index.ts +5 -2
- package/src/tests/serialization.test.ts +18 -0
|
@@ -4,25 +4,33 @@ import { type Query } from "@lightsparkdev/core";
|
|
|
4
4
|
import autoBind from "auto-bind";
|
|
5
5
|
import type LightsparkClient from "../client.js";
|
|
6
6
|
import type Balances from "./Balances.js";
|
|
7
|
-
import { BalancesFromJson } from "./Balances.js";
|
|
7
|
+
import { BalancesFromJson, BalancesToJson } from "./Balances.js";
|
|
8
8
|
import BitcoinNetwork from "./BitcoinNetwork.js";
|
|
9
9
|
import type BlockchainBalance from "./BlockchainBalance.js";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
BlockchainBalanceFromJson,
|
|
12
|
+
BlockchainBalanceToJson,
|
|
13
|
+
} from "./BlockchainBalance.js";
|
|
11
14
|
import type ChannelStatus from "./ChannelStatus.js";
|
|
12
15
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
13
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CurrencyAmountFromJson,
|
|
18
|
+
CurrencyAmountToJson,
|
|
19
|
+
} from "./CurrencyAmount.js";
|
|
20
|
+
import type Entity from "./Entity.js";
|
|
14
21
|
import type LightsparkNode from "./LightsparkNode.js";
|
|
15
22
|
import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
|
|
16
23
|
import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
|
|
17
24
|
import { LightsparkNodeToChannelsConnectionFromJson } from "./LightsparkNodeToChannelsConnection.js";
|
|
25
|
+
import type Node from "./Node.js";
|
|
18
26
|
import type NodeAddressType from "./NodeAddressType.js";
|
|
19
27
|
import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
|
|
20
28
|
import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
|
|
21
29
|
import type Secret from "./Secret.js";
|
|
22
|
-
import { SecretFromJson } from "./Secret.js";
|
|
30
|
+
import { SecretFromJson, SecretToJson } from "./Secret.js";
|
|
23
31
|
|
|
24
32
|
/** This is a Lightspark node with OSK. **/
|
|
25
|
-
class LightsparkNodeWithOSK implements LightsparkNode {
|
|
33
|
+
class LightsparkNodeWithOSK implements LightsparkNode, Node, Entity {
|
|
26
34
|
constructor(
|
|
27
35
|
public readonly id: string,
|
|
28
36
|
public readonly createdAt: string,
|
|
@@ -32,18 +40,18 @@ class LightsparkNodeWithOSK implements LightsparkNode {
|
|
|
32
40
|
public readonly ownerId: string,
|
|
33
41
|
public readonly umaPrescreeningUtxos: string[],
|
|
34
42
|
public readonly typename: string,
|
|
35
|
-
public readonly alias?: string,
|
|
36
|
-
public readonly color?: string,
|
|
37
|
-
public readonly conductivity?: number,
|
|
38
|
-
public readonly publicKey?: string,
|
|
39
|
-
public readonly status?: LightsparkNodeStatus,
|
|
40
|
-
public readonly totalBalance?: CurrencyAmount,
|
|
41
|
-
public readonly totalLocalBalance?: CurrencyAmount,
|
|
42
|
-
public readonly localBalance?: CurrencyAmount,
|
|
43
|
-
public readonly remoteBalance?: CurrencyAmount,
|
|
44
|
-
public readonly blockchainBalance?: BlockchainBalance,
|
|
45
|
-
public readonly balances?: Balances,
|
|
46
|
-
public readonly encryptedSigningPrivateKey?: Secret,
|
|
43
|
+
public readonly alias?: string | undefined,
|
|
44
|
+
public readonly color?: string | undefined,
|
|
45
|
+
public readonly conductivity?: number | undefined,
|
|
46
|
+
public readonly publicKey?: string | undefined,
|
|
47
|
+
public readonly status?: LightsparkNodeStatus | undefined,
|
|
48
|
+
public readonly totalBalance?: CurrencyAmount | undefined,
|
|
49
|
+
public readonly totalLocalBalance?: CurrencyAmount | undefined,
|
|
50
|
+
public readonly localBalance?: CurrencyAmount | undefined,
|
|
51
|
+
public readonly remoteBalance?: CurrencyAmount | undefined,
|
|
52
|
+
public readonly blockchainBalance?: BlockchainBalance | undefined,
|
|
53
|
+
public readonly balances?: Balances | undefined,
|
|
54
|
+
public readonly encryptedSigningPrivateKey?: Secret | undefined,
|
|
47
55
|
) {
|
|
48
56
|
autoBind(this);
|
|
49
57
|
}
|
|
@@ -232,6 +240,47 @@ ${FRAGMENT}
|
|
|
232
240
|
LightsparkNodeWithOSKFromJson(data.entity),
|
|
233
241
|
};
|
|
234
242
|
}
|
|
243
|
+
|
|
244
|
+
public toJson() {
|
|
245
|
+
return {
|
|
246
|
+
__typename: "LightsparkNodeWithOSK",
|
|
247
|
+
lightspark_node_with_o_s_k_id: this.id,
|
|
248
|
+
lightspark_node_with_o_s_k_created_at: this.createdAt,
|
|
249
|
+
lightspark_node_with_o_s_k_updated_at: this.updatedAt,
|
|
250
|
+
lightspark_node_with_o_s_k_alias: this.alias,
|
|
251
|
+
lightspark_node_with_o_s_k_bitcoin_network: this.bitcoinNetwork,
|
|
252
|
+
lightspark_node_with_o_s_k_color: this.color,
|
|
253
|
+
lightspark_node_with_o_s_k_conductivity: this.conductivity,
|
|
254
|
+
lightspark_node_with_o_s_k_display_name: this.displayName,
|
|
255
|
+
lightspark_node_with_o_s_k_public_key: this.publicKey,
|
|
256
|
+
lightspark_node_with_o_s_k_owner: { id: this.ownerId },
|
|
257
|
+
lightspark_node_with_o_s_k_status: this.status,
|
|
258
|
+
lightspark_node_with_o_s_k_total_balance: this.totalBalance
|
|
259
|
+
? CurrencyAmountToJson(this.totalBalance)
|
|
260
|
+
: undefined,
|
|
261
|
+
lightspark_node_with_o_s_k_total_local_balance: this.totalLocalBalance
|
|
262
|
+
? CurrencyAmountToJson(this.totalLocalBalance)
|
|
263
|
+
: undefined,
|
|
264
|
+
lightspark_node_with_o_s_k_local_balance: this.localBalance
|
|
265
|
+
? CurrencyAmountToJson(this.localBalance)
|
|
266
|
+
: undefined,
|
|
267
|
+
lightspark_node_with_o_s_k_remote_balance: this.remoteBalance
|
|
268
|
+
? CurrencyAmountToJson(this.remoteBalance)
|
|
269
|
+
: undefined,
|
|
270
|
+
lightspark_node_with_o_s_k_blockchain_balance: this.blockchainBalance
|
|
271
|
+
? BlockchainBalanceToJson(this.blockchainBalance)
|
|
272
|
+
: undefined,
|
|
273
|
+
lightspark_node_with_o_s_k_uma_prescreening_utxos:
|
|
274
|
+
this.umaPrescreeningUtxos,
|
|
275
|
+
lightspark_node_with_o_s_k_balances: this.balances
|
|
276
|
+
? BalancesToJson(this.balances)
|
|
277
|
+
: undefined,
|
|
278
|
+
lightspark_node_with_o_s_k_encrypted_signing_private_key: this
|
|
279
|
+
.encryptedSigningPrivateKey
|
|
280
|
+
? SecretToJson(this.encryptedSigningPrivateKey)
|
|
281
|
+
: undefined,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
235
284
|
}
|
|
236
285
|
|
|
237
286
|
export const LightsparkNodeWithOSKFromJson = (
|
|
@@ -4,23 +4,31 @@ import { type Query } from "@lightsparkdev/core";
|
|
|
4
4
|
import autoBind from "auto-bind";
|
|
5
5
|
import type LightsparkClient from "../client.js";
|
|
6
6
|
import type Balances from "./Balances.js";
|
|
7
|
-
import { BalancesFromJson } from "./Balances.js";
|
|
7
|
+
import { BalancesFromJson, BalancesToJson } from "./Balances.js";
|
|
8
8
|
import BitcoinNetwork from "./BitcoinNetwork.js";
|
|
9
9
|
import type BlockchainBalance from "./BlockchainBalance.js";
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
BlockchainBalanceFromJson,
|
|
12
|
+
BlockchainBalanceToJson,
|
|
13
|
+
} from "./BlockchainBalance.js";
|
|
11
14
|
import type ChannelStatus from "./ChannelStatus.js";
|
|
12
15
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
13
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CurrencyAmountFromJson,
|
|
18
|
+
CurrencyAmountToJson,
|
|
19
|
+
} from "./CurrencyAmount.js";
|
|
20
|
+
import type Entity from "./Entity.js";
|
|
14
21
|
import type LightsparkNode from "./LightsparkNode.js";
|
|
15
22
|
import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
|
|
16
23
|
import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
|
|
17
24
|
import { LightsparkNodeToChannelsConnectionFromJson } from "./LightsparkNodeToChannelsConnection.js";
|
|
25
|
+
import type Node from "./Node.js";
|
|
18
26
|
import type NodeAddressType from "./NodeAddressType.js";
|
|
19
27
|
import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
|
|
20
28
|
import { NodeToAddressesConnectionFromJson } from "./NodeToAddressesConnection.js";
|
|
21
29
|
|
|
22
30
|
/** This is a Lightspark node with remote signing. **/
|
|
23
|
-
class LightsparkNodeWithRemoteSigning implements LightsparkNode {
|
|
31
|
+
class LightsparkNodeWithRemoteSigning implements LightsparkNode, Node, Entity {
|
|
24
32
|
constructor(
|
|
25
33
|
public readonly id: string,
|
|
26
34
|
public readonly createdAt: string,
|
|
@@ -30,17 +38,17 @@ class LightsparkNodeWithRemoteSigning implements LightsparkNode {
|
|
|
30
38
|
public readonly ownerId: string,
|
|
31
39
|
public readonly umaPrescreeningUtxos: string[],
|
|
32
40
|
public readonly typename: string,
|
|
33
|
-
public readonly alias?: string,
|
|
34
|
-
public readonly color?: string,
|
|
35
|
-
public readonly conductivity?: number,
|
|
36
|
-
public readonly publicKey?: string,
|
|
37
|
-
public readonly status?: LightsparkNodeStatus,
|
|
38
|
-
public readonly totalBalance?: CurrencyAmount,
|
|
39
|
-
public readonly totalLocalBalance?: CurrencyAmount,
|
|
40
|
-
public readonly localBalance?: CurrencyAmount,
|
|
41
|
-
public readonly remoteBalance?: CurrencyAmount,
|
|
42
|
-
public readonly blockchainBalance?: BlockchainBalance,
|
|
43
|
-
public readonly balances?: Balances,
|
|
41
|
+
public readonly alias?: string | undefined,
|
|
42
|
+
public readonly color?: string | undefined,
|
|
43
|
+
public readonly conductivity?: number | undefined,
|
|
44
|
+
public readonly publicKey?: string | undefined,
|
|
45
|
+
public readonly status?: LightsparkNodeStatus | undefined,
|
|
46
|
+
public readonly totalBalance?: CurrencyAmount | undefined,
|
|
47
|
+
public readonly totalLocalBalance?: CurrencyAmount | undefined,
|
|
48
|
+
public readonly localBalance?: CurrencyAmount | undefined,
|
|
49
|
+
public readonly remoteBalance?: CurrencyAmount | undefined,
|
|
50
|
+
public readonly blockchainBalance?: BlockchainBalance | undefined,
|
|
51
|
+
public readonly balances?: Balances | undefined,
|
|
44
52
|
) {
|
|
45
53
|
autoBind(this);
|
|
46
54
|
}
|
|
@@ -229,6 +237,45 @@ ${FRAGMENT}
|
|
|
229
237
|
LightsparkNodeWithRemoteSigningFromJson(data.entity),
|
|
230
238
|
};
|
|
231
239
|
}
|
|
240
|
+
|
|
241
|
+
public toJson() {
|
|
242
|
+
return {
|
|
243
|
+
__typename: "LightsparkNodeWithRemoteSigning",
|
|
244
|
+
lightspark_node_with_remote_signing_id: this.id,
|
|
245
|
+
lightspark_node_with_remote_signing_created_at: this.createdAt,
|
|
246
|
+
lightspark_node_with_remote_signing_updated_at: this.updatedAt,
|
|
247
|
+
lightspark_node_with_remote_signing_alias: this.alias,
|
|
248
|
+
lightspark_node_with_remote_signing_bitcoin_network: this.bitcoinNetwork,
|
|
249
|
+
lightspark_node_with_remote_signing_color: this.color,
|
|
250
|
+
lightspark_node_with_remote_signing_conductivity: this.conductivity,
|
|
251
|
+
lightspark_node_with_remote_signing_display_name: this.displayName,
|
|
252
|
+
lightspark_node_with_remote_signing_public_key: this.publicKey,
|
|
253
|
+
lightspark_node_with_remote_signing_owner: { id: this.ownerId },
|
|
254
|
+
lightspark_node_with_remote_signing_status: this.status,
|
|
255
|
+
lightspark_node_with_remote_signing_total_balance: this.totalBalance
|
|
256
|
+
? CurrencyAmountToJson(this.totalBalance)
|
|
257
|
+
: undefined,
|
|
258
|
+
lightspark_node_with_remote_signing_total_local_balance: this
|
|
259
|
+
.totalLocalBalance
|
|
260
|
+
? CurrencyAmountToJson(this.totalLocalBalance)
|
|
261
|
+
: undefined,
|
|
262
|
+
lightspark_node_with_remote_signing_local_balance: this.localBalance
|
|
263
|
+
? CurrencyAmountToJson(this.localBalance)
|
|
264
|
+
: undefined,
|
|
265
|
+
lightspark_node_with_remote_signing_remote_balance: this.remoteBalance
|
|
266
|
+
? CurrencyAmountToJson(this.remoteBalance)
|
|
267
|
+
: undefined,
|
|
268
|
+
lightspark_node_with_remote_signing_blockchain_balance: this
|
|
269
|
+
.blockchainBalance
|
|
270
|
+
? BlockchainBalanceToJson(this.blockchainBalance)
|
|
271
|
+
: undefined,
|
|
272
|
+
lightspark_node_with_remote_signing_uma_prescreening_utxos:
|
|
273
|
+
this.umaPrescreeningUtxos,
|
|
274
|
+
lightspark_node_with_remote_signing_balances: this.balances
|
|
275
|
+
? BalancesToJson(this.balances)
|
|
276
|
+
: undefined,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
232
279
|
}
|
|
233
280
|
|
|
234
281
|
export const LightsparkNodeWithRemoteSigningFromJson = (
|
package/src/objects/Node.ts
CHANGED
|
@@ -1,87 +1,80 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
3
|
import { LightsparkException, type Query } from "@lightsparkdev/core";
|
|
4
|
-
import autoBind from "auto-bind";
|
|
5
4
|
import type LightsparkClient from "../client.js";
|
|
6
|
-
import { BalancesFromJson } from "./Balances.js";
|
|
5
|
+
import { BalancesFromJson, BalancesToJson } from "./Balances.js";
|
|
7
6
|
import BitcoinNetwork from "./BitcoinNetwork.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {
|
|
8
|
+
BlockchainBalanceFromJson,
|
|
9
|
+
BlockchainBalanceToJson,
|
|
10
|
+
} from "./BlockchainBalance.js";
|
|
11
|
+
import {
|
|
12
|
+
CurrencyAmountFromJson,
|
|
13
|
+
CurrencyAmountToJson,
|
|
14
|
+
} from "./CurrencyAmount.js";
|
|
11
15
|
import GraphNode from "./GraphNode.js";
|
|
12
16
|
import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
|
|
13
17
|
import LightsparkNodeWithOSK from "./LightsparkNodeWithOSK.js";
|
|
14
18
|
import LightsparkNodeWithRemoteSigning from "./LightsparkNodeWithRemoteSigning.js";
|
|
15
19
|
import type NodeAddressType from "./NodeAddressType.js";
|
|
16
20
|
import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
|
|
17
|
-
import {
|
|
18
|
-
import { SecretFromJson } from "./Secret.js";
|
|
21
|
+
import { SecretFromJson, SecretToJson } from "./Secret.js";
|
|
19
22
|
|
|
20
23
|
/** This object is an interface representing a Lightning Node on the Lightning Network, and could either be a Lightspark node or a node managed by a third party. **/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
public readonly displayName: string,
|
|
28
|
-
public readonly typename: string,
|
|
29
|
-
public readonly alias?: string,
|
|
30
|
-
public readonly color?: string,
|
|
31
|
-
public readonly conductivity?: number,
|
|
32
|
-
public readonly publicKey?: string,
|
|
33
|
-
) {
|
|
34
|
-
autoBind(this);
|
|
35
|
-
}
|
|
24
|
+
interface Node {
|
|
25
|
+
/**
|
|
26
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
27
|
+
* string.
|
|
28
|
+
**/
|
|
29
|
+
id: string;
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
first: number | undefined = undefined,
|
|
40
|
-
types: NodeAddressType[] | undefined = undefined,
|
|
41
|
-
): Promise<NodeToAddressesConnection> {
|
|
42
|
-
return (await client.executeRawQuery({
|
|
43
|
-
queryPayload: `
|
|
44
|
-
query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) {
|
|
45
|
-
entity(id: $entity_id) {
|
|
46
|
-
... on Node {
|
|
47
|
-
addresses(, first: $first, types: $types) {
|
|
48
|
-
__typename
|
|
49
|
-
node_to_addresses_connection_count: count
|
|
50
|
-
node_to_addresses_connection_entities: entities {
|
|
51
|
-
__typename
|
|
52
|
-
node_address_address: address
|
|
53
|
-
node_address_type: type
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
variables: { entity_id: this.id, first: first, types: types },
|
|
61
|
-
constructObject: (json) => {
|
|
62
|
-
const connection = json["entity"]["addresses"];
|
|
63
|
-
return NodeToAddressesConnectionFromJson(connection);
|
|
64
|
-
},
|
|
65
|
-
}))!;
|
|
66
|
-
}
|
|
31
|
+
/** The date and time when the entity was first created. **/
|
|
32
|
+
createdAt: string;
|
|
67
33
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
queryPayload: `
|
|
71
|
-
query GetNode($id: ID!) {
|
|
72
|
-
entity(id: $id) {
|
|
73
|
-
... on Node {
|
|
74
|
-
...NodeFragment
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
34
|
+
/** The date and time when the entity was last updated. **/
|
|
35
|
+
updatedAt: string;
|
|
78
36
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
37
|
+
/** The Bitcoin Network this node is deployed in. **/
|
|
38
|
+
bitcoinNetwork: BitcoinNetwork;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The name of this node in the network. It will be the most human-readable option possible, depending
|
|
42
|
+
* on the data available for this node.
|
|
43
|
+
**/
|
|
44
|
+
displayName: string;
|
|
45
|
+
|
|
46
|
+
/** The typename of the object **/
|
|
47
|
+
typename: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A name that identifies the node. It has no importance in terms of operating the node, it is just a
|
|
51
|
+
* way to identify and search for commercial services or popular nodes. This alias can be changed at
|
|
52
|
+
* any time by the node operator.
|
|
53
|
+
**/
|
|
54
|
+
alias?: string | undefined;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It
|
|
58
|
+
* has no importance in terms of operating the node, it is just a way to visually differentiate nodes.
|
|
59
|
+
* That color can be changed at any time by the node operator.
|
|
60
|
+
**/
|
|
61
|
+
color?: string | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A summary metric used to capture how well positioned a node is to send, receive, or route
|
|
65
|
+
* transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be
|
|
66
|
+
* capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
|
|
67
|
+
**/
|
|
68
|
+
conductivity?: number | undefined;
|
|
69
|
+
|
|
70
|
+
/** The public key of this node. It acts as a unique identifier of this node in the Lightning Network. **/
|
|
71
|
+
publicKey?: string | undefined;
|
|
72
|
+
|
|
73
|
+
getAddresses(
|
|
74
|
+
client: LightsparkClient,
|
|
75
|
+
first?: number | undefined,
|
|
76
|
+
types?: NodeAddressType[] | undefined,
|
|
77
|
+
): Promise<NodeToAddressesConnection>;
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
export const NodeFromJson = (obj: any): Node => {
|
|
@@ -210,6 +203,136 @@ export const NodeFromJson = (obj: any): Node => {
|
|
|
210
203
|
`Couldn't find a concrete type for interface Node corresponding to the typename=${obj["__typename"]}`,
|
|
211
204
|
);
|
|
212
205
|
};
|
|
206
|
+
export const NodeToJson = (obj: Node): any => {
|
|
207
|
+
if (obj.typename == "GraphNode") {
|
|
208
|
+
const graphNode = obj as GraphNode;
|
|
209
|
+
return {
|
|
210
|
+
__typename: "GraphNode",
|
|
211
|
+
graph_node_id: graphNode.id,
|
|
212
|
+
graph_node_created_at: graphNode.createdAt,
|
|
213
|
+
graph_node_updated_at: graphNode.updatedAt,
|
|
214
|
+
graph_node_alias: graphNode.alias,
|
|
215
|
+
graph_node_bitcoin_network: graphNode.bitcoinNetwork,
|
|
216
|
+
graph_node_color: graphNode.color,
|
|
217
|
+
graph_node_conductivity: graphNode.conductivity,
|
|
218
|
+
graph_node_display_name: graphNode.displayName,
|
|
219
|
+
graph_node_public_key: graphNode.publicKey,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (obj.typename == "LightsparkNodeWithOSK") {
|
|
223
|
+
const lightsparkNodeWithOSK = obj as LightsparkNodeWithOSK;
|
|
224
|
+
return {
|
|
225
|
+
__typename: "LightsparkNodeWithOSK",
|
|
226
|
+
lightspark_node_with_o_s_k_id: lightsparkNodeWithOSK.id,
|
|
227
|
+
lightspark_node_with_o_s_k_created_at: lightsparkNodeWithOSK.createdAt,
|
|
228
|
+
lightspark_node_with_o_s_k_updated_at: lightsparkNodeWithOSK.updatedAt,
|
|
229
|
+
lightspark_node_with_o_s_k_alias: lightsparkNodeWithOSK.alias,
|
|
230
|
+
lightspark_node_with_o_s_k_bitcoin_network:
|
|
231
|
+
lightsparkNodeWithOSK.bitcoinNetwork,
|
|
232
|
+
lightspark_node_with_o_s_k_color: lightsparkNodeWithOSK.color,
|
|
233
|
+
lightspark_node_with_o_s_k_conductivity:
|
|
234
|
+
lightsparkNodeWithOSK.conductivity,
|
|
235
|
+
lightspark_node_with_o_s_k_display_name:
|
|
236
|
+
lightsparkNodeWithOSK.displayName,
|
|
237
|
+
lightspark_node_with_o_s_k_public_key: lightsparkNodeWithOSK.publicKey,
|
|
238
|
+
lightspark_node_with_o_s_k_owner: { id: lightsparkNodeWithOSK.ownerId },
|
|
239
|
+
lightspark_node_with_o_s_k_status: lightsparkNodeWithOSK.status,
|
|
240
|
+
lightspark_node_with_o_s_k_total_balance:
|
|
241
|
+
lightsparkNodeWithOSK.totalBalance
|
|
242
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.totalBalance)
|
|
243
|
+
: undefined,
|
|
244
|
+
lightspark_node_with_o_s_k_total_local_balance:
|
|
245
|
+
lightsparkNodeWithOSK.totalLocalBalance
|
|
246
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.totalLocalBalance)
|
|
247
|
+
: undefined,
|
|
248
|
+
lightspark_node_with_o_s_k_local_balance:
|
|
249
|
+
lightsparkNodeWithOSK.localBalance
|
|
250
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.localBalance)
|
|
251
|
+
: undefined,
|
|
252
|
+
lightspark_node_with_o_s_k_remote_balance:
|
|
253
|
+
lightsparkNodeWithOSK.remoteBalance
|
|
254
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.remoteBalance)
|
|
255
|
+
: undefined,
|
|
256
|
+
lightspark_node_with_o_s_k_blockchain_balance:
|
|
257
|
+
lightsparkNodeWithOSK.blockchainBalance
|
|
258
|
+
? BlockchainBalanceToJson(lightsparkNodeWithOSK.blockchainBalance)
|
|
259
|
+
: undefined,
|
|
260
|
+
lightspark_node_with_o_s_k_uma_prescreening_utxos:
|
|
261
|
+
lightsparkNodeWithOSK.umaPrescreeningUtxos,
|
|
262
|
+
lightspark_node_with_o_s_k_balances: lightsparkNodeWithOSK.balances
|
|
263
|
+
? BalancesToJson(lightsparkNodeWithOSK.balances)
|
|
264
|
+
: undefined,
|
|
265
|
+
lightspark_node_with_o_s_k_encrypted_signing_private_key:
|
|
266
|
+
lightsparkNodeWithOSK.encryptedSigningPrivateKey
|
|
267
|
+
? SecretToJson(lightsparkNodeWithOSK.encryptedSigningPrivateKey)
|
|
268
|
+
: undefined,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
if (obj.typename == "LightsparkNodeWithRemoteSigning") {
|
|
272
|
+
const lightsparkNodeWithRemoteSigning =
|
|
273
|
+
obj as LightsparkNodeWithRemoteSigning;
|
|
274
|
+
return {
|
|
275
|
+
__typename: "LightsparkNodeWithRemoteSigning",
|
|
276
|
+
lightspark_node_with_remote_signing_id:
|
|
277
|
+
lightsparkNodeWithRemoteSigning.id,
|
|
278
|
+
lightspark_node_with_remote_signing_created_at:
|
|
279
|
+
lightsparkNodeWithRemoteSigning.createdAt,
|
|
280
|
+
lightspark_node_with_remote_signing_updated_at:
|
|
281
|
+
lightsparkNodeWithRemoteSigning.updatedAt,
|
|
282
|
+
lightspark_node_with_remote_signing_alias:
|
|
283
|
+
lightsparkNodeWithRemoteSigning.alias,
|
|
284
|
+
lightspark_node_with_remote_signing_bitcoin_network:
|
|
285
|
+
lightsparkNodeWithRemoteSigning.bitcoinNetwork,
|
|
286
|
+
lightspark_node_with_remote_signing_color:
|
|
287
|
+
lightsparkNodeWithRemoteSigning.color,
|
|
288
|
+
lightspark_node_with_remote_signing_conductivity:
|
|
289
|
+
lightsparkNodeWithRemoteSigning.conductivity,
|
|
290
|
+
lightspark_node_with_remote_signing_display_name:
|
|
291
|
+
lightsparkNodeWithRemoteSigning.displayName,
|
|
292
|
+
lightspark_node_with_remote_signing_public_key:
|
|
293
|
+
lightsparkNodeWithRemoteSigning.publicKey,
|
|
294
|
+
lightspark_node_with_remote_signing_owner: {
|
|
295
|
+
id: lightsparkNodeWithRemoteSigning.ownerId,
|
|
296
|
+
},
|
|
297
|
+
lightspark_node_with_remote_signing_status:
|
|
298
|
+
lightsparkNodeWithRemoteSigning.status,
|
|
299
|
+
lightspark_node_with_remote_signing_total_balance:
|
|
300
|
+
lightsparkNodeWithRemoteSigning.totalBalance
|
|
301
|
+
? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.totalBalance)
|
|
302
|
+
: undefined,
|
|
303
|
+
lightspark_node_with_remote_signing_total_local_balance:
|
|
304
|
+
lightsparkNodeWithRemoteSigning.totalLocalBalance
|
|
305
|
+
? CurrencyAmountToJson(
|
|
306
|
+
lightsparkNodeWithRemoteSigning.totalLocalBalance,
|
|
307
|
+
)
|
|
308
|
+
: undefined,
|
|
309
|
+
lightspark_node_with_remote_signing_local_balance:
|
|
310
|
+
lightsparkNodeWithRemoteSigning.localBalance
|
|
311
|
+
? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.localBalance)
|
|
312
|
+
: undefined,
|
|
313
|
+
lightspark_node_with_remote_signing_remote_balance:
|
|
314
|
+
lightsparkNodeWithRemoteSigning.remoteBalance
|
|
315
|
+
? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.remoteBalance)
|
|
316
|
+
: undefined,
|
|
317
|
+
lightspark_node_with_remote_signing_blockchain_balance:
|
|
318
|
+
lightsparkNodeWithRemoteSigning.blockchainBalance
|
|
319
|
+
? BlockchainBalanceToJson(
|
|
320
|
+
lightsparkNodeWithRemoteSigning.blockchainBalance,
|
|
321
|
+
)
|
|
322
|
+
: undefined,
|
|
323
|
+
lightspark_node_with_remote_signing_uma_prescreening_utxos:
|
|
324
|
+
lightsparkNodeWithRemoteSigning.umaPrescreeningUtxos,
|
|
325
|
+
lightspark_node_with_remote_signing_balances:
|
|
326
|
+
lightsparkNodeWithRemoteSigning.balances
|
|
327
|
+
? BalancesToJson(lightsparkNodeWithRemoteSigning.balances)
|
|
328
|
+
: undefined,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
throw new LightsparkException(
|
|
332
|
+
"DeserializationError",
|
|
333
|
+
`Couldn't find a concrete type for interface Node corresponding to the typename=${obj.typename}`,
|
|
334
|
+
);
|
|
335
|
+
};
|
|
213
336
|
|
|
214
337
|
export const FRAGMENT = `
|
|
215
338
|
fragment NodeFragment on Node {
|
|
@@ -487,4 +610,22 @@ fragment NodeFragment on Node {
|
|
|
487
610
|
}
|
|
488
611
|
}`;
|
|
489
612
|
|
|
613
|
+
export const getNodeQuery = (id: string): Query<Node> => {
|
|
614
|
+
return {
|
|
615
|
+
queryPayload: `
|
|
616
|
+
query GetNode($id: ID!) {
|
|
617
|
+
entity(id: $id) {
|
|
618
|
+
... on Node {
|
|
619
|
+
...NodeFragment
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
${FRAGMENT}
|
|
625
|
+
`,
|
|
626
|
+
variables: { id },
|
|
627
|
+
constructObject: (data: any) => NodeFromJson(data.entity),
|
|
628
|
+
};
|
|
629
|
+
};
|
|
630
|
+
|
|
490
631
|
export default Node;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import NodeAddressType from "./NodeAddressType.js";
|
|
4
4
|
|
|
5
5
|
/** This object represents the address of a node on the Lightning Network. **/
|
|
6
|
-
|
|
6
|
+
interface NodeAddress {
|
|
7
7
|
/** The string representation of the address. **/
|
|
8
8
|
address: string;
|
|
9
9
|
|
|
10
10
|
/** The type, or protocol, of this address. **/
|
|
11
11
|
type: NodeAddressType;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
export const NodeAddressFromJson = (obj: any): NodeAddress => {
|
|
15
15
|
return {
|
|
@@ -18,6 +18,12 @@ export const NodeAddressFromJson = (obj: any): NodeAddress => {
|
|
|
18
18
|
NodeAddressType[obj["node_address_type"]] ?? NodeAddressType.FUTURE_VALUE,
|
|
19
19
|
} as NodeAddress;
|
|
20
20
|
};
|
|
21
|
+
export const NodeAddressToJson = (obj: NodeAddress): any => {
|
|
22
|
+
return {
|
|
23
|
+
node_address_address: obj.address,
|
|
24
|
+
node_address_type: obj.type,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
21
27
|
|
|
22
28
|
export const FRAGMENT = `
|
|
23
29
|
fragment NodeAddressFragment on NodeAddress {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
3
|
import type NodeAddress from "./NodeAddress.js";
|
|
4
|
-
import { NodeAddressFromJson } from "./NodeAddress.js";
|
|
4
|
+
import { NodeAddressFromJson, NodeAddressToJson } from "./NodeAddress.js";
|
|
5
5
|
|
|
6
6
|
/** A connection between a node and the addresses it has announced for itself on Lightning Network. **/
|
|
7
|
-
|
|
7
|
+
interface NodeToAddressesConnection {
|
|
8
8
|
/**
|
|
9
9
|
* The total count of objects in this connection, using the current filters. It is different from the
|
|
10
10
|
* number of objects returned in the current page (in the `entities` field).
|
|
@@ -13,7 +13,7 @@ type NodeToAddressesConnection = {
|
|
|
13
13
|
|
|
14
14
|
/** The addresses for the current page of this connection. **/
|
|
15
15
|
entities: NodeAddress[];
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
|
|
18
18
|
export const NodeToAddressesConnectionFromJson = (
|
|
19
19
|
obj: any,
|
|
@@ -25,6 +25,16 @@ export const NodeToAddressesConnectionFromJson = (
|
|
|
25
25
|
),
|
|
26
26
|
} as NodeToAddressesConnection;
|
|
27
27
|
};
|
|
28
|
+
export const NodeToAddressesConnectionToJson = (
|
|
29
|
+
obj: NodeToAddressesConnection,
|
|
30
|
+
): any => {
|
|
31
|
+
return {
|
|
32
|
+
node_to_addresses_connection_count: obj.count,
|
|
33
|
+
node_to_addresses_connection_entities: obj.entities.map((e) =>
|
|
34
|
+
NodeAddressToJson(e),
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
28
38
|
|
|
29
39
|
export const FRAGMENT = `
|
|
30
40
|
fragment NodeToAddressesConnectionFragment on NodeToAddressesConnection {
|