@buildonspark/spark-sdk 0.2.3 → 0.2.5

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-3SEOTO43.js → chunk-3SPMJMUX.js} +3 -2
  3. package/dist/{chunk-CDLETEDT.js → chunk-CQY5ML2A.js} +16 -3
  4. package/dist/{chunk-PTRXJS7Q.js → chunk-LQZL2D3Y.js} +1 -1
  5. package/dist/{chunk-PLLJIZC3.js → chunk-U7LRIWTF.js} +2471 -822
  6. package/dist/{client-CcYzmpmj.d.cts → client-C88GCTPB.d.cts} +211 -104
  7. package/dist/{client-CGTRS23n.d.ts → client-Dg6vS_2I.d.ts} +211 -104
  8. package/dist/debug.cjs +2511 -831
  9. package/dist/debug.d.cts +19 -6
  10. package/dist/debug.d.ts +19 -6
  11. package/dist/debug.js +3 -3
  12. package/dist/graphql/objects/index.cjs +13 -1
  13. package/dist/graphql/objects/index.d.cts +6 -51
  14. package/dist/graphql/objects/index.d.ts +6 -51
  15. package/dist/graphql/objects/index.js +1 -1
  16. package/dist/index.cjs +2491 -797
  17. package/dist/index.d.cts +189 -9
  18. package/dist/index.d.ts +189 -9
  19. package/dist/index.js +32 -4
  20. package/dist/index.node.cjs +2596 -799
  21. package/dist/index.node.d.cts +9 -190
  22. package/dist/index.node.d.ts +9 -190
  23. package/dist/index.node.js +134 -4
  24. package/dist/native/index.cjs +2491 -797
  25. package/dist/native/index.d.cts +309 -174
  26. package/dist/native/index.d.ts +309 -174
  27. package/dist/native/index.js +2495 -814
  28. package/dist/proto/lrc20.d.cts +1 -1
  29. package/dist/proto/lrc20.d.ts +1 -1
  30. package/dist/proto/spark.d.cts +1 -1
  31. package/dist/proto/spark.d.ts +1 -1
  32. package/dist/proto/spark_token.d.cts +1 -1
  33. package/dist/proto/spark_token.d.ts +1 -1
  34. package/dist/{spark-B_7nZx6T.d.cts → spark-ESAfZARg.d.cts} +1 -1
  35. package/dist/{spark-B_7nZx6T.d.ts → spark-ESAfZARg.d.ts} +1 -1
  36. package/dist/{spark-wallet-CxcGPXRB.d.ts → spark-wallet-B2WwKN8W.d.ts} +57 -35
  37. package/dist/{spark-wallet-DJJm19BP.d.cts → spark-wallet-Di65w0Us.d.cts} +57 -35
  38. package/dist/spark-wallet.node-7R0Rxyj9.d.cts +13 -0
  39. package/dist/spark-wallet.node-CSPWOWRu.d.ts +13 -0
  40. package/dist/tests/test-utils.cjs +578 -77
  41. package/dist/tests/test-utils.d.cts +12 -13
  42. package/dist/tests/test-utils.d.ts +12 -13
  43. package/dist/tests/test-utils.js +54 -17
  44. package/dist/types/index.cjs +16 -3
  45. package/dist/types/index.d.cts +3 -4
  46. package/dist/types/index.d.ts +3 -4
  47. package/dist/types/index.js +2 -2
  48. package/dist/{xchain-address-Bh9w1SeC.d.ts → xchain-address-BsveIy5l.d.ts} +56 -8
  49. package/dist/{xchain-address-SZ7dkVUE.d.cts → xchain-address-CqRu3F21.d.cts} +56 -8
  50. package/package.json +1 -1
  51. package/src/graphql/client.ts +57 -8
  52. package/src/graphql/mutations/CompleteLeavesSwap.ts +9 -1
  53. package/src/graphql/mutations/RequestSwapLeaves.ts +4 -0
  54. package/src/graphql/objects/CompleteLeavesSwapInput.ts +34 -34
  55. package/src/graphql/objects/LeavesSwapRequest.ts +4 -0
  56. package/src/graphql/objects/RequestLeavesSwapInput.ts +48 -47
  57. package/src/graphql/objects/SparkWalletUser.ts +1 -1
  58. package/src/graphql/objects/SwapLeaf.ts +40 -32
  59. package/src/graphql/objects/UserLeafInput.ts +24 -0
  60. package/src/graphql/objects/UserRequest.ts +4 -0
  61. package/src/graphql/queries/Transfers.ts +15 -0
  62. package/src/index.node.ts +1 -1
  63. package/src/native/index.ts +4 -5
  64. package/src/services/coop-exit.ts +171 -36
  65. package/src/services/deposit.ts +471 -74
  66. package/src/services/lightning.ts +18 -5
  67. package/src/services/signing.ts +162 -50
  68. package/src/services/transfer.ts +950 -384
  69. package/src/services/tree-creation.ts +342 -121
  70. package/src/spark-wallet/spark-wallet.node.ts +71 -66
  71. package/src/spark-wallet/spark-wallet.ts +561 -192
  72. package/src/tests/integration/coop-exit.test.ts +3 -8
  73. package/src/tests/integration/deposit.test.ts +3 -3
  74. package/src/tests/integration/lightning.test.ts +521 -466
  75. package/src/tests/integration/ssp/static_deposit.test.ts +83 -1
  76. package/src/tests/integration/ssp/transfers.test.ts +97 -0
  77. package/src/tests/integration/swap.test.ts +559 -307
  78. package/src/tests/integration/transfer.test.ts +625 -623
  79. package/src/tests/integration/wallet.test.ts +2 -2
  80. package/src/tests/integration/watchtower.test.ts +211 -0
  81. package/src/tests/test-utils.ts +63 -14
  82. package/src/tests/utils/test-faucet.ts +4 -2
  83. package/src/types/sdk-types.ts +15 -0
  84. package/src/utils/adaptor-signature.ts +15 -5
  85. package/src/utils/bitcoin.ts +13 -0
  86. package/src/utils/fetch.ts +75 -0
  87. package/src/utils/mempool.ts +9 -4
  88. package/src/utils/transaction.ts +388 -26
  89. package/dist/sdk-types-CB9HrW5O.d.cts +0 -44
  90. package/dist/sdk-types-CkRNraXT.d.ts +0 -44
  91. package/src/graphql/queries/Transfer.ts +0 -10
