@lightsparkdev/lightspark-sdk 1.4.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lightsparkdev/lightspark-sdk
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - e77aa92: - fix runtime error in non-node environments by dynamically importing crypto-wasm for node environments
8
+
9
+ ## 1.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 4c93e7f: Add withdrawal_fee_estimate to the js sdks
14
+
3
15
  ## 1.4.0
4
16
 
5
17
  ### Minor Changes
@@ -10354,6 +10354,27 @@ ${FRAGMENT34}
10354
10354
  };
10355
10355
  };
10356
10356
 
10357
+ // src/objects/WithdrawalFeeEstimateOutput.ts
10358
+ var WithdrawalFeeEstimateOutputFromJson = (obj) => {
10359
+ return {
10360
+ feeEstimate: CurrencyAmountFromJson(
10361
+ obj["withdrawal_fee_estimate_output_fee_estimate"]
10362
+ )
10363
+ };
10364
+ };
10365
+ var FRAGMENT35 = `
10366
+ fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput {
10367
+ __typename
10368
+ withdrawal_fee_estimate_output_fee_estimate: fee_estimate {
10369
+ __typename
10370
+ currency_amount_original_value: original_value
10371
+ currency_amount_original_unit: original_unit
10372
+ currency_amount_preferred_currency_unit: preferred_currency_unit
10373
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
10374
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
10375
+ }
10376
+ }`;
10377
+
10357
10378
  export {
10358
10379
  CurrencyUnit_default,
10359
10380
  CurrencyAmountFromJson,
@@ -10414,6 +10435,8 @@ export {
10414
10435
  getTransactionQuery,
10415
10436
  TransactionUpdateFromJson,
10416
10437
  FRAGMENT32 as FRAGMENT13,
10438
+ WithdrawalFeeEstimateOutputFromJson,
10439
+ FRAGMENT35 as FRAGMENT14,
10417
10440
  AccountToChannelsConnection_default,
10418
10441
  getLightsparkNodeQuery,
10419
10442
  WalletStatus_default,
@@ -2981,6 +2981,16 @@ declare class LightsparkClient {
2981
2981
  * @returns An estimate of the fees that will be paid to send a payment to another Lightning node.
2982
2982
  */
2983
2983
  getLightningFeeEstimateForNode(nodeId: string, destinationNodePublicKey: string, amountMsats: number): Promise<CurrencyAmount>;
2984
+ /**
2985
+ * Returns an estimated amount for the L1 withdrawal fees for the specified node, amount, and
2986
+ * strategy.
2987
+ *
2988
+ * @param nodeId The node from which you'd like to make the withdrawal.
2989
+ * @param amountSats The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node.
2990
+ * @param withdrawalMode The strategy that should be used to withdraw the funds from this node.
2991
+ * @returns An estimated amount for the L1 withdrawal fees for the specified node, amount, and strategy.
2992
+ */
2993
+ getWithrawalFeeEstimate(nodeId: string, amountSats: number, withdrawalMode: WithdrawalMode): Promise<CurrencyAmount>;
2984
2994
  /**
2985
2995
  * Directly unlocks a node with a signing private key or alias.
2986
2996
  *
@@ -4434,4 +4444,21 @@ interface Withdrawal {
4434
4444
  }
4435
4445
  declare const getWithdrawalQuery: (id: string) => Query<Withdrawal>;
4436
4446
 
4437
- export { Deposit as $, Account as A, Balances as B, CancelInvoiceInput as C, CreateApiTokenInput as D, CreateApiTokenOutput as E, CreateInvitationWithIncentivesInput as F, CreateInvitationWithIncentivesOutput as G, CreateInvoiceInput as H, CreateInvoiceOutput as I, CreateLnurlInvoiceInput as J, CreateNodeWalletAddressInput as K, LightsparkClient as L, CreateNodeWalletAddressOutput as M, CreateTestModeInvoiceInput as N, CreateTestModeInvoiceOutput as O, CreateTestModePaymentInput as P, CreateTestModePaymentoutput as Q, CreateUmaInvitationInput as R, CreateUmaInvitationOutput as S, CreateUmaInvoiceInput as T, CurrencyAmount as U, CurrencyUnit as V, WebhookEventType as W, DeclineToSignMessagesInput as X, DeclineToSignMessagesOutput as Y, DeleteApiTokenInput as Z, DeleteApiTokenOutput as _, AccountToApiTokensConnection as a, ReleaseChannelPerCommitmentSecretInput as a$, getDepositQuery as a0, Entity as a1, FeeEstimate as a2, FundNodeInput as a3, FundNodeOutput as a4, GraphNode as a5, Hop as a6, getHopQuery as a7, HtlcAttemptFailureCode as a8, IdAndSignature as a9, NodeAddress as aA, NodeAddressType as aB, NodeToAddressesConnection as aC, OnChainTransaction as aD, getOnChainTransactionQuery as aE, OutgoingPayment as aF, OutgoingPaymentAttempt as aG, OutgoingPaymentAttemptStatus as aH, OutgoingPaymentAttemptToHopsConnection as aI, OutgoingPaymentToAttemptsConnection as aJ, OutgoingPaymentsForInvoiceQueryInput as aK, OutgoingPaymentsForInvoiceQueryOutput as aL, PageInfo as aM, PayInvoiceInput as aN, PayInvoiceOutput as aO, PayUmaInvoiceInput as aP, PaymentDirection as aQ, PaymentFailureReason as aR, PaymentRequest as aS, getPaymentRequestQuery as aT, PaymentRequestData as aU, PaymentRequestStatus as aV, Permission as aW, PostTransactionData as aX, RegionCode as aY, RegisterPaymentInput as aZ, RegisterPaymentOutput as a_, IncentivesIneligibilityReason as aa, IncentivesStatus as ab, IncomingPayment as ac, IncomingPaymentAttempt as ad, getIncomingPaymentAttemptQuery as ae, IncomingPaymentAttemptStatus as af, IncomingPaymentToAttemptsConnection as ag, Invoice as ah, getInvoiceQuery as ai, InvoiceData as aj, InvoiceType as ak, LightningFeeEstimateForInvoiceInput as al, LightningFeeEstimateForNodeInput as am, LightningFeeEstimateOutput as an, LightningTransaction as ao, getLightningTransactionQuery as ap, LightsparkNode as aq, getLightsparkNodeQuery as ar, LightsparkNodeOwner as as, getLightsparkNodeOwnerQuery as at, LightsparkNodeStatus as au, LightsparkNodeToChannelsConnection as av, LightsparkNodeWithOSK as aw, LightsparkNodeWithRemoteSigning as ax, Node as ay, getNodeQuery as az, AccountToChannelsConnection as b, ReleaseChannelPerCommitmentSecretOutput as b0, ReleasePaymentPreimageInput as b1, ReleasePaymentPreimageOutput as b2, RemoteSigningSubEventType as b3, RequestWithdrawalInput as b4, RequestWithdrawalOutput as b5, RichText as b6, RiskRating as b7, RoutingTransaction as b8, getRoutingTransactionQuery as b9, UpdateChannelPerCommitmentPointInput as bA, UpdateChannelPerCommitmentPointOutput as bB, UpdateNodeSharedSecretInput as bC, UpdateNodeSharedSecretOutput as bD, Wallet as bE, WalletStatus as bF, WalletToPaymentRequestsConnection as bG, WalletToTransactionsConnection as bH, WalletToWithdrawalRequestsConnection as bI, Withdrawal as bJ, getWithdrawalQuery as bK, WithdrawalMode as bL, WithdrawalRequest as bM, WithdrawalRequestStatus as bN, WithdrawalRequestToChannelClosingTransactionsConnection as bO, WithdrawalRequestToChannelOpeningTransactionsConnection as bP, RoutingTransactionFailureReason as ba, ScreenNodeInput as bb, ScreenNodeOutput as bc, Secret as bd, SendPaymentInput as be, SendPaymentOutput as bf, SetInvoicePaymentHashInput as bg, SetInvoicePaymentHashOutput as bh, SignInvoiceInput as bi, SignInvoiceOutput as bj, SignMessagesInput as bk, SignMessagesOutput as bl, Signable as bm, getSignableQuery as bn, SignablePayload as bo, getSignablePayloadQuery as bp, SignablePayloadStatus as bq, SingleNodeDashboard as br, Transaction as bs, getTransactionQuery as bt, TransactionFailures as bu, TransactionStatus as bv, TransactionType as bw, TransactionUpdate as bx, UmaInvitation as by, getUmaInvitationQuery as bz, AccountToNodesConnection as c, AccountToPaymentRequestsConnection as d, AccountToTransactionsConnection as e, AccountToWalletsConnection as f, AccountToWithdrawalRequestsConnection as g, ApiToken as h, getApiTokenQuery as i, BlockchainBalance as j, CancelInvoiceOutput as k, Channel as l, ChannelClosingTransaction as m, getChannelClosingTransactionQuery as n, ChannelFees as o, ChannelOpeningTransaction as p, getChannelOpeningTransactionQuery as q, ChannelSnapshot as r, ChannelStatus as s, ChannelToTransactionsConnection as t, ClaimUmaInvitationInput as u, ClaimUmaInvitationOutput as v, ClaimUmaInvitationWithIncentivesInput as w, ClaimUmaInvitationWithIncentivesOutput as x, ComplianceProvider as y, Connection as z };
4447
+ interface WithdrawalFeeEstimateInput {
4448
+ /** The node from which you'd like to make the withdrawal. **/
4449
+ nodeId: string;
4450
+ /**
4451
+ * The amount you want to withdraw from this node in Satoshis. Use the special value -1 to
4452
+ * withdrawal all funds from this node.
4453
+ **/
4454
+ amountSats: number;
4455
+ /** The strategy that should be used to withdraw the funds from this node. **/
4456
+ withdrawalMode: WithdrawalMode;
4457
+ }
4458
+
4459
+ interface WithdrawalFeeEstimateOutput {
4460
+ /** The estimated fee for the withdrawal. **/
4461
+ feeEstimate: CurrencyAmount;
4462
+ }
4463
+
4464
+ export { Deposit as $, Account as A, Balances as B, CancelInvoiceInput as C, CreateApiTokenInput as D, CreateApiTokenOutput as E, CreateInvitationWithIncentivesInput as F, CreateInvitationWithIncentivesOutput as G, CreateInvoiceInput as H, CreateInvoiceOutput as I, CreateLnurlInvoiceInput as J, CreateNodeWalletAddressInput as K, LightsparkClient as L, CreateNodeWalletAddressOutput as M, CreateTestModeInvoiceInput as N, CreateTestModeInvoiceOutput as O, CreateTestModePaymentInput as P, CreateTestModePaymentoutput as Q, CreateUmaInvitationInput as R, CreateUmaInvitationOutput as S, CreateUmaInvoiceInput as T, CurrencyAmount as U, CurrencyUnit as V, WebhookEventType as W, DeclineToSignMessagesInput as X, DeclineToSignMessagesOutput as Y, DeleteApiTokenInput as Z, DeleteApiTokenOutput as _, AccountToApiTokensConnection as a, ReleaseChannelPerCommitmentSecretInput as a$, getDepositQuery as a0, Entity as a1, FeeEstimate as a2, FundNodeInput as a3, FundNodeOutput as a4, GraphNode as a5, Hop as a6, getHopQuery as a7, HtlcAttemptFailureCode as a8, IdAndSignature as a9, NodeAddress as aA, NodeAddressType as aB, NodeToAddressesConnection as aC, OnChainTransaction as aD, getOnChainTransactionQuery as aE, OutgoingPayment as aF, OutgoingPaymentAttempt as aG, OutgoingPaymentAttemptStatus as aH, OutgoingPaymentAttemptToHopsConnection as aI, OutgoingPaymentToAttemptsConnection as aJ, OutgoingPaymentsForInvoiceQueryInput as aK, OutgoingPaymentsForInvoiceQueryOutput as aL, PageInfo as aM, PayInvoiceInput as aN, PayInvoiceOutput as aO, PayUmaInvoiceInput as aP, PaymentDirection as aQ, PaymentFailureReason as aR, PaymentRequest as aS, getPaymentRequestQuery as aT, PaymentRequestData as aU, PaymentRequestStatus as aV, Permission as aW, PostTransactionData as aX, RegionCode as aY, RegisterPaymentInput as aZ, RegisterPaymentOutput as a_, IncentivesIneligibilityReason as aa, IncentivesStatus as ab, IncomingPayment as ac, IncomingPaymentAttempt as ad, getIncomingPaymentAttemptQuery as ae, IncomingPaymentAttemptStatus as af, IncomingPaymentToAttemptsConnection as ag, Invoice as ah, getInvoiceQuery as ai, InvoiceData as aj, InvoiceType as ak, LightningFeeEstimateForInvoiceInput as al, LightningFeeEstimateForNodeInput as am, LightningFeeEstimateOutput as an, LightningTransaction as ao, getLightningTransactionQuery as ap, LightsparkNode as aq, getLightsparkNodeQuery as ar, LightsparkNodeOwner as as, getLightsparkNodeOwnerQuery as at, LightsparkNodeStatus as au, LightsparkNodeToChannelsConnection as av, LightsparkNodeWithOSK as aw, LightsparkNodeWithRemoteSigning as ax, Node as ay, getNodeQuery as az, AccountToChannelsConnection as b, ReleaseChannelPerCommitmentSecretOutput as b0, ReleasePaymentPreimageInput as b1, ReleasePaymentPreimageOutput as b2, RemoteSigningSubEventType as b3, RequestWithdrawalInput as b4, RequestWithdrawalOutput as b5, RichText as b6, RiskRating as b7, RoutingTransaction as b8, getRoutingTransactionQuery as b9, UpdateChannelPerCommitmentPointInput as bA, UpdateChannelPerCommitmentPointOutput as bB, UpdateNodeSharedSecretInput as bC, UpdateNodeSharedSecretOutput as bD, Wallet as bE, WalletStatus as bF, WalletToPaymentRequestsConnection as bG, WalletToTransactionsConnection as bH, WalletToWithdrawalRequestsConnection as bI, Withdrawal as bJ, getWithdrawalQuery as bK, WithdrawalFeeEstimateInput as bL, WithdrawalFeeEstimateOutput as bM, WithdrawalMode as bN, WithdrawalRequest as bO, WithdrawalRequestStatus as bP, WithdrawalRequestToChannelClosingTransactionsConnection as bQ, WithdrawalRequestToChannelOpeningTransactionsConnection as bR, RoutingTransactionFailureReason as ba, ScreenNodeInput as bb, ScreenNodeOutput as bc, Secret as bd, SendPaymentInput as be, SendPaymentOutput as bf, SetInvoicePaymentHashInput as bg, SetInvoicePaymentHashOutput as bh, SignInvoiceInput as bi, SignInvoiceOutput as bj, SignMessagesInput as bk, SignMessagesOutput as bl, Signable as bm, getSignableQuery as bn, SignablePayload as bo, getSignablePayloadQuery as bp, SignablePayloadStatus as bq, SingleNodeDashboard as br, Transaction as bs, getTransactionQuery as bt, TransactionFailures as bu, TransactionStatus as bv, TransactionType as bw, TransactionUpdate as bx, UmaInvitation as by, getUmaInvitationQuery as bz, AccountToNodesConnection as c, AccountToPaymentRequestsConnection as d, AccountToTransactionsConnection as e, AccountToWalletsConnection as f, AccountToWithdrawalRequestsConnection as g, ApiToken as h, getApiTokenQuery as i, BlockchainBalance as j, CancelInvoiceOutput as k, Channel as l, ChannelClosingTransaction as m, getChannelClosingTransactionQuery as n, ChannelFees as o, ChannelOpeningTransaction as p, getChannelOpeningTransactionQuery as q, ChannelSnapshot as r, ChannelStatus as s, ChannelToTransactionsConnection as t, ClaimUmaInvitationInput as u, ClaimUmaInvitationOutput as v, ClaimUmaInvitationWithIncentivesInput as w, ClaimUmaInvitationWithIncentivesOutput as x, ComplianceProvider as y, Connection as z };
package/dist/index.cjs CHANGED
@@ -1949,7 +1949,7 @@ var import_core9 = require("@lightsparkdev/core");
1949
1949
  // package.json
1950
1950
  var package_default = {
1951
1951
  name: "@lightsparkdev/lightspark-sdk",
1952
- version: "1.4.0",
1952
+ version: "1.5.1",
1953
1953
  description: "Lightspark JS SDK",
1954
1954
  author: "Lightspark Inc.",
1955
1955
  keywords: [
@@ -8401,6 +8401,46 @@ ${FRAGMENT22}
8401
8401
  ${FRAGMENT}
8402
8402
  `;
8403
8403
 
8404
+ // src/objects/WithdrawalFeeEstimateOutput.ts
8405
+ var WithdrawalFeeEstimateOutputFromJson = (obj) => {
8406
+ return {
8407
+ feeEstimate: CurrencyAmountFromJson(
8408
+ obj["withdrawal_fee_estimate_output_fee_estimate"]
8409
+ )
8410
+ };
8411
+ };
8412
+ var FRAGMENT24 = `
8413
+ fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput {
8414
+ __typename
8415
+ withdrawal_fee_estimate_output_fee_estimate: fee_estimate {
8416
+ __typename
8417
+ currency_amount_original_value: original_value
8418
+ currency_amount_original_unit: original_unit
8419
+ currency_amount_preferred_currency_unit: preferred_currency_unit
8420
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
8421
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
8422
+ }
8423
+ }`;
8424
+
8425
+ // src/graphql/WithdrawalFeeEstimate.ts
8426
+ var WithdrawalFeeEstimate = `
8427
+ query WithdrawalFeeEstimate(
8428
+ $node_id: ID!
8429
+ $amount_sats: Long!
8430
+ $withdrawal_mode: WithdrawalMode!
8431
+ ) {
8432
+ withdrawal_fee_estimate(input: {
8433
+ node_id: $node_id,
8434
+ amount_sats: $amount_sats,
8435
+ withdrawal_mode: $withdrawal_mode
8436
+ }) {
8437
+ ...WithdrawalFeeEstimateOutputFragment
8438
+ }
8439
+ }
8440
+
8441
+ ${FRAGMENT24}
8442
+ `;
8443
+
8404
8444
  // src/objects/Account.ts
8405
8445
  var import_auto_bind12 = __toESM(require("auto-bind"), 1);
8406
8446
 
@@ -8522,7 +8562,7 @@ var LightsparkNodeFromJson = (obj) => {
8522
8562
  `Couldn't find a concrete type for interface LightsparkNode corresponding to the typename=${obj["__typename"]}`
8523
8563
  );
8524
8564
  };
8525
- var FRAGMENT24 = `
8565
+ var FRAGMENT25 = `
8526
8566
  fragment LightsparkNodeFragment on LightsparkNode {
8527
8567
  __typename
8528
8568
  ... on LightsparkNodeWithOSK {
@@ -8796,7 +8836,7 @@ query GetLightsparkNode($id: ID!) {
8796
8836
  }
8797
8837
  }
8798
8838
 
8799
- ${FRAGMENT24}
8839
+ ${FRAGMENT25}
8800
8840
  `,
8801
8841
  variables: { id },
8802
8842
  constructObject: (data) => LightsparkNodeFromJson(data.entity)
@@ -10000,7 +10040,7 @@ query GetWallet($id: ID!) {
10000
10040
  }
10001
10041
  }
10002
10042
 
10003
- ${FRAGMENT25}
10043
+ ${FRAGMENT26}
10004
10044
  `,
10005
10045
  variables: { id },
10006
10046
  constructObject: (data) => WalletFromJson(data.entity)
@@ -10033,7 +10073,7 @@ var WalletFromJson = (obj) => {
10033
10073
  obj["wallet_account"]?.id ?? void 0
10034
10074
  );
10035
10075
  };
10036
- var FRAGMENT25 = `
10076
+ var FRAGMENT26 = `
10037
10077
  fragment WalletFragment on Wallet {
10038
10078
  __typename
10039
10079
  wallet_id: id
@@ -11833,7 +11873,7 @@ query GetAccount {
11833
11873
  }
11834
11874
  }
11835
11875
 
11836
- ${FRAGMENT26}
11876
+ ${FRAGMENT27}
11837
11877
  `,
11838
11878
  variables: {},
11839
11879
  constructObject: (data) => AccountFromJson(data.current_account)
@@ -11858,7 +11898,7 @@ var AccountFromJson = (obj) => {
11858
11898
  obj["account_name"]
11859
11899
  );
11860
11900
  };
11861
- var FRAGMENT26 = `
11901
+ var FRAGMENT27 = `
11862
11902
  fragment AccountFragment on Account {
11863
11903
  __typename
11864
11904
  account_id: id
@@ -12365,6 +12405,37 @@ var LightsparkClient = class {
12365
12405
  response.lightning_fee_estimate_for_node.lightning_fee_estimate_output_fee_estimate
12366
12406
  );
12367
12407
  }
12408
+ /**
12409
+ * Returns an estimated amount for the L1 withdrawal fees for the specified node, amount, and
12410
+ * strategy.
12411
+ *
12412
+ * @param nodeId The node from which you'd like to make the withdrawal.
12413
+ * @param amountSats The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node.
12414
+ * @param withdrawalMode The strategy that should be used to withdraw the funds from this node.
12415
+ * @returns An estimated amount for the L1 withdrawal fees for the specified node, amount, and strategy.
12416
+ */
12417
+ async getWithrawalFeeEstimate(nodeId, amountSats, withdrawalMode) {
12418
+ const response = await this.executeRawQuery({
12419
+ queryPayload: WithdrawalFeeEstimate,
12420
+ variables: {
12421
+ node_id: nodeId,
12422
+ amount_sats: amountSats,
12423
+ withdrawal_mode: withdrawalMode
12424
+ },
12425
+ constructObject: (response2) => {
12426
+ return WithdrawalFeeEstimateOutputFromJson(
12427
+ response2.withdrawal_fee_estimate
12428
+ );
12429
+ }
12430
+ });
12431
+ if (!response) {
12432
+ throw new import_core9.LightsparkException(
12433
+ "WithdrawalFeeEstimateError",
12434
+ "Null or invalid fee estimate response from server"
12435
+ );
12436
+ }
12437
+ return response.feeEstimate;
12438
+ }
12368
12439
  /**
12369
12440
  * Directly unlocks a node with a signing private key or alias.
12370
12441
  *
@@ -13235,7 +13306,7 @@ var SignablePayloadFromJson = (obj) => {
13235
13306
  mulTweak: obj["signable_payload_mul_tweak"]
13236
13307
  };
13237
13308
  };
13238
- var FRAGMENT27 = `
13309
+ var FRAGMENT28 = `
13239
13310
  fragment SignablePayloadFragment on SignablePayload {
13240
13311
  __typename
13241
13312
  signable_payload_id: id
@@ -13261,7 +13332,7 @@ query GetSignablePayload($id: ID!) {
13261
13332
  }
13262
13333
  }
13263
13334
 
13264
- ${FRAGMENT27}
13335
+ ${FRAGMENT28}
13265
13336
  `,
13266
13337
  variables: { id },
13267
13338
  constructObject: (data) => SignablePayloadFromJson(data.entity)
@@ -13287,7 +13358,7 @@ var DepositFromJson = (obj) => {
13287
13358
  numConfirmations: obj["deposit_num_confirmations"]
13288
13359
  };
13289
13360
  };
13290
- var FRAGMENT28 = `
13361
+ var FRAGMENT29 = `
13291
13362
  fragment DepositFragment on Deposit {
13292
13363
  __typename
13293
13364
  deposit_id: id
@@ -13331,7 +13402,7 @@ query GetDeposit($id: ID!) {
13331
13402
  }
13332
13403
  }
13333
13404
 
13334
- ${FRAGMENT28}
13405
+ ${FRAGMENT29}
13335
13406
  `,
13336
13407
  variables: { id },
13337
13408
  constructObject: (data) => DepositFromJson(data.entity)
@@ -13404,7 +13475,7 @@ var LightningTransactionFromJson = (obj) => {
13404
13475
  `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj["__typename"]}`
13405
13476
  );
13406
13477
  };
13407
- var FRAGMENT29 = `
13478
+ var FRAGMENT30 = `
13408
13479
  fragment LightningTransactionFragment on LightningTransaction {
13409
13480
  __typename
13410
13481
  ... on IncomingPayment {
@@ -13833,7 +13904,7 @@ query GetLightningTransaction($id: ID!) {
13833
13904
  }
13834
13905
  }
13835
13906
 
13836
- ${FRAGMENT29}
13907
+ ${FRAGMENT30}
13837
13908
  `,
