@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
|
@@ -1,234 +1,141 @@
|
|
|
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
5
|
import type Balances from "./Balances.js";
|
|
7
|
-
import { BalancesFromJson } from "./Balances.js";
|
|
6
|
+
import { BalancesFromJson, BalancesToJson } from "./Balances.js";
|
|
8
7
|
import BitcoinNetwork from "./BitcoinNetwork.js";
|
|
9
8
|
import type BlockchainBalance from "./BlockchainBalance.js";
|
|
10
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
BlockchainBalanceFromJson,
|
|
11
|
+
BlockchainBalanceToJson,
|
|
12
|
+
} from "./BlockchainBalance.js";
|
|
11
13
|
import type ChannelStatus from "./ChannelStatus.js";
|
|
12
14
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
13
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
CurrencyAmountFromJson,
|
|
17
|
+
CurrencyAmountToJson,
|
|
18
|
+
} from "./CurrencyAmount.js";
|
|
14
19
|
import LightsparkNodeStatus from "./LightsparkNodeStatus.js";
|
|
15
20
|
import type LightsparkNodeToChannelsConnection from "./LightsparkNodeToChannelsConnection.js";
|
|
16
|
-
import { LightsparkNodeToChannelsConnectionFromJson } from "./LightsparkNodeToChannelsConnection.js";
|
|
17
21
|
import LightsparkNodeWithOSK from "./LightsparkNodeWithOSK.js";
|
|
18
22
|
import LightsparkNodeWithRemoteSigning from "./LightsparkNodeWithRemoteSigning.js";
|
|
19
|
-
import type Node from "./Node.js";
|
|
20
23
|
import type NodeAddressType from "./NodeAddressType.js";
|
|
21
24
|
import type NodeToAddressesConnection from "./NodeToAddressesConnection.js";
|
|
22
|
-
import {
|
|
23
|
-
import { SecretFromJson } from "./Secret.js";
|
|
25
|
+
import { SecretFromJson, SecretToJson } from "./Secret.js";
|
|
24
26
|
|
|
25
27
|
/** This is an object representing a node managed by Lightspark and owned by the current connected account. This object contains information about the node’s configuration, state, and metadata. **/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
public readonly displayName: string,
|
|
33
|
-
public readonly ownerId: string,
|
|
34
|
-
public readonly umaPrescreeningUtxos: string[],
|
|
35
|
-
public readonly typename: string,
|
|
36
|
-
public readonly alias?: string,
|
|
37
|
-
public readonly color?: string,
|
|
38
|
-
public readonly conductivity?: number,
|
|
39
|
-
public readonly publicKey?: string,
|
|
40
|
-
public readonly status?: LightsparkNodeStatus,
|
|
41
|
-
public readonly totalBalance?: CurrencyAmount,
|
|
42
|
-
public readonly totalLocalBalance?: CurrencyAmount,
|
|
43
|
-
public readonly localBalance?: CurrencyAmount,
|
|
44
|
-
public readonly remoteBalance?: CurrencyAmount,
|
|
45
|
-
public readonly blockchainBalance?: BlockchainBalance,
|
|
46
|
-
public readonly balances?: Balances,
|
|
47
|
-
) {
|
|
48
|
-
autoBind(this);
|
|
49
|
-
}
|
|
28
|
+
interface LightsparkNode {
|
|
29
|
+
/**
|
|
30
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
31
|
+
* string.
|
|
32
|
+
**/
|
|
33
|
+
id: string;
|
|
50
34
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
first: number | undefined = undefined,
|
|
54
|
-
types: NodeAddressType[] | undefined = undefined,
|
|
55
|
-
): Promise<NodeToAddressesConnection> {
|
|
56
|
-
return (await client.executeRawQuery({
|
|
57
|
-
queryPayload: `
|
|
58
|
-
query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) {
|
|
59
|
-
entity(id: $entity_id) {
|
|
60
|
-
... on LightsparkNode {
|
|
61
|
-
addresses(, first: $first, types: $types) {
|
|
62
|
-
__typename
|
|
63
|
-
node_to_addresses_connection_count: count
|
|
64
|
-
node_to_addresses_connection_entities: entities {
|
|
65
|
-
__typename
|
|
66
|
-
node_address_address: address
|
|
67
|
-
node_address_type: type
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
`,
|
|
74
|
-
variables: { entity_id: this.id, first: first, types: types },
|
|
75
|
-
constructObject: (json) => {
|
|
76
|
-
const connection = json["entity"]["addresses"];
|
|
77
|
-
return NodeToAddressesConnectionFromJson(connection);
|
|
78
|
-
},
|
|
79
|
-
}))!;
|
|
80
|
-
}
|
|
35
|
+
/** The date and time when the entity was first created. **/
|
|
36
|
+
createdAt: string;
|
|
81
37
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
first: number | undefined = undefined,
|
|
85
|
-
statuses: ChannelStatus[] | undefined = undefined,
|
|
86
|
-
after: string | undefined = undefined,
|
|
87
|
-
): Promise<LightsparkNodeToChannelsConnection> {
|
|
88
|
-
return (await client.executeRawQuery({
|
|
89
|
-
queryPayload: `
|
|
90
|
-
query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $statuses: [ChannelStatus!], $after: String) {
|
|
91
|
-
entity(id: $entity_id) {
|
|
92
|
-
... on LightsparkNode {
|
|
93
|
-
channels(, first: $first, statuses: $statuses, after: $after) {
|
|
94
|
-
__typename
|
|
95
|
-
lightspark_node_to_channels_connection_count: count
|
|
96
|
-
lightspark_node_to_channels_connection_page_info: page_info {
|
|
97
|
-
__typename
|
|
98
|
-
page_info_has_next_page: has_next_page
|
|
99
|
-
page_info_has_previous_page: has_previous_page
|
|
100
|
-
page_info_start_cursor: start_cursor
|
|
101
|
-
page_info_end_cursor: end_cursor
|
|
102
|
-
}
|
|
103
|
-
lightspark_node_to_channels_connection_entities: entities {
|
|
104
|
-
__typename
|
|
105
|
-
channel_id: id
|
|
106
|
-
channel_created_at: created_at
|
|
107
|
-
channel_updated_at: updated_at
|
|
108
|
-
channel_funding_transaction: funding_transaction {
|
|
109
|
-
id
|
|
110
|
-
}
|
|
111
|
-
channel_capacity: capacity {
|
|
112
|
-
__typename
|
|
113
|
-
currency_amount_original_value: original_value
|
|
114
|
-
currency_amount_original_unit: original_unit
|
|
115
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
116
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
117
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
118
|
-
}
|
|
119
|
-
channel_local_balance: local_balance {
|
|
120
|
-
__typename
|
|
121
|
-
currency_amount_original_value: original_value
|
|
122
|
-
currency_amount_original_unit: original_unit
|
|
123
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
124
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
125
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
126
|
-
}
|
|
127
|
-
channel_local_unsettled_balance: local_unsettled_balance {
|
|
128
|
-
__typename
|
|
129
|
-
currency_amount_original_value: original_value
|
|
130
|
-
currency_amount_original_unit: original_unit
|
|
131
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
132
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
133
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
134
|
-
}
|
|
135
|
-
channel_remote_balance: remote_balance {
|
|
136
|
-
__typename
|
|
137
|
-
currency_amount_original_value: original_value
|
|
138
|
-
currency_amount_original_unit: original_unit
|
|
139
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
140
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
141
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
142
|
-
}
|
|
143
|
-
channel_remote_unsettled_balance: remote_unsettled_balance {
|
|
144
|
-
__typename
|
|
145
|
-
currency_amount_original_value: original_value
|
|
146
|
-
currency_amount_original_unit: original_unit
|
|
147
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
148
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
149
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
150
|
-
}
|
|
151
|
-
channel_unsettled_balance: unsettled_balance {
|
|
152
|
-
__typename
|
|
153
|
-
currency_amount_original_value: original_value
|
|
154
|
-
currency_amount_original_unit: original_unit
|
|
155
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
156
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
157
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
158
|
-
}
|
|
159
|
-
channel_total_balance: total_balance {
|
|
160
|
-
__typename
|
|
161
|
-
currency_amount_original_value: original_value
|
|
162
|
-
currency_amount_original_unit: original_unit
|
|
163
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
164
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
165
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
166
|
-
}
|
|
167
|
-
channel_status: status
|
|
168
|
-
channel_estimated_force_closure_wait_minutes: estimated_force_closure_wait_minutes
|
|
169
|
-
channel_commit_fee: commit_fee {
|
|
170
|
-
__typename
|
|
171
|
-
currency_amount_original_value: original_value
|
|
172
|
-
currency_amount_original_unit: original_unit
|
|
173
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
174
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
175
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
176
|
-
}
|
|
177
|
-
channel_fees: fees {
|
|
178
|
-
__typename
|
|
179
|
-
channel_fees_base_fee: base_fee {
|
|
180
|
-
__typename
|
|
181
|
-
currency_amount_original_value: original_value
|
|
182
|
-
currency_amount_original_unit: original_unit
|
|
183
|
-
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
184
|
-
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
185
|
-
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
186
|
-
}
|
|
187
|
-
channel_fees_fee_rate_per_mil: fee_rate_per_mil
|
|
188
|
-
}
|
|
189
|
-
channel_remote_node: remote_node {
|
|
190
|
-
id
|
|
191
|
-
}
|
|
192
|
-
channel_local_node: local_node {
|
|
193
|
-
id
|
|
194
|
-
}
|
|
195
|
-
channel_short_channel_id: short_channel_id
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
`,
|
|
202
|
-
variables: {
|
|
203
|
-
entity_id: this.id,
|
|
204
|
-
first: first,
|
|
205
|
-
statuses: statuses,
|
|
206
|
-
after: after,
|
|
207
|
-
},
|
|
208
|
-
constructObject: (json) => {
|
|
209
|
-
const connection = json["entity"]["channels"];
|
|
210
|
-
return LightsparkNodeToChannelsConnectionFromJson(connection);
|
|
211
|
-
},
|
|
212
|
-
}))!;
|
|
213
|
-
}
|
|
38
|
+
/** The date and time when the entity was last updated. **/
|
|
39
|
+
updatedAt: string;
|
|
214
40
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
queryPayload: `
|
|
218
|
-
query GetLightsparkNode($id: ID!) {
|
|
219
|
-
entity(id: $id) {
|
|
220
|
-
... on LightsparkNode {
|
|
221
|
-
...LightsparkNodeFragment
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
41
|
+
/** The Bitcoin Network this node is deployed in. **/
|
|
42
|
+
bitcoinNetwork: BitcoinNetwork;
|
|
225
43
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
**/
|
|
48
|
+
displayName: string;
|
|
49
|
+
|
|
50
|
+
/** The owner of this LightsparkNode. **/
|
|
51
|
+
ownerId: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The utxos of the channels that are connected to this node. This is used in uma flow for
|
|
55
|
+
* pre-screening.
|
|
56
|
+
**/
|
|
57
|
+
umaPrescreeningUtxos: string[];
|
|
58
|
+
|
|
59
|
+
/** The typename of the object **/
|
|
60
|
+
typename: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A name that identifies the node. It has no importance in terms of operating the node, it is just a
|
|
64
|
+
* way to identify and search for commercial services or popular nodes. This alias can be changed at
|
|
65
|
+
* any time by the node operator.
|
|
66
|
+
**/
|
|
67
|
+
alias?: string | undefined;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It
|
|
71
|
+
* has no importance in terms of operating the node, it is just a way to visually differentiate nodes.
|
|
72
|
+
* That color can be changed at any time by the node operator.
|
|
73
|
+
**/
|
|
74
|
+
color?: string | undefined;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A summary metric used to capture how well positioned a node is to send, receive, or route
|
|
78
|
+
* transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be
|
|
79
|
+
* capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
|
|
80
|
+
**/
|
|
81
|
+
conductivity?: number | undefined;
|
|
82
|
+
|
|
83
|
+
/** The public key of this node. It acts as a unique identifier of this node in the Lightning Network. **/
|
|
84
|
+
publicKey?: string | undefined;
|
|
85
|
+
|
|
86
|
+
/** The current status of this node. **/
|
|
87
|
+
status?: LightsparkNodeStatus | undefined;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The sum of the balance on the Bitcoin Network, channel balances, and commit fees on this node.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated Use `balances` instead.
|
|
93
|
+
**/
|
|
94
|
+
totalBalance?: CurrencyAmount | undefined;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The total sum of the channel balances (online and offline) on this node.
|
|
98
|
+
*
|
|
99
|
+
* @deprecated Use `balances` instead.
|
|
100
|
+
**/
|
|
101
|
+
totalLocalBalance?: CurrencyAmount | undefined;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The sum of the channel balances (online only) that are available to send on this node.
|
|
105
|
+
*
|
|
106
|
+
* @deprecated Use `balances` instead.
|
|
107
|
+
**/
|
|
108
|
+
localBalance?: CurrencyAmount | undefined;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The sum of the channel balances that are available to receive on this node.
|
|
112
|
+
*
|
|
113
|
+
* @deprecated Use `balances` instead.
|
|
114
|
+
**/
|
|
115
|
+
remoteBalance?: CurrencyAmount | undefined;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The details of the balance of this node on the Bitcoin Network.
|
|
119
|
+
*
|
|
120
|
+
* @deprecated Use `balances` instead.
|
|
121
|
+
**/
|
|
122
|
+
blockchainBalance?: BlockchainBalance | undefined;
|
|
123
|
+
|
|
124
|
+
/** The balances that describe the funds in this node. **/
|
|
125
|
+
balances?: Balances | undefined;
|
|
126
|
+
|
|
127
|
+
getAddresses(
|
|
128
|
+
client: LightsparkClient,
|
|
129
|
+
first?: number | undefined,
|
|
130
|
+
types?: NodeAddressType[] | undefined,
|
|
131
|
+
): Promise<NodeToAddressesConnection>;
|
|
132
|
+
|
|
133
|
+
getChannels(
|
|
134
|
+
client: LightsparkClient,
|
|
135
|
+
first?: number | undefined,
|
|
136
|
+
statuses?: ChannelStatus[] | undefined,
|
|
137
|
+
after?: string | undefined,
|
|
138
|
+
): Promise<LightsparkNodeToChannelsConnection>;
|
|
232
139
|
}
|
|
233
140
|
|
|
234
141
|
export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
|
|
@@ -342,6 +249,121 @@ export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
|
|
|
342
249
|
`Couldn't find a concrete type for interface LightsparkNode corresponding to the typename=${obj["__typename"]}`,
|
|
343
250
|
);
|
|
344
251
|
};
|
|
252
|
+
export const LightsparkNodeToJson = (obj: LightsparkNode): any => {
|
|
253
|
+
if (obj.typename == "LightsparkNodeWithOSK") {
|
|
254
|
+
const lightsparkNodeWithOSK = obj as LightsparkNodeWithOSK;
|
|
255
|
+
return {
|
|
256
|
+
__typename: "LightsparkNodeWithOSK",
|
|
257
|
+
lightspark_node_with_o_s_k_id: lightsparkNodeWithOSK.id,
|
|
258
|
+
lightspark_node_with_o_s_k_created_at: lightsparkNodeWithOSK.createdAt,
|
|
259
|
+
lightspark_node_with_o_s_k_updated_at: lightsparkNodeWithOSK.updatedAt,
|
|
260
|
+
lightspark_node_with_o_s_k_alias: lightsparkNodeWithOSK.alias,
|
|
261
|
+
lightspark_node_with_o_s_k_bitcoin_network:
|
|
262
|
+
lightsparkNodeWithOSK.bitcoinNetwork,
|
|
263
|
+
lightspark_node_with_o_s_k_color: lightsparkNodeWithOSK.color,
|
|
264
|
+
lightspark_node_with_o_s_k_conductivity:
|
|
265
|
+
lightsparkNodeWithOSK.conductivity,
|
|
266
|
+
lightspark_node_with_o_s_k_display_name:
|
|
267
|
+
lightsparkNodeWithOSK.displayName,
|
|
268
|
+
lightspark_node_with_o_s_k_public_key: lightsparkNodeWithOSK.publicKey,
|
|
269
|
+
lightspark_node_with_o_s_k_owner: { id: lightsparkNodeWithOSK.ownerId },
|
|
270
|
+
lightspark_node_with_o_s_k_status: lightsparkNodeWithOSK.status,
|
|
271
|
+
lightspark_node_with_o_s_k_total_balance:
|
|
272
|
+
lightsparkNodeWithOSK.totalBalance
|
|
273
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.totalBalance)
|
|
274
|
+
: undefined,
|
|
275
|
+
lightspark_node_with_o_s_k_total_local_balance:
|
|
276
|
+
lightsparkNodeWithOSK.totalLocalBalance
|
|
277
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.totalLocalBalance)
|
|
278
|
+
: undefined,
|
|
279
|
+
lightspark_node_with_o_s_k_local_balance:
|
|
280
|
+
lightsparkNodeWithOSK.localBalance
|
|
281
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.localBalance)
|
|
282
|
+
: undefined,
|
|
283
|
+
lightspark_node_with_o_s_k_remote_balance:
|
|
284
|
+
lightsparkNodeWithOSK.remoteBalance
|
|
285
|
+
? CurrencyAmountToJson(lightsparkNodeWithOSK.remoteBalance)
|
|
286
|
+
: undefined,
|
|
287
|
+
lightspark_node_with_o_s_k_blockchain_balance:
|
|
288
|
+
lightsparkNodeWithOSK.blockchainBalance
|
|
289
|
+
? BlockchainBalanceToJson(lightsparkNodeWithOSK.blockchainBalance)
|
|
290
|
+
: undefined,
|
|
291
|
+
lightspark_node_with_o_s_k_uma_prescreening_utxos:
|
|
292
|
+
lightsparkNodeWithOSK.umaPrescreeningUtxos,
|
|
293
|
+
lightspark_node_with_o_s_k_balances: lightsparkNodeWithOSK.balances
|
|
294
|
+
? BalancesToJson(lightsparkNodeWithOSK.balances)
|
|
295
|
+
: undefined,
|
|
296
|
+
lightspark_node_with_o_s_k_encrypted_signing_private_key:
|
|
297
|
+
lightsparkNodeWithOSK.encryptedSigningPrivateKey
|
|
298
|
+
? SecretToJson(lightsparkNodeWithOSK.encryptedSigningPrivateKey)
|
|
299
|
+
: undefined,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if (obj.typename == "LightsparkNodeWithRemoteSigning") {
|
|
303
|
+
const lightsparkNodeWithRemoteSigning =
|
|
304
|
+
obj as LightsparkNodeWithRemoteSigning;
|
|
305
|
+
return {
|
|
306
|
+
__typename: "LightsparkNodeWithRemoteSigning",
|
|
307
|
+
lightspark_node_with_remote_signing_id:
|
|
308
|
+
lightsparkNodeWithRemoteSigning.id,
|
|
309
|
+
lightspark_node_with_remote_signing_created_at:
|
|
310
|
+
lightsparkNodeWithRemoteSigning.createdAt,
|
|
311
|
+
lightspark_node_with_remote_signing_updated_at:
|
|
312
|
+
lightsparkNodeWithRemoteSigning.updatedAt,
|
|
313
|
+
lightspark_node_with_remote_signing_alias:
|
|
314
|
+
lightsparkNodeWithRemoteSigning.alias,
|
|
315
|
+
lightspark_node_with_remote_signing_bitcoin_network:
|
|
316
|
+
lightsparkNodeWithRemoteSigning.bitcoinNetwork,
|
|
317
|
+
lightspark_node_with_remote_signing_color:
|
|
318
|
+
lightsparkNodeWithRemoteSigning.color,
|
|
319
|
+
lightspark_node_with_remote_signing_conductivity:
|
|
320
|
+
lightsparkNodeWithRemoteSigning.conductivity,
|
|
321
|
+
lightspark_node_with_remote_signing_display_name:
|
|
322
|
+
lightsparkNodeWithRemoteSigning.displayName,
|
|
323
|
+
lightspark_node_with_remote_signing_public_key:
|
|
324
|
+
lightsparkNodeWithRemoteSigning.publicKey,
|
|
325
|
+
lightspark_node_with_remote_signing_owner: {
|
|
326
|
+
id: lightsparkNodeWithRemoteSigning.ownerId,
|
|
327
|
+
},
|
|
328
|
+
lightspark_node_with_remote_signing_status:
|
|
329
|
+
lightsparkNodeWithRemoteSigning.status,
|
|
330
|
+
lightspark_node_with_remote_signing_total_balance:
|
|
331
|
+
lightsparkNodeWithRemoteSigning.totalBalance
|
|
332
|
+
? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.totalBalance)
|
|
333
|
+
: undefined,
|
|
334
|
+
lightspark_node_with_remote_signing_total_local_balance:
|
|
335
|
+
lightsparkNodeWithRemoteSigning.totalLocalBalance
|
|
336
|
+
? CurrencyAmountToJson(
|
|
337
|
+
lightsparkNodeWithRemoteSigning.totalLocalBalance,
|
|
338
|
+
)
|
|
339
|
+
: undefined,
|
|
340
|
+
lightspark_node_with_remote_signing_local_balance:
|
|
341
|
+
lightsparkNodeWithRemoteSigning.localBalance
|
|
342
|
+
? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.localBalance)
|
|
343
|
+
: undefined,
|
|
344
|
+
lightspark_node_with_remote_signing_remote_balance:
|
|
345
|
+
lightsparkNodeWithRemoteSigning.remoteBalance
|
|
346
|
+
? CurrencyAmountToJson(lightsparkNodeWithRemoteSigning.remoteBalance)
|
|
347
|
+
: undefined,
|
|
348
|
+
lightspark_node_with_remote_signing_blockchain_balance:
|
|
349
|
+
lightsparkNodeWithRemoteSigning.blockchainBalance
|
|
350
|
+
? BlockchainBalanceToJson(
|
|
351
|
+
lightsparkNodeWithRemoteSigning.blockchainBalance,
|
|
352
|
+
)
|
|
353
|
+
: undefined,
|
|
354
|
+
lightspark_node_with_remote_signing_uma_prescreening_utxos:
|
|
355
|
+
lightsparkNodeWithRemoteSigning.umaPrescreeningUtxos,
|
|
356
|
+
lightspark_node_with_remote_signing_balances:
|
|
357
|
+
lightsparkNodeWithRemoteSigning.balances
|
|
358
|
+
? BalancesToJson(lightsparkNodeWithRemoteSigning.balances)
|
|
359
|
+
: undefined,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
throw new LightsparkException(
|
|
363
|
+
"DeserializationError",
|
|
364
|
+
`Couldn't find a concrete type for interface LightsparkNode corresponding to the typename=${obj.typename}`,
|
|
365
|
+
);
|
|
366
|
+
};
|
|
345
367
|
|
|
346
368
|
export const FRAGMENT = `
|
|
347
369
|
fragment LightsparkNodeFragment on LightsparkNode {
|
|
@@ -607,4 +629,22 @@ fragment LightsparkNodeFragment on LightsparkNode {
|
|
|
607
629
|
}
|
|
608
630
|
}`;
|
|
609
631
|
|
|
632
|
+
export const getLightsparkNodeQuery = (id: string): Query<LightsparkNode> => {
|
|
633
|
+
return {
|
|
634
|
+
queryPayload: `
|
|
635
|
+
query GetLightsparkNode($id: ID!) {
|
|
636
|
+
entity(id: $id) {
|
|
637
|
+
... on LightsparkNode {
|
|
638
|
+
...LightsparkNodeFragment
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
${FRAGMENT}
|
|
644
|
+
`,
|
|
645
|
+
variables: { id },
|
|
646
|
+
constructObject: (data: any) => LightsparkNodeFromJson(data.entity),
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
|
|
610
650
|
export default LightsparkNode;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { LightsparkException, type Query } from "@lightsparkdev/core";
|
|
4
4
|
import Account from "./Account.js";
|
|
5
|
-
import { BalancesFromJson } from "./Balances.js";
|
|
6
|
-
import type Entity from "./Entity.js";
|
|
5
|
+
import { BalancesFromJson, BalancesToJson } from "./Balances.js";
|
|
7
6
|
import Wallet from "./Wallet.js";
|
|
8
7
|
import WalletStatus from "./WalletStatus.js";
|
|
9
8
|
|
|
10
9
|
/** This is an object representing the owner of a LightsparkNode. **/
|
|
11
|
-
|
|
10
|
+
interface LightsparkNodeOwner {
|
|
12
11
|
/**
|
|
13
12
|
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
14
13
|
* string.
|
|
@@ -23,7 +22,7 @@ type LightsparkNodeOwner = Entity & {
|
|
|
23
22
|
|
|
24
23
|
/** The typename of the object **/
|
|
25
24
|
typename: string;
|
|
26
|
-
}
|
|
25
|
+
}
|
|
27
26
|
|
|
28
27
|
export const LightsparkNodeOwnerFromJson = (obj: any): LightsparkNodeOwner => {
|
|
29
28
|
if (obj["__typename"] == "Account") {
|
|
@@ -55,6 +54,38 @@ export const LightsparkNodeOwnerFromJson = (obj: any): LightsparkNodeOwner => {
|
|
|
55
54
|
`Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename=${obj["__typename"]}`,
|
|
56
55
|
);
|
|
57
56
|
};
|
|
57
|
+
export const LightsparkNodeOwnerToJson = (obj: LightsparkNodeOwner): any => {
|
|
58
|
+
if (obj.typename == "Account") {
|
|
59
|
+
const account = obj as Account;
|
|
60
|
+
return {
|
|
61
|
+
__typename: "Account",
|
|
62
|
+
account_id: account.id,
|
|
63
|
+
account_created_at: account.createdAt,
|
|
64
|
+
account_updated_at: account.updatedAt,
|
|
65
|
+
account_name: account.name,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (obj.typename == "Wallet") {
|
|
69
|
+
const wallet = obj as Wallet;
|
|
70
|
+
return {
|
|
71
|
+
__typename: "Wallet",
|
|
72
|
+
wallet_id: wallet.id,
|
|
73
|
+
wallet_created_at: wallet.createdAt,
|
|
74
|
+
wallet_updated_at: wallet.updatedAt,
|
|
75
|
+
wallet_last_login_at: wallet.lastLoginAt,
|
|
76
|
+
wallet_balances: wallet.balances
|
|
77
|
+
? BalancesToJson(wallet.balances)
|
|
78
|
+
: undefined,
|
|
79
|
+
wallet_third_party_identifier: wallet.thirdPartyIdentifier,
|
|
80
|
+
wallet_account: { id: wallet.accountId } ?? undefined,
|
|
81
|
+
wallet_status: wallet.status,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
throw new LightsparkException(
|
|
85
|
+
"DeserializationError",
|
|
86
|
+
`Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename=${obj.typename}`,
|
|
87
|
+
);
|
|
88
|
+
};
|
|
58
89
|
|
|
59
90
|
export const FRAGMENT = `
|
|
60
91
|
fragment LightsparkNodeOwnerFragment on LightsparkNodeOwner {
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import type Channel from "./Channel.js";
|
|
4
4
|
import { ChannelFromJson } from "./Channel.js";
|
|
5
|
-
import type Connection from "./Connection.js";
|
|
6
5
|
import type PageInfo from "./PageInfo.js";
|
|
7
|
-
import { PageInfoFromJson } from "./PageInfo.js";
|
|
6
|
+
import { PageInfoFromJson, PageInfoToJson } from "./PageInfo.js";
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
interface LightsparkNodeToChannelsConnection {
|
|
10
9
|
/**
|
|
11
10
|
* The total count of objects in this connection, using the current filters. It is different from the
|
|
12
11
|
* number of objects returned in the current page (in the `entities` field).
|
|
@@ -21,7 +20,7 @@ type LightsparkNodeToChannelsConnection = Connection & {
|
|
|
21
20
|
|
|
22
21
|
/** The typename of the object **/
|
|
23
22
|
typename: string;
|
|
24
|
-
}
|
|
23
|
+
}
|
|
25
24
|
|
|
26
25
|
export const LightsparkNodeToChannelsConnectionFromJson = (
|
|
27
26
|
obj: any,
|
|
@@ -37,6 +36,20 @@ export const LightsparkNodeToChannelsConnectionFromJson = (
|
|
|
37
36
|
typename: "LightsparkNodeToChannelsConnection",
|
|
38
37
|
} as LightsparkNodeToChannelsConnection;
|
|
39
38
|
};
|
|
39
|
+
export const LightsparkNodeToChannelsConnectionToJson = (
|
|
40
|
+
obj: LightsparkNodeToChannelsConnection,
|
|
41
|
+
): any => {
|
|
42
|
+
return {
|
|
43
|
+
__typename: "LightsparkNodeToChannelsConnection",
|
|
44
|
+
lightspark_node_to_channels_connection_count: obj.count,
|
|
45
|
+
lightspark_node_to_channels_connection_page_info: PageInfoToJson(
|
|
46
|
+
obj.pageInfo,
|
|
47
|
+
),
|
|
48
|
+
lightspark_node_to_channels_connection_entities: obj.entities.map((e) =>
|
|
49
|
+
e.toJson(),
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
};
|
|
40
53
|
|
|
41
54
|
export const FRAGMENT = `
|
|
42
55
|
fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsConnection {
|