@lightsparkdev/lightspark-sdk 1.1.0 → 1.1.2

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AuthProvider } from '@lightsparkdev/core';
2
- import { W as WebhookEventType, L as LightsparkClient } from './index-bddc6d51.js';
3
- 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 BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-bddc6d51.js';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-95299cb4.js';
3
+ 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 BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-95299cb4.js';
4
4
  import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
5
5
  import 'zen-observable';
6
6
 
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  FRAGMENT,
16
16
  FRAGMENT10,
17
17
  FRAGMENT11,
18
+ FRAGMENT12,
18
19
  FRAGMENT2,
19
20
  FRAGMENT3,
20
21
  FRAGMENT4,
@@ -44,6 +45,7 @@ import {
44
45
  OutgoingPayment_default,
45
46
  PaymentDirection_default,
46
47
  PaymentFailureReason_default,
48
+ PaymentRequestFromJson,
47
49
  PaymentRequestStatus_default,
48
50
  Permission_default,
49
51
  RemoteSigningSubEventType_default,
@@ -78,7 +80,7 @@ import {
78
80
  getSignableQuery,
79
81
  getTransactionQuery,
80
82
  getWithdrawalQuery
81
- } from "./chunk-AXCZMV2D.js";
83
+ } from "./chunk-PZMOKVDK.js";
82
84
  import {
83
85
  BitcoinNetwork_default
84
86
  } from "./chunk-K6SAUSAX.js";