13838
13909
  variables: { id },
13839
13910
  constructObject: (data) => LightningTransactionFromJson(data.entity)
@@ -13870,7 +13941,7 @@ var LightsparkNodeOwnerFromJson = (obj) => {
13870
13941
  `Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename=${obj["__typename"]}`
13871
13942
  );
13872
13943
  };
13873
- var FRAGMENT30 = `
13944
+ var FRAGMENT31 = `
13874
13945
  fragment LightsparkNodeOwnerFragment on LightsparkNodeOwner {
13875
13946
  __typename
13876
13947
  ... on Account {
@@ -13931,7 +14002,7 @@ query GetLightsparkNodeOwner($id: ID!) {
13931
14002
  }
13932
14003
  }
13933
14004
 
13934
- ${FRAGMENT30}
14005
+ ${FRAGMENT31}
13935
14006
  `,
13936
14007
  variables: { id },
13937
14008
  constructObject: (data) => LightsparkNodeOwnerFromJson(data.entity)
@@ -14018,7 +14089,7 @@ var OnChainTransactionFromJson = (obj) => {
14018
14089
  `Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename=${obj["__typename"]}`
14019
14090
  );
14020
14091
  };
14021
- var FRAGMENT31 = `
14092
+ var FRAGMENT32 = `
14022
14093
  fragment OnChainTransactionFragment on OnChainTransaction {
14023
14094
  __typename
14024
14095
  ... on ChannelClosingTransaction {
@@ -14161,7 +14232,7 @@ query GetOnChainTransaction($id: ID!) {
14161
14232
  }
14162
14233
  }
14163
14234
 
14164
- ${FRAGMENT31}
14235
+ ${FRAGMENT32}
14165
14236
  `,
14166
14237
  variables: { id },
14167
14238
  constructObject: (data) => OnChainTransactionFromJson(data.entity)
@@ -14220,7 +14291,7 @@ var RoutingTransactionFromJson = (obj) => {
14220
14291
  failureReason: !!obj["routing_transaction_failure_reason"] ? RoutingTransactionFailureReason_default[obj["routing_transaction_failure_reason"]] ?? RoutingTransactionFailureReason_default.FUTURE_VALUE : null
14221
14292
  };
14222
14293
  };