@@ -10,6 +10,7 @@ import {
10
10
  import { sha256 } from "@noble/hashes/sha2";
11
11
  import { AuthenticationError, NetworkError } from "../errors/index.js";
12
12
  import { SparkSigner } from "../signer/signer.js";
13
+ import { UserRequestType } from "../types/sdk-types.js";
13
14
  import { ClaimStaticDeposit } from "./mutations/ClaimStaticDeposit.js";
14
15
  import { CompleteCoopExit } from "./mutations/CompleteCoopExit.js";
15
16
  import { CompleteLeavesSwap } from "./mutations/CompleteLeavesSwap.js";
@@ -19,6 +20,7 @@ import { RequestLightningReceive } from "./mutations/RequestLightningReceive.js"
19
20
  import { RequestLightningSend } from "./mutations/RequestLightningSend.js";
20
21
  import { RequestSwapLeaves } from "./mutations/RequestSwapLeaves.js";
21
22
  import { VerifyChallenge } from "./mutations/VerifyChallenge.js";
23
+ import { ClaimStaticDepositFromJson } from "./objects/ClaimStaticDeposit.js";
22
24
  import ClaimStaticDepositOutput, {
23
25
  ClaimStaticDepositOutputFromJson,
24
26
  } from "./objects/ClaimStaticDepositOutput.js";
@@ -29,7 +31,7 @@ import CoopExitRequest, {
29
31
  CoopExitRequestFromJson,
30
32
  } from "./objects/CoopExitRequest.js";
31
33
  import { GetChallengeOutputFromJson } from "./objects/GetChallengeOutput.js";
32
- import type {
34
+ import {
33
35
  BitcoinNetwork,
34
36
  CompleteCoopExitInput,
35
37
  CompleteLeavesSwapInput,
@@ -70,7 +72,7 @@ import { GetClaimDepositQuote } from "./queries/GetClaimDepositQuote.js";
70
72
  import { GetCoopExitFeeQuote } from "./queries/GetCoopExitFeeQuote.js";
71
73
  import { LeavesSwapFeeEstimate } from "./queries/LeavesSwapFeeEstimate.js";
72
74
  import { LightningSendFeeEstimate } from "./queries/LightningSendFeeEstimate.js";
73
- import { GetTransfer } from "./queries/Transfer.js";
75
+ import { GetTransfers } from "./queries/Transfers.js";
74
76
  import { UserRequest } from "./queries/UserRequest.js";
75
77
 
76
78
  export interface SspClientOptions {
@@ -79,6 +81,10 @@ export interface SspClientOptions {
79
81
  schemaEndpoint?: string;
80
82
  }
81
83
 
84
+ export interface TransferWithUserRequest extends Transfer {
85
+ userRequest?: UserRequestType;
86
+ }
87
+
82
88
  export interface MayHaveSspClientOptions {
83
89
  readonly sspClientOptions?: SspClientOptions;
84
90
  }
@@ -309,6 +315,8 @@ export default class SspClient {
309
315
 
310
316
  async requestLeaveSwap({
311
317
  adaptorPubkey,
318
+ directAdaptorPubkey,
319
+ directFromCpfpAdaptorPubkey,
312
320
  totalAmountSats,
313
321
  targetAmountSats,
314
322
  feeSats,
@@ -320,6 +328,8 @@ export default class SspClient {
320
328
  queryPayload: RequestSwapLeaves,
321
329
  variables: {
322
330
  adaptor_pubkey: adaptorPubkey,
331
+ direct_adaptor_pubkey: directAdaptorPubkey,
332
+ direct_from_cpfp_adaptor_pubkey: directFromCpfpAdaptorPubkey,
323
333
  total_amount_sats: totalAmountSats,
324
334
  target_amount_sats: targetAmountSats,
325
335
  fee_sats: feeSats,
@@ -340,6 +350,8 @@ export default class SspClient {
340
350
 
341
351
  async completeLeaveSwap({
342
352
  adaptorSecretKey,
353
+ directAdaptorSecretKey,
354
+ directFromCpfpAdaptorSecretKey,
343
355
  userOutboundTransferExternalId,
344
356
  leavesSwapRequestId,
345
357
  }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null> {
@@ -347,6 +359,8 @@ export default class SspClient {
347
359
  queryPayload: CompleteLeavesSwap,
348
360
  variables: {
349
361
  adaptor_secret_key: adaptorSecretKey,
362
+ direct_adaptor_secret_key: directAdaptorSecretKey,
363
+ direct_from_cpfp_adaptor_secret_key: directFromCpfpAdaptorSecretKey,
350
364
  user_outbound_transfer_external_id: userOutboundTransferExternalId,
351
365
  leaves_swap_request_id: leavesSwapRequestId,
352
366
  },
@@ -477,14 +491,49 @@ export default class SspClient {
477
491
  });
478
492
  }
479
493
 
480
- async getTransfer(id: string): Promise<Transfer | null> {
494
+ async getTransfers(ids: string[]): Promise<TransferWithUserRequest[]> {
481
495
  return await this.executeRawQuery({
482
- queryPayload: GetTransfer,
496
+ queryPayload: GetTransfers,
483
497
  variables: {
484
- transfer_spark_id: id,
485
- },
486
- constructObject: (response: { transfer: any }) => {
487
- return TransferFromJson(response.transfer);
498
+ transfer_spark_ids: ids,
499
+ },
500
+ constructObject: (response: { transfers: any }) => {
501
+ return response.transfers.map((transfer: any) => {
502
+ const transferObj: TransferWithUserRequest = TransferFromJson(
503
+ transfer,
504
+ ) as TransferWithUserRequest;
505
+
506
+ switch (transfer.transfer_user_request.__typename) {
507
+ case "ClaimStaticDeposit":
508
+ transferObj.userRequest = ClaimStaticDepositFromJson(
509
+ transfer.transfer_user_request,
510
+ );
511
+ break;
512
+ case "CoopExitRequest":
513
+ transferObj.userRequest = CoopExitRequestFromJson(
514
+ transfer.transfer_user_request,
515
+ );
516
+ break;
517
+ case "LeavesSwapRequest":
518
+ transferObj.userRequest = LeavesSwapRequestFromJson(
519
+ transfer.transfer_user_request,
520
+ );
521
+ break;
522
+ case "LightningReceiveRequest":
523
+ transferObj.userRequest = LightningReceiveRequestFromJson(
524
+ transfer.transfer_user_request,
525
+ );
526
+ break;
527
+ case "LightningSendRequest":
528
+ transferObj.userRequest = LightningSendRequestFromJson(
529
+ transfer.transfer_user_request,
530
+ );
531
+ break;
532
+ }
533
+
534
+ const { userRequestId, ...rest } = transferObj;
535
+ return rest;
536
+ });
488
537
  },
489
538
  });
490
539
  }
@@ -3,10 +3,18 @@ import { FRAGMENT as LeavesSwapRequestFragment } from "../objects/LeavesSwapRequ
3
3
  export const CompleteLeavesSwap = `
4
4
  mutation CompleteLeavesSwap(
5
5
  $adaptor_secret_key: String!
6
+ $direct_adaptor_secret_key: String!
7
+ $direct_from_cpfp_adaptor_secret_key: String!
6
8
  $user_outbound_transfer_external_id: UUID!
7
9
  $leaves_swap_request_id: ID!
8
10
  ) {
9
- complete_leaves_swap(input: { adaptor_secret_key: $adaptor_secret_key, user_outbound_transfer_external_id: $user_outbound_transfer_external_id, leaves_swap_request_id: $leaves_swap_request_id }) {
11
+ complete_leaves_swap(input: {
12
+ adaptor_secret_key: $adaptor_secret_key,
13
+ direct_adaptor_secret_key: $direct_adaptor_secret_key,
14
+ direct_from_cpfp_adaptor_secret_key: $direct_from_cpfp_adaptor_secret_key,
15
+ user_outbound_transfer_external_id: $user_outbound_transfer_external_id,
16
+ leaves_swap_request_id: $leaves_swap_request_id
17
+ }) {
10
18
  request {
11
19
  ...LeavesSwapRequestFragment
12
20
  }
@@ -3,6 +3,8 @@ import { FRAGMENT as LeavesSwapRequestFragment } from "../objects/LeavesSwapRequ
3
3
  export const RequestSwapLeaves = `
4
4
  mutation RequestSwapLeaves(
5
5
  $adaptor_pubkey: PublicKey!
6
+ $direct_adaptor_pubkey: PublicKey
7
+ $direct_from_cpfp_adaptor_pubkey: PublicKey
6
8
  $total_amount_sats: Long!
7
9
  $target_amount_sats: Long!
8
10
  $fee_sats: Long!
@@ -12,6 +14,8 @@ export const RequestSwapLeaves = `
12
14
  ) {
13
15
  request_leaves_swap(input: {
14
16
  adaptor_pubkey: $adaptor_pubkey
17
+ direct_adaptor_pubkey: $direct_adaptor_pubkey
18
+ direct_from_cpfp_adaptor_pubkey: $direct_from_cpfp_adaptor_pubkey
15
19
  total_amount_sats: $total_amount_sats
16
20
  target_amount_sats: $target_amount_sats
17
21
  fee_sats: $fee_sats
@@ -1,45 +1,45 @@
1
-
2
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
2
 
4
-
5
-
6
-
7
-
8
3
  interface CompleteLeavesSwapInput {
4
+ adaptorSecretKey: string;
9
5
 
6
+ directAdaptorSecretKey: string;
10
7
 
11
- adaptorSecretKey: string;
12
-
13
- userOutboundTransferExternalId: string;
14
-
15
- leavesSwapRequestId: string;
16
-
17
-
8
+ directFromCpfpAdaptorSecretKey: string;
18
9
 
10
+ userOutboundTransferExternalId: string;
19
11
 
12
+ leavesSwapRequestId: string;
20
13
  }
21
14
 
22
- export const CompleteLeavesSwapInputFromJson = (obj: any): CompleteLeavesSwapInput => {
23
- return {
24
- adaptorSecretKey: obj["complete_leaves_swap_input_adaptor_secret_key"],
25
- userOutboundTransferExternalId: obj["complete_leaves_swap_input_user_outbound_transfer_external_id"],
26
- leavesSwapRequestId: obj["complete_leaves_swap_input_leaves_swap_request_id"],
27
-
28
- } as CompleteLeavesSwapInput;
29
-
30
- }
31
- export const CompleteLeavesSwapInputToJson = (obj: CompleteLeavesSwapInput): any => {
32
- return {
33
- complete_leaves_swap_input_adaptor_secret_key: obj.adaptorSecretKey,
34
- complete_leaves_swap_input_user_outbound_transfer_external_id: obj.userOutboundTransferExternalId,
35
- complete_leaves_swap_input_leaves_swap_request_id: obj.leavesSwapRequestId,
36
-
37
- }
38
-
39
- }
40
-
41
-
42
-
43
-
15
+ export const CompleteLeavesSwapInputFromJson = (
16
+ obj: any,
17
+ ): CompleteLeavesSwapInput => {
18
+ return {
19
+ adaptorSecretKey: obj["complete_leaves_swap_input_adaptor_secret_key"],
20
+ directAdaptorSecretKey:
21
+ obj["complete_leaves_swap_input_direct_adaptor_secret_key"],
22
+ directFromCpfpAdaptorSecretKey:
23
+ obj["complete_leaves_swap_input_direct_from_cpfp_adaptor_secret_key"],
24
+ userOutboundTransferExternalId:
25
+ obj["complete_leaves_swap_input_user_outbound_transfer_external_id"],
26
+ leavesSwapRequestId:
27
+ obj["complete_leaves_swap_input_leaves_swap_request_id"],
28
+ } as CompleteLeavesSwapInput;
29
+ };
30
+ export const CompleteLeavesSwapInputToJson = (
31
+ obj: CompleteLeavesSwapInput,
32
+ ): any => {
33
+ return {
34
+ complete_leaves_swap_input_adaptor_secret_key: obj.adaptorSecretKey,
35
+ complete_leaves_swap_input_direct_adaptor_secret_key:
36
+ obj.directAdaptorSecretKey,
37
+ complete_leaves_swap_input_direct_from_cpfp_adaptor_secret_key:
38
+ obj.directFromCpfpAdaptorSecretKey,
39
+ complete_leaves_swap_input_user_outbound_transfer_external_id:
40
+ obj.userOutboundTransferExternalId,
41
+ complete_leaves_swap_input_leaves_swap_request_id: obj.leavesSwapRequestId,
42
+ };
43
+ };
44
44
 
45
45
  export default CompleteLeavesSwapInput;
@@ -175,6 +175,10 @@ fragment LeavesSwapRequestFragment on LeavesSwapRequest {
175
175
  swap_leaf_leaf_id: leaf_id
176
176
  swap_leaf_raw_unsigned_refund_transaction: raw_unsigned_refund_transaction
177
177
  swap_leaf_adaptor_signed_signature: adaptor_signed_signature
178
+ swap_leaf_direct_raw_unsigned_refund_transaction: direct_raw_unsigned_refund_transaction
179
+ swap_leaf_direct_adaptor_signed_signature: direct_adaptor_signed_signature
180
+ swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction: direct_from_cpfp_raw_unsigned_refund_transaction
181
+ swap_leaf_direct_from_cpfp_adaptor_signed_signature: direct_from_cpfp_adaptor_signed_signature
178
182
  }
179
183
  }`;
180
184
 
@@ -1,63 +1,64 @@
1
-
2
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
2
 
4
-
5
- import {UserLeafInputFromJson} from './UserLeafInput.js';
6
- import {UserLeafInputToJson} from './UserLeafInput.js';
7
- import UserLeafInput from './UserLeafInput.js';
8
-
3
+ import UserLeafInput, {
4
+ UserLeafInputFromJson,
5
+ UserLeafInputToJson,
6
+ } from "./UserLeafInput.js";
9
7
 
10
8
  interface RequestLeavesSwapInput {
9
+ adaptorPubkey: string;
11
10
 
11
+ directAdaptorPubkey?: string;
12
12
 
13
- adaptorPubkey: string;
14
-
15
- totalAmountSats: number;
16
-
17
- targetAmountSats: number;
18
-
19
- feeSats: number;
20
-
21
- userLeaves: UserLeafInput[];
22
-
23
- idempotencyKey: string;
13
+ directFromCpfpAdaptorPubkey?: string;
24
14
 
25
- targetAmountSatsList?: number[] | undefined;
15
+ totalAmountSats: number;
26
16
 
17
+ targetAmountSats: number;
27
18
 
19
+ feeSats: number;
28
20
 
21
+ userLeaves: UserLeafInput[];
29
22
 
30
- }
31
-
32
- export const RequestLeavesSwapInputFromJson = (obj: any): RequestLeavesSwapInput => {
33
- return {
34
- adaptorPubkey: obj["request_leaves_swap_input_adaptor_pubkey"],
35
- totalAmountSats: obj["request_leaves_swap_input_total_amount_sats"],
36
- targetAmountSats: obj["request_leaves_swap_input_target_amount_sats"],
37
- feeSats: obj["request_leaves_swap_input_fee_sats"],
38
- userLeaves: obj["request_leaves_swap_input_user_leaves"].map((e) => UserLeafInputFromJson(e)),
39
- idempotencyKey: obj["request_leaves_swap_input_idempotency_key"],
40
- targetAmountSatsList: obj["request_leaves_swap_input_target_amount_sats_list"],
41
-
42
- } as RequestLeavesSwapInput;
43
-
44
- }
45
- export const RequestLeavesSwapInputToJson = (obj: RequestLeavesSwapInput): any => {
46
- return {
47
- request_leaves_swap_input_adaptor_pubkey: obj.adaptorPubkey,
48
- request_leaves_swap_input_total_amount_sats: obj.totalAmountSats,
49
- request_leaves_swap_input_target_amount_sats: obj.targetAmountSats,
50
- request_leaves_swap_input_fee_sats: obj.feeSats,
51
- request_leaves_swap_input_user_leaves: obj.userLeaves.map((e) => UserLeafInputToJson(e)),
52
- request_leaves_swap_input_idempotency_key: obj.idempotencyKey,
53
- request_leaves_swap_input_target_amount_sats_list: obj.targetAmountSatsList,
54
-
55
- }
23
+ idempotencyKey: string;
56
24
 
25
+ targetAmountSatsList?: number[] | undefined;
57
26
  }
58
27
 
59
-
60
-
61
-
28
+ export const RequestLeavesSwapInputFromJson = (
29
+ obj: any,
30
+ ): RequestLeavesSwapInput => {
31
+ return {
32
+ adaptorPubkey: obj["request_leaves_swap_input_adaptor_pubkey"],
33
+ directAdaptorPubkey: obj["request_leaves_swap_input_direct_adaptor_pubkey"],
34
+ directFromCpfpAdaptorPubkey: obj["request_leaves_swap_input_direct_from_cpfp_adaptor_pubkey"],
35
+ totalAmountSats: obj["request_leaves_swap_input_total_amount_sats"],
36
+ targetAmountSats: obj["request_leaves_swap_input_target_amount_sats"],
37
+ feeSats: obj["request_leaves_swap_input_fee_sats"],
38
+ userLeaves: obj["request_leaves_swap_input_user_leaves"].map((e) =>
39
+ UserLeafInputFromJson(e),
40
+ ),
41
+ idempotencyKey: obj["request_leaves_swap_input_idempotency_key"],
42
+ targetAmountSatsList:
43
+ obj["request_leaves_swap_input_target_amount_sats_list"],
44
+ } as RequestLeavesSwapInput;
45
+ };
46
+ export const RequestLeavesSwapInputToJson = (
47
+ obj: RequestLeavesSwapInput,
48
+ ): any => {
49
+ return {
50
+ request_leaves_swap_input_adaptor_pubkey: obj.adaptorPubkey,
51
+ request_leaves_swap_input_direct_adaptor_pubkey: obj.directAdaptorPubkey,
52
+ request_leaves_swap_input_direct_from_cpfp_adaptor_pubkey: obj.directFromCpfpAdaptorPubkey,
53
+ request_leaves_swap_input_total_amount_sats: obj.totalAmountSats,
54
+ request_leaves_swap_input_target_amount_sats: obj.targetAmountSats,
55
+ request_leaves_swap_input_fee_sats: obj.feeSats,
56
+ request_leaves_swap_input_user_leaves: obj.userLeaves.map((e) =>
57
+ UserLeafInputToJson(e),
58
+ ),
59
+ request_leaves_swap_input_idempotency_key: obj.idempotencyKey,
60
+ request_leaves_swap_input_target_amount_sats_list: obj.targetAmountSatsList,
61
+ };
62
+ };
62
63
 
63
64
  export default RequestLeavesSwapInput;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { Query, isObject } from "@lightsparkdev/core";
4
4
  import autoBind from "../../auto-bind.js";
5
- import LightsparkClient from "../client.js";
5
+ import type LightsparkClient from "../client.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
7
7
  import Entity from "./Entity.js";
8
8
  import SparkUserRequestStatus from "./SparkUserRequestStatus.js";
@@ -1,53 +1,61 @@
1
-
2
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
3
2
 
4
-
5
-
6
-
7
-
8
3
  interface SwapLeaf {
4
+ leafId: string;
9
5
 
6
+ rawUnsignedRefundTransaction: string;
10
7
 
11
- leafId: string;
12
-
13
- rawUnsignedRefundTransaction: string;
14
-
15
- adaptorSignedSignature: string;
8
+ adaptorSignedSignature: string;
16
9
 
10
+ directRawUnsignedRefundTransaction?: string;
17
11
 
12
+ directAdaptorSignedSignature?: string;
18
13
 
14
+ directFromCpfpRawUnsignedRefundTransaction?: string;
19
15
 
16
+ directFromCpfpAdaptorSignedSignature?: string;
20
17
  }
21
18
 
22
19
  export const SwapLeafFromJson = (obj: any): SwapLeaf => {
23
- return {
24
- leafId: obj["swap_leaf_leaf_id"],
25
- rawUnsignedRefundTransaction: obj["swap_leaf_raw_unsigned_refund_transaction"],
26
- adaptorSignedSignature: obj["swap_leaf_adaptor_signed_signature"],
27
-
28
- } as SwapLeaf;
29
-
30
- }
20
+ return {
21
+ leafId: obj["swap_leaf_leaf_id"],
22
+ rawUnsignedRefundTransaction:
23
+ obj["swap_leaf_raw_unsigned_refund_transaction"],
24
+ adaptorSignedSignature: obj["swap_leaf_adaptor_signed_signature"],
25
+ directRawUnsignedRefundTransaction:
26
+ obj["swap_leaf_direct_raw_unsigned_refund_transaction"],
27
+ directAdaptorSignedSignature:
28
+ obj["swap_leaf_direct_adaptor_signed_signature"],
29
+ directFromCpfpRawUnsignedRefundTransaction:
30
+ obj["swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction"],
31
+ directFromCpfpAdaptorSignedSignature:
32
+ obj["swap_leaf_direct_from_cpfp_adaptor_signed_signature"],
33
+ } as SwapLeaf;
34
+ };
31
35
  export const SwapLeafToJson = (obj: SwapLeaf): any => {
32
- return {
33
- swap_leaf_leaf_id: obj.leafId,
34
- swap_leaf_raw_unsigned_refund_transaction: obj.rawUnsignedRefundTransaction,
35
- swap_leaf_adaptor_signed_signature: obj.adaptorSignedSignature,
36
-
37
- }
38
-
39
- }
40
-
41
-
42
- export const FRAGMENT = `
36
+ return {
37
+ swap_leaf_leaf_id: obj.leafId,
38
+ swap_leaf_raw_unsigned_refund_transaction: obj.rawUnsignedRefundTransaction,
39
+ swap_leaf_adaptor_signed_signature: obj.adaptorSignedSignature,
40
+ swap_leaf_direct_raw_unsigned_refund_transaction:
41
+ obj.directRawUnsignedRefundTransaction,
42
+ swap_leaf_direct_adaptor_signed_signature: obj.directAdaptorSignedSignature,
43
+ swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction:
44
+ obj.directFromCpfpRawUnsignedRefundTransaction,
45
+ swap_leaf_direct_from_cpfp_adaptor_signed_signature: obj.directFromCpfpAdaptorSignedSignature,
46
+ };
47
+ };
48
+
49
+ export const FRAGMENT = `
43
50
  fragment SwapLeafFragment on SwapLeaf {
44
51
  __typename
45
52
  swap_leaf_leaf_id: leaf_id
46
53
  swap_leaf_raw_unsigned_refund_transaction: raw_unsigned_refund_transaction
47
54
  swap_leaf_adaptor_signed_signature: adaptor_signed_signature
55
+ swap_leaf_direct_raw_unsigned_refund_transaction: direct_raw_unsigned_refund_transaction
56
+ swap_leaf_direct_adaptor_signed_signature: direct_adaptor_signed_signature
57
+ swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction: direct_from_cpfp_raw_unsigned_refund_transaction
58
+ swap_leaf_direct_from_cpfp_adaptor_signed_signature: direct_from_cpfp_adaptor_signed_signature
48
59
  }`;
49
60
 
50
-
51
-
52
-
53
61
  export default SwapLeaf;
@@ -5,7 +5,15 @@ interface UserLeafInput {
5
5
 
6
6
  raw_unsigned_refund_transaction: string;
7
7
 
8
+ direct_raw_unsigned_refund_transaction: string;
9
+
10
+ direct_from_cpfp_raw_unsigned_refund_transaction: string;
11
+
8
12
  adaptor_added_signature: string;
13
+
14
+ direct_adaptor_added_signature: string;
15
+
16
+ direct_from_cpfp_adaptor_added_signature: string;
9
17
  }
10
18
 
11
19
  export const UserLeafInputFromJson = (obj: any): UserLeafInput => {
@@ -13,7 +21,15 @@ export const UserLeafInputFromJson = (obj: any): UserLeafInput => {
13
21
  leaf_id: obj["user_leaf_input_leaf_id"],
14
22
  raw_unsigned_refund_transaction:
15
23
  obj["user_leaf_input_raw_unsigned_refund_transaction"],
24
+ direct_raw_unsigned_refund_transaction:
25
+ obj["user_leaf_input_direct_raw_unsigned_refund_transaction"],
26
+ direct_from_cpfp_raw_unsigned_refund_transaction:
27
+ obj["user_leaf_input_direct_from_cpfp_unsigned_refund_transaction"],
16
28
  adaptor_added_signature: obj["user_leaf_input_adaptor_added_signature"],
29
+ direct_adaptor_added_signature:
30
+ obj["user_leaf_input_direct_adaptor_added_signature"],
31
+ direct_from_cpfp_adaptor_added_signature:
32
+ obj["user_leaf_input_direct_from_cpfp_adaptor_added_signature"],
17
33
  } as UserLeafInput;
18
34
  };
19
35
  export const UserLeafInputToJson = (obj: UserLeafInput): any => {
@@ -21,7 +37,15 @@ export const UserLeafInputToJson = (obj: UserLeafInput): any => {
21
37
  user_leaf_input_leaf_id: obj.leaf_id,
22
38
  user_leaf_input_raw_unsigned_refund_transaction:
23
39
  obj.raw_unsigned_refund_transaction,
40
+ user_leaf_input_direct_raw_unsigned_refund_transaction:
41
+ obj.direct_raw_unsigned_refund_transaction,
42
+ user_leaf_input_direct_from_cpfp_raw_unsigned_refund_transaction:
43
+ obj.direct_from_cpfp_raw_unsigned_refund_transaction,
24
44
  user_leaf_input_adaptor_added_signature: obj.adaptor_added_signature,
45
+ user_leaf_input_direct_adaptor_added_signature:
46
+ obj.direct_adaptor_added_signature,
47
+ user_leaf_input_direct_from_cpfp_adaptor_added_signature:
48
+ obj.direct_from_cpfp_adaptor_added_signature,
25
49
  };
26
50
  };
27
51
 
@@ -448,6 +448,10 @@ fragment UserRequestFragment on UserRequest {
448
448
  swap_leaf_leaf_id: leaf_id
449
449
  swap_leaf_raw_unsigned_refund_transaction: raw_unsigned_refund_transaction
450
450
  swap_leaf_adaptor_signed_signature: adaptor_signed_signature
451
+ swap_leaf_direct_raw_unsigned_refund_transaction: direct_raw_unsigned_refund_transaction
452
+ swap_leaf_direct_adaptor_signed_signature: direct_adaptor_signed_signature
453
+ swap_leaf_direct_from_cpfp_raw_unsigned_refund_transaction: direct_from_cpfp_raw_unsigned_refund_transaction
454
+ swap_leaf_direct_from_cpfp_adaptor_signed_signature: direct_from_cpfp_adaptor_signed_signature
451
455
  }
452
456
  }
453
457
  ... on LightningReceiveRequest {
@@ -0,0 +1,15 @@
1
+ import { FRAGMENT as TransferFragment } from "../objects/Transfer.js";
2
+ import { FRAGMENT as UserRequestFragment } from "../objects/UserRequest.js";
3
+
4
+ export const GetTransfers = `
5
+ query Transfers($transfer_spark_ids: [UUID!]!) {
6
+ transfers(transfer_spark_ids: $transfer_spark_ids) {
7
+ ...TransferFragment
8
+ transfer_user_request: user_request {
9
+ ...UserRequestFragment
10
+ }
11
+ }
12
+ }
13
+ ${TransferFragment}
14
+ ${UserRequestFragment}
15
+ `;
package/src/index.node.ts CHANGED
@@ -21,7 +21,7 @@ export {
21
21
  } from "./signer/signer.js";
22
22
  export * from "./signer/types.js";
23
23
 
24
- export { SparkWallet } from "./spark-wallet/spark-wallet.js";
24
+ export { SparkWallet } from "./spark-wallet/spark-wallet.node.js";
25
25
  export * from "./spark-wallet/types.js";
26
26
 
27
27
  export { type WalletConfigService } from "./services/config.js";
@@ -1,6 +1,6 @@
1
1
  /* Root React Native entrypoint */
2
2
 
3
- import { setCrypto, SparkCrypto } from "../utils/crypto.js";
3
+ import { setCrypto } from "../utils/crypto.js";
4
4
 
5
5
  setCrypto(globalThis.crypto);
6
6
 
@@ -14,8 +14,7 @@ export { ReactNativeSparkSigner as DefaultSparkSigner } from "../signer/signer.r
14
14
  export { SparkWallet } from "../spark-wallet/spark-wallet.js";
15
15
  export * from "../spark-wallet/types.js";
16
16
 
17
- export { WalletConfig } from "../services/wallet-config.js";
18
- export { TokenTransactionService } from "../services/token-transactions.js";
19
- export { type ConnectionManager } from "../services/connection.js";
20
17
  export { type WalletConfigService } from "../services/config.js";
21
- export { type ConfigOptions } from "../services/wallet-config.js";
18
+ export { type ConnectionManager } from "../services/connection.js";
19
+ export { TokenTransactionService } from "../services/token-transactions.js";
20
+ export { WalletConfig, type ConfigOptions } from "../services/wallet-config.js";