@lightsparkdev/lightspark-sdk 0.3.3 → 0.4.0
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-PD33OHE4.js → chunk-VAJWSX3C.js} +186 -32
- package/dist/{index-d2343f8f.d.ts → index-aa922ada.d.ts} +98 -28
- package/dist/index.cjs +994 -795
- package/dist/index.d.ts +3 -2
- package/dist/index.js +69 -14
- package/dist/objects/index.cjs +168 -17
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +5 -1
- package/package.json +3 -2
- package/src/client.ts +34 -0
- package/src/graphql/CreateLnurlInvoice.ts +21 -0
- package/src/objects/Account.ts +12 -2
- package/src/objects/CreateLnurlInvoiceInput.ts +27 -0
- package/src/objects/Entity.ts +10 -0
- package/src/objects/Invoice.ts +3 -0
- package/src/objects/InvoiceData.ts +3 -0
- package/src/objects/LightningTransaction.ts +3 -0
- package/src/objects/LightsparkNode.ts +5 -0
- package/src/objects/LightsparkNodeOwner.ts +125 -0
- package/src/objects/Node.ts +4 -0
- package/src/objects/OutgoingPayment.ts +3 -0
- package/src/objects/PaymentRequest.ts +3 -0
- package/src/objects/PaymentRequestData.ts +3 -0
- package/src/objects/Transaction.ts +3 -0
- package/src/objects/Wallet.ts +11 -7
- package/src/objects/WalletStatus.ts +29 -0
- package/src/objects/index.ts +6 -0
- package/src/webhooks.ts +2 -0
package/dist/objects/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BitcoinNetwork, j as BlockchainBalance, C as Channel, k as ChannelClosingTransaction, m as ChannelFees, n as ChannelOpeningTransaction, p as ChannelStatus, q as ChannelToTransactionsConnection, r as CreateApiTokenInput, s as CreateApiTokenOutput, t as CreateInvoiceInput, u as CreateInvoiceOutput, v as
|
|
1
|
+
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BitcoinNetwork, j as BlockchainBalance, C as Channel, k as ChannelClosingTransaction, m as ChannelFees, n as ChannelOpeningTransaction, p as ChannelStatus, q as ChannelToTransactionsConnection, r as CreateApiTokenInput, s as CreateApiTokenOutput, t as CreateInvoiceInput, u as CreateInvoiceOutput, v as CreateLnurlInvoiceInput, w as CreateNodeWalletAddressInput, x as CreateNodeWalletAddressOutput, y as CreateTestModeInvoiceInput, z as CreateTestModeInvoiceOutput, D as CreateTestModePaymentInput, E as CreateTestModePaymentoutput, F as CurrencyAmount, G as CurrencyUnit, H as DeleteApiTokenInput, I as DeleteApiTokenOutput, J as Deposit, M as Entity, N as FeeEstimate, O as FundNodeInput, P as FundNodeOutput, Q as GraphNode, R as Hop, T as HtlcAttemptFailureCode, U as IncomingPayment, V as IncomingPaymentAttempt, Y as IncomingPaymentAttemptStatus, Z as IncomingPaymentToAttemptsConnection, _ as Invoice, a0 as InvoiceData, a1 as InvoiceType, a2 as LightningFeeEstimateForInvoiceInput, a3 as LightningFeeEstimateForNodeInput, a4 as LightningFeeEstimateOutput, a5 as LightningTransaction, a7 as LightsparkNode, a8 as LightsparkNodeOwner, aa as LightsparkNodePurpose, ab as LightsparkNodeStatus, ac as LightsparkNodeToChannelsConnection, ad as Node, ae as NodeAddress, af as NodeAddressType, ag as NodeToAddressesConnection, ah as OnChainTransaction, aj as OutgoingPayment, ak as OutgoingPaymentAttempt, al as OutgoingPaymentAttemptStatus, am as OutgoingPaymentAttemptToHopsConnection, an as OutgoingPaymentToAttemptsConnection, ao as PageInfo, ap as PayInvoiceInput, aq as PayInvoiceOutput, ar as PaymentFailureReason, as as PaymentRequest, au as PaymentRequestData, av as PaymentRequestStatus, aw as Permission, ax as RequestWithdrawalInput, ay as RequestWithdrawalOutput, az as RichText, aA as RoutingTransaction, aC as RoutingTransactionFailureReason, aD as Secret, aE as SendPaymentInput, aF as SendPaymentOutput, aG as SingleNodeDashboard, aH as Transaction, aJ as TransactionFailures, aK as TransactionStatus, aL as TransactionType, aM as TransactionUpdate, aN as Wallet, aO as WalletStatus, W as WebhookEventType, aP as Withdrawal, aR as WithdrawalMode, aS as WithdrawalRequest, aT as WithdrawalRequestStatus, aU as WithdrawalRequestToChannelClosingTransactionsConnection, aV as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, K as getDepositQuery, S as getHopQuery, X as getIncomingPaymentAttemptQuery, $ as getInvoiceQuery, a6 as getLightningTransactionQuery, a9 as getLightsparkNodeOwnerQuery, ai as getOnChainTransactionQuery, at as getPaymentRequestQuery, aB as getRoutingTransactionQuery, aI as getTransactionQuery, aQ as getWithdrawalQuery } from '../index-aa922ada.js';
|
|
2
2
|
import '@lightsparkdev/core';
|
|
3
3
|
import 'zen-observable';
|
package/dist/objects/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
RoutingTransactionFailureReason_default,
|
|
25
25
|
TransactionStatus_default,
|
|
26
26
|
TransactionType_default,
|
|
27
|
+
WalletStatus_default,
|
|
27
28
|
Wallet_default,
|
|
28
29
|
WebhookEventType_default,
|
|
29
30
|
WithdrawalMode_default,
|
|
@@ -37,12 +38,13 @@ import {
|
|
|
37
38
|
getIncomingPaymentAttemptQuery,
|
|
38
39
|
getInvoiceQuery,
|
|
39
40
|
getLightningTransactionQuery,
|
|
41
|
+
getLightsparkNodeOwnerQuery,
|
|
40
42
|
getOnChainTransactionQuery,
|
|
41
43
|
getPaymentRequestQuery,
|
|
42
44
|
getRoutingTransactionQuery,
|
|
43
45
|
getTransactionQuery,
|
|
44
46
|
getWithdrawalQuery
|
|
45
|
-
} from "../chunk-
|
|
47
|
+
} from "../chunk-VAJWSX3C.js";
|
|
46
48
|
import "../chunk-NIMBE7W3.js";
|
|
47
49
|
export {
|
|
48
50
|
Account_default as Account,
|
|
@@ -71,6 +73,7 @@ export {
|
|
|
71
73
|
TransactionStatus_default as TransactionStatus,
|
|
72
74
|
TransactionType_default as TransactionType,
|
|
73
75
|
Wallet_default as Wallet,
|
|
76
|
+
WalletStatus_default as WalletStatus,
|
|
74
77
|
WebhookEventType_default as WebhookEventType,
|
|
75
78
|
WithdrawalMode_default as WithdrawalMode,
|
|
76
79
|
WithdrawalRequest_default as WithdrawalRequest,
|
|
@@ -83,6 +86,7 @@ export {
|
|
|
83
86
|
getIncomingPaymentAttemptQuery,
|
|
84
87
|
getInvoiceQuery,
|
|
85
88
|
getLightningTransactionQuery,
|
|
89
|
+
getLightsparkNodeOwnerQuery,
|
|
86
90
|
getOnChainTransactionQuery,
|
|
87
91
|
getPaymentRequestQuery,
|
|
88
92
|
getRoutingTransactionQuery,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/lightspark-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"license": "Apache-2.0",
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@lightsparkdev/core": "0.3.
|
|
72
|
+
"@lightsparkdev/core": "0.3.3",
|
|
73
73
|
"auto-bind": "^5.0.1",
|
|
74
74
|
"crypto": "^1.0.1",
|
|
75
75
|
"crypto-browserify": "^3.12.0",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"@types/ws": "^8.5.4",
|
|
86
86
|
"jest": "^29.4.1",
|
|
87
87
|
"prettier": "2.8.7",
|
|
88
|
+
"prettier-plugin-organize-imports": "^3.2.2",
|
|
88
89
|
"ts-jest": "^29.0.5",
|
|
89
90
|
"ts-node": "^10.9.1",
|
|
90
91
|
"tsconfig": "*",
|
package/src/client.ts
CHANGED
|
@@ -19,9 +19,11 @@ import {
|
|
|
19
19
|
Requester,
|
|
20
20
|
StubAuthProvider,
|
|
21
21
|
} from "@lightsparkdev/core";
|
|
22
|
+
import { createHash } from "crypto";
|
|
22
23
|
import { BitcoinFeeEstimate as BitcoinFeeEstimateQuery } from "./graphql/BitcoinFeeEstimate.js";
|
|
23
24
|
import { CreateApiToken } from "./graphql/CreateApiToken.js";
|
|
24
25
|
import { CreateInvoice } from "./graphql/CreateInvoice.js";
|
|
26
|
+
import { CreateLnurlInvoice } from "./graphql/CreateLnurlInvoice.js";
|
|
25
27
|
import { CreateNodeWalletAddress } from "./graphql/CreateNodeWalletAddress.js";
|
|
26
28
|
import { CreateTestModeInvoice } from "./graphql/CreateTestModeInvoice.js";
|
|
27
29
|
import { CreateTestModePayment } from "./graphql/CreateTestModePayment.js";
|
|
@@ -49,6 +51,7 @@ import CurrencyAmount, {
|
|
|
49
51
|
CurrencyAmountFromJson,
|
|
50
52
|
} from "./objects/CurrencyAmount.js";
|
|
51
53
|
import FeeEstimate, { FeeEstimateFromJson } from "./objects/FeeEstimate.js";
|
|
54
|
+
import Invoice, { InvoiceFromJson } from "./objects/Invoice.js";
|
|
52
55
|
import InvoiceData, { InvoiceDataFromJson } from "./objects/InvoiceData.js";
|
|
53
56
|
import InvoiceType from "./objects/InvoiceType.js";
|
|
54
57
|
import OutgoingPayment, {
|
|
@@ -405,6 +408,37 @@ class LightsparkClient {
|
|
|
405
408
|
return response.create_invoice?.invoice.data?.encoded_payment_request;
|
|
406
409
|
}
|
|
407
410
|
|
|
411
|
+
/**
|
|
412
|
+
* Generates a Lightning Invoice (follows the Bolt 11 specification) to request a payment
|
|
413
|
+
* from another Lightning Node. This should only be used for generating invoices for LNURLs,
|
|
414
|
+
* with [createInvoice] preferred in the general case.
|
|
415
|
+
*
|
|
416
|
+
* Test mode note: You can simulate a payment of this invoice in test move using [createTestModePayment].
|
|
417
|
+
*
|
|
418
|
+
* @param nodeId The node ID for which to create an invoice.
|
|
419
|
+
* @param amountMsats The amount of the invoice in msats. You can create a zero-amount invoice to accept any payment amount.
|
|
420
|
+
* @param metadata The LNURL metadata payload field in the initial payreq response. This wil be hashed and present in the
|
|
421
|
+
* h-tag (SHA256 purpose of payment) of the resulting Bolt 11 invoice. See
|
|
422
|
+
* [this spec](https://github.com/lnurl/luds/blob/luds/06.md#pay-to-static-qrnfclink) for details.
|
|
423
|
+
* @returns An Invoice object representing the generated invoice.
|
|
424
|
+
*/
|
|
425
|
+
public async createLnurlInvoice(
|
|
426
|
+
nodeId: string,
|
|
427
|
+
amountMsats: number,
|
|
428
|
+
metadata: string
|
|
429
|
+
): Promise<Invoice | undefined> {
|
|
430
|
+
const response = await this.requester.makeRawRequest(CreateLnurlInvoice, {
|
|
431
|
+
node_id: nodeId,
|
|
432
|
+
amount_msats: amountMsats,
|
|
433
|
+
metadata_hash: createHash("sha256").update(metadata).digest("hex"),
|
|
434
|
+
});
|
|
435
|
+
const invoiceJson = response.create_lnurl_invoice?.invoice;
|
|
436
|
+
if (!invoiceJson) {
|
|
437
|
+
return undefined;
|
|
438
|
+
}
|
|
439
|
+
return InvoiceFromJson(invoiceJson);
|
|
440
|
+
}
|
|
441
|
+
|
|
408
442
|
/**
|
|
409
443
|
* Decodes an encoded lightning invoice string.
|
|
410
444
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
import { FRAGMENT as InvoiceFragment } from "../objects/Invoice.js";
|
|
3
|
+
|
|
4
|
+
export const CreateLnurlInvoice = `
|
|
5
|
+
mutation CreateLnurlInvoice(
|
|
6
|
+
$node_id: ID!
|
|
7
|
+
$amount_msats: Long!
|
|
8
|
+
$metadata_hash: String!
|
|
9
|
+
) {
|
|
10
|
+
create_lnurl_invoice(input: {
|
|
11
|
+
node_id: $node_id
|
|
12
|
+
amount_msats: $amount_msats
|
|
13
|
+
metadata_hash: $metadata_hash
|
|
14
|
+
}) {
|
|
15
|
+
invoice {
|
|
16
|
+
...InvoiceFragment
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
${InvoiceFragment}
|
|
21
|
+
`;
|
package/src/objects/Account.ts
CHANGED
|
@@ -26,12 +26,12 @@ import BlockchainBalance, {
|
|
|
26
26
|
BlockchainBalanceFromJson,
|
|
27
27
|
} from "./BlockchainBalance.js";
|
|
28
28
|
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
29
|
-
import
|
|
29
|
+
import LightsparkNodeOwner from "./LightsparkNodeOwner.js";
|
|
30
30
|
import TransactionFailures from "./TransactionFailures.js";
|
|
31
31
|
import TransactionStatus from "./TransactionStatus.js";
|
|
32
32
|
import TransactionType from "./TransactionType.js";
|
|
33
33
|
|
|
34
|
-
class Account implements
|
|
34
|
+
class Account implements LightsparkNodeOwner {
|
|
35
35
|
constructor(
|
|
36
36
|
public readonly id: string,
|
|
37
37
|
public readonly createdAt: string,
|
|
@@ -245,6 +245,9 @@ query FetchAccountToNodesConnection($first: Int, $bitcoin_networks: [BitcoinNetw
|
|
|
245
245
|
lightspark_node_account: account {
|
|
246
246
|
id
|
|
247
247
|
}
|
|
248
|
+
lightspark_node_owner: owner {
|
|
249
|
+
id
|
|
250
|
+
}
|
|
248
251
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
249
252
|
__typename
|
|
250
253
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -786,6 +789,9 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
|
|
|
786
789
|
lightspark_node_account: account {
|
|
787
790
|
id
|
|
788
791
|
}
|
|
792
|
+
lightspark_node_owner: owner {
|
|
793
|
+
id
|
|
794
|
+
}
|
|
789
795
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
790
796
|
__typename
|
|
791
797
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -1053,6 +1059,9 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
|
|
|
1053
1059
|
lightspark_node_account: account {
|
|
1054
1060
|
id
|
|
1055
1061
|
}
|
|
1062
|
+
lightspark_node_owner: owner {
|
|
1063
|
+
id
|
|
1064
|
+
}
|
|
1056
1065
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
1057
1066
|
__typename
|
|
1058
1067
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -1237,6 +1246,7 @@ query FetchAccountToWalletsConnection($first: Int) {
|
|
|
1237
1246
|
}
|
|
1238
1247
|
}
|
|
1239
1248
|
wallet_third_party_identifier: third_party_identifier
|
|
1249
|
+
wallet_status: status
|
|
1240
1250
|
}
|
|
1241
1251
|
}
|
|
1242
1252
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
type CreateLnurlInvoiceInput = {
|
|
4
|
+
/** The node from which to create the invoice. **/
|
|
5
|
+
nodeId: string;
|
|
6
|
+
|
|
7
|
+
/** The amount for which the invoice should be created, in millisatoshis. **/
|
|
8
|
+
amountMsats: number;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The SHA256 hash of the LNURL metadata payload. This will be present in the h-tag (SHA256 purpose of
|
|
12
|
+
* payment) of the resulting Bolt 11 invoice.
|
|
13
|
+
**/
|
|
14
|
+
metadataHash: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const CreateLnurlInvoiceInputFromJson = (
|
|
18
|
+
obj: any
|
|
19
|
+
): CreateLnurlInvoiceInput => {
|
|
20
|
+
return {
|
|
21
|
+
nodeId: obj["create_lnurl_invoice_input_node_id"],
|
|
22
|
+
amountMsats: obj["create_lnurl_invoice_input_amount_msats"],
|
|
23
|
+
metadataHash: obj["create_lnurl_invoice_input_metadata_hash"],
|
|
24
|
+
} as CreateLnurlInvoiceInput;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default CreateLnurlInvoiceInput;
|
package/src/objects/Entity.ts
CHANGED
|
@@ -361,6 +361,9 @@ fragment EntityFragment on Entity {
|
|
|
361
361
|
lightspark_node_account: account {
|
|
362
362
|
id
|
|
363
363
|
}
|
|
364
|
+
lightspark_node_owner: owner {
|
|
365
|
+
id
|
|
366
|
+
}
|
|
364
367
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
365
368
|
__typename
|
|
366
369
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -478,6 +481,9 @@ fragment EntityFragment on Entity {
|
|
|
478
481
|
lightspark_node_account: account {
|
|
479
482
|
id
|
|
480
483
|
}
|
|
484
|
+
lightspark_node_owner: owner {
|
|
485
|
+
id
|
|
486
|
+
}
|
|
481
487
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
482
488
|
__typename
|
|
483
489
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -645,6 +651,9 @@ fragment EntityFragment on Entity {
|
|
|
645
651
|
lightspark_node_account: account {
|
|
646
652
|
id
|
|
647
653
|
}
|
|
654
|
+
lightspark_node_owner: owner {
|
|
655
|
+
id
|
|
656
|
+
}
|
|
648
657
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
649
658
|
__typename
|
|
650
659
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -844,6 +853,7 @@ fragment EntityFragment on Entity {
|
|
|
844
853
|
}
|
|
845
854
|
}
|
|
846
855
|
wallet_third_party_identifier: third_party_identifier
|
|
856
|
+
wallet_status: status
|
|
847
857
|
}
|
|
848
858
|
... on Withdrawal {
|
|
849
859
|
__typename
|
package/src/objects/Invoice.ts
CHANGED
|
@@ -101,6 +101,9 @@ fragment InvoiceFragment on Invoice {
|
|
|
101
101
|
lightspark_node_account: account {
|
|
102
102
|
id
|
|
103
103
|
}
|
|
104
|
+
lightspark_node_owner: owner {
|
|
105
|
+
id
|
|
106
|
+
}
|
|
104
107
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
105
108
|
__typename
|
|
106
109
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -97,6 +97,9 @@ fragment InvoiceDataFragment on InvoiceData {
|
|
|
97
97
|
lightspark_node_account: account {
|
|
98
98
|
id
|
|
99
99
|
}
|
|
100
|
+
lightspark_node_owner: owner {
|
|
101
|
+
id
|
|
102
|
+
}
|
|
100
103
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
101
104
|
__typename
|
|
102
105
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -232,6 +232,9 @@ fragment LightningTransactionFragment on LightningTransaction {
|
|
|
232
232
|
lightspark_node_account: account {
|
|
233
233
|
id
|
|
234
234
|
}
|
|
235
|
+
lightspark_node_owner: owner {
|
|
236
|
+
id
|
|
237
|
+
}
|
|
235
238
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
236
239
|
__typename
|
|
237
240
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -30,6 +30,7 @@ class LightsparkNode implements Node {
|
|
|
30
30
|
public readonly bitcoinNetwork: BitcoinNetwork,
|
|
31
31
|
public readonly displayName: string,
|
|
32
32
|
public readonly accountId: string,
|
|
33
|
+
public readonly ownerId: string,
|
|
33
34
|
public readonly typename: string,
|
|
34
35
|
public readonly alias?: string,
|
|
35
36
|
public readonly color?: string,
|
|
@@ -233,6 +234,7 @@ export const LightsparkNodeFromJson = (obj: any): LightsparkNode => {
|
|
|
233
234
|
BitcoinNetwork.FUTURE_VALUE,
|
|
234
235
|
obj["lightspark_node_display_name"],
|
|
235
236
|
obj["lightspark_node_account"].id,
|
|
237
|
+
obj["lightspark_node_owner"].id,
|
|
236
238
|
"LightsparkNode",
|
|
237
239
|
obj["lightspark_node_alias"],
|
|
238
240
|
obj["lightspark_node_color"],
|
|
@@ -282,6 +284,9 @@ fragment LightsparkNodeFragment on LightsparkNode {
|
|
|
282
284
|
lightspark_node_account: account {
|
|
283
285
|
id
|
|
284
286
|
}
|
|
287
|
+
lightspark_node_owner: owner {
|
|
288
|
+
id
|
|
289
|
+
}
|
|
285
290
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
286
291
|
__typename
|
|
287
292
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
import { LightsparkException, Query } from "@lightsparkdev/core";
|
|
4
|
+
import Account from "./Account.js";
|
|
5
|
+
import { BalancesFromJson } from "./Balances.js";
|
|
6
|
+
import Entity from "./Entity.js";
|
|
7
|
+
import Wallet from "./Wallet.js";
|
|
8
|
+
import WalletStatus from "./WalletStatus.js";
|
|
9
|
+
|
|
10
|
+
type LightsparkNodeOwner = Entity & {
|
|
11
|
+
/**
|
|
12
|
+
* The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
|
|
13
|
+
* string.
|
|
14
|
+
**/
|
|
15
|
+
id: string;
|
|
16
|
+
|
|
17
|
+
/** The date and time when the entity was first created. **/
|
|
18
|
+
createdAt: string;
|
|
19
|
+
|
|
20
|
+
/** The date and time when the entity was last updated. **/
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
|
|
23
|
+
/** The typename of the object **/
|
|
24
|
+
typename: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const LightsparkNodeOwnerFromJson = (obj: any): LightsparkNodeOwner => {
|
|
28
|
+
if (obj["__typename"] == "Account") {
|
|
29
|
+
return new Account(
|
|
30
|
+
obj["account_id"],
|
|
31
|
+
obj["account_created_at"],
|
|
32
|
+
obj["account_updated_at"],
|
|
33
|
+
"Account",
|
|
34
|
+
obj["account_name"]
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (obj["__typename"] == "Wallet") {
|
|
38
|
+
return new Wallet(
|
|
39
|
+
obj["wallet_id"],
|
|
40
|
+
obj["wallet_created_at"],
|
|
41
|
+
obj["wallet_updated_at"],
|
|
42
|
+
obj["wallet_third_party_identifier"],
|
|
43
|
+
WalletStatus[obj["wallet_status"]] ?? WalletStatus.FUTURE_VALUE,
|
|
44
|
+
"Wallet",
|
|
45
|
+
obj["wallet_last_login_at"],
|
|
46
|
+
!!obj["wallet_balances"]
|
|
47
|
+
? BalancesFromJson(obj["wallet_balances"])
|
|
48
|
+
: undefined
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
throw new LightsparkException(
|
|
52
|
+
"DeserializationError",
|
|
53
|
+
`Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename=${obj["__typename"]}`
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const FRAGMENT = `
|
|
58
|
+
fragment LightsparkNodeOwnerFragment on LightsparkNodeOwner {
|
|
59
|
+
__typename
|
|
60
|
+
... on Account {
|
|
61
|
+
__typename
|
|
62
|
+
account_id: id
|
|
63
|
+
account_created_at: created_at
|
|
64
|
+
account_updated_at: updated_at
|
|
65
|
+
account_name: name
|
|
66
|
+
}
|
|
67
|
+
... on Wallet {
|
|
68
|
+
__typename
|
|
69
|
+
wallet_id: id
|
|
70
|
+
wallet_created_at: created_at
|
|
71
|
+
wallet_updated_at: updated_at
|
|
72
|
+
wallet_last_login_at: last_login_at
|
|
73
|
+
wallet_balances: balances {
|
|
74
|
+
__typename
|
|
75
|
+
balances_owned_balance: owned_balance {
|
|
76
|
+
__typename
|
|
77
|
+
currency_amount_original_value: original_value
|
|
78
|
+
currency_amount_original_unit: original_unit
|
|
79
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
80
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
81
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
82
|
+
}
|
|
83
|
+
balances_available_to_send_balance: available_to_send_balance {
|
|
84
|
+
__typename
|
|
85
|
+
currency_amount_original_value: original_value
|
|
86
|
+
currency_amount_original_unit: original_unit
|
|
87
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
88
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
89
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
90
|
+
}
|
|
91
|
+
balances_available_to_withdraw_balance: available_to_withdraw_balance {
|
|
92
|
+
__typename
|
|
93
|
+
currency_amount_original_value: original_value
|
|
94
|
+
currency_amount_original_unit: original_unit
|
|
95
|
+
currency_amount_preferred_currency_unit: preferred_currency_unit
|
|
96
|
+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
|
|
97
|
+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
wallet_third_party_identifier: third_party_identifier
|
|
101
|
+
wallet_status: status
|
|
102
|
+
}
|
|
103
|
+
}`;
|
|
104
|
+
|
|
105
|
+
export const getLightsparkNodeOwnerQuery = (
|
|
106
|
+
id: string
|
|
107
|
+
): Query<LightsparkNodeOwner> => {
|
|
108
|
+
return {
|
|
109
|
+
queryPayload: `
|
|
110
|
+
query GetLightsparkNodeOwner($id: ID!) {
|
|
111
|
+
entity(id: $id) {
|
|
112
|
+
... on LightsparkNodeOwner {
|
|
113
|
+
...LightsparkNodeOwnerFragment
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
${FRAGMENT}
|
|
119
|
+
`,
|
|
120
|
+
variables: { id },
|
|
121
|
+
constructObject: (data: any) => LightsparkNodeOwnerFromJson(data.entity),
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default LightsparkNodeOwner;
|
package/src/objects/Node.ts
CHANGED
|
@@ -109,6 +109,7 @@ export const NodeFromJson = (obj: any): Node => {
|
|
|
109
109
|
BitcoinNetwork.FUTURE_VALUE,
|
|
110
110
|
obj["lightspark_node_display_name"],
|
|
111
111
|
obj["lightspark_node_account"].id,
|
|
112
|
+
obj["lightspark_node_owner"].id,
|
|
112
113
|
"LightsparkNode",
|
|
113
114
|
obj["lightspark_node_alias"],
|
|
114
115
|
obj["lightspark_node_color"],
|
|
@@ -177,6 +178,9 @@ fragment NodeFragment on Node {
|
|
|
177
178
|
lightspark_node_account: account {
|
|
178
179
|
id
|
|
179
180
|
}
|
|
181
|
+
lightspark_node_owner: owner {
|
|
182
|
+
id
|
|
183
|
+
}
|
|
180
184
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
181
185
|
__typename
|
|
182
186
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -215,6 +215,9 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
|
|
|
215
215
|
lightspark_node_account: account {
|
|
216
216
|
id
|
|
217
217
|
}
|
|
218
|
+
lightspark_node_owner: owner {
|
|
219
|
+
id
|
|
220
|
+
}
|
|
218
221
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
219
222
|
__typename
|
|
220
223
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -105,6 +105,9 @@ fragment PaymentRequestFragment on PaymentRequest {
|
|
|
105
105
|
lightspark_node_account: account {
|
|
106
106
|
id
|
|
107
107
|
}
|
|
108
|
+
lightspark_node_owner: owner {
|
|
109
|
+
id
|
|
110
|
+
}
|
|
108
111
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
109
112
|
__typename
|
|
110
113
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -85,6 +85,9 @@ fragment PaymentRequestDataFragment on PaymentRequestData {
|
|
|
85
85
|
lightspark_node_account: account {
|
|
86
86
|
id
|
|
87
87
|
}
|
|
88
|
+
lightspark_node_owner: owner {
|
|
89
|
+
id
|
|
90
|
+
}
|
|
88
91
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
89
92
|
__typename
|
|
90
93
|
blockchain_balance_total_balance: total_balance {
|
|
@@ -418,6 +418,9 @@ fragment TransactionFragment on Transaction {
|
|
|
418
418
|
lightspark_node_account: account {
|
|
419
419
|
id
|
|
420
420
|
}
|
|
421
|
+
lightspark_node_owner: owner {
|
|
422
|
+
id
|
|
423
|
+
}
|
|
421
424
|
lightspark_node_blockchain_balance: blockchain_balance {
|
|
422
425
|
__typename
|
|
423
426
|
blockchain_balance_total_balance: total_balance {
|
package/src/objects/Wallet.ts
CHANGED
|
@@ -5,14 +5,16 @@ import autoBind from "auto-bind";
|
|
|
5
5
|
import LightsparkClient from "../client.js";
|
|
6
6
|
import Balances, { BalancesFromJson } from "./Balances.js";
|
|
7
7
|
import CurrencyAmount, { CurrencyAmountFromJson } from "./CurrencyAmount.js";
|
|
8
|
-
import
|
|
8
|
+
import LightsparkNodeOwner from "./LightsparkNodeOwner.js";
|
|
9
|
+
import WalletStatus from "./WalletStatus.js";
|
|
9
10
|
|
|
10
|
-
class Wallet implements
|
|
11
|
+
class Wallet implements LightsparkNodeOwner {
|
|
11
12
|
constructor(
|
|
12
13
|
public readonly id: string,
|
|
13
14
|
public readonly createdAt: string,
|
|
14
15
|
public readonly updatedAt: string,
|
|
15
16
|
public readonly thirdPartyIdentifier: string,
|
|
17
|
+
public readonly status: WalletStatus,
|
|
16
18
|
public readonly typename: string,
|
|
17
19
|
public readonly lastLoginAt?: string,
|
|
18
20
|
public readonly balances?: Balances
|
|
@@ -86,11 +88,11 @@ query FetchWalletTotalAmountSent($created_after_date: DateTime, $created_before_
|
|
|
86
88
|
}))!;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
static getWalletQuery(): Query<Wallet> {
|
|
91
|
+
static getWalletQuery(id: string): Query<Wallet> {
|
|
90
92
|
return {
|
|
91
93
|
queryPayload: `
|
|
92
|
-
query GetWallet {
|
|
93
|
-
|
|
94
|
+
query GetWallet($id: ID!) {
|
|
95
|
+
entity(id: $id) {
|
|
94
96
|
... on Wallet {
|
|
95
97
|
...WalletFragment
|
|
96
98
|
}
|
|
@@ -99,8 +101,8 @@ query GetWallet {
|
|
|
99
101
|
|
|
100
102
|
${FRAGMENT}
|
|
101
103
|
`,
|
|
102
|
-
variables: {},
|
|
103
|
-
constructObject: (data: any) => WalletFromJson(data.
|
|
104
|
+
variables: { id },
|
|
105
|
+
constructObject: (data: any) => WalletFromJson(data.entity),
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -111,6 +113,7 @@ export const WalletFromJson = (obj: any): Wallet => {
|
|
|
111
113
|
obj["wallet_created_at"],
|
|
112
114
|
obj["wallet_updated_at"],
|
|
113
115
|
obj["wallet_third_party_identifier"],
|
|
116
|
+
WalletStatus[obj["wallet_status"]] ?? WalletStatus.FUTURE_VALUE,
|
|
114
117
|
"Wallet",
|
|
115
118
|
obj["wallet_last_login_at"],
|
|
116
119
|
!!obj["wallet_balances"]
|
|
@@ -154,6 +157,7 @@ fragment WalletFragment on Wallet {
|
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
wallet_third_party_identifier: third_party_identifier
|
|
160
|
+
wallet_status: status
|
|
157
161
|
}`;
|
|
158
162
|
|
|
159
163
|
export default Wallet;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
|
|
2
|
+
|
|
3
|
+
export enum WalletStatus {
|
|
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 wallet has not been set up yet and is ready to be deployed. This is the default status after the first login. **/
|
|
10
|
+
NOT_SETUP = "NOT_SETUP",
|
|
11
|
+
/** The wallet is currently being deployed in the Lightspark infrastructure. **/
|
|
12
|
+
DEPLOYING = "DEPLOYING",
|
|
13
|
+
/** The wallet has been deployed in the Lightspark infrastructure and is ready to be initialized. **/
|
|
14
|
+
DEPLOYED = "DEPLOYED",
|
|
15
|
+
/** The wallet is currently being initialized. **/
|
|
16
|
+
INITIALIZING = "INITIALIZING",
|
|
17
|
+
/** The wallet is available and ready to be used. **/
|
|
18
|
+
READY = "READY",
|
|
19
|
+
/** The wallet is temporarily available, due to a transient issue or a scheduled maintenance. **/
|
|
20
|
+
UNAVAILABLE = "UNAVAILABLE",
|
|
21
|
+
/** The wallet had an unrecoverable failure. This status is not expected to happend and will be investigated by the Lightspark team. **/
|
|
22
|
+
FAILED = "FAILED",
|
|
23
|
+
/** The wallet is being terminated. **/
|
|
24
|
+
TERMINATING = "TERMINATING",
|
|
25
|
+
/** The wallet has been terminated and is not available in the Lightspark infrastructure anymore. It is not connected to the Lightning network and its funds can only be accessed using the Funds Recovery flow. **/
|
|
26
|
+
TERMINATED = "TERMINATED",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default WalletStatus;
|
package/src/objects/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export { default as CreateApiTokenInput } from "./CreateApiTokenInput.js";
|
|
|
25
25
|
export { default as CreateApiTokenOutput } from "./CreateApiTokenOutput.js";
|
|
26
26
|
export { default as CreateInvoiceInput } from "./CreateInvoiceInput.js";
|
|
27
27
|
export { default as CreateInvoiceOutput } from "./CreateInvoiceOutput.js";
|
|
28
|
+
export { default as CreateLnurlInvoiceInput } from "./CreateLnurlInvoiceInput.js";
|
|
28
29
|
export { default as CreateNodeWalletAddressInput } from "./CreateNodeWalletAddressInput.js";
|
|
29
30
|
export { default as CreateNodeWalletAddressOutput } from "./CreateNodeWalletAddressOutput.js";
|
|
30
31
|
export { default as CreateTestModeInvoiceInput } from "./CreateTestModeInvoiceInput.js";
|
|
@@ -61,6 +62,10 @@ export {
|
|
|
61
62
|
getLightningTransactionQuery,
|
|
62
63
|
} from "./LightningTransaction.js";
|
|
63
64
|
export { default as LightsparkNode } from "./LightsparkNode.js";
|
|
65
|
+
export {
|
|
66
|
+
default as LightsparkNodeOwner,
|
|
67
|
+
getLightsparkNodeOwnerQuery,
|
|
68
|
+
} from "./LightsparkNodeOwner.js";
|
|
64
69
|
export { default as LightsparkNodePurpose } from "./LightsparkNodePurpose.js";
|
|
65
70
|
export { default as LightsparkNodeStatus } from "./LightsparkNodeStatus.js";
|
|
66
71
|
export { default as LightsparkNodeToChannelsConnection } from "./LightsparkNodeToChannelsConnection.js";
|
|
@@ -106,6 +111,7 @@ export { default as TransactionStatus } from "./TransactionStatus.js";
|
|
|
106
111
|
export { default as TransactionType } from "./TransactionType.js";
|
|
107
112
|
export { default as TransactionUpdate } from "./TransactionUpdate.js";
|
|
108
113
|
export { default as Wallet } from "./Wallet.js";
|
|
114
|
+
export { default as WalletStatus } from "./WalletStatus.js";
|
|
109
115
|
export { default as WebhookEventType } from "./WebhookEventType.js";
|
|
110
116
|
export { default as Withdrawal, getWithdrawalQuery } from "./Withdrawal.js";
|
|
111
117
|
export { default as WithdrawalMode } from "./WithdrawalMode.js";
|
package/src/webhooks.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface WebhookEvent {
|
|
|
8
8
|
event_id: string;
|
|
9
9
|
timestamp: Date;
|
|
10
10
|
entity_id: string;
|
|
11
|
+
wallet_id?: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const verifyAndParseWebhook = (
|
|
@@ -38,5 +39,6 @@ const parseWebhook = async (data: Uint8Array): Promise<WebhookEvent> => {
|
|
|
38
39
|
event_id: event.event_id,
|
|
39
40
|
timestamp: new Date(event.timestamp),
|
|
40
41
|
entity_id: event.entity_id,
|
|
42
|
+
wallet_id: event.wallet_id,
|
|
41
43
|
};
|
|
42
44
|
};
|