14223
- var FRAGMENT32 = `
14294
+ var FRAGMENT33 = `
14224
14295
  fragment RoutingTransactionFragment on RoutingTransaction {
14225
14296
  __typename
14226
14297
  routing_transaction_id: id
@@ -14268,7 +14339,7 @@ query GetRoutingTransaction($id: ID!) {
14268
14339
  }
14269
14340
  }
14270
14341
 
14271
- ${FRAGMENT32}
14342
+ ${FRAGMENT33}
14272
14343
  `,
14273
14344
  variables: { id },
14274
14345
  constructObject: (data) => RoutingTransactionFromJson(data.entity)
@@ -14284,7 +14355,7 @@ var SignableFromJson = (obj) => {
14284
14355
  typename: "Signable"
14285
14356
  };
14286
14357
  };
14287
- var FRAGMENT33 = `
14358
+ var FRAGMENT34 = `
14288
14359
  fragment SignableFragment on Signable {
14289
14360
  __typename
14290
14361
  signable_id: id
@@ -14302,7 +14373,7 @@ query GetSignable($id: ID!) {
14302
14373
  }
14303
14374
  }
14304
14375
 
14305
- ${FRAGMENT33}
14376
+ ${FRAGMENT34}
14306
14377
  `,
14307
14378
  variables: { id },
