@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,226 @@
|
|
|
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 InvoiceData, { InvoiceDataFromJson } from "./InvoiceData.js";
|
|
7
|
+
import PaymentRequest from "./PaymentRequest.js";
|
|
8
|
+
import PaymentRequestStatus from "./PaymentRequestStatus.js";
|
|
9
|
+
|
|
10
|
+
/** This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) initiated by a Lightspark Node. **/
|
|
11
|
+
type Invoice = PaymentRequest &
|
|
12
|
+
Entity & {
|
|
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 the entity was first created. **/
|
|
20
|
+
createdAt: string;
|
|
21
|
+
|
|
22
|
+
/** The date and time when the entity was last updated. **/
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
|
|
25
|
+
/** The details of the invoice. **/
|
|
26
|
+
data: InvoiceData;
|
|
27
|
+
|
|
28
|
+
/** The status of the payment request. **/
|
|
29
|
+
status: PaymentRequestStatus;
|
|
30
|
+
|
|
31
|
+
/** The typename of the object **/
|
|
32
|
+
typename: string;
|
|
33
|
+
|
|
34
|
+
/** The total amount that has been paid to this invoice. **/
|
|
35
|
+
amountPaid?: CurrencyAmount;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const InvoiceFromJson = (obj: any): Invoice => {
|
|
39
|
+
return {
|
|
40
|
+
id: obj["invoice_id"],
|
|
41
|
+
createdAt: obj["invoice_created_at"],
|
|
42
|
+
updatedAt: obj["invoice_updated_at"],
|
|
43
|
+
data: InvoiceDataFromJson(obj["invoice_data"]),
|
|
44
|
+
status:
|
|
45
|
+
PaymentRequestStatus[obj["invoice_status"]] ??
|
|
46
|
+
PaymentRequestStatus.FUTURE_VALUE,
|
|
47
|
+
typename: "Invoice",
|
|
48
|
+
amountPaid: !!obj["invoice_amount_paid"]
|
|
49
|
+
? CurrencyAmountFromJson(obj["invoice_amount_paid"])
|
|
50
|
+
: undefined,
|
|
51
|
+
} as Invoice;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const FRAGMENT = `
|
|
55
|
+
fragment InvoiceFragment on Invoice {
|
|
56
|
+
__typename
|
|
57
|
+
invoice_id: id
|
|
58
|
+
invoice_created_at: created_at
|
|
59
|
+
invoice_updated_at: updated_at
|
|
60
|
+
invoice_data: data {
|
|
61
|
+
__typename
|
|
62
|
+
invoice_data_encoded_payment_request: encoded_payment_request
|
|
63
|
+
invoice_data_bitcoin_network: bitcoin_network
|
|
64
|
+
invoice_data_payment_hash: payment_hash
|
|
65
|
+
invoice_data_amount: amount {
|
|
66
|
+
__typename
|
|
67
|
+
currency_amount_original_value: original_value
|
|
68
|
+
currency_amount_original_unit: original_unit
|
|
69
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
70
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
71
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
72
|
+
}
|
|
73
|
+
invoice_data_created_at: created_at
|
|
74
|
+
invoice_data_expires_at: expires_at
|
|
75
|
+
invoice_data_destination: destination {
|
|
76
|
+
__typename
|
|
77
|
+
... on GraphNode {
|
|
78
|
+
__typename
|
|
79
|
+
graph_node_id: id
|
|
80
|
+
graph_node_created_at: created_at
|
|
81
|
+
graph_node_updated_at: updated_at
|
|
82
|
+
graph_node_alias: alias
|
|
83
|
+
graph_node_bitcoin_network: bitcoin_network
|
|
84
|
+
graph_node_color: color
|
|
85
|
+
graph_node_conductivity: conductivity
|
|
86
|
+
graph_node_display_name: display_name
|
|
87
|
+
graph_node_public_key: public_key
|
|
88
|
+
}
|
|
89
|
+
... on LightsparkNode {
|
|
90
|
+
__typename
|
|
91
|
+
lightspark_node_id: id
|
|
92
|
+
lightspark_node_created_at: created_at
|
|
93
|
+
lightspark_node_updated_at: updated_at
|
|
94
|
+
lightspark_node_alias: alias
|
|
95
|
+
lightspark_node_bitcoin_network: bitcoin_network
|
|
96
|
+
lightspark_node_color: color
|
|
97
|
+
lightspark_node_conductivity: conductivity
|
|
98
|
+
lightspark_node_display_name: display_name
|
|
99
|
+
lightspark_node_public_key: public_key
|
|
100
|
+
lightspark_node_account: account {
|
|
101
|
+
id
|
|
102
|
+
}
|
|
103
|
+
lightspark_node_blockchain_balance: blockchain_balance {
|
|
104
|
+
__typename
|
|
105
|
+
blockchain_balance_total_balance: total_balance {
|
|
106
|
+
__typename
|
|
107
|
+
currency_amount_original_value: original_value
|
|
108
|
+
currency_amount_original_unit: original_unit
|
|
109
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
110
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
111
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
112
|
+
}
|
|
113
|
+
blockchain_balance_confirmed_balance: confirmed_balance {
|
|
114
|
+
__typename
|
|
115
|
+
currency_amount_original_value: original_value
|
|
116
|
+
currency_amount_original_unit: original_unit
|
|
117
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
118
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
119
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
120
|
+
}
|
|
121
|
+
blockchain_balance_unconfirmed_balance: unconfirmed_balance {
|
|
122
|
+
__typename
|
|
123
|
+
currency_amount_original_value: original_value
|
|
124
|
+
currency_amount_original_unit: original_unit
|
|
125
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
126
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
127
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
128
|
+
}
|
|
129
|
+
blockchain_balance_locked_balance: locked_balance {
|
|
130
|
+
__typename
|
|
131
|
+
currency_amount_original_value: original_value
|
|
132
|
+
currency_amount_original_unit: original_unit
|
|
133
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
134
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
135
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
136
|
+
}
|
|
137
|
+
blockchain_balance_required_reserve: required_reserve {
|
|
138
|
+
__typename
|
|
139
|
+
currency_amount_original_value: original_value
|
|
140
|
+
currency_amount_original_unit: original_unit
|
|
141
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
142
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
143
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
144
|
+
}
|
|
145
|
+
blockchain_balance_available_balance: available_balance {
|
|
146
|
+
__typename
|
|
147
|
+
currency_amount_original_value: original_value
|
|
148
|
+
currency_amount_original_unit: original_unit
|
|
149
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
150
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
151
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
|
|
155
|
+
__typename
|
|
156
|
+
secret_encrypted_value: encrypted_value
|
|
157
|
+
secret_cipher: cipher
|
|
158
|
+
}
|
|
159
|
+
lightspark_node_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
|
+
lightspark_node_total_local_balance: total_local_balance {
|
|
168
|
+
__typename
|
|
169
|
+
currency_amount_original_value: original_value
|
|
170
|
+
currency_amount_original_unit: original_unit
|
|
171
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
172
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
173
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
174
|
+
}
|
|
175
|
+
lightspark_node_local_balance: local_balance {
|
|
176
|
+
__typename
|
|
177
|
+
currency_amount_original_value: original_value
|
|
178
|
+
currency_amount_original_unit: original_unit
|
|
179
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
180
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
181
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
182
|
+
}
|
|
183
|
+
lightspark_node_purpose: purpose
|
|
184
|
+
lightspark_node_remote_balance: remote_balance {
|
|
185
|
+
__typename
|
|
186
|
+
currency_amount_original_value: original_value
|
|
187
|
+
currency_amount_original_unit: original_unit
|
|
188
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
189
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
190
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
191
|
+
}
|
|
192
|
+
lightspark_node_status: status
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
invoice_data_memo: memo
|
|
196
|
+
}
|
|
197
|
+
invoice_status: status
|
|
198
|
+
invoice_amount_paid: amount_paid {
|
|
199
|
+
__typename
|
|
200
|
+
currency_amount_original_value: original_value
|
|
201
|
+
currency_amount_original_unit: original_unit
|
|
202
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
203
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
204
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
205
|
+
}
|
|
206
|
+
}`;
|
|
207
|
+
|
|
208
|
+
export const getInvoiceQuery = (id: string): Query<Invoice> => {
|
|
209
|
+
return {
|
|
210
|
+
queryPayload: `
|
|
211
|
+
query GetInvoice($id: ID!) {
|
|
212
|
+
entity(id: $id) {
|
|
213
|
+
... on Invoice {
|
|
214
|
+
...InvoiceFragment
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
${FRAGMENT}
|
|
220
|
+
`,
|
|
221
|
+
variables: { id },
|
|
222
|
+
constructObject: (data: any) => InvoiceFromJson(data.entity),
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export default Invoice;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import BitcoinNetwork from "./BitcoinNetwork.js";
|
|
4
|
+
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
5
|
+
import Node, { NodeFromJson } from "./Node.js";
|
|
6
|
+
import PaymentRequestData from "./PaymentRequestData.js";
|
|
7
|
+
|
|
8
|
+
/** This object represents the BOLT #11 invoice protocol for Lightning Payments. See https://github.com/lightning/bolts/blob/master/11-payment-encoding.md. **/
|
|
9
|
+
type InvoiceData = PaymentRequestData & {
|
|
10
|
+
encodedPaymentRequest: string;
|
|
11
|
+
|
|
12
|
+
bitcoinNetwork: BitcoinNetwork;
|
|
13
|
+
|
|
14
|
+
paymentHash: string;
|
|
15
|
+
|
|
16
|
+
amount: CurrencyAmount;
|
|
17
|
+
|
|
18
|
+
createdAt: string;
|
|
19
|
+
|
|
20
|
+
expiresAt: string;
|
|
21
|
+
|
|
22
|
+
destination: Node;
|
|
23
|
+
|
|
24
|
+
/** The typename of the object **/
|
|
25
|
+
typename: string;
|
|
26
|
+
|
|
27
|
+
memo?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const InvoiceDataFromJson = (obj: any): InvoiceData => {
|
|
31
|
+
return {
|
|
32
|
+
encodedPaymentRequest: obj["invoice_data_encoded_payment_request"],
|
|
33
|
+
bitcoinNetwork:
|
|
34
|
+
BitcoinNetwork[obj["invoice_data_bitcoin_network"]] ??
|
|
35
|
+
BitcoinNetwork.FUTURE_VALUE,
|
|
36
|
+
paymentHash: obj["invoice_data_payment_hash"],
|
|
37
|
+
amount: CurrencyAmountFromJson(obj["invoice_data_amount"]),
|
|
38
|
+
createdAt: obj["invoice_data_created_at"],
|
|
39
|
+
expiresAt: obj["invoice_data_expires_at"],
|
|
40
|
+
destination: NodeFromJson(obj["invoice_data_destination"]),
|
|
41
|
+
typename: "InvoiceData",
|
|
42
|
+
memo: obj["invoice_data_memo"],
|
|
43
|
+
} as InvoiceData;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const FRAGMENT = `
|
|
47
|
+
fragment InvoiceDataFragment on InvoiceData {
|
|
48
|
+
__typename
|
|
49
|
+
invoice_data_encoded_payment_request: encoded_payment_request
|
|
50
|
+
invoice_data_bitcoin_network: bitcoin_network
|
|
51
|
+
invoice_data_payment_hash: payment_hash
|
|
52
|
+
invoice_data_amount: amount {
|
|
53
|
+
__typename
|
|
54
|
+
currency_amount_original_value: original_value
|
|
55
|
+
currency_amount_original_unit: original_unit
|
|
56
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
57
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
58
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
59
|
+
}
|
|
60
|
+
invoice_data_created_at: created_at
|
|
61
|
+
invoice_data_expires_at: expires_at
|
|
62
|
+
invoice_data_destination: destination {
|
|
63
|
+
__typename
|
|
64
|
+
... on GraphNode {
|
|
65
|
+
__typename
|
|
66
|
+
graph_node_id: id
|
|
67
|
+
graph_node_created_at: created_at
|
|
68
|
+
graph_node_updated_at: updated_at
|
|
69
|
+
graph_node_alias: alias
|
|
70
|
+
graph_node_bitcoin_network: bitcoin_network
|
|
71
|
+
graph_node_color: color
|
|
72
|
+
graph_node_conductivity: conductivity
|
|
73
|
+
graph_node_display_name: display_name
|
|
74
|
+
graph_node_public_key: public_key
|
|
75
|
+
}
|
|
76
|
+
... on LightsparkNode {
|
|
77
|
+
__typename
|
|
78
|
+
lightspark_node_id: id
|
|
79
|
+
lightspark_node_created_at: created_at
|
|
80
|
+
lightspark_node_updated_at: updated_at
|
|
81
|
+
lightspark_node_alias: alias
|
|
82
|
+
lightspark_node_bitcoin_network: bitcoin_network
|
|
83
|
+
lightspark_node_color: color
|
|
84
|
+
lightspark_node_conductivity: conductivity
|
|
85
|
+
lightspark_node_display_name: display_name
|
|
86
|
+
lightspark_node_public_key: public_key
|
|
87
|
+
lightspark_node_account: account {
|
|
88
|
+
id
|
|
89
|
+
}
|
|
90
|
+
lightspark_node_blockchain_balance: blockchain_balance {
|
|
91
|
+
__typename
|
|
92
|
+
blockchain_balance_total_balance: total_balance {
|
|
93
|
+
__typename
|
|
94
|
+
currency_amount_original_value: original_value
|
|
95
|
+
currency_amount_original_unit: original_unit
|
|
96
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
97
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
98
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
99
|
+
}
|
|
100
|
+
blockchain_balance_confirmed_balance: confirmed_balance {
|
|
101
|
+
__typename
|
|
102
|
+
currency_amount_original_value: original_value
|
|
103
|
+
currency_amount_original_unit: original_unit
|
|
104
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
105
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
106
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
107
|
+
}
|
|
108
|
+
blockchain_balance_unconfirmed_balance: unconfirmed_balance {
|
|
109
|
+
__typename
|
|
110
|
+
currency_amount_original_value: original_value
|
|
111
|
+
currency_amount_original_unit: original_unit
|
|
112
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
113
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
114
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
115
|
+
}
|
|
116
|
+
blockchain_balance_locked_balance: locked_balance {
|
|
117
|
+
__typename
|
|
118
|
+
currency_amount_original_value: original_value
|
|
119
|
+
currency_amount_original_unit: original_unit
|
|
120
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
121
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
122
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
123
|
+
}
|
|
124
|
+
blockchain_balance_required_reserve: required_reserve {
|
|
125
|
+
__typename
|
|
126
|
+
currency_amount_original_value: original_value
|
|
127
|
+
currency_amount_original_unit: original_unit
|
|
128
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
129
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
130
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
131
|
+
}
|
|
132
|
+
blockchain_balance_available_balance: available_balance {
|
|
133
|
+
__typename
|
|
134
|
+
currency_amount_original_value: original_value
|
|
135
|
+
currency_amount_original_unit: original_unit
|
|
136
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
137
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
138
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
lightspark_node_encrypted_signing_private_key: encrypted_signing_private_key {
|
|
142
|
+
__typename
|
|
143
|
+
secret_encrypted_value: encrypted_value
|
|
144
|
+
secret_cipher: cipher
|
|
145
|
+
}
|
|
146
|
+
lightspark_node_total_balance: total_balance {
|
|
147
|
+
__typename
|
|
148
|
+
currency_amount_original_value: original_value
|
|
149
|
+
currency_amount_original_unit: original_unit
|
|
150
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
151
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
152
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
153
|
+
}
|
|
154
|
+
lightspark_node_total_local_balance: total_local_balance {
|
|
155
|
+
__typename
|
|
156
|
+
currency_amount_original_value: original_value
|
|
157
|
+
currency_amount_original_unit: original_unit
|
|
158
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
159
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
160
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
161
|
+
}
|
|
162
|
+
lightspark_node_local_balance: local_balance {
|
|
163
|
+
__typename
|
|
164
|
+
currency_amount_original_value: original_value
|
|
165
|
+
currency_amount_original_unit: original_unit
|
|
166
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
167
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
168
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
169
|
+
}
|
|
170
|
+
lightspark_node_purpose: purpose
|
|
171
|
+
lightspark_node_remote_balance: remote_balance {
|
|
172
|
+
__typename
|
|
173
|
+
currency_amount_original_value: original_value
|
|
174
|
+
currency_amount_original_unit: original_unit
|
|
175
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
176
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
177
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
178
|
+
}
|
|
179
|
+
lightspark_node_status: status
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
invoice_data_memo: memo
|
|
183
|
+
}`;
|
|
184
|
+
|
|
185
|
+
export default InvoiceData;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
export enum InvoiceType {
|
|
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
|
+
/** A standard Bolt 11 invoice. **/
|
|
10
|
+
STANDARD = "STANDARD",
|
|
11
|
+
/** An AMP (Atomic Multi-path Payment) invoice. **/
|
|
12
|
+
AMP = "AMP",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default InvoiceType;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
type LightningFeeEstimateForInvoiceInput = {
|
|
4
|
+
/** The node from where you want to send the payment. **/
|
|
5
|
+
nodeId: string;
|
|
6
|
+
|
|
7
|
+
/** The invoice you want to pay (as defined by the BOLT11 standard). **/
|
|
8
|
+
encodedPaymentRequest: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* If the invoice does not specify a payment amount, then the amount that you wish to pay, expressed
|
|
12
|
+
* in msats.
|
|
13
|
+
**/
|
|
14
|
+
amountMsats?: number;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const LightningFeeEstimateForInvoiceInputFromJson = (
|
|
18
|
+
obj: any
|
|
19
|
+
): LightningFeeEstimateForInvoiceInput => {
|
|
20
|
+
return {
|
|
21
|
+
nodeId: obj["lightning_fee_estimate_for_invoice_input_node_id"],
|
|
22
|
+
encodedPaymentRequest:
|
|
23
|
+
obj["lightning_fee_estimate_for_invoice_input_encoded_payment_request"],
|
|
24
|
+
amountMsats: obj["lightning_fee_estimate_for_invoice_input_amount_msats"],
|
|
25
|
+
} as LightningFeeEstimateForInvoiceInput;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default LightningFeeEstimateForInvoiceInput;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
type LightningFeeEstimateForNodeInput = {
|
|
4
|
+
/** The node from where you want to send the payment. **/
|
|
5
|
+
nodeId: string;
|
|
6
|
+
|
|
7
|
+
/** The public key of the node that you want to pay. **/
|
|
8
|
+
destinationNodePublicKey: string;
|
|
9
|
+
|
|
10
|
+
/** The payment amount expressed in msats. **/
|
|
11
|
+
amountMsats: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const LightningFeeEstimateForNodeInputFromJson = (
|
|
15
|
+
obj: any
|
|
16
|
+
): LightningFeeEstimateForNodeInput => {
|
|
17
|
+
return {
|
|
18
|
+
nodeId: obj["lightning_fee_estimate_for_node_input_node_id"],
|
|
19
|
+
destinationNodePublicKey:
|
|
20
|
+
obj["lightning_fee_estimate_for_node_input_destination_node_public_key"],
|
|
21
|
+
amountMsats: obj["lightning_fee_estimate_for_node_input_amount_msats"],
|
|
22
|
+
} as LightningFeeEstimateForNodeInput;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default LightningFeeEstimateForNodeInput;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
4
|
+
|
|
5
|
+
type LightningFeeEstimateOutput = {
|
|
6
|
+
/** The estimated fees for the payment. **/
|
|
7
|
+
feeEstimate: CurrencyAmount;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const LightningFeeEstimateOutputFromJson = (
|
|
11
|
+
obj: any
|
|
12
|
+
): LightningFeeEstimateOutput => {
|
|
13
|
+
return {
|
|
14
|
+
feeEstimate: CurrencyAmountFromJson(
|
|
15
|
+
obj["lightning_fee_estimate_output_fee_estimate"]
|
|
16
|
+
),
|
|
17
|
+
} as LightningFeeEstimateOutput;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const FRAGMENT = `
|
|
21
|
+
fragment LightningFeeEstimateOutputFragment on LightningFeeEstimateOutput {
|
|
22
|
+
__typename
|
|
23
|
+
lightning_fee_estimate_output_fee_estimate: fee_estimate {
|
|
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
|
+
}`;
|
|
32
|
+
|
|
33
|
+
export default LightningFeeEstimateOutput;
|