@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,28 +1,31 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
3
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CurrencyAmountFromJson,
|
|
6
|
+
CurrencyAmountToJson,
|
|
7
|
+
} from "./CurrencyAmount.js";
|
|
5
8
|
|
|
6
9
|
/** This is an object representing a detailed breakdown of the balance for a Lightspark Node. **/
|
|
7
|
-
|
|
10
|
+
interface BlockchainBalance {
|
|
8
11
|
/** The total wallet balance, including unconfirmed UTXOs. **/
|
|
9
|
-
totalBalance?: CurrencyAmount;
|
|
12
|
+
totalBalance?: CurrencyAmount | undefined;
|
|
10
13
|
|
|
11
14
|
/** The balance of confirmed UTXOs in the wallet. **/
|
|
12
|
-
confirmedBalance?: CurrencyAmount;
|
|
15
|
+
confirmedBalance?: CurrencyAmount | undefined;
|
|
13
16
|
|
|
14
17
|
/** The balance of unconfirmed UTXOs in the wallet. **/
|
|
15
|
-
unconfirmedBalance?: CurrencyAmount;
|
|
18
|
+
unconfirmedBalance?: CurrencyAmount | undefined;
|
|
16
19
|
|
|
17
20
|
/** The balance that's locked by an on-chain transaction. **/
|
|
18
|
-
lockedBalance?: CurrencyAmount;
|
|
21
|
+
lockedBalance?: CurrencyAmount | undefined;
|
|
19
22
|
|
|
20
23
|
/** Funds required to be held in reserve for channel bumping. **/
|
|
21
|
-
requiredReserve?: CurrencyAmount;
|
|
24
|
+
requiredReserve?: CurrencyAmount | undefined;
|
|
22
25
|
|
|
23
26
|
/** Funds available for creating channels or withdrawing. **/
|
|
24
|
-
availableBalance?: CurrencyAmount;
|
|
25
|
-
}
|
|
27
|
+
availableBalance?: CurrencyAmount | undefined;
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
export const BlockchainBalanceFromJson = (obj: any): BlockchainBalance => {
|
|
28
31
|
return {
|
|
@@ -46,6 +49,28 @@ export const BlockchainBalanceFromJson = (obj: any): BlockchainBalance => {
|
|
|
46
49
|
: undefined,
|
|
47
50
|
} as BlockchainBalance;
|
|
48
51
|
};
|
|
52
|
+
export const BlockchainBalanceToJson = (obj: BlockchainBalance): any => {
|
|
53
|
+
return {
|
|
54
|
+
blockchain_balance_total_balance: obj.totalBalance
|
|
55
|
+
? CurrencyAmountToJson(obj.totalBalance)
|
|
56
|
+
: undefined,
|
|
57
|
+
blockchain_balance_confirmed_balance: obj.confirmedBalance
|
|
58
|
+
? CurrencyAmountToJson(obj.confirmedBalance)
|
|
59
|
+
: undefined,
|
|
60
|
+
blockchain_balance_unconfirmed_balance: obj.unconfirmedBalance
|
|
61
|
+
? CurrencyAmountToJson(obj.unconfirmedBalance)
|
|
62
|
+
: undefined,
|
|
63
|
+
blockchain_balance_locked_balance: obj.lockedBalance
|
|
64
|
+
? CurrencyAmountToJson(obj.lockedBalance)
|
|
65
|
+
: undefined,
|
|
66
|
+
blockchain_balance_required_reserve: obj.requiredReserve
|
|
67
|
+
? CurrencyAmountToJson(obj.requiredReserve)
|
|
68
|
+
: undefined,
|
|
69
|
+
blockchain_balance_available_balance: obj.availableBalance
|
|
70
|
+
? CurrencyAmountToJson(obj.availableBalance)
|
|
71
|
+
: undefined,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
49
74
|
|
|
50
75
|
export const FRAGMENT = `
|
|
51
76
|
fragment BlockchainBalanceFragment on BlockchainBalance {
|
package/src/objects/Channel.ts
CHANGED
|
@@ -4,37 +4,71 @@ 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 ChannelFees from "./ChannelFees.js";
|
|
7
|
-
import { ChannelFeesFromJson } from "./ChannelFees.js";
|
|
7
|
+
import { ChannelFeesFromJson, ChannelFeesToJson } from "./ChannelFees.js";
|
|
8
8
|
import ChannelStatus from "./ChannelStatus.js";
|
|
9
9
|
import type ChannelToTransactionsConnection from "./ChannelToTransactionsConnection.js";
|
|
10
10
|
import { ChannelToTransactionsConnectionFromJson } from "./ChannelToTransactionsConnection.js";
|
|
11
11
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
CurrencyAmountFromJson,
|
|
14
|
+
CurrencyAmountToJson,
|
|
15
|
+
} from "./CurrencyAmount.js";
|
|
13
16
|
import type Entity from "./Entity.js";
|
|
14
17
|
import type TransactionType from "./TransactionType.js";
|
|
15
18
|
|
|
16
19
|
/** This is an object representing a channel on the Lightning Network. You can retrieve this object to get detailed information on a specific Lightning Network channel. **/
|
|
17
20
|
class Channel implements Entity {
|
|
18
21
|
constructor(
|
|
22
|
+
/**
|
|
23
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
24
|
+
* string.
|
|
25
|
+
**/
|
|
19
26
|
public readonly id: string,
|
|
27
|
+
/** The date and time when the entity was first created. **/
|
|
20
28
|
public readonly createdAt: string,
|
|
29
|
+
/** The date and time when the entity was last updated. **/
|
|
21
30
|
public readonly updatedAt: string,
|
|
31
|
+
/** The local Lightspark node of the channel. **/
|
|
22
32
|
public readonly localNodeId: string,
|
|
33
|
+
/** The typename of the object **/
|
|
23
34
|
public readonly typename: string,
|
|
24
|
-
|
|
25
|
-
public readonly
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
public readonly
|
|
31
|
-
|
|
32
|
-
public readonly
|
|
33
|
-
|
|
34
|
-
public readonly
|
|
35
|
-
|
|
36
|
-
public readonly
|
|
37
|
-
|
|
35
|
+
/** The transaction that funded the channel upon channel opening. **/
|
|
36
|
+
public readonly fundingTransactionId?: string | undefined,
|
|
37
|
+
/**
|
|
38
|
+
* The total amount of funds in this channel, including the channel balance on the local node, the
|
|
39
|
+
* channel balance on the remote node and the on-chain fees to close the channel.
|
|
40
|
+
**/
|
|
41
|
+
public readonly capacity?: CurrencyAmount | undefined,
|
|
42
|
+
/** The channel balance on the local node. **/
|
|
43
|
+
public readonly localBalance?: CurrencyAmount | undefined,
|
|
44
|
+
/** The channel balance on the local node that is currently allocated to in-progress payments. **/
|
|
45
|
+
public readonly localUnsettledBalance?: CurrencyAmount | undefined,
|
|
46
|
+
/** The channel balance on the remote node. **/
|
|
47
|
+
public readonly remoteBalance?: CurrencyAmount | undefined,
|
|
48
|
+
/** The channel balance on the remote node that is currently allocated to in-progress payments. **/
|
|
49
|
+
public readonly remoteUnsettledBalance?: CurrencyAmount | undefined,
|
|
50
|
+
/** The channel balance that is currently allocated to in-progress payments. **/
|
|
51
|
+
public readonly unsettledBalance?: CurrencyAmount | undefined,
|
|
52
|
+
/** The total balance in this channel, including the channel balance on both local and remote nodes. **/
|
|
53
|
+
public readonly totalBalance?: CurrencyAmount | undefined,
|
|
54
|
+
/** The current status of this channel. **/
|
|
55
|
+
public readonly status?: ChannelStatus | undefined,
|
|
56
|
+
/**
|
|
57
|
+
* The estimated time to wait for the channel's hash timelock contract to expire when force closing
|
|
58
|
+
* the channel. It is in unit of minutes.
|
|
59
|
+
**/
|
|
60
|
+
public readonly estimatedForceClosureWaitMinutes?: number | undefined,
|
|
61
|
+
/** The amount to be paid in fees for the current set of commitment transactions. **/
|
|
62
|
+
public readonly commitFee?: CurrencyAmount | undefined,
|
|
63
|
+
/** The fees charged for routing payments through this channel. **/
|
|
64
|
+
public readonly fees?: ChannelFees | undefined,
|
|
65
|
+
/** If known, the remote node of the channel. **/
|
|
66
|
+
public readonly remoteNodeId?: string | undefined,
|
|
67
|
+
/**
|
|
68
|
+
* The unique identifier of the channel on Lightning Network, which is the location in the chain that
|
|
69
|
+
* the channel was confirmed. The format is <block-height>:<tx-index>:<tx-output>.
|
|
70
|
+
**/
|
|
71
|
+
public readonly shortChannelId?: string | undefined,
|
|
38
72
|
) {
|
|
39
73
|
autoBind(this);
|
|
40
74
|
}
|
|
@@ -139,6 +173,48 @@ ${FRAGMENT}
|
|
|
139
173
|
constructObject: (data: any) => ChannelFromJson(data.entity),
|
|
140
174
|
};
|
|
141
175
|
}
|
|
176
|
+
|
|
177
|
+
public toJson() {
|
|
178
|
+
return {
|
|
179
|
+
__typename: "Channel",
|
|
180
|
+
channel_id: this.id,
|
|
181
|
+
channel_created_at: this.createdAt,
|
|
182
|
+
channel_updated_at: this.updatedAt,
|
|
183
|
+
channel_funding_transaction:
|
|
184
|
+
{ id: this.fundingTransactionId } ?? undefined,
|
|
185
|
+
channel_capacity: this.capacity
|
|
186
|
+
? CurrencyAmountToJson(this.capacity)
|
|
187
|
+
: undefined,
|
|
188
|
+
channel_local_balance: this.localBalance
|
|
189
|
+
? CurrencyAmountToJson(this.localBalance)
|
|
190
|
+
: undefined,
|
|
191
|
+
channel_local_unsettled_balance: this.localUnsettledBalance
|
|
192
|
+
? CurrencyAmountToJson(this.localUnsettledBalance)
|
|
193
|
+
: undefined,
|
|
194
|
+
channel_remote_balance: this.remoteBalance
|
|
195
|
+
? CurrencyAmountToJson(this.remoteBalance)
|
|
196
|
+
: undefined,
|
|
197
|
+
channel_remote_unsettled_balance: this.remoteUnsettledBalance
|
|
198
|
+
? CurrencyAmountToJson(this.remoteUnsettledBalance)
|
|
199
|
+
: undefined,
|
|
200
|
+
channel_unsettled_balance: this.unsettledBalance
|
|
201
|
+
? CurrencyAmountToJson(this.unsettledBalance)
|
|
202
|
+
: undefined,
|
|
203
|
+
channel_total_balance: this.totalBalance
|
|
204
|
+
? CurrencyAmountToJson(this.totalBalance)
|
|
205
|
+
: undefined,
|
|
206
|
+
channel_status: this.status,
|
|
207
|
+
channel_estimated_force_closure_wait_minutes:
|
|
208
|
+
this.estimatedForceClosureWaitMinutes,
|
|
209
|
+
channel_commit_fee: this.commitFee
|
|
210
|
+
? CurrencyAmountToJson(this.commitFee)
|
|
211
|
+
: undefined,
|
|
212
|
+
channel_fees: this.fees ? ChannelFeesToJson(this.fees) : undefined,
|
|
213
|
+
channel_remote_node: { id: this.remoteNodeId } ?? undefined,
|
|
214
|
+
channel_local_node: { id: this.localNodeId },
|
|
215
|
+
channel_short_channel_id: this.shortChannelId,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
142
218
|
}
|
|
143
219
|
|
|
144
220
|
export const ChannelFromJson = (obj: any): Channel => {
|
|
@@ -2,70 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
import { type Query } from "@lightsparkdev/core";
|
|
4
4
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
CurrencyAmountFromJson,
|
|
7
|
+
CurrencyAmountToJson,
|
|
8
|
+
} from "./CurrencyAmount.js";
|
|
9
9
|
import TransactionStatus from "./TransactionStatus.js";
|
|
10
10
|
|
|
11
11
|
/** This is an object representing a transaction which closes a channel on the Lightning Network. This operation allocates balances back to the local and remote nodes. **/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
channelId?: string;
|
|
68
|
-
};
|
|
12
|
+
interface ChannelClosingTransaction {
|
|
13
|
+
/**
|
|
14
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
15
|
+
* string.
|
|
16
|
+
**/
|
|
17
|
+
id: string;
|
|
18
|
+
|
|
19
|
+
/** The date and time when this transaction was initiated. **/
|
|
20
|
+
createdAt: string;
|
|
21
|
+
|
|
22
|
+
/** The date and time when the entity was last updated. **/
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
|
|
25
|
+
/** The current status of this transaction. **/
|
|
26
|
+
status: TransactionStatus;
|
|
27
|
+
|
|
28
|
+
/** The amount of money involved in this transaction. **/
|
|
29
|
+
amount: CurrencyAmount;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The height of the block that included this transaction. This will be zero for unconfirmed
|
|
33
|
+
* transactions.
|
|
34
|
+
**/
|
|
35
|
+
blockHeight: number;
|
|
36
|
+
|
|
37
|
+
/** The Bitcoin blockchain addresses this transaction was sent to. **/
|
|
38
|
+
destinationAddresses: string[];
|
|
39
|
+
|
|
40
|
+
/** The typename of the object **/
|
|
41
|
+
typename: string;
|
|
42
|
+
|
|
43
|
+
/** The date and time when this transaction was completed or failed. **/
|
|
44
|
+
resolvedAt?: string | undefined;
|
|
45
|
+
|
|
46
|
+
/** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
|
|
47
|
+
transactionHash?: string | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
|
|
51
|
+
* blockchain.
|
|
52
|
+
**/
|
|
53
|
+
fees?: CurrencyAmount | undefined;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The hash of the block that included this transaction. This will be null for unconfirmed
|
|
57
|
+
* transactions.
|
|
58
|
+
**/
|
|
59
|
+
blockHash?: string | undefined;
|
|
60
|
+
|
|
61
|
+
/** The number of blockchain confirmations for this transaction in real time. **/
|
|
62
|
+
numConfirmations?: number | undefined;
|
|
63
|
+
|
|
64
|
+
/** If known, the channel this transaction is closing. **/
|
|
65
|
+
channelId?: string | undefined;
|
|
66
|
+
}
|
|
69
67
|
|
|
70
68
|
export const ChannelClosingTransactionFromJson = (
|
|
71
69
|
obj: any,
|
|
@@ -92,6 +90,28 @@ export const ChannelClosingTransactionFromJson = (
|
|
|
92
90
|
channelId: obj["channel_closing_transaction_channel"]?.id ?? undefined,
|
|
93
91
|
} as ChannelClosingTransaction;
|
|
94
92
|
};
|
|
93
|
+
export const ChannelClosingTransactionToJson = (
|
|
94
|
+
obj: ChannelClosingTransaction,
|
|
95
|
+
): any => {
|
|
96
|
+
return {
|
|
97
|
+
__typename: "ChannelClosingTransaction",
|
|
98
|
+
channel_closing_transaction_id: obj.id,
|
|
99
|
+
channel_closing_transaction_created_at: obj.createdAt,
|
|
100
|
+
channel_closing_transaction_updated_at: obj.updatedAt,
|
|
101
|
+
channel_closing_transaction_status: obj.status,
|
|
102
|
+
channel_closing_transaction_resolved_at: obj.resolvedAt,
|
|
103
|
+
channel_closing_transaction_amount: CurrencyAmountToJson(obj.amount),
|
|
104
|
+
channel_closing_transaction_transaction_hash: obj.transactionHash,
|
|
105
|
+
channel_closing_transaction_fees: obj.fees
|
|
106
|
+
? CurrencyAmountToJson(obj.fees)
|
|
107
|
+
: undefined,
|
|
108
|
+
channel_closing_transaction_block_hash: obj.blockHash,
|
|
109
|
+
channel_closing_transaction_block_height: obj.blockHeight,
|
|
110
|
+
channel_closing_transaction_destination_addresses: obj.destinationAddresses,
|
|
111
|
+
channel_closing_transaction_num_confirmations: obj.numConfirmations,
|
|
112
|
+
channel_closing_transaction_channel: { id: obj.channelId } ?? undefined,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
95
115
|
|
|
96
116
|
export const FRAGMENT = `
|
|
97
117
|
fragment ChannelClosingTransactionFragment on ChannelClosingTransaction {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
3
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CurrencyAmountFromJson,
|
|
6
|
+
CurrencyAmountToJson,
|
|
7
|
+
} from "./CurrencyAmount.js";
|
|
5
8
|
|
|
6
9
|
/** This represents the fee policies set for a channel on the Lightning Network. **/
|
|
7
|
-
|
|
8
|
-
baseFee?: CurrencyAmount;
|
|
10
|
+
interface ChannelFees {
|
|
11
|
+
baseFee?: CurrencyAmount | undefined;
|
|
9
12
|
|
|
10
|
-
feeRatePerMil?: number;
|
|
11
|
-
}
|
|
13
|
+
feeRatePerMil?: number | undefined;
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
export const ChannelFeesFromJson = (obj: any): ChannelFees => {
|
|
14
17
|
return {
|
|
@@ -18,6 +21,14 @@ export const ChannelFeesFromJson = (obj: any): ChannelFees => {
|
|
|
18
21
|
feeRatePerMil: obj["channel_fees_fee_rate_per_mil"],
|
|
19
22
|
} as ChannelFees;
|
|
20
23
|
};
|
|
24
|
+
export const ChannelFeesToJson = (obj: ChannelFees): any => {
|
|
25
|
+
return {
|
|
26
|
+
channel_fees_base_fee: obj.baseFee
|
|
27
|
+
? CurrencyAmountToJson(obj.baseFee)
|
|
28
|
+
: undefined,
|
|
29
|
+
channel_fees_fee_rate_per_mil: obj.feeRatePerMil,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
21
32
|
|
|
22
33
|
export const FRAGMENT = `
|
|
23
34
|
fragment ChannelFeesFragment on ChannelFees {
|
|
@@ -2,70 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
import { type Query } from "@lightsparkdev/core";
|
|
4
4
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import {
|
|
6
|
+
CurrencyAmountFromJson,
|
|
7
|
+
CurrencyAmountToJson,
|
|
8
|
+
} from "./CurrencyAmount.js";
|
|
9
9
|
import TransactionStatus from "./TransactionStatus.js";
|
|
10
10
|
|
|
11
11
|
/** This is an object representing a transaction which opens a channel on the Lightning Network. This object occurs only for channels funded by the local Lightspark node. **/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
channelId?: string;
|
|
68
|
-
};
|
|
12
|
+
interface ChannelOpeningTransaction {
|
|
13
|
+
/**
|
|
14
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
15
|
+
* string.
|
|
16
|
+
**/
|
|
17
|
+
id: string;
|
|
18
|
+
|
|
19
|
+
/** The date and time when this transaction was initiated. **/
|
|
20
|
+
createdAt: string;
|
|
21
|
+
|
|
22
|
+
/** The date and time when the entity was last updated. **/
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
|
|
25
|
+
/** The current status of this transaction. **/
|
|
26
|
+
status: TransactionStatus;
|
|
27
|
+
|
|
28
|
+
/** The amount of money involved in this transaction. **/
|
|
29
|
+
amount: CurrencyAmount;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The height of the block that included this transaction. This will be zero for unconfirmed
|
|
33
|
+
* transactions.
|
|
34
|
+
**/
|
|
35
|
+
blockHeight: number;
|
|
36
|
+
|
|
37
|
+
/** The Bitcoin blockchain addresses this transaction was sent to. **/
|
|
38
|
+
destinationAddresses: string[];
|
|
39
|
+
|
|
40
|
+
/** The typename of the object **/
|
|
41
|
+
typename: string;
|
|
42
|
+
|
|
43
|
+
/** The date and time when this transaction was completed or failed. **/
|
|
44
|
+
resolvedAt?: string | undefined;
|
|
45
|
+
|
|
46
|
+
/** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
|
|
47
|
+
transactionHash?: string | undefined;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
|
|
51
|
+
* blockchain.
|
|
52
|
+
**/
|
|
53
|
+
fees?: CurrencyAmount | undefined;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The hash of the block that included this transaction. This will be null for unconfirmed
|
|
57
|
+
* transactions.
|
|
58
|
+
**/
|
|
59
|
+
blockHash?: string | undefined;
|
|
60
|
+
|
|
61
|
+
/** The number of blockchain confirmations for this transaction in real time. **/
|
|
62
|
+
numConfirmations?: number | undefined;
|
|
63
|
+
|
|
64
|
+
/** If known, the channel this transaction is opening. **/
|
|
65
|
+
channelId?: string | undefined;
|
|
66
|
+
}
|
|
69
67
|
|
|
70
68
|
export const ChannelOpeningTransactionFromJson = (
|
|
71
69
|
obj: any,
|
|
@@ -92,6 +90,28 @@ export const ChannelOpeningTransactionFromJson = (
|
|
|
92
90
|
channelId: obj["channel_opening_transaction_channel"]?.id ?? undefined,
|
|
93
91
|
} as ChannelOpeningTransaction;
|
|
94
92
|
};
|
|
93
|
+
export const ChannelOpeningTransactionToJson = (
|
|
94
|
+
obj: ChannelOpeningTransaction,
|
|
95
|
+
): any => {
|
|
96
|
+
return {
|
|
97
|
+
__typename: "ChannelOpeningTransaction",
|
|
98
|
+
channel_opening_transaction_id: obj.id,
|
|
99
|
+
channel_opening_transaction_created_at: obj.createdAt,
|
|
100
|
+
channel_opening_transaction_updated_at: obj.updatedAt,
|
|
101
|
+
channel_opening_transaction_status: obj.status,
|
|
102
|
+
channel_opening_transaction_resolved_at: obj.resolvedAt,
|
|
103
|
+
channel_opening_transaction_amount: CurrencyAmountToJson(obj.amount),
|
|
104
|
+
channel_opening_transaction_transaction_hash: obj.transactionHash,
|
|
105
|
+
channel_opening_transaction_fees: obj.fees
|
|
106
|
+
? CurrencyAmountToJson(obj.fees)
|
|
107
|
+
: undefined,
|
|
108
|
+
channel_opening_transaction_block_hash: obj.blockHash,
|
|
109
|
+
channel_opening_transaction_block_height: obj.blockHeight,
|
|
110
|
+
channel_opening_transaction_destination_addresses: obj.destinationAddresses,
|
|
111
|
+
channel_opening_transaction_num_confirmations: obj.numConfirmations,
|
|
112
|
+
channel_opening_transaction_channel: { id: obj.channelId } ?? undefined,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
95
115
|
|
|
96
116
|
export const FRAGMENT = `
|
|
97
117
|
fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction {
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
2
|
|
|
3
3
|
import type CurrencyAmount from "./CurrencyAmount.js";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CurrencyAmountFromJson,
|
|
6
|
+
CurrencyAmountToJson,
|
|
7
|
+
} from "./CurrencyAmount.js";
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
interface ChannelSnapshot {
|
|
7
10
|
channelId: string;
|
|
8
11
|
|
|
9
12
|
timestamp: string;
|
|
10
13
|
|
|
11
|
-
localBalance?: CurrencyAmount;
|
|
14
|
+
localBalance?: CurrencyAmount | undefined;
|
|
12
15
|
|
|
13
|
-
localUnsettledBalance?: CurrencyAmount;
|
|
16
|
+
localUnsettledBalance?: CurrencyAmount | undefined;
|
|
14
17
|
|
|
15
|
-
localChannelReserve?: CurrencyAmount;
|
|
18
|
+
localChannelReserve?: CurrencyAmount | undefined;
|
|
16
19
|
|
|
17
|
-
remoteBalance?: CurrencyAmount;
|
|
20
|
+
remoteBalance?: CurrencyAmount | undefined;
|
|
18
21
|
|
|
19
|
-
remoteUnsettledBalance?: CurrencyAmount;
|
|
20
|
-
}
|
|
22
|
+
remoteUnsettledBalance?: CurrencyAmount | undefined;
|
|
23
|
+
}
|
|
21
24
|
|
|
22
25
|
export const ChannelSnapshotFromJson = (obj: any): ChannelSnapshot => {
|
|
23
26
|
return {
|
|
@@ -40,6 +43,27 @@ export const ChannelSnapshotFromJson = (obj: any): ChannelSnapshot => {
|
|
|
40
43
|
: undefined,
|
|
41
44
|
} as ChannelSnapshot;
|
|
42
45
|
};
|
|
46
|
+
export const ChannelSnapshotToJson = (obj: ChannelSnapshot): any => {
|
|
47
|
+
return {
|
|
48
|
+
channel_snapshot_channel: { id: obj.channelId },
|
|
49
|
+
channel_snapshot_timestamp: obj.timestamp,
|
|
50
|
+
channel_snapshot_local_balance: obj.localBalance
|
|
51
|
+
? CurrencyAmountToJson(obj.localBalance)
|
|
52
|
+
: undefined,
|
|
53
|
+
channel_snapshot_local_unsettled_balance: obj.localUnsettledBalance
|
|
54
|
+
? CurrencyAmountToJson(obj.localUnsettledBalance)
|
|
55
|
+
: undefined,
|
|
56
|
+
channel_snapshot_local_channel_reserve: obj.localChannelReserve
|
|
57
|
+
? CurrencyAmountToJson(obj.localChannelReserve)
|
|
58
|
+
: undefined,
|
|
59
|
+
channel_snapshot_remote_balance: obj.remoteBalance
|
|
60
|
+
? CurrencyAmountToJson(obj.remoteBalance)
|
|
61
|
+
: undefined,
|
|
62
|
+
channel_snapshot_remote_unsettled_balance: obj.remoteUnsettledBalance
|
|
63
|
+
? CurrencyAmountToJson(obj.remoteUnsettledBalance)
|
|
64
|
+
: undefined,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
43
67
|
|
|
44
68
|
export const FRAGMENT = `
|
|
45
69
|
fragment ChannelSnapshotFragment on ChannelSnapshot {
|