@lightsparkdev/lightspark-sdk 1.1.7 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/{chunk-5RDIWPBE.js → chunk-D32EWIPX.js} +3 -1
- package/dist/{chunk-7UT6YX37.js → chunk-VTPDR6P4.js} +393 -275
- package/dist/env.cjs +3 -1
- package/dist/env.d.cts +17 -0
- package/dist/env.js +2 -2
- package/dist/{index-d31f4469.d.ts → index-5acc6526.d.ts} +1403 -408
- package/dist/index.cjs +424 -296
- package/dist/index.d.cts +41 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +32 -27
- package/dist/objects/index.cjs +395 -277
- package/dist/objects/index.d.cts +4 -0
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +6 -6
- package/dist/{text-encoding-MDIPJAHL.js → text-encoding-26SMKBAQ.js} +3 -1
- package/package.json +5 -5
- package/src/auth/AccountTokenAuthProvider.ts +15 -11
- package/src/client.ts +7 -6
- package/src/helpers.ts +3 -1
- package/src/objects/Account.ts +21 -2
- package/src/objects/AccountToApiTokensConnection.ts +16 -5
- package/src/objects/AccountToChannelsConnection.ts +14 -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 +92 -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 +49 -5
- package/src/objects/Hop.ts +27 -9
- package/src/objects/IdAndSignature.ts +8 -2
- package/src/objects/IncomingPayment.ts +50 -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 +127 -17
- package/src/objects/LightsparkNodeWithRemoteSigning.ts +122 -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 +72 -14
- package/src/objects/OutgoingPaymentAttempt.ts +63 -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 +34 -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 +42 -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/integration/constants.ts +13 -0
- package/src/tests/integration/general-regtest.test.ts +652 -0
- package/src/tests/serialization.test.ts +21 -0
- package/src/webhooks.ts +1 -1
- package/src/tests/integration/client.test.ts +0 -207
- /package/dist/{chunk-NIMBE7W3.js → chunk-BMTV3EA2.js} +0 -0
|
@@ -4,46 +4,115 @@ 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(
|
|
35
|
+
/**
|
|
36
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
37
|
+
* string.
|
|
38
|
+
**/
|
|
27
39
|
public readonly id: string,
|
|
40
|
+
/** The date and time when the entity was first created. **/
|
|
28
41
|
public readonly createdAt: string,
|
|
42
|
+
/** The date and time when the entity was last updated. **/
|
|
29
43
|
public readonly updatedAt: string,
|
|
44
|
+
/** The Bitcoin Network this node is deployed in. **/
|
|
30
45
|
public readonly bitcoinNetwork: BitcoinNetwork,
|
|
46
|
+
/**
|
|
47
|
+
* The name of this node in the network. It will be the most human-readable option possible, depending
|
|
48
|
+
* on the data available for this node.
|
|
49
|
+
**/
|
|
31
50
|
public readonly displayName: string,
|
|
51
|
+
/** The owner of this LightsparkNode. **/
|
|
32
52
|
public readonly ownerId: string,
|
|
53
|
+
/**
|
|
54
|
+
* The utxos of the channels that are connected to this node. This is used in uma flow for
|
|
55
|
+
* pre-screening.
|
|
56
|
+
**/
|
|
33
57
|
public readonly umaPrescreeningUtxos: string[],
|
|
58
|
+
/** The typename of the object **/
|
|
34
59
|
public readonly typename: string,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
public readonly
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
public readonly
|
|
60
|
+
/**
|
|
61
|
+
* A name that identifies the node. It has no importance in terms of operating the node, it is just a
|
|
62
|
+
* way to identify and search for commercial services or popular nodes. This alias can be changed at
|
|
63
|
+
* any time by the node operator.
|
|
64
|
+
**/
|
|
65
|
+
public readonly alias?: string | undefined,
|
|
66
|
+
/**
|
|
67
|
+
* A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It
|
|
68
|
+
* has no importance in terms of operating the node, it is just a way to visually differentiate nodes.
|
|
69
|
+
* That color can be changed at any time by the node operator.
|
|
70
|
+
**/
|
|
71
|
+
public readonly color?: string | undefined,
|
|
72
|
+
/**
|
|
73
|
+
* A summary metric used to capture how well positioned a node is to send, receive, or route
|
|
74
|
+
* transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be
|
|
75
|
+
* capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
|
|
76
|
+
**/
|
|
77
|
+
public readonly conductivity?: number | undefined,
|
|
78
|
+
/** The public key of this node. It acts as a unique identifier of this node in the Lightning Network. **/
|
|
79
|
+
public readonly publicKey?: string | undefined,
|
|
80
|
+
/** The current status of this node. **/
|
|
81
|
+
public readonly status?: LightsparkNodeStatus | undefined,
|
|
82
|
+
/**
|
|
83
|
+
* The sum of the balance on the Bitcoin Network, channel balances, and commit fees on this node.
|
|
84
|
+
*
|
|
85
|
+
* @deprecated Use `balances` instead.
|
|
86
|
+
**/
|
|
87
|
+
public readonly totalBalance?: CurrencyAmount | undefined,
|
|
88
|
+
/**
|
|
89
|
+
* The total sum of the channel balances (online and offline) on this node.
|
|
90
|
+
*
|
|
91
|
+
* @deprecated Use `balances` instead.
|
|
92
|
+
**/
|
|
93
|
+
public readonly totalLocalBalance?: CurrencyAmount | undefined,
|
|
94
|
+
/**
|
|
95
|
+
* The sum of the channel balances (online only) that are available to send on this node.
|
|
96
|
+
*
|
|
97
|
+
* @deprecated Use `balances` instead.
|
|
98
|
+
**/
|
|
99
|
+
public readonly localBalance?: CurrencyAmount | undefined,
|
|
100
|
+
/**
|
|
101
|
+
* The sum of the channel balances that are available to receive on this node.
|
|
102
|
+
*
|
|
103
|
+
* @deprecated Use `balances` instead.
|
|
104
|
+
**/
|
|
105
|
+
public readonly remoteBalance?: CurrencyAmount | undefined,
|
|
106
|
+
/**
|
|
107
|
+
* The details of the balance of this node on the Bitcoin Network.
|
|
108
|
+
*
|
|
109
|
+
* @deprecated Use `balances` instead.
|
|
110
|
+
**/
|
|
111
|
+
public readonly blockchainBalance?: BlockchainBalance | undefined,
|
|
112
|
+
/** The balances that describe the funds in this node. **/
|
|
113
|
+
public readonly balances?: Balances | undefined,
|
|
114
|
+
/** The private key client is using to sign a GraphQL request which will be verified at server side. **/
|
|
115
|
+
public readonly encryptedSigningPrivateKey?: Secret | undefined,
|
|
47
116
|
) {
|
|
48
117
|
autoBind(this);
|
|
49
118
|
}
|
|
@@ -232,6 +301,47 @@ ${FRAGMENT}
|
|
|
232
301
|
LightsparkNodeWithOSKFromJson(data.entity),
|
|
233
302
|
};
|
|
234
303
|
}
|
|
304
|
+
|
|
305
|
+
public toJson() {
|
|
306
|
+
return {
|
|
307
|
+
__typename: "LightsparkNodeWithOSK",
|
|
308
|
+
lightspark_node_with_o_s_k_id: this.id,
|
|
309
|
+
lightspark_node_with_o_s_k_created_at: this.createdAt,
|
|
310
|
+
lightspark_node_with_o_s_k_updated_at: this.updatedAt,
|
|
311
|
+
lightspark_node_with_o_s_k_alias: this.alias,
|
|
312
|
+
lightspark_node_with_o_s_k_bitcoin_network: this.bitcoinNetwork,
|
|
313
|
+
lightspark_node_with_o_s_k_color: this.color,
|
|
314
|
+
lightspark_node_with_o_s_k_conductivity: this.conductivity,
|
|
315
|
+
lightspark_node_with_o_s_k_display_name: this.displayName,
|
|
316
|
+
lightspark_node_with_o_s_k_public_key: this.publicKey,
|
|
317
|
+
lightspark_node_with_o_s_k_owner: { id: this.ownerId },
|
|
318
|
+
lightspark_node_with_o_s_k_status: this.status,
|
|
319
|
+
lightspark_node_with_o_s_k_total_balance: this.totalBalance
|
|
320
|
+
? CurrencyAmountToJson(this.totalBalance)
|
|
321
|
+
: undefined,
|
|
322
|
+
lightspark_node_with_o_s_k_total_local_balance: this.totalLocalBalance
|
|
323
|
+
? CurrencyAmountToJson(this.totalLocalBalance)
|
|
324
|
+
: undefined,
|
|
325
|
+
lightspark_node_with_o_s_k_local_balance: this.localBalance
|
|
326
|
+
? CurrencyAmountToJson(this.localBalance)
|
|
327
|
+
: undefined,
|
|
328
|
+
lightspark_node_with_o_s_k_remote_balance: this.remoteBalance
|
|
329
|
+
? CurrencyAmountToJson(this.remoteBalance)
|
|
330
|
+
: undefined,
|
|
331
|
+
lightspark_node_with_o_s_k_blockchain_balance: this.blockchainBalance
|
|
332
|
+
? BlockchainBalanceToJson(this.blockchainBalance)
|
|
333
|
+
: undefined,
|
|
334
|
+
lightspark_node_with_o_s_k_uma_prescreening_utxos:
|
|
335
|
+
this.umaPrescreeningUtxos,
|
|
336
|
+
lightspark_node_with_o_s_k_balances: this.balances
|
|
337
|
+
? BalancesToJson(this.balances)
|
|
338
|
+
: undefined,
|
|
339
|
+
lightspark_node_with_o_s_k_encrypted_signing_private_key: this
|
|
340
|
+
.encryptedSigningPrivateKey
|
|
341
|
+
? SecretToJson(this.encryptedSigningPrivateKey)
|
|
342
|
+
: undefined,
|
|
343
|
+
};
|
|
344
|
+
}
|
|
235
345
|
}
|
|
236
346
|
|
|
237
347
|
export const LightsparkNodeWithOSKFromJson = (
|
|
@@ -4,43 +4,111 @@ 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(
|
|
33
|
+
/**
|
|
34
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
35
|
+
* string.
|
|
36
|
+
**/
|
|
25
37
|
public readonly id: string,
|
|
38
|
+
/** The date and time when the entity was first created. **/
|
|
26
39
|
public readonly createdAt: string,
|
|
40
|
+
/** The date and time when the entity was last updated. **/
|
|
27
41
|
public readonly updatedAt: string,
|
|
42
|
+
/** The Bitcoin Network this node is deployed in. **/
|
|
28
43
|
public readonly bitcoinNetwork: BitcoinNetwork,
|
|
44
|
+
/**
|
|
45
|
+
* The name of this node in the network. It will be the most human-readable option possible, depending
|
|
46
|
+
* on the data available for this node.
|
|
47
|
+
**/
|
|
29
48
|
public readonly displayName: string,
|
|
49
|
+
/** The owner of this LightsparkNode. **/
|
|
30
50
|
public readonly ownerId: string,
|
|
51
|
+
/**
|
|
52
|
+
* The utxos of the channels that are connected to this node. This is used in uma flow for
|
|
53
|
+
* pre-screening.
|
|
54
|
+
**/
|
|
31
55
|
public readonly umaPrescreeningUtxos: string[],
|
|
56
|
+
/** The typename of the object **/
|
|
32
57
|
public readonly typename: string,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
public readonly
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
/**
|
|
59
|
+
* A name that identifies the node. It has no importance in terms of operating the node, it is just a
|
|
60
|
+
* way to identify and search for commercial services or popular nodes. This alias can be changed at
|
|
61
|
+
* any time by the node operator.
|
|
62
|
+
**/
|
|
63
|
+
public readonly alias?: string | undefined,
|
|
64
|
+
/**
|
|
65
|
+
* A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It
|
|
66
|
+
* has no importance in terms of operating the node, it is just a way to visually differentiate nodes.
|
|
67
|
+
* That color can be changed at any time by the node operator.
|
|
68
|
+
**/
|
|
69
|
+
public readonly color?: string | undefined,
|
|
70
|
+
/**
|
|
71
|
+
* A summary metric used to capture how well positioned a node is to send, receive, or route
|
|
72
|
+
* transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be
|
|
73
|
+
* capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
|
|
74
|
+
**/
|
|
75
|
+
public readonly conductivity?: number | undefined,
|
|
76
|
+
/** The public key of this node. It acts as a unique identifier of this node in the Lightning Network. **/
|
|
77
|
+
public readonly publicKey?: string | undefined,
|
|
78
|
+
/** The current status of this node. **/
|
|
79
|
+
public readonly status?: LightsparkNodeStatus | undefined,
|
|
80
|
+
/**
|
|
81
|
+
* The sum of the balance on the Bitcoin Network, channel balances, and commit fees on this node.
|
|
82
|
+
*
|
|
83
|
+
* @deprecated Use `balances` instead.
|
|
84
|
+
**/
|
|
85
|
+
public readonly totalBalance?: CurrencyAmount | undefined,
|
|
86
|
+
/**
|
|
87
|
+
* The total sum of the channel balances (online and offline) on this node.
|
|
88
|
+
*
|
|
89
|
+
* @deprecated Use `balances` instead.
|
|
90
|
+
**/
|
|
91
|
+
public readonly totalLocalBalance?: CurrencyAmount | undefined,
|
|
92
|
+
/**
|
|
93
|
+
* The sum of the channel balances (online only) that are available to send on this node.
|
|
94
|
+
*
|
|
95
|
+
* @deprecated Use `balances` instead.
|
|
96
|
+
**/
|
|
97
|
+
public readonly localBalance?: CurrencyAmount | undefined,
|
|
98
|
+
/**
|
|
99
|
+
* The sum of the channel balances that are available to receive on this node.
|
|
100
|
+
*
|
|
101
|
+
* @deprecated Use `balances` instead.
|
|
102
|
+
**/
|
|
103
|
+
public readonly remoteBalance?: CurrencyAmount | undefined,
|
|
104
|
+
/**
|
|
105
|
+
* The details of the balance of this node on the Bitcoin Network.
|
|
106
|
+
*
|
|
107
|
+
* @deprecated Use `balances` instead.
|
|
108
|
+
**/
|
|
109
|
+
public readonly blockchainBalance?: BlockchainBalance | undefined,
|
|
110
|
+
/** The balances that describe the funds in this node. **/
|
|
111
|
+
public readonly balances?: Balances | undefined,
|
|
44
112
|
) {
|
|
45
113
|
autoBind(this);
|
|
46
114
|
}
|
|
@@ -229,6 +297,45 @@ ${FRAGMENT}
|
|
|
229
297
|
LightsparkNodeWithRemoteSigningFromJson(data.entity),
|
|
230
298
|
};
|
|
231
299
|
}
|
|
300
|
+
|
|
301
|
+
public toJson() {
|
|
302
|
+
return {
|
|
303
|
+
__typename: "LightsparkNodeWithRemoteSigning",
|
|
304
|
+
lightspark_node_with_remote_signing_id: this.id,
|
|
305
|
+
lightspark_node_with_remote_signing_created_at: this.createdAt,
|
|
306
|
+
lightspark_node_with_remote_signing_updated_at: this.updatedAt,
|
|
307
|
+
lightspark_node_with_remote_signing_alias: this.alias,
|
|
308
|
+
lightspark_node_with_remote_signing_bitcoin_network: this.bitcoinNetwork,
|
|
309
|
+
lightspark_node_with_remote_signing_color: this.color,
|
|
310
|
+
lightspark_node_with_remote_signing_conductivity: this.conductivity,
|
|
311
|
+
lightspark_node_with_remote_signing_display_name: this.displayName,
|
|
312
|
+
lightspark_node_with_remote_signing_public_key: this.publicKey,
|
|
313
|
+
lightspark_node_with_remote_signing_owner: { id: this.ownerId },
|
|
314
|
+
lightspark_node_with_remote_signing_status: this.status,
|
|
315
|
+
lightspark_node_with_remote_signing_total_balance: this.totalBalance
|
|
316
|
+
? CurrencyAmountToJson(this.totalBalance)
|
|
317
|
+
: undefined,
|
|
318
|
+
lightspark_node_with_remote_signing_total_local_balance: this
|
|
319
|
+
.totalLocalBalance
|
|
320
|
+
? CurrencyAmountToJson(this.totalLocalBalance)
|
|
321
|
+
: undefined,
|
|
322
|
+
lightspark_node_with_remote_signing_local_balance: this.localBalance
|
|
323
|
+
? CurrencyAmountToJson(this.localBalance)
|
|
324
|
+
: undefined,
|
|
325
|
+
lightspark_node_with_remote_signing_remote_balance: this.remoteBalance
|
|
326
|
+
? CurrencyAmountToJson(this.remoteBalance)
|
|
327
|
+
: undefined,
|
|
328
|
+
lightspark_node_with_remote_signing_blockchain_balance: this
|
|
329
|
+
.blockchainBalance
|
|
330
|
+
? BlockchainBalanceToJson(this.blockchainBalance)
|
|
331
|
+
: undefined,
|
|
332
|
+
lightspark_node_with_remote_signing_uma_prescreening_utxos:
|
|
333
|
+
this.umaPrescreeningUtxos,
|
|
334
|
+
lightspark_node_with_remote_signing_balances: this.balances
|
|
335
|
+
? BalancesToJson(this.balances)
|
|
336
|
+
: undefined,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
232
339
|
}
|
|
233
340
|
|
|
234
341
|
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;
|