14308
14379
  constructObject: (data) => SignableFromJson(data.entity)
@@ -14365,7 +14436,7 @@ var WithdrawalFromJson = (obj) => {
14365
14436
  numConfirmations: obj["withdrawal_num_confirmations"]
14366
14437
  };
14367
14438
  };
14368
- var FRAGMENT34 = `
14439
+ var FRAGMENT35 = `
14369
14440
  fragment WithdrawalFragment on Withdrawal {
14370
14441
  __typename
14371
14442
  withdrawal_id: id
@@ -14409,7 +14480,7 @@ query GetWithdrawal($id: ID!) {
14409
14480
  }
14410
14481
  }
14411
14482
 
14412
- ${FRAGMENT34}
14483
+ ${FRAGMENT35}
14413
14484
  `,
14414
14485
  variables: { id },
14415
14486
  constructObject: (data) => WithdrawalFromJson(data.entity)
@@ -14417,7 +14488,7 @@ ${FRAGMENT34}
14417
14488
  };
14418
14489
 
14419
14490
  // src/webhooks.ts
14420
- var import_crypto_wasm = require("@lightsparkdev/crypto-wasm");
14491
+ var import_core14 = require("@lightsparkdev/core");
14421
14492
  var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
14422
14493
  var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
14423
14494
  const { createHmac } = await import("crypto");
@@ -14452,8 +14523,14 @@ var RemoteSigningWebhookHandler = class {
14452
14523
  this.#masterSeed = masterSeed;
14453
14524
  this.validator = validator;
14454
14525
  }
14455
- handleWebhookRequest(data, webhookSignature, webhookSecret) {
14456
- const response = (0, import_crypto_wasm.wasm_handle_remote_signing_webhook_event)(
14526
+ async handleWebhookRequest(data, webhookSignature, webhookSecret) {
14527
+ if (!import_core14.isNode) {
14528
+ throw new import_core14.LightsparkSigningException(
14529
+ "Environment not supported for handling webhooks."
14530
+ );
14531
+ }
14532
+ const { wasm_handle_remote_signing_webhook_event } = await import("@lightsparkdev/crypto-wasm");
14533
+ const response = wasm_handle_remote_signing_webhook_event(
14457
14534
  data,
14458
14535
  webhookSignature,
14459
14536
  webhookSecret,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AuthProvider } from '@lightsparkdev/core';
2
- import { W as WebhookEventType, L as LightsparkClient } from './index-6f544cad.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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, bJ as Withdrawal, bL as WithdrawalMode, bM as WithdrawalRequest, bN as WithdrawalRequestStatus, bO as WithdrawalRequestToChannelClosingTransactionsConnection, bP as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from './index-6f544cad.js';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-f100aa27.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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, bJ as Withdrawal, bL as WithdrawalFeeEstimateInput, bM as WithdrawalFeeEstimateOutput, bN as WithdrawalMode, bO as WithdrawalRequest, bP as WithdrawalRequestStatus, bQ as WithdrawalRequestToChannelClosingTransactionsConnection, bR as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from './index-f100aa27.js';
4
4
  import { B as BitcoinNetwork } from './BitcoinNetwork-4f6ea015.js';
5
5
  import 'zen-observable';
6
6
 
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-6f544cad.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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, bJ as Withdrawal, bL as WithdrawalMode, bM as WithdrawalRequest, bN as WithdrawalRequestStatus, bO as WithdrawalRequestToChannelClosingTransactionsConnection, bP as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from './index-6f544cad.js';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-f100aa27.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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, bJ as Withdrawal, bL as WithdrawalFeeEstimateInput, bM as WithdrawalFeeEstimateOutput, bN as WithdrawalMode, bO as WithdrawalRequest, bP as WithdrawalRequestStatus, bQ as WithdrawalRequestToChannelClosingTransactionsConnection, bR as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from './index-f100aa27.js';
4
4
  import { B as BitcoinNetwork } from './BitcoinNetwork-4f6ea015.js';
5
5
  import 'zen-observable';
6
6
 
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  FRAGMENT11,
18
18
  FRAGMENT12,
19
19
  FRAGMENT13,
20
+ FRAGMENT14,
20
21
  FRAGMENT2,
21
22
  FRAGMENT3,
22
23
  FRAGMENT4,
@@ -63,6 +64,7 @@ import {
63
64
  Wallet_default,
64
65
  WebhookEventType,
65
66
  WebhookEventType_default,
67
+ WithdrawalFeeEstimateOutputFromJson,
66
68
  WithdrawalMode_default,
67
69
  WithdrawalRequestFromJson,
68
70
  WithdrawalRequestStatus_default,
@@ -86,7 +88,7 @@ import {
86
88
  getTransactionQuery,
87
89
  getUmaInvitationQuery,
88
90
  getWithdrawalQuery
89
- } from "./chunk-LCDROGA5.js";
91
+ } from "./chunk-ENYS5WAU.js";
90
92
  import {
91
93
  BitcoinNetwork_default
92
94
  } from "./chunk-K6SAUSAX.js";
@@ -144,7 +146,7 @@ import {
144
146
  // package.json
145
147
  var package_default = {
146
148
  name: "@lightsparkdev/lightspark-sdk",
147
- version: "1.4.0",
149
+ version: "1.5.1",
148
150
  description: "Lightspark JS SDK",
149
151
  author: "Lightspark Inc.",
150
152
  keywords: [
@@ -1195,6 +1197,25 @@ ${FRAGMENT12}
1195
1197
  ${FRAGMENT}
1196
1198
  `;