@@ -131,7 +133,7 @@ import {
131
133
  // package.json
132
134
  var package_default = {
133
135
  name: "@lightsparkdev/lightspark-sdk",
134
- version: "1.1.0",
136
+ version: "1.1.2",
135
137
  description: "Lightspark JS SDK",
136
138
  author: "Lightspark Inc.",
137
139
  keywords: [
@@ -211,7 +213,9 @@ var package_default = {
211
213
  "lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
212
214
  lint: "eslint .",
213
215
  postversion: "yarn build",
214
- test: "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
216
+ "test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
217
+ test: "yarn test-cmd src/tests/*.test.ts",
218
+ "test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
215
219
  "types:watch": "tsc-absolute --watch",
216
220
  types: "tsc"
217
221
  },
@@ -430,7 +434,7 @@ var FundNode = `
430
434
  $node_id: ID!,
431
435
  $amountSats: Long
432
436
  ) {
433
- fund_node(input: { node_id: $node_id, amount_sats: $amountMsats }) {
437
+ fund_node(input: { node_id: $node_id, amount_sats: $amountSats }) {
434
438
  amount {
435
439
  ...CurrencyAmountFragment
436
440
  }
@@ -580,6 +584,37 @@ var PayInvoice = `
580
584
  ${FRAGMENT8}
581
585
  `;
582
586
 
587
+ // src/graphql/PaymentRequestsForNode.ts
588
+ var PaymentRequestsForNode = `
589
+ query PaymentRequestsForNode(
590
+ $network: BitcoinNetwork!,
591
+ $nodeId: ID!,
592
+ $numTransactions: Int,
593
+ $afterDate: DateTime,
594
+ ) {
595
+ current_account {
596
+ id
597
+ name
598
+ recent_payment_requests: payment_requests(
599
+ first: $numTransactions
600
+ bitcoin_network: $network
601
+ lightning_node_id: $nodeId
602
+ after_date: $afterDate
603
+ ) {
604
+ count
605
+ entities {
606
+ ...PaymentRequestFragment
607
+ __typename
608
+ }
609
+ __typename
610
+ }
611
+ __typename
612
+ }
613
+ }
614
+
615
+ ${FRAGMENT9}
616
+ `;
617
+
583
618
  // src/graphql/PayUmaInvoice.ts
584
619
  var PayUmaInvoice = `
585
620
  mutation PayUmaInvoice(
@@ -627,7 +662,7 @@ var RequestWithdrawal = `
627
662
  }
628
663
  }
629
664
 
630
- ${FRAGMENT9}
665
+ ${FRAGMENT10}
631
666
  `;
632
667
 
633
668
  // src/graphql/SendPayment.ts
@@ -765,7 +800,7 @@ query SingleNodeDashboard(
765
800
  }
766
801
  }
767
802
 
768
- ${FRAGMENT10}
803
+ ${FRAGMENT11}
769
804
  ${FRAGMENT}
770
805
  `;
771
806
 
@@ -804,7 +839,7 @@ query TransactionsForNode(
804
839
  }
805
840
  }
806
841
 
807
- ${FRAGMENT10}
842
+ ${FRAGMENT11}
808
843
  ${FRAGMENT}
809
844
  `;
810
845
 
@@ -819,7 +854,7 @@ subscription TransactionSubscription(
819
854
  }
820
855
  }
821
856
 
822
- ${FRAGMENT11}
857
+ ${FRAGMENT12}
823
858
  `;
824
859
 
825
860
  // src/NodeKeyLoaderCache.ts
@@ -1114,6 +1149,29 @@ var LightsparkClient = class {
1114
1149
  (transaction) => TransactionFromJson(transaction)
1115
1150
  ) ?? [];
1116
1151
  }
1152
+ /**
1153
+ * Retrieves the most recent payment requests for a given node.
1154
+ *
1155
+ * @param nodeId The node ID for which to read transactions
1156
+ * @param numTransactions The maximum number of transactions to read. Defaults to 20.
1157
+ * @param bitcoinNetwork The bitcoin network on which to read transactions. Defaults to MAINNET.
1158
+ * @param afterDate Filters transactions to those after the given date. Defaults to undefined (no limit).
1159
+ * @returns An array of payment requests for the given node ID.
1160
+ */
1161
+ async getRecentPaymentRequests(nodeId, numTransactions = 20, bitcoinNetwork = BitcoinNetwork_default.MAINNET, afterDate = void 0) {
1162
+ const response = await this.requester.makeRawRequest(
1163
+ PaymentRequestsForNode,
1164
+ {
1165
+ nodeId,
1166
+ numTransactions,
1167
+ network: bitcoinNetwork,
1168
+ afterDate
1169
+ }
1170
+ );
1171
+ return response.current_account?.recent_payment_requests.entities.map(
1172
+ (paymentRequest) => PaymentRequestFromJson(paymentRequest)
1173
+ ) ?? [];
1174
+ }
1117
1175
  /**
1118
1176
  * Starts listening for new transactions or updates to existing transactions for a list of nodes.
1119
1177
  *
@@ -1,4 +1,4 @@
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 BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-bddc6d51.js';
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 BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-95299cb4.js';
2
2
  export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
3
3
  import '@lightsparkdev/core';
4
4
  import 'zen-observable';
@@ -51,7 +51,7 @@ import {
51
51
  getSignableQuery,
52
52
  getTransactionQuery,
53
53
  getWithdrawalQuery
54
- } from "../chunk-AXCZMV2D.js";
54
+ } from "../chunk-PZMOKVDK.js";
55
55
  import {
56
56
  BitcoinNetwork_default
57
57
  } from "../chunk-K6SAUSAX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -80,7 +80,9 @@
80
80
  "lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
81
81
  "lint": "eslint .",
82
82
  "postversion": "yarn build",
83
- "test": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
83
+ "test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
84
+ "test": "yarn test-cmd src/tests/*.test.ts",
85
+ "test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
84
86
  "types:watch": "tsc-absolute --watch",
85
87
  "types": "tsc"
86
88
  },
package/src/client.ts CHANGED
@@ -39,6 +39,7 @@ import { LightningFeeEstimateForNode } from "./graphql/LightningFeeEstimateForNo
39
39
  import type { AccountDashboard } from "./graphql/MultiNodeDashboard.js";
40
40
  import { MultiNodeDashboard } from "./graphql/MultiNodeDashboard.js";
41
41
  import { PayInvoice } from "./graphql/PayInvoice.js";
42
+ import { PaymentRequestsForNode } from "./graphql/PaymentRequestsForNode.js";
42
43
  import { PayUmaInvoice } from "./graphql/PayUmaInvoice.js";
43
44
  import { RequestWithdrawal } from "./graphql/RequestWithdrawal.js";
44
45
  import { SendPayment } from "./graphql/SendPayment.js";
@@ -63,6 +64,7 @@ import { InvoiceDataFromJson } from "./objects/InvoiceData.js";
63
64
  import InvoiceType from "./objects/InvoiceType.js";
64
65
  import type OutgoingPayment from "./objects/OutgoingPayment.js";
65
66
  import { OutgoingPaymentFromJson } from "./objects/OutgoingPayment.js";
67
+ import { PaymentRequestFromJson } from "./objects/PaymentRequest.js";
66
68
  import Permission from "./objects/Permission.js";
67
69
  import type SingleNodeDashboard from "./objects/SingleNodeDashboard.js";
68
70
  import type Transaction from "./objects/Transaction.js";
@@ -228,6 +230,37 @@ class LightsparkClient {
228
230
  );
229
231
  }
230
232
 
233
+ /**
234
+ * Retrieves the most recent payment requests for a given node.
235
+ *
236
+ * @param nodeId The node ID for which to read transactions
237
+ * @param numTransactions The maximum number of transactions to read. Defaults to 20.
238
+ * @param bitcoinNetwork The bitcoin network on which to read transactions. Defaults to MAINNET.
239
+ * @param afterDate Filters transactions to those after the given date. Defaults to undefined (no limit).
240
+ * @returns An array of payment requests for the given node ID.
241
+ */
242
+ public async getRecentPaymentRequests(
243
+ nodeId: string,
244
+ numTransactions: number = 20,
245
+ bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.MAINNET,
246
+ afterDate: Maybe<string> = undefined,
247
+ ): Promise<Transaction[]> {
248
+ const response = await this.requester.makeRawRequest(
249
+ PaymentRequestsForNode,
250
+ {
251
+ nodeId,
252
+ numTransactions,
253
+ network: bitcoinNetwork,
254
+ afterDate,
255
+ },
256
+ );
257
+ return (
258
+ response.current_account?.recent_payment_requests.entities.map(
259
+ (paymentRequest) => PaymentRequestFromJson(paymentRequest),
260
+ ) ?? []
261
+ );
262
+ }
263
+
231
264
  /**
232
265
  * Starts listening for new transactions or updates to existing transactions for a list of nodes.
233
266
  *
@@ -7,7 +7,7 @@ export const FundNode = `
7
7
  $node_id: ID!,
8
8
  $amountSats: Long
9
9
  ) {
10
- fund_node(input: { node_id: $node_id, amount_sats: $amountMsats }) {
10
+ fund_node(input: { node_id: $node_id, amount_sats: $amountSats }) {
11
11
  amount {
12
12
  ...CurrencyAmountFragment
13
13
  }
@@ -0,0 +1,33 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { FRAGMENT as PaymentRequestFragment } from "../objects/PaymentRequest.js";
4
+
5
+ export const PaymentRequestsForNode = `
6
+ query PaymentRequestsForNode(
7
+ $network: BitcoinNetwork!,
8
+ $nodeId: ID!,
9
+ $numTransactions: Int,
10
+ $afterDate: DateTime,
11
+ ) {
12
+ current_account {
13
+ id
14
+ name
15
+ recent_payment_requests: payment_requests(
16
+ first: $numTransactions
17
+ bitcoin_network: $network
18
+ lightning_node_id: $nodeId
19
+ after_date: $afterDate
20
+ ) {
21
+ count
22
+ entities {
23
+ ...PaymentRequestFragment
24
+ __typename
25
+ }
26
+ __typename
27
+ }
28
+ __typename
29
+ }
30
+ }
31
+
32
+ ${PaymentRequestFragment}
33
+ `;
@@ -0,0 +1,60 @@
1
+ import LightsparkClient from "../../client.js";
2
+ import { getCredentialsFromEnvOrThrow } from "../../env.js";
3
+ import {
4
+ AccountTokenAuthProvider,
5
+ BitcoinNetwork,
6
+ PaymentRequestStatus,
7
+ } from "../../index.js";
8
+
9
+ describe("lightspark-sdk client", () => {
10
+ const { apiTokenClientId, apiTokenClientSecret, baseUrl } =
11
+ getCredentialsFromEnvOrThrow();
12
+ const accountAuthProvider = new AccountTokenAuthProvider(
13
+ apiTokenClientId,
14
+ apiTokenClientSecret,
15
+ );
16
+ let regtestNodeId: string | undefined;
17
+
18
+ function getRegtestNodeId() {
19
+ expect(regtestNodeId).toBeDefined();
20
+ if (!regtestNodeId) {
21
+ throw new Error("regtestNodeId is not set");
22
+ }
23
+ return regtestNodeId as string;
24
+ }
25
+
26
+ it("should get env vars and construct the client successfully", async () => {
27
+ const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
28
+ expect(lightsparkClient).toBeDefined();
29
+ });
30
+
31
+ it("should successfully get the current account regtest node", async () => {
32
+ const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
33
+
34
+ const account = await lightsparkClient.getCurrentAccount();
35
+ const nodesConnection = await account?.getNodes(lightsparkClient, 1, [
36
+ BitcoinNetwork.REGTEST,
37
+ ]);
38
+
39
+ const regtestNode = nodesConnection?.entities[0];
40
+ expect(regtestNode).toBeDefined();
41
+ regtestNodeId = regtestNode?.id;
42
+ });
43
+
44
+ it("should successfully create an uma invoice", async () => {
45
+ const nodeId = getRegtestNodeId();
46
+ const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
47
+
48
+ const metadata = JSON.stringify([
49
+ ["text/plain", "Pay to vasp2.com user $bob"],
50
+ ["text/identifier", "$bob@vasp2.com"],
51
+ ]);
52
+
53
+ const umaInvoice = await lightsparkClient.createUmaInvoice(
54
+ nodeId,
55
+ 1000,
56
+ metadata,
57
+ );
58
+ expect(umaInvoice?.status).toEqual(PaymentRequestStatus.OPEN);
59
+ });
60
+ });