@lightsparkdev/lightspark-sdk 0.1.6
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/.fossa.yml +6 -0
- package/.prettierrc +1 -0
- package/.turbo/turbo-build.log +19 -0
- package/.turbo/turbo-lint.log +3 -0
- package/CHANGELOG.md +49 -0
- package/LICENSE +201 -0
- package/README.md +137 -0
- package/dist/Withdrawal-17e1c8af.d.ts +1672 -0
- package/dist/Withdrawal-27a4d10d.d.ts +1672 -0
- package/dist/chunk-3VRI7CHE.js +5508 -0
- package/dist/chunk-AGEUDR2V.js +4498 -0
- package/dist/chunk-N27QHRE4.js +5508 -0
- package/dist/client-3bba3f64.d.ts +1302 -0
- package/dist/index.cjs +6633 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1177 -0
- package/dist/objects/index.cjs +5347 -0
- package/dist/objects/index.d.ts +3 -0
- package/dist/objects/index.js +88 -0
- package/examples/node-scripts/authHelpers.ts +20 -0
- package/examples/node-scripts/createInvoice.ts +64 -0
- package/examples/node-scripts/example.ts +288 -0
- package/examples/node-scripts/getAccountDashboard.ts +24 -0
- package/examples/node-scripts/getNodeChannels.ts +34 -0
- package/examples/node-scripts/internalAuthHelpers.ts +26 -0
- package/examples/node-scripts/internal_example.ts +296 -0
- package/examples/node-scripts/package-lock.json +887 -0
- package/examples/node-scripts/package.json +22 -0
- package/examples/node-scripts/prettyPrintJsonForDocs.ts +62 -0
- package/examples/node-scripts/tsconfig.json +27 -0
- package/examples/oauth-example/README.md +19 -0
- package/examples/oauth-example/package-lock.json +16071 -0
- package/examples/oauth-example/package.json +50 -0
- package/examples/oauth-example/public/favicon.ico +0 -0
- package/examples/oauth-example/public/index.html +43 -0
- package/examples/oauth-example/public/logo192.png +0 -0
- package/examples/oauth-example/public/logo512.png +0 -0
- package/examples/oauth-example/public/manifest.json +25 -0
- package/examples/oauth-example/public/robots.txt +3 -0
- package/examples/oauth-example/src/App.css +7 -0
- package/examples/oauth-example/src/App.test.tsx +12 -0
- package/examples/oauth-example/src/App.tsx +16 -0
- package/examples/oauth-example/src/auth/AuthContext.ts +8 -0
- package/examples/oauth-example/src/auth/AuthProvider.tsx +44 -0
- package/examples/oauth-example/src/auth/RequireAuth.tsx +19 -0
- package/examples/oauth-example/src/auth/oauthProvider.ts +35 -0
- package/examples/oauth-example/src/components/Button.tsx +39 -0
- package/examples/oauth-example/src/components/CurrencyAmount.tsx +117 -0
- package/examples/oauth-example/src/components/Dashboard.tsx +158 -0
- package/examples/oauth-example/src/components/Table.tsx +22 -0
- package/examples/oauth-example/src/hooks/useAccountInfo.tsx +31 -0
- package/examples/oauth-example/src/icons/BitcoinB.tsx +20 -0
- package/examples/oauth-example/src/icons/Icon.tsx +121 -0
- package/examples/oauth-example/src/icons/Satoshi.tsx +28 -0
- package/examples/oauth-example/src/index.css +13 -0
- package/examples/oauth-example/src/index.tsx +23 -0
- package/examples/oauth-example/src/lightsparkclient/LightsparkClientContext.ts +10 -0
- package/examples/oauth-example/src/lightsparkclient/LightsparkClientProvider.tsx +53 -0
- package/examples/oauth-example/src/logo.svg +1 -0
- package/examples/oauth-example/src/pages/DashboardPage.tsx +71 -0
- package/examples/oauth-example/src/pages/LoginPage.tsx +63 -0
- package/examples/oauth-example/src/react-app-env.d.ts +1 -0
- package/examples/oauth-example/src/reportWebVitals.ts +15 -0
- package/examples/oauth-example/src/routes/index.tsx +15 -0
- package/examples/oauth-example/src/setupTests.ts +5 -0
- package/examples/oauth-example/src/utils/currency.ts +483 -0
- package/examples/oauth-example/tsconfig.json +20 -0
- package/examples/streaming-wallet-extension/.fossa.yml +6 -0
- package/examples/streaming-wallet-extension/README.md +17 -0
- package/examples/streaming-wallet-extension/craco.config.js +58 -0
- package/examples/streaming-wallet-extension/package-lock.json +18260 -0
- package/examples/streaming-wallet-extension/package.json +77 -0
- package/examples/streaming-wallet-extension/public/index.html +24 -0
- package/examples/streaming-wallet-extension/public/lightspark_full.png +0 -0
- package/examples/streaming-wallet-extension/public/lightspark_icon_circle.png +0 -0
- package/examples/streaming-wallet-extension/public/manifest.json +43 -0
- package/examples/streaming-wallet-extension/public/robots.txt +3 -0
- package/examples/streaming-wallet-extension/src/App.css +53 -0
- package/examples/streaming-wallet-extension/src/App.tsx +425 -0
- package/examples/streaming-wallet-extension/src/auth/AccountStorage.ts +28 -0
- package/examples/streaming-wallet-extension/src/auth/DemoAccountProvider.ts +99 -0
- package/examples/streaming-wallet-extension/src/auth/StreamingDemoCredentials.ts +10 -0
- package/examples/streaming-wallet-extension/src/background/PaymentStrategy.ts +36 -0
- package/examples/streaming-wallet-extension/src/background/PlaybackRange.ts +31 -0
- package/examples/streaming-wallet-extension/src/background/StreamingInvoiceHolder.ts +33 -0
- package/examples/streaming-wallet-extension/src/background/TransactionObserver.ts +66 -0
- package/examples/streaming-wallet-extension/src/background/VideoPlaybackRanges.ts +38 -0
- package/examples/streaming-wallet-extension/src/background/VideoProgressCache.ts +87 -0
- package/examples/streaming-wallet-extension/src/background/background.ts +145 -0
- package/examples/streaming-wallet-extension/src/background/messageHandling.ts +185 -0
- package/examples/streaming-wallet-extension/src/common/datetimes.ts +28 -0
- package/examples/streaming-wallet-extension/src/common/settings.ts +12 -0
- package/examples/streaming-wallet-extension/src/common/storage.ts +8 -0
- package/examples/streaming-wallet-extension/src/common/streamingTabs.ts +27 -0
- package/examples/streaming-wallet-extension/src/common/types.tsx +23 -0
- package/examples/streaming-wallet-extension/src/components/CirclePlusIcon.tsx +19 -0
- package/examples/streaming-wallet-extension/src/components/CurrencyAmount.tsx +110 -0
- package/examples/streaming-wallet-extension/src/components/CurrencyAmountRaw.tsx +195 -0
- package/examples/streaming-wallet-extension/src/components/LeftArrow.tsx +21 -0
- package/examples/streaming-wallet-extension/src/components/Loading.tsx +151 -0
- package/examples/streaming-wallet-extension/src/components/StreamingTransactionChip.tsx +95 -0
- package/examples/streaming-wallet-extension/src/components/TransactionRow.tsx +93 -0
- package/examples/streaming-wallet-extension/src/contentscript/content.ts +123 -0
- package/examples/streaming-wallet-extension/src/contentscript/lightsparkDemoDom.tsx +113 -0
- package/examples/streaming-wallet-extension/src/contentscript/videoElementParsers.ts +92 -0
- package/examples/streaming-wallet-extension/src/index.css +16 -0
- package/examples/streaming-wallet-extension/src/index.tsx +11 -0
- package/examples/streaming-wallet-extension/src/lightsparkClientProvider.tsx +26 -0
- package/examples/streaming-wallet-extension/src/react-app-env.d.ts +1 -0
- package/examples/streaming-wallet-extension/src/types/Messages.ts +17 -0
- package/examples/streaming-wallet-extension/tsconfig.json +20 -0
- package/package.json +87 -0
- package/src/auth/AccountTokenAuthProvider.ts +37 -0
- package/src/auth/index.ts +3 -0
- package/src/client.ts +759 -0
- package/src/graphql/BitcoinFeeEstimate.ts +13 -0
- package/src/graphql/CreateApiToken.ts +22 -0
- package/src/graphql/CreateInvoice.ts +18 -0
- package/src/graphql/CreateNodeWalletAddress.ts +13 -0
- package/src/graphql/CurrentAccount.ts +13 -0
- package/src/graphql/DecodeInvoice.ts +16 -0
- package/src/graphql/DeleteApiToken.ts +13 -0
- package/src/graphql/FundNode.ts +18 -0
- package/src/graphql/LightningFeeEstimateForInvoice.ts +21 -0
- package/src/graphql/LightningFeeEstimateForNode.ts +21 -0
- package/src/graphql/MultiNodeDashboard.ts +118 -0
- package/src/graphql/PayInvoice.ts +29 -0
- package/src/graphql/RecoverNodeSigningKey.ts +15 -0
- package/src/graphql/RequestWithdrawal.ts +25 -0
- package/src/graphql/SendPayment.ts +29 -0
- package/src/graphql/SingleNodeDashboard.ts +116 -0
- package/src/graphql/TransactionSubscription.ts +16 -0
- package/src/graphql/TransactionsForNode.ts +42 -0
- package/src/index.ts +5 -0
- package/src/objects/Account.ts +1222 -0
- package/src/objects/AccountToApiTokensConnection.ts +50 -0
- package/src/objects/AccountToChannelsConnection.ts +35 -0
- package/src/objects/AccountToNodesConnection.ts +62 -0
- package/src/objects/AccountToPaymentRequestsConnection.ts +50 -0
- package/src/objects/AccountToTransactionsConnection.ts +112 -0
- package/src/objects/ApiToken.ts +80 -0
- package/src/objects/BitcoinNetwork.ts +19 -0
- package/src/objects/BlockchainBalance.ts +102 -0
- package/src/objects/Channel.ts +283 -0
- package/src/objects/ChannelClosingTransaction.ts +150 -0
- package/src/objects/ChannelFees.ts +34 -0
- package/src/objects/ChannelOpeningTransaction.ts +150 -0
- package/src/objects/ChannelStatus.ts +25 -0
- package/src/objects/ChannelToTransactionsConnection.ts +86 -0
- package/src/objects/CreateApiTokenInput.ts +22 -0
- package/src/objects/CreateApiTokenOutput.ts +41 -0
- package/src/objects/CreateInvoiceInput.ts +27 -0
- package/src/objects/CreateInvoiceOutput.ts +21 -0
- package/src/objects/CreateNodeWalletAddressInput.ts +15 -0
- package/src/objects/CreateNodeWalletAddressOutput.ts +27 -0
- package/src/objects/CurrencyAmount.ts +55 -0
- package/src/objects/CurrencyUnit.ts +25 -0
- package/src/objects/DeleteApiTokenInput.ts +13 -0
- package/src/objects/DeleteApiTokenOutput.ts +23 -0
- package/src/objects/Deposit.ts +144 -0
- package/src/objects/Entity.ts +868 -0
- package/src/objects/FeeEstimate.ts +39 -0
- package/src/objects/FundNodeInput.ts +16 -0
- package/src/objects/FundNodeOutput.ts +28 -0
- package/src/objects/GraphNode.ts +110 -0
- package/src/objects/Hop.ts +108 -0
- package/src/objects/HtlcAttemptFailureCode.ts +65 -0
- package/src/objects/IncomingPayment.ts +141 -0
- package/src/objects/IncomingPaymentAttempt.ts +96 -0
- package/src/objects/IncomingPaymentAttemptStatus.ts +20 -0
- package/src/objects/IncomingPaymentToAttemptsConnection.ts +39 -0
- package/src/objects/Invoice.ts +226 -0
- package/src/objects/InvoiceData.ts +185 -0
- package/src/objects/InvoiceType.ts +15 -0
- package/src/objects/LightningFeeEstimateForInvoiceInput.ts +28 -0
- package/src/objects/LightningFeeEstimateForNodeInput.ts +25 -0
- package/src/objects/LightningFeeEstimateOutput.ts +33 -0
- package/src/objects/LightningTransaction.ts +393 -0
- package/src/objects/LightsparkNode.ts +377 -0
- package/src/objects/LightsparkNodePurpose.ts +17 -0
- package/src/objects/LightsparkNodeStatus.ts +29 -0
- package/src/objects/LightsparkNodeToChannelsConnection.ts +50 -0
- package/src/objects/Node.ts +273 -0
- package/src/objects/NodeAddress.ts +29 -0
- package/src/objects/NodeAddressType.ts +18 -0
- package/src/objects/NodeToAddressesConnection.ts +39 -0
- package/src/objects/OnChainTransaction.ts +318 -0
- package/src/objects/OutgoingPayment.ts +319 -0
- package/src/objects/OutgoingPaymentAttempt.ts +164 -0
- package/src/objects/OutgoingPaymentAttemptStatus.ts +18 -0
- package/src/objects/OutgoingPaymentAttemptToHopsConnection.ts +37 -0
- package/src/objects/OutgoingPaymentToAttemptsConnection.ts +39 -0
- package/src/objects/PageInfo.ts +31 -0
- package/src/objects/PayInvoiceInput.ts +33 -0
- package/src/objects/PayInvoiceOutput.ts +22 -0
- package/src/objects/PaymentFailureReason.ts +29 -0
- package/src/objects/PaymentRequest.ts +231 -0
- package/src/objects/PaymentRequestData.ts +183 -0
- package/src/objects/PaymentRequestStatus.ts +15 -0
- package/src/objects/Permission.ts +39 -0
- package/src/objects/RequestWithdrawalInput.ts +35 -0
- package/src/objects/RequestWithdrawalOutput.ts +24 -0
- package/src/objects/RichText.ts +19 -0
- package/src/objects/RoutingTransaction.ts +150 -0
- package/src/objects/RoutingTransactionFailureReason.ts +17 -0
- package/src/objects/Secret.ts +23 -0
- package/src/objects/SendPaymentInput.ts +30 -0
- package/src/objects/SendPaymentOutput.ts +22 -0
- package/src/objects/Transaction.ts +609 -0
- package/src/objects/TransactionFailures.ts +23 -0
- package/src/objects/TransactionStatus.ts +23 -0
- package/src/objects/TransactionType.ts +31 -0
- package/src/objects/TransactionUpdate.ts +67 -0
- package/src/objects/WalletDashboard.ts +32 -0
- package/src/objects/WebhookEventType.ts +15 -0
- package/src/objects/Withdrawal.ts +144 -0
- package/src/objects/WithdrawalMode.ts +15 -0
- package/src/objects/WithdrawalRequest.ts +224 -0
- package/src/objects/WithdrawalRequestStatus.ts +17 -0
- package/src/objects/WithdrawalRequestToChannelClosingTransactionsConnection.ts +57 -0
- package/src/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.ts +57 -0
- package/src/objects/index.ts +108 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import { Query } from "@lightsparkdev/core";
|
|
4
|
+
import autoBind from "auto-bind";
|
|
5
|
+
import LightsparkClient from "../client.js";
|
|
6
|
+
import ChannelFees, { ChannelFeesFromJson } from "./ChannelFees.js";
|
|
7
|
+
import ChannelStatus from "./ChannelStatus.js";
|
|
8
|
+
import ChannelToTransactionsConnection, {
|
|
9
|
+
ChannelToTransactionsConnectionFromJson,
|
|
10
|
+
} from "./ChannelToTransactionsConnection.js";
|
|
11
|
+
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
12
|
+
import Entity from "./Entity.js";
|
|
13
|
+
import TransactionType from "./TransactionType.js";
|
|
14
|
+
|
|
15
|
+
/** An object that represents a payment channel between two nodes in the Lightning Network. **/
|
|
16
|
+
class Channel implements Entity {
|
|
17
|
+
constructor(
|
|
18
|
+
public readonly id: string,
|
|
19
|
+
public readonly createdAt: string,
|
|
20
|
+
public readonly updatedAt: string,
|
|
21
|
+
public readonly localNodeId: string,
|
|
22
|
+
public readonly typename: string,
|
|
23
|
+
public readonly fundingTransactionId?: string,
|
|
24
|
+
public readonly capacity?: CurrencyAmount,
|
|
25
|
+
public readonly localBalance?: CurrencyAmount,
|
|
26
|
+
public readonly localUnsettledBalance?: CurrencyAmount,
|
|
27
|
+
public readonly remoteBalance?: CurrencyAmount,
|
|
28
|
+
public readonly remoteUnsettledBalance?: CurrencyAmount,
|
|
29
|
+
public readonly unsettledBalance?: CurrencyAmount,
|
|
30
|
+
public readonly totalBalance?: CurrencyAmount,
|
|
31
|
+
public readonly status?: ChannelStatus,
|
|
32
|
+
public readonly estimatedForceClosureWaitMinutes?: number,
|
|
33
|
+
public readonly commitFee?: CurrencyAmount,
|
|
34
|
+
public readonly fees?: ChannelFees,
|
|
35
|
+
public readonly remoteNodeId?: string,
|
|
36
|
+
public readonly shortChannelId?: string
|
|
37
|
+
) {
|
|
38
|
+
autoBind(this);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public async getUptimePercentage(
|
|
42
|
+
client: LightsparkClient,
|
|
43
|
+
afterDate: string | undefined = undefined,
|
|
44
|
+
beforeDate: string | undefined = undefined
|
|
45
|
+
): Promise<number> {
|
|
46
|
+
return await client.executeRawQuery({
|
|
47
|
+
queryPayload: `
|
|
48
|
+
query FetchChannelUptimePercentage($entity_id: ID!, $after_date: DateTime, $before_date: DateTime) {
|
|
49
|
+
entity(id: $entity_id) {
|
|
50
|
+
... on Channel {
|
|
51
|
+
uptime_percentage(, after_date: $after_date, before_date: $before_date)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`,
|
|
56
|
+
variables: {
|
|
57
|
+
entity_id: this.id,
|
|
58
|
+
after_date: afterDate,
|
|
59
|
+
before_date: beforeDate,
|
|
60
|
+
},
|
|
61
|
+
constructObject: (json) => {
|
|
62
|
+
const connection = json["entity"]["uptime_percentage"];
|
|
63
|
+
return connection;
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async getTransactions(
|
|
69
|
+
client: LightsparkClient,
|
|
70
|
+
types: TransactionType[] | undefined = undefined,
|
|
71
|
+
afterDate: string | undefined = undefined,
|
|
72
|
+
beforeDate: string | undefined = undefined
|
|
73
|
+
): Promise<ChannelToTransactionsConnection> {
|
|
74
|
+
return (await client.executeRawQuery({
|
|
75
|
+
queryPayload: `
|
|
76
|
+
query FetchChannelToTransactionsConnection($entity_id: ID!, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime) {
|
|
77
|
+
entity(id: $entity_id) {
|
|
78
|
+
... on Channel {
|
|
79
|
+
transactions(, types: $types, after_date: $after_date, before_date: $before_date) {
|
|
80
|
+
__typename
|
|
81
|
+
channel_to_transactions_connection_count: count
|
|
82
|
+
channel_to_transactions_connection_average_fee: average_fee {
|
|
83
|
+
__typename
|
|
84
|
+
currency_amount_original_value: original_value
|
|
85
|
+
currency_amount_original_unit: original_unit
|
|
86
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
87
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
88
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
89
|
+
}
|
|
90
|
+
channel_to_transactions_connection_total_amount_transacted: total_amount_transacted {
|
|
91
|
+
__typename
|
|
92
|
+
currency_amount_original_value: original_value
|
|
93
|
+
currency_amount_original_unit: original_unit
|
|
94
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
95
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
96
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
97
|
+
}
|
|
98
|
+
channel_to_transactions_connection_total_fees: total_fees {
|
|
99
|
+
__typename
|
|
100
|
+
currency_amount_original_value: original_value
|
|
101
|
+
currency_amount_original_unit: original_unit
|
|
102
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
103
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
104
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`,
|
|
111
|
+
variables: {
|
|
112
|
+
entity_id: this.id,
|
|
113
|
+
types: types,
|
|
114
|
+
after_date: afterDate,
|
|
115
|
+
before_date: beforeDate,
|
|
116
|
+
},
|
|
117
|
+
constructObject: (json) => {
|
|
118
|
+
const connection = json["entity"]["transactions"];
|
|
119
|
+
return ChannelToTransactionsConnectionFromJson(connection);
|
|
120
|
+
},
|
|
121
|
+
}))!;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static getChannelQuery(id: string): Query<Channel> {
|
|
125
|
+
return {
|
|
126
|
+
queryPayload: `
|
|
127
|
+
query GetChannel($id: ID!) {
|
|
128
|
+
entity(id: $id) {
|
|
129
|
+
... on Channel {
|
|
130
|
+
...ChannelFragment
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
${FRAGMENT}
|
|
136
|
+
`,
|
|
137
|
+
variables: { id },
|
|
138
|
+
constructObject: (data: any) => ChannelFromJson(data.entity),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const ChannelFromJson = (obj: any): Channel => {
|
|
144
|
+
return new Channel(
|
|
145
|
+
obj["channel_id"],
|
|
146
|
+
obj["channel_created_at"],
|
|
147
|
+
obj["channel_updated_at"],
|
|
148
|
+
obj["channel_local_node"].id,
|
|
149
|
+
"Channel",
|
|
150
|
+
obj["channel_funding_transaction"]?.id ?? undefined,
|
|
151
|
+
!!obj["channel_capacity"]
|
|
152
|
+
? CurrencyAmountFromJson(obj["channel_capacity"])
|
|
153
|
+
: undefined,
|
|
154
|
+
!!obj["channel_local_balance"]
|
|
155
|
+
? CurrencyAmountFromJson(obj["channel_local_balance"])
|
|
156
|
+
: undefined,
|
|
157
|
+
!!obj["channel_local_unsettled_balance"]
|
|
158
|
+
? CurrencyAmountFromJson(obj["channel_local_unsettled_balance"])
|
|
159
|
+
: undefined,
|
|
160
|
+
!!obj["channel_remote_balance"]
|
|
161
|
+
? CurrencyAmountFromJson(obj["channel_remote_balance"])
|
|
162
|
+
: undefined,
|
|
163
|
+
!!obj["channel_remote_unsettled_balance"]
|
|
164
|
+
? CurrencyAmountFromJson(obj["channel_remote_unsettled_balance"])
|
|
165
|
+
: undefined,
|
|
166
|
+
!!obj["channel_unsettled_balance"]
|
|
167
|
+
? CurrencyAmountFromJson(obj["channel_unsettled_balance"])
|
|
168
|
+
: undefined,
|
|
169
|
+
!!obj["channel_total_balance"]
|
|
170
|
+
? CurrencyAmountFromJson(obj["channel_total_balance"])
|
|
171
|
+
: undefined,
|
|
172
|
+
!!obj["channel_status"]
|
|
173
|
+
? ChannelStatus[obj["channel_status"]] ?? ChannelStatus.FUTURE_VALUE
|
|
174
|
+
: null,
|
|
175
|
+
obj["channel_estimated_force_closure_wait_minutes"],
|
|
176
|
+
!!obj["channel_commit_fee"]
|
|
177
|
+
? CurrencyAmountFromJson(obj["channel_commit_fee"])
|
|
178
|
+
: undefined,
|
|
179
|
+
!!obj["channel_fees"]
|
|
180
|
+
? ChannelFeesFromJson(obj["channel_fees"])
|
|
181
|
+
: undefined,
|
|
182
|
+
obj["channel_remote_node"]?.id ?? undefined,
|
|
183
|
+
obj["channel_short_channel_id"]
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const FRAGMENT = `
|
|
188
|
+
fragment ChannelFragment on Channel {
|
|
189
|
+
__typename
|
|
190
|
+
channel_id: id
|
|
191
|
+
channel_created_at: created_at
|
|
192
|
+
channel_updated_at: updated_at
|
|
193
|
+
channel_funding_transaction: funding_transaction {
|
|
194
|
+
id
|
|
195
|
+
}
|
|
196
|
+
channel_capacity: capacity {
|
|
197
|
+
__typename
|
|
198
|
+
currency_amount_original_value: original_value
|
|
199
|
+
currency_amount_original_unit: original_unit
|
|
200
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
201
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
202
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
203
|
+
}
|
|
204
|
+
channel_local_balance: local_balance {
|
|
205
|
+
__typename
|
|
206
|
+
currency_amount_original_value: original_value
|
|
207
|
+
currency_amount_original_unit: original_unit
|
|
208
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
209
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
210
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
211
|
+
}
|
|
212
|
+
channel_local_unsettled_balance: local_unsettled_balance {
|
|
213
|
+
__typename
|
|
214
|
+
currency_amount_original_value: original_value
|
|
215
|
+
currency_amount_original_unit: original_unit
|
|
216
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
217
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
218
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
219
|
+
}
|
|
220
|
+
channel_remote_balance: remote_balance {
|
|
221
|
+
__typename
|
|
222
|
+
currency_amount_original_value: original_value
|
|
223
|
+
currency_amount_original_unit: original_unit
|
|
224
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
225
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
226
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
227
|
+
}
|
|
228
|
+
channel_remote_unsettled_balance: remote_unsettled_balance {
|
|
229
|
+
__typename
|
|
230
|
+
currency_amount_original_value: original_value
|
|
231
|
+
currency_amount_original_unit: original_unit
|
|
232
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
233
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
234
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
235
|
+
}
|
|
236
|
+
channel_unsettled_balance: unsettled_balance {
|
|
237
|
+
__typename
|
|
238
|
+
currency_amount_original_value: original_value
|
|
239
|
+
currency_amount_original_unit: original_unit
|
|
240
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
241
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
242
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
243
|
+
}
|
|
244
|
+
channel_total_balance: total_balance {
|
|
245
|
+
__typename
|
|
246
|
+
currency_amount_original_value: original_value
|
|
247
|
+
currency_amount_original_unit: original_unit
|
|
248
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
249
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
250
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
251
|
+
}
|
|
252
|
+
channel_status: status
|
|
253
|
+
channel_estimated_force_closure_wait_minutes: estimated_force_closure_wait_minutes
|
|
254
|
+
channel_commit_fee: commit_fee {
|
|
255
|
+
__typename
|
|
256
|
+
currency_amount_original_value: original_value
|
|
257
|
+
currency_amount_original_unit: original_unit
|
|
258
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
259
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
260
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
261
|
+
}
|
|
262
|
+
channel_fees: fees {
|
|
263
|
+
__typename
|
|
264
|
+
channel_fees_base_fee: base_fee {
|
|
265
|
+
__typename
|
|
266
|
+
currency_amount_original_value: original_value
|
|
267
|
+
currency_amount_original_unit: original_unit
|
|
268
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
269
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
270
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
271
|
+
}
|
|
272
|
+
channel_fees_fee_rate_per_mil: fee_rate_per_mil
|
|
273
|
+
}
|
|
274
|
+
channel_remote_node: remote_node {
|
|
275
|
+
id
|
|
276
|
+
}
|
|
277
|
+
channel_local_node: local_node {
|
|
278
|
+
id
|
|
279
|
+
}
|
|
280
|
+
channel_short_channel_id: short_channel_id
|
|
281
|
+
}`;
|
|
282
|
+
|
|
283
|
+
export default Channel;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import { Query } from "@lightsparkdev/core";
|
|
4
|
+
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
5
|
+
import Entity from "./Entity.js";
|
|
6
|
+
import OnChainTransaction from "./OnChainTransaction.js";
|
|
7
|
+
import Transaction from "./Transaction.js";
|
|
8
|
+
import TransactionStatus from "./TransactionStatus.js";
|
|
9
|
+
|
|
10
|
+
/** The transaction on Bitcoin blockchain to close a channel on Lightning Network where the balances are allocated back to local and remote nodes. **/
|
|
11
|
+
type ChannelClosingTransaction = OnChainTransaction &
|
|
12
|
+
Transaction &
|
|
13
|
+
Entity & {
|
|
14
|
+
/**
|
|
15
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
16
|
+
* string.
|
|
17
|
+
**/
|
|
18
|
+
id: string;
|
|
19
|
+
|
|
20
|
+
/** The date and time when this transaction was initiated. **/
|
|
21
|
+
createdAt: string;
|
|
22
|
+
|
|
23
|
+
/** The date and time when the entity was last updated. **/
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
|
|
26
|
+
/** The current status of this transaction. **/
|
|
27
|
+
status: TransactionStatus;
|
|
28
|
+
|
|
29
|
+
/** The amount of money involved in this transaction. **/
|
|
30
|
+
amount: CurrencyAmount;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The height of the block that included this transaction. This will be zero for unconfirmed
|
|
34
|
+
* transactions.
|
|
35
|
+
**/
|
|
36
|
+
blockHeight: number;
|
|
37
|
+
|
|
38
|
+
/** The Bitcoin blockchain addresses this transaction was sent to. **/
|
|
39
|
+
destinationAddresses: string[];
|
|
40
|
+
|
|
41
|
+
/** The typename of the object **/
|
|
42
|
+
typename: string;
|
|
43
|
+
|
|
44
|
+
/** The date and time when this transaction was completed or failed. **/
|
|
45
|
+
resolvedAt?: string;
|
|
46
|
+
|
|
47
|
+
/** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
|
|
48
|
+
transactionHash?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
|
|
52
|
+
* blockchain.
|
|
53
|
+
**/
|
|
54
|
+
fees?: CurrencyAmount;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The hash of the block that included this transaction. This will be null for unconfirmed
|
|
58
|
+
* transactions.
|
|
59
|
+
**/
|
|
60
|
+
blockHash?: string;
|
|
61
|
+
|
|
62
|
+
/** The number of blockchain confirmations for this transaction in real time. **/
|
|
63
|
+
numConfirmations?: number;
|
|
64
|
+
|
|
65
|
+
/** If known, the channel this transaction is closing. **/
|
|
66
|
+
channelId?: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const ChannelClosingTransactionFromJson = (
|
|
70
|
+
obj: any
|
|
71
|
+
): ChannelClosingTransaction => {
|
|
72
|
+
return {
|
|
73
|
+
id: obj["channel_closing_transaction_id"],
|
|
74
|
+
createdAt: obj["channel_closing_transaction_created_at"],
|
|
75
|
+
updatedAt: obj["channel_closing_transaction_updated_at"],
|
|
76
|
+
status:
|
|
77
|
+
TransactionStatus[obj["channel_closing_transaction_status"]] ??
|
|
78
|
+
TransactionStatus.FUTURE_VALUE,
|
|
79
|
+
amount: CurrencyAmountFromJson(obj["channel_closing_transaction_amount"]),
|
|
80
|
+
blockHeight: obj["channel_closing_transaction_block_height"],
|
|
81
|
+
destinationAddresses:
|
|
82
|
+
obj["channel_closing_transaction_destination_addresses"],
|
|
83
|
+
typename: "ChannelClosingTransaction",
|
|
84
|
+
resolvedAt: obj["channel_closing_transaction_resolved_at"],
|
|
85
|
+
transactionHash: obj["channel_closing_transaction_transaction_hash"],
|
|
86
|
+
fees: !!obj["channel_closing_transaction_fees"]
|
|
87
|
+
? CurrencyAmountFromJson(obj["channel_closing_transaction_fees"])
|
|
88
|
+
: undefined,
|
|
89
|
+
blockHash: obj["channel_closing_transaction_block_hash"],
|
|
90
|
+
numConfirmations: obj["channel_closing_transaction_num_confirmations"],
|
|
91
|
+
channelId: obj["channel_closing_transaction_channel"]?.id ?? undefined,
|
|
92
|
+
} as ChannelClosingTransaction;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const FRAGMENT = `
|
|
96
|
+
fragment ChannelClosingTransactionFragment on ChannelClosingTransaction {
|
|
97
|
+
__typename
|
|
98
|
+
channel_closing_transaction_id: id
|
|
99
|
+
channel_closing_transaction_created_at: created_at
|
|
100
|
+
channel_closing_transaction_updated_at: updated_at
|
|
101
|
+
channel_closing_transaction_status: status
|
|
102
|
+
channel_closing_transaction_resolved_at: resolved_at
|
|
103
|
+
channel_closing_transaction_amount: amount {
|
|
104
|
+
__typename
|
|
105
|
+
currency_amount_original_value: original_value
|
|
106
|
+
currency_amount_original_unit: original_unit
|
|
107
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
108
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
109
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
110
|
+
}
|
|
111
|
+
channel_closing_transaction_transaction_hash: transaction_hash
|
|
112
|
+
channel_closing_transaction_fees: fees {
|
|
113
|
+
__typename
|
|
114
|
+
currency_amount_original_value: original_value
|
|
115
|
+
currency_amount_original_unit: original_unit
|
|
116
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
117
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
118
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
119
|
+
}
|
|
120
|
+
channel_closing_transaction_block_hash: block_hash
|
|
121
|
+
channel_closing_transaction_block_height: block_height
|
|
122
|
+
channel_closing_transaction_destination_addresses: destination_addresses
|
|
123
|
+
channel_closing_transaction_num_confirmations: num_confirmations
|
|
124
|
+
channel_closing_transaction_channel: channel {
|
|
125
|
+
id
|
|
126
|
+
}
|
|
127
|
+
}`;
|
|
128
|
+
|
|
129
|
+
export const getChannelClosingTransactionQuery = (
|
|
130
|
+
id: string
|
|
131
|
+
): Query<ChannelClosingTransaction> => {
|
|
132
|
+
return {
|
|
133
|
+
queryPayload: `
|
|
134
|
+
query GetChannelClosingTransaction($id: ID!) {
|
|
135
|
+
entity(id: $id) {
|
|
136
|
+
... on ChannelClosingTransaction {
|
|
137
|
+
...ChannelClosingTransactionFragment
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
${FRAGMENT}
|
|
143
|
+
`,
|
|
144
|
+
variables: { id },
|
|
145
|
+
constructObject: (data: any) =>
|
|
146
|
+
ChannelClosingTransactionFromJson(data.entity),
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default ChannelClosingTransaction;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
4
|
+
|
|
5
|
+
type ChannelFees = {
|
|
6
|
+
baseFee?: CurrencyAmount;
|
|
7
|
+
|
|
8
|
+
feeRatePerMil?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const ChannelFeesFromJson = (obj: any): ChannelFees => {
|
|
12
|
+
return {
|
|
13
|
+
baseFee: !!obj["channel_fees_base_fee"]
|
|
14
|
+
? CurrencyAmountFromJson(obj["channel_fees_base_fee"])
|
|
15
|
+
: undefined,
|
|
16
|
+
feeRatePerMil: obj["channel_fees_fee_rate_per_mil"],
|
|
17
|
+
} as ChannelFees;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const FRAGMENT = `
|
|
21
|
+
fragment ChannelFeesFragment on ChannelFees {
|
|
22
|
+
__typename
|
|
23
|
+
channel_fees_base_fee: base_fee {
|
|
24
|
+
__typename
|
|
25
|
+
currency_amount_original_value: original_value
|
|
26
|
+
currency_amount_original_unit: original_unit
|
|
27
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
28
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
29
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
30
|
+
}
|
|
31
|
+
channel_fees_fee_rate_per_mil: fee_rate_per_mil
|
|
32
|
+
}`;
|
|
33
|
+
|
|
34
|
+
export default ChannelFees;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import { Query } from "@lightsparkdev/core";
|
|
4
|
+
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
5
|
+
import Entity from "./Entity.js";
|
|
6
|
+
import OnChainTransaction from "./OnChainTransaction.js";
|
|
7
|
+
import Transaction from "./Transaction.js";
|
|
8
|
+
import TransactionStatus from "./TransactionStatus.js";
|
|
9
|
+
|
|
10
|
+
/** The transaction on Bitcoin blockchain to open a channel on Lightning Network funded by the local Lightspark node. **/
|
|
11
|
+
type ChannelOpeningTransaction = OnChainTransaction &
|
|
12
|
+
Transaction &
|
|
13
|
+
Entity & {
|
|
14
|
+
/**
|
|
15
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
16
|
+
* string.
|
|
17
|
+
**/
|
|
18
|
+
id: string;
|
|
19
|
+
|
|
20
|
+
/** The date and time when this transaction was initiated. **/
|
|
21
|
+
createdAt: string;
|
|
22
|
+
|
|
23
|
+
/** The date and time when the entity was last updated. **/
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
|
|
26
|
+
/** The current status of this transaction. **/
|
|
27
|
+
status: TransactionStatus;
|
|
28
|
+
|
|
29
|
+
/** The amount of money involved in this transaction. **/
|
|
30
|
+
amount: CurrencyAmount;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The height of the block that included this transaction. This will be zero for unconfirmed
|
|
34
|
+
* transactions.
|
|
35
|
+
**/
|
|
36
|
+
blockHeight: number;
|
|
37
|
+
|
|
38
|
+
/** The Bitcoin blockchain addresses this transaction was sent to. **/
|
|
39
|
+
destinationAddresses: string[];
|
|
40
|
+
|
|
41
|
+
/** The typename of the object **/
|
|
42
|
+
typename: string;
|
|
43
|
+
|
|
44
|
+
/** The date and time when this transaction was completed or failed. **/
|
|
45
|
+
resolvedAt?: string;
|
|
46
|
+
|
|
47
|
+
/** The hash of this transaction, so it can be uniquely identified on the Lightning Network. **/
|
|
48
|
+
transactionHash?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin
|
|
52
|
+
* blockchain.
|
|
53
|
+
**/
|
|
54
|
+
fees?: CurrencyAmount;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The hash of the block that included this transaction. This will be null for unconfirmed
|
|
58
|
+
* transactions.
|
|
59
|
+
**/
|
|
60
|
+
blockHash?: string;
|
|
61
|
+
|
|
62
|
+
/** The number of blockchain confirmations for this transaction in real time. **/
|
|
63
|
+
numConfirmations?: number;
|
|
64
|
+
|
|
65
|
+
/** If known, the channel this transaction is opening. **/
|
|
66
|
+
channelId?: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const ChannelOpeningTransactionFromJson = (
|
|
70
|
+
obj: any
|
|
71
|
+
): ChannelOpeningTransaction => {
|
|
72
|
+
return {
|
|
73
|
+
id: obj["channel_opening_transaction_id"],
|
|
74
|
+
createdAt: obj["channel_opening_transaction_created_at"],
|
|
75
|
+
updatedAt: obj["channel_opening_transaction_updated_at"],
|
|
76
|
+
status:
|
|
77
|
+
TransactionStatus[obj["channel_opening_transaction_status"]] ??
|
|
78
|
+
TransactionStatus.FUTURE_VALUE,
|
|
79
|
+
amount: CurrencyAmountFromJson(obj["channel_opening_transaction_amount"]),
|
|
80
|
+
blockHeight: obj["channel_opening_transaction_block_height"],
|
|
81
|
+
destinationAddresses:
|
|
82
|
+
obj["channel_opening_transaction_destination_addresses"],
|
|
83
|
+
typename: "ChannelOpeningTransaction",
|
|
84
|
+
resolvedAt: obj["channel_opening_transaction_resolved_at"],
|
|
85
|
+
transactionHash: obj["channel_opening_transaction_transaction_hash"],
|
|
86
|
+
fees: !!obj["channel_opening_transaction_fees"]
|
|
87
|
+
? CurrencyAmountFromJson(obj["channel_opening_transaction_fees"])
|
|
88
|
+
: undefined,
|
|
89
|
+
blockHash: obj["channel_opening_transaction_block_hash"],
|
|
90
|
+
numConfirmations: obj["channel_opening_transaction_num_confirmations"],
|
|
91
|
+
channelId: obj["channel_opening_transaction_channel"]?.id ?? undefined,
|
|
92
|
+
} as ChannelOpeningTransaction;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const FRAGMENT = `
|
|
96
|
+
fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction {
|
|
97
|
+
__typename
|
|
98
|
+
channel_opening_transaction_id: id
|
|
99
|
+
channel_opening_transaction_created_at: created_at
|
|
100
|
+
channel_opening_transaction_updated_at: updated_at
|
|
101
|
+
channel_opening_transaction_status: status
|
|
102
|
+
channel_opening_transaction_resolved_at: resolved_at
|
|
103
|
+
channel_opening_transaction_amount: amount {
|
|
104
|
+
__typename
|
|
105
|
+
currency_amount_original_value: original_value
|
|
106
|
+
currency_amount_original_unit: original_unit
|
|
107
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
108
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
109
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
110
|
+
}
|
|
111
|
+
channel_opening_transaction_transaction_hash: transaction_hash
|
|
112
|
+
channel_opening_transaction_fees: fees {
|
|
113
|
+
__typename
|
|
114
|
+
currency_amount_original_value: original_value
|
|
115
|
+
currency_amount_original_unit: original_unit
|
|
116
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
117
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
118
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
119
|
+
}
|
|
120
|
+
channel_opening_transaction_block_hash: block_hash
|
|
121
|
+
channel_opening_transaction_block_height: block_height
|
|
122
|
+
channel_opening_transaction_destination_addresses: destination_addresses
|
|
123
|
+
channel_opening_transaction_num_confirmations: num_confirmations
|
|
124
|
+
channel_opening_transaction_channel: channel {
|
|
125
|
+
id
|
|
126
|
+
}
|
|
127
|
+
}`;
|
|
128
|
+
|
|
129
|
+
export const getChannelOpeningTransactionQuery = (
|
|
130
|
+
id: string
|
|
131
|
+
): Query<ChannelOpeningTransaction> => {
|
|
132
|
+
return {
|
|
133
|
+
queryPayload: `
|
|
134
|
+
query GetChannelOpeningTransaction($id: ID!) {
|
|
135
|
+
entity(id: $id) {
|
|
136
|
+
... on ChannelOpeningTransaction {
|
|
137
|
+
...ChannelOpeningTransactionFragment
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
${FRAGMENT}
|
|
143
|
+
`,
|
|
144
|
+
variables: { id },
|
|
145
|
+
constructObject: (data: any) =>
|
|
146
|
+
ChannelOpeningTransactionFromJson(data.entity),
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default ChannelOpeningTransaction;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
export enum ChannelStatus {
|
|
4
|
+
/**
|
|
5
|
+
* This is an enum value that represents values that could be added in the future.
|
|
6
|
+
* Clients should support unknown values as more of them could be added without notice.
|
|
7
|
+
*/
|
|
8
|
+
FUTURE_VALUE = "FUTURE_VALUE",
|
|
9
|
+
/** The channel is online and ready to send and receive funds. **/
|
|
10
|
+
OK = "OK",
|
|
11
|
+
/** The channel has been created, but the Bitcoin transaction that initiates it still needs to be confirmed on the Bitcoin blockchain. **/
|
|
12
|
+
PENDING = "PENDING",
|
|
13
|
+
/** The channel is not available, likely because the peer is not online. **/
|
|
14
|
+
OFFLINE = "OFFLINE",
|
|
15
|
+
/** The channel is behaving properly, but its remote balance is much higher than its local balance so it is not balanced properly for sending funds out. **/
|
|
16
|
+
UNBALANCED_FOR_SEND = "UNBALANCED_FOR_SEND",
|
|
17
|
+
/** The channel is behaving properly, but its remote balance is much lower than its local balance so it is not balanced properly for receiving funds. **/
|
|
18
|
+
UNBALANCED_FOR_RECEIVE = "UNBALANCED_FOR_RECEIVE",
|
|
19
|
+
/** The channel has been closed. Information about the channel is still available for historical purposes but the channel cannot be used anymore. **/
|
|
20
|
+
CLOSED = "CLOSED",
|
|
21
|
+
/** Something unexpected happened and we cannot determine the status of this channel. Please try again later or contact the support. **/
|
|
22
|
+
ERROR = "ERROR",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default ChannelStatus;
|