1197
1199
 
1200
+ // src/graphql/WithdrawalFeeEstimate.ts
1201
+ var WithdrawalFeeEstimate = `
1202
+ query WithdrawalFeeEstimate(
1203
+ $node_id: ID!
1204
+ $amount_sats: Long!
1205
+ $withdrawal_mode: WithdrawalMode!
1206
+ ) {
1207
+ withdrawal_fee_estimate(input: {
1208
+ node_id: $node_id,
1209
+ amount_sats: $amount_sats,
1210
+ withdrawal_mode: $withdrawal_mode
1211
+ }) {
1212
+ ...WithdrawalFeeEstimateOutputFragment
1213
+ }
1214
+ }
1215
+
1216
+ ${FRAGMENT14}
1217
+ `;
1218
+
1198
1219
  // src/client.ts
1199
1220
  var sdkVersion = package_default.version;
1200
1221
  var LightsparkClient = class {
@@ -1683,6 +1704,37 @@ var LightsparkClient = class {
1683
1704
  response.lightning_fee_estimate_for_node.lightning_fee_estimate_output_fee_estimate
1684
1705
  );
1685
1706
  }
1707
+ /**
1708
+ * Returns an estimated amount for the L1 withdrawal fees for the specified node, amount, and
1709
+ * strategy.
1710
+ *
1711
+ * @param nodeId The node from which you'd like to make the withdrawal.
1712
+ * @param amountSats The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node.
1713
+ * @param withdrawalMode The strategy that should be used to withdraw the funds from this node.
1714
+ * @returns An estimated amount for the L1 withdrawal fees for the specified node, amount, and strategy.
1715
+ */
1716
+ async getWithrawalFeeEstimate(nodeId, amountSats, withdrawalMode) {
1717
+ const response = await this.executeRawQuery({
1718
+ queryPayload: WithdrawalFeeEstimate,
1719
+ variables: {
1720
+ node_id: nodeId,
1721
+ amount_sats: amountSats,
1722
+ withdrawal_mode: withdrawalMode
1723
+ },
1724
+ constructObject: (response2) => {
1725
+ return WithdrawalFeeEstimateOutputFromJson(
1726
+ response2.withdrawal_fee_estimate
1727
+ );
1728
+ }
1729
+ });
1730
+ if (!response) {
1731
+ throw new LightsparkException(
1732
+ "WithdrawalFeeEstimateError",
1733
+ "Null or invalid fee estimate response from server"
1734
+ );
1735
+ }
1736
+ return response.feeEstimate;
1737
+ }
1686
1738
  /**
1687
1739
  * Directly unlocks a node with a signing private key or alias.
1688
1740
  *
@@ -2237,7 +2289,7 @@ var LightsparkClient = class {
2237
2289
  var client_default = LightsparkClient;
2238
2290
 
2239
2291
  // src/webhooks.ts
2240
- import { wasm_handle_remote_signing_webhook_event } from "@lightsparkdev/crypto-wasm";
2292
+ import { LightsparkSigningException as LightsparkSigningException4, isNode } from "@lightsparkdev/core";
2241
2293
  var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
2242
2294
  var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
2243
2295
  const { createHmac } = await import("crypto");
@@ -2272,7 +2324,13 @@ var RemoteSigningWebhookHandler = class {
2272
2324
  this.#masterSeed = masterSeed;
2273
2325
  this.validator = validator;
2274
2326
  }
2275
- handleWebhookRequest(data, webhookSignature, webhookSecret) {
2327
+ async handleWebhookRequest(data, webhookSignature, webhookSecret) {
2328
+ if (!isNode) {
2329
+ throw new LightsparkSigningException4(
2330
+ "Environment not supported for handling webhooks."
2331
+ );
2332
+ }
2333
+ const { wasm_handle_remote_signing_webhook_event } = await import("@lightsparkdev/crypto-wasm");
2276
2334
  const response = wasm_handle_remote_signing_webhook_event(
2277
2335
  data,
2278
2336
  webhookSignature,
@@ -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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, W as WebhookEventType, bJ as Withdrawal, bL as WithdrawalMode, bM as WithdrawalRequest, bN as WithdrawalRequestStatus, bO as WithdrawalRequestToChannelClosingTransactionsConnection, bP as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from '../index-6f544cad.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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, W as WebhookEventType, bJ as Withdrawal, bL as WithdrawalFeeEstimateInput, bM as WithdrawalFeeEstimateOutput, bN as WithdrawalMode, bO as WithdrawalRequest, bP as WithdrawalRequestStatus, bQ as WithdrawalRequestToChannelClosingTransactionsConnection, bR as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from '../index-f100aa27.js';
2
2
  export { B as BitcoinNetwork } from '../BitcoinNetwork-4f6ea015.js';
3
3
  import '@lightsparkdev/core';
4
4
  import 'zen-observable';
@@ -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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, W as WebhookEventType, bJ as Withdrawal, bL as WithdrawalMode, bM as WithdrawalRequest, bN as WithdrawalRequestStatus, bO as WithdrawalRequestToChannelClosingTransactionsConnection, bP as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from '../index-6f544cad.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 AccountToWithdrawalRequestsConnection, h as ApiToken, B as Balances, j as BlockchainBalance, C as CancelInvoiceInput, k as CancelInvoiceOutput, l as Channel, m as ChannelClosingTransaction, o as ChannelFees, p as ChannelOpeningTransaction, r as ChannelSnapshot, s as ChannelStatus, t as ChannelToTransactionsConnection, u as ClaimUmaInvitationInput, v as ClaimUmaInvitationOutput, w as ClaimUmaInvitationWithIncentivesInput, x as ClaimUmaInvitationWithIncentivesOutput, y as ComplianceProvider, z as Connection, D as CreateApiTokenInput, E as CreateApiTokenOutput, F as CreateInvitationWithIncentivesInput, G as CreateInvitationWithIncentivesOutput, H as CreateInvoiceInput, I as CreateInvoiceOutput, J as CreateLnurlInvoiceInput, K as CreateNodeWalletAddressInput, M as CreateNodeWalletAddressOutput, N as CreateTestModeInvoiceInput, O as CreateTestModeInvoiceOutput, P as CreateTestModePaymentInput, Q as CreateTestModePaymentoutput, R as CreateUmaInvitationInput, S as CreateUmaInvitationOutput, T as CreateUmaInvoiceInput, U as CurrencyAmount, V as CurrencyUnit, X as DeclineToSignMessagesInput, Y as DeclineToSignMessagesOutput, Z as DeleteApiTokenInput, _ as DeleteApiTokenOutput, $ as Deposit, a1 as Entity, a2 as FeeEstimate, a3 as FundNodeInput, a4 as FundNodeOutput, a5 as GraphNode, a6 as Hop, a8 as HtlcAttemptFailureCode, a9 as IdAndSignature, aa as IncentivesIneligibilityReason, ab as IncentivesStatus, ac as IncomingPayment, ad as IncomingPaymentAttempt, af as IncomingPaymentAttemptStatus, ag as IncomingPaymentToAttemptsConnection, ah as Invoice, aj as InvoiceData, ak as InvoiceType, al as LightningFeeEstimateForInvoiceInput, am as LightningFeeEstimateForNodeInput, an as LightningFeeEstimateOutput, ao as LightningTransaction, aq as LightsparkNode, as as LightsparkNodeOwner, au as LightsparkNodeStatus, av as LightsparkNodeToChannelsConnection, aw as LightsparkNodeWithOSK, ax as LightsparkNodeWithRemoteSigning, ay as Node, aA as NodeAddress, aB as NodeAddressType, aC as NodeToAddressesConnection, aD as OnChainTransaction, aF as OutgoingPayment, aG as OutgoingPaymentAttempt, aH as OutgoingPaymentAttemptStatus, aI as OutgoingPaymentAttemptToHopsConnection, aJ as OutgoingPaymentToAttemptsConnection, aK as OutgoingPaymentsForInvoiceQueryInput, aL as OutgoingPaymentsForInvoiceQueryOutput, aM as PageInfo, aN as PayInvoiceInput, aO as PayInvoiceOutput, aP as PayUmaInvoiceInput, aQ as PaymentDirection, aR as PaymentFailureReason, aS as PaymentRequest, aU as PaymentRequestData, aV as PaymentRequestStatus, aW as Permission, aX as PostTransactionData, aY as RegionCode, aZ as RegisterPaymentInput, a_ as RegisterPaymentOutput, a$ as ReleaseChannelPerCommitmentSecretInput, b0 as ReleaseChannelPerCommitmentSecretOutput, b1 as ReleasePaymentPreimageInput, b2 as ReleasePaymentPreimageOutput, b3 as RemoteSigningSubEventType, b4 as RequestWithdrawalInput, b5 as RequestWithdrawalOutput, b6 as RichText, b7 as RiskRating, b8 as RoutingTransaction, ba as RoutingTransactionFailureReason, bb as ScreenNodeInput, bc as ScreenNodeOutput, bd as Secret, be as SendPaymentInput, bf as SendPaymentOutput, bg as SetInvoicePaymentHashInput, bh as SetInvoicePaymentHashOutput, bi as SignInvoiceInput, bj as SignInvoiceOutput, bk as SignMessagesInput, bl as SignMessagesOutput, bm as Signable, bo as SignablePayload, bq as SignablePayloadStatus, br as SingleNodeDashboard, bs as Transaction, bu as TransactionFailures, bv as TransactionStatus, bw as TransactionType, bx as TransactionUpdate, by as UmaInvitation, bA as UpdateChannelPerCommitmentPointInput, bB as UpdateChannelPerCommitmentPointOutput, bC as UpdateNodeSharedSecretInput, bD as UpdateNodeSharedSecretOutput, bE as Wallet, bF as WalletStatus, bG as WalletToPaymentRequestsConnection, bH as WalletToTransactionsConnection, bI as WalletToWithdrawalRequestsConnection, W as WebhookEventType, bJ as Withdrawal, bL as WithdrawalFeeEstimateInput, bM as WithdrawalFeeEstimateOutput, bN as WithdrawalMode, bO as WithdrawalRequest, bP as WithdrawalRequestStatus, bQ as WithdrawalRequestToChannelClosingTransactionsConnection, bR as WithdrawalRequestToChannelOpeningTransactionsConnection, i as getApiTokenQuery, n as getChannelClosingTransactionQuery, q as getChannelOpeningTransactionQuery, a0 as getDepositQuery, a7 as getHopQuery, ae as getIncomingPaymentAttemptQuery, ai as getInvoiceQuery, ap as getLightningTransactionQuery, at as getLightsparkNodeOwnerQuery, ar as getLightsparkNodeQuery, az as getNodeQuery, aE as getOnChainTransactionQuery, aT as getPaymentRequestQuery, b9 as getRoutingTransactionQuery, bp as getSignablePayloadQuery, bn as getSignableQuery, bt as getTransactionQuery, bz as getUmaInvitationQuery, bK as getWithdrawalQuery } from '../index-f100aa27.js';
2
2
  export { B as BitcoinNetwork } from '../BitcoinNetwork-4f6ea015.js';
3
3
  import '@lightsparkdev/core';
4
4
  import 'zen-observable';
@@ -55,7 +55,7 @@ import {
55
55
  getTransactionQuery,
56
56
  getUmaInvitationQuery,
57
57
  getWithdrawalQuery
58
- } from "../chunk-LCDROGA5.js";
58
+ } from "../chunk-ENYS5WAU.js";
59
59
  import {
60
60
  BitcoinNetwork_default
61
61
  } from "../chunk-K6SAUSAX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
package/src/client.ts CHANGED
@@ -57,6 +57,7 @@ import { SendPayment } from "./graphql/SendPayment.js";
57
57
  import { SingleNodeDashboard as SingleNodeDashboardQuery } from "./graphql/SingleNodeDashboard.js";
58
58
  import { TransactionSubscription } from "./graphql/TransactionSubscription.js";
59
59
  import { TransactionsForNode } from "./graphql/TransactionsForNode.js";
60
+ import { WithdrawalFeeEstimate } from "./graphql/WithdrawalFeeEstimate.js";
60
61
  import { RiskRating, TransactionStatus } from "./index.js";
61
62
  import Account from "./objects/Account.js";
62
63
  import { ApiTokenFromJson } from "./objects/ApiToken.js";
@@ -90,6 +91,8 @@ import type TransactionUpdate from "./objects/TransactionUpdate.js";
90
91
  import { TransactionUpdateFromJson } from "./objects/TransactionUpdate.js";
91
92
  import type UmaInvitation from "./objects/UmaInvitation.js";
92
93
  import { UmaInvitationFromJson } from "./objects/UmaInvitation.js";
94
+ import type WithdrawalFeeEstimateOutput from "./objects/WithdrawalFeeEstimateOutput.js";
95
+ import { WithdrawalFeeEstimateOutputFromJson } from "./objects/WithdrawalFeeEstimateOutput.js";
93
96
  import type WithdrawalMode from "./objects/WithdrawalMode.js";
94
97
  import type WithdrawalRequest from "./objects/WithdrawalRequest.js";
95
98
  import { WithdrawalRequestFromJson } from "./objects/WithdrawalRequest.js";
@@ -714,6 +717,47 @@ class LightsparkClient {
714
717
  );
715
718
  }
716
719
 
720
+ /**
721
+ * Returns an estimated amount for the L1 withdrawal fees for the specified node, amount, and
722
+ * strategy.
723
+ *
724
+ * @param nodeId The node from which you'd like to make the withdrawal.
725
+ * @param amountSats The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node.
726
+ * @param withdrawalMode The strategy that should be used to withdraw the funds from this node.
727
+ * @returns An estimated amount for the L1 withdrawal fees for the specified node, amount, and strategy.
728
+ */
729
+ public async getWithrawalFeeEstimate(
730
+ nodeId: string,
731
+ amountSats: number,
732
+ withdrawalMode: WithdrawalMode,
733
+ ): Promise<CurrencyAmount> {
734
+ const response: WithdrawalFeeEstimateOutput | null =
735
+ await this.executeRawQuery({
736
+ queryPayload: WithdrawalFeeEstimate,
737
+ variables: {
738
+ node_id: nodeId,
739
+ amount_sats: amountSats,
740
+ withdrawal_mode: withdrawalMode,
741
+ },
742
+ constructObject: (response: {
743
+ withdrawal_fee_estimate: any; // eslint-disable-line @typescript-eslint/no-explicit-any
744
+ }) => {
745
+ return WithdrawalFeeEstimateOutputFromJson(
746
+ response.withdrawal_fee_estimate,
747
+ );
748
+ },
749
+ });
750
+
751
+ if (!response) {
752
+ throw new LightsparkException(
753
+ "WithdrawalFeeEstimateError",
754
+ "Null or invalid fee estimate response from server",
755
+ );
756
+ }
757
+
758
+ return response.feeEstimate;
759
+ }
760
+
717
761
  /**
718
762
  * Directly unlocks a node with a signing private key or alias.
719
763
  *
@@ -0,0 +1,21 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { FRAGMENT as WithdrawalFeeEstimateOutputFragment } from "../objects/WithdrawalFeeEstimateOutput.js";
4
+
5
+ export const WithdrawalFeeEstimate = `
6
+ query WithdrawalFeeEstimate(
7
+ $node_id: ID!
8
+ $amount_sats: Long!
9
+ $withdrawal_mode: WithdrawalMode!
10
+ ) {
11
+ withdrawal_fee_estimate(input: {
12
+ node_id: $node_id,
13
+ amount_sats: $amount_sats,
14
+ withdrawal_mode: $withdrawal_mode
15
+ }) {
16
+ ...WithdrawalFeeEstimateOutputFragment
17
+ }
18
+ }
19
+
20
+ ${WithdrawalFeeEstimateOutputFragment}
21
+ `;
@@ -0,0 +1,40 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import WithdrawalMode from "./WithdrawalMode.js";
4
+
5
+ interface WithdrawalFeeEstimateInput {
6
+ /** The node from which you'd like to make the withdrawal. **/
7
+ nodeId: string;
8
+
9
+ /**
10
+ * The amount you want to withdraw from this node in Satoshis. Use the special value -1 to
11
+ * withdrawal all funds from this node.
12
+ **/
13
+ amountSats: number;
14
+
15
+ /** The strategy that should be used to withdraw the funds from this node. **/
16
+ withdrawalMode: WithdrawalMode;
17
+ }
18
+
19
+ export const WithdrawalFeeEstimateInputFromJson = (
20
+ obj: any,
21
+ ): WithdrawalFeeEstimateInput => {
22
+ return {
23
+ nodeId: obj["withdrawal_fee_estimate_input_node_id"],
24
+ amountSats: obj["withdrawal_fee_estimate_input_amount_sats"],
25
+ withdrawalMode:
26
+ WithdrawalMode[obj["withdrawal_fee_estimate_input_withdrawal_mode"]] ??
27
+ WithdrawalMode.FUTURE_VALUE,
28
+ } as WithdrawalFeeEstimateInput;
29
+ };
30
+ export const WithdrawalFeeEstimateInputToJson = (
31
+ obj: WithdrawalFeeEstimateInput,
32
+ ): any => {
33
+ return {
34
+ withdrawal_fee_estimate_input_node_id: obj.nodeId,
35
+ withdrawal_fee_estimate_input_amount_sats: obj.amountSats,
36
+ withdrawal_fee_estimate_input_withdrawal_mode: obj.withdrawalMode,
37
+ };
38
+ };
39
+
40
+ export default WithdrawalFeeEstimateInput;
@@ -0,0 +1,46 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import type CurrencyAmount from "./CurrencyAmount.js";
4
+ import {
5
+ CurrencyAmountFromJson,
6
+ CurrencyAmountToJson,
7
+ } from "./CurrencyAmount.js";
8
+
9
+ interface WithdrawalFeeEstimateOutput {
10
+ /** The estimated fee for the withdrawal. **/
11
+ feeEstimate: CurrencyAmount;
12
+ }
13
+
14
+ export const WithdrawalFeeEstimateOutputFromJson = (
15
+ obj: any,
16
+ ): WithdrawalFeeEstimateOutput => {
17
+ return {
18
+ feeEstimate: CurrencyAmountFromJson(
19
+ obj["withdrawal_fee_estimate_output_fee_estimate"],
20
+ ),
21
+ } as WithdrawalFeeEstimateOutput;
22
+ };
23
+ export const WithdrawalFeeEstimateOutputToJson = (
24
+ obj: WithdrawalFeeEstimateOutput,
25
+ ): any => {
26
+ return {
27
+ withdrawal_fee_estimate_output_fee_estimate: CurrencyAmountToJson(
28
+ obj.feeEstimate,
29
+ ),
30
+ };
31
+ };
32
+
33
+ export const FRAGMENT = `
34
+ fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput {
35
+ __typename
36
+ withdrawal_fee_estimate_output_fee_estimate: fee_estimate {
37
+ __typename
38
+ currency_amount_original_value: original_value
39
+ currency_amount_original_unit: original_unit
40
+ currency_amount_preferred_currency_unit: preferred_currency_unit
41
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
42
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
43
+ }
44
+ }`;
45
+
46
+ export default WithdrawalFeeEstimateOutput;
@@ -177,6 +177,8 @@ export { default as WalletToTransactionsConnection } from "./WalletToTransaction
177
177
  export { default as WalletToWithdrawalRequestsConnection } from "./WalletToWithdrawalRequestsConnection.js";
178
178
  export { default as WebhookEventType } from "./WebhookEventType.js";
179
179
  export { default as Withdrawal, getWithdrawalQuery } from "./Withdrawal.js";
180
+ export { default as WithdrawalFeeEstimateInput } from "./WithdrawalFeeEstimateInput.js";
181
+ export { default as WithdrawalFeeEstimateOutput } from "./WithdrawalFeeEstimateOutput.js";
180
182
  export { default as WithdrawalMode } from "./WithdrawalMode.js";
181
183
  export { default as WithdrawalRequest } from "./WithdrawalRequest.js";
182
184
  export { default as WithdrawalRequestStatus } from "./WithdrawalRequestStatus.js";
@@ -601,6 +601,15 @@ describe(p2SuiteName, () => {
601
601
  TESTS_TIMEOUT,
602
602
  );
603
603
 
604
+ test("Should get a withdrawal fee estimate", async () => {
605
+ const fee = await lightsparkClient.getWithrawalFeeEstimate(
606
+ getRegtestNodeId(),
607
+ 100,
608
+ WithdrawalMode.WALLET_THEN_CHANNELS,
609
+ );
610
+ expect(fee).not.toBeNull();
611
+ });
612
+
604
613
  test(
605
614
  "Should execute a raw graphql query",
606
615
  async () => {
package/src/webhooks.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { wasm_handle_remote_signing_webhook_event } from "@lightsparkdev/crypto-wasm";
1
+ import { LightsparkSigningException, isNode } from "@lightsparkdev/core";
2
2
  import type LightsparkClient from "./client.js";
3
3
  import { WebhookEventType } from "./objects/WebhookEventType.js";
4
4
 
@@ -65,11 +65,20 @@ export class RemoteSigningWebhookHandler {
65
65
  this.validator = validator;
66
66
  }
67
67
 
68
- handleWebhookRequest(
68
+ async handleWebhookRequest(
69
69
  data: Uint8Array,
70
70
  webhookSignature: string,
71
71
  webhookSecret: string,
72
72
  ) {
73
+ if (!isNode) {
74
+ throw new LightsparkSigningException(
75
+ "Environment not supported for handling webhooks.",
76
+ );
77
+ }
78
+
79
+ const { wasm_handle_remote_signing_webhook_event } = await import(
80
+ "@lightsparkdev/crypto-wasm"
81
+ );
73
82
  const response = wasm_handle_remote_signing_webhook_event(
74
83
  data,
75
84
  webhookSignature,