@buildonspark/spark-sdk 0.3.7 → 0.3.9
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 +15 -0
- package/dist/bare/index.cjs +8088 -7723
- package/dist/bare/index.d.cts +350 -262
- package/dist/bare/index.d.ts +350 -262
- package/dist/bare/index.js +7968 -7608
- package/dist/{chunk-J2P3KTQP.js → chunk-4YFT7DAE.js} +1 -1
- package/dist/{chunk-XWLR6G5C.js → chunk-JLF6WJ7K.js} +1 -1
- package/dist/{chunk-UYTT3C6H.js → chunk-MFCM6GUD.js} +40 -213
- package/dist/{chunk-KDEVNW7C.js → chunk-O4C4HGQL.js} +3391 -3292
- package/dist/{chunk-SRPKOCG4.js → chunk-S55NZT4P.js} +8 -10
- package/dist/{chunk-P4HYYSMU.js → chunk-WRE2T22S.js} +1 -1
- package/dist/{chunk-IC4IUEOS.js → chunk-YEBEN7XD.js} +309 -38
- package/dist/{client-Bcb7TUIp.d.cts → client-BIqiUNy4.d.cts} +2 -2
- package/dist/{client-D9T58OY8.d.ts → client-BaQf-5gD.d.ts} +2 -2
- package/dist/debug.cjs +8068 -7704
- package/dist/debug.d.cts +25 -18
- package/dist/debug.d.ts +25 -18
- package/dist/debug.js +5 -5
- package/dist/graphql/objects/index.d.cts +3 -3
- package/dist/graphql/objects/index.d.ts +3 -3
- package/dist/index.cjs +6871 -6501
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +36 -24
- package/dist/index.node.cjs +7102 -6903
- package/dist/index.node.d.cts +9 -8
- package/dist/index.node.d.ts +9 -8
- package/dist/index.node.js +35 -23
- package/dist/{logging-zkr4UlOi.d.cts → logging-CXhvuqJJ.d.cts} +45 -35
- package/dist/{logging-JIaZZIbR.d.ts → logging-DDeMLsVN.d.ts} +45 -35
- package/dist/native/{chunk-X2QXUON7.js → chunk-AFP5QR4O.js} +11 -8
- package/dist/native/index.react-native.cjs +7054 -6677
- package/dist/native/index.react-native.d.cts +180 -92
- package/dist/native/index.react-native.d.ts +180 -92
- package/dist/native/index.react-native.js +6760 -6393
- package/dist/native/{wasm-GKEDPGTM.js → wasm-D4TI35NF.js} +1 -1
- package/dist/proto/spark.cjs +309 -38
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +5 -1
- package/dist/proto/spark_token.d.cts +1 -1
- package/dist/proto/spark_token.d.ts +1 -1
- package/dist/proto/spark_token.js +2 -2
- package/dist/{spark-WA_4wcBr.d.cts → spark-DOpheE8_.d.cts} +69 -7
- package/dist/{spark-WA_4wcBr.d.ts → spark-DOpheE8_.d.ts} +69 -7
- package/dist/{spark-wallet.browser-DC3jdQPW.d.cts → spark-wallet.browser-CbYo8A_U.d.cts} +8 -8
- package/dist/{spark-wallet.browser-BwYkkOBU.d.ts → spark-wallet.browser-Cz8c4kOW.d.ts} +8 -8
- package/dist/{spark-wallet.node-CR_zNxmy.d.cts → spark-wallet.node-4WQgWwB2.d.cts} +9 -31
- package/dist/{spark-wallet.node-C9d2W-Nb.d.ts → spark-wallet.node-CmIvxtcC.d.ts} +9 -31
- package/dist/tests/test-utils.cjs +7341 -7065
- package/dist/tests/test-utils.d.cts +7 -5
- package/dist/tests/test-utils.d.ts +7 -5
- package/dist/tests/test-utils.js +7 -7
- package/dist/{token-transactions-BZoJuvuE.d.ts → token-transactions-Bu023ztN.d.ts} +2 -2
- package/dist/{token-transactions-I_OFIoNH.d.cts → token-transactions-CV8QD3I7.d.cts} +2 -2
- package/dist/types/index.cjs +307 -38
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/dist/{spark-wallet-CE5PYiIb.d.ts → wallet-config-Bmk2eAn8.d.ts} +310 -287
- package/dist/{spark-wallet-BuFrUWeE.d.cts → wallet-config-DQw5llqA.d.cts} +310 -287
- package/package.json +3 -3
- package/src/proto/mock.ts +0 -264
- package/src/proto/spark.ts +433 -46
- package/src/services/config.ts +5 -0
- package/src/services/connection/connection.browser.ts +27 -19
- package/src/services/connection/connection.node.ts +79 -24
- package/src/services/connection/connection.ts +395 -233
- package/src/services/coop-exit.ts +26 -107
- package/src/services/deposit.ts +12 -48
- package/src/services/lightning.ts +30 -4
- package/src/services/signing.ts +187 -37
- package/src/services/transfer.ts +553 -723
- package/src/services/wallet-config.ts +6 -0
- package/src/spark-wallet/proto-descriptors.ts +1 -1
- package/src/spark-wallet/spark-wallet.ts +132 -313
- package/src/spark-wallet/types.ts +2 -2
- package/src/spark_descriptors.pb +0 -0
- package/src/tests/connection.test.ts +537 -0
- package/src/tests/integration/connection.test.ts +39 -0
- package/src/tests/integration/lightning.test.ts +32 -16
- package/src/tests/integration/static_deposit.test.ts +13 -11
- package/src/tests/integration/transfer.test.ts +13 -1
- package/src/tests/isHermeticTest.ts +1 -1
- package/src/tests/utils/test-faucet.ts +53 -20
- package/src/utils/htlc-transactions.ts +224 -0
- package/src/utils/transaction.ts +285 -248
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _scure_base from '@scure/base';
|
|
2
2
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
3
|
-
import { CallOptions, ClientMiddlewareCall, Metadata } from 'nice-grpc-common';
|
|
3
|
+
import { CallOptions, ClientMiddleware, ClientMiddlewareCall, Metadata } from 'nice-grpc-common';
|
|
4
4
|
import * as btc from '@scure/btc-signer';
|
|
5
5
|
import { Transaction } from '@scure/btc-signer';
|
|
6
6
|
import { TransactionOutput, TransactionInput } from '@scure/btc-signer/psbt';
|
|
@@ -8,6 +8,7 @@ import { HDKey } from '@scure/bip32';
|
|
|
8
8
|
import { Query, Logger, LoggingLevel } from '@lightsparkdev/core';
|
|
9
9
|
import { Channel } from 'nice-grpc';
|
|
10
10
|
import { Channel as Channel$1, createChannel } from 'nice-grpc-web';
|
|
11
|
+
import { RetryOptions as RetryOptions$1 } from 'nice-grpc-client-middleware-retry';
|
|
11
12
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
12
13
|
import { EventEmitter } from 'eventemitter3';
|
|
13
14
|
import * as nice_grpc_web_lib_client_Transport_js from 'nice-grpc-web/lib/client/Transport.js';
|
|
@@ -359,7 +360,7 @@ interface GenerateDepositAddressRequest {
|
|
|
359
360
|
}
|
|
360
361
|
declare const GenerateDepositAddressRequest: MessageFns$2<GenerateDepositAddressRequest>;
|
|
361
362
|
/** Address is the address of the user's public key + SE's public key. */
|
|
362
|
-
interface Address {
|
|
363
|
+
interface Address$1 {
|
|
363
364
|
/** The p2tr address of the user's public key + SE's public key. */
|
|
364
365
|
address: string;
|
|
365
366
|
/** The verifying key of the address, which is user's public key + SE's public key. */
|
|
@@ -369,10 +370,10 @@ interface Address {
|
|
|
369
370
|
/** Is it a static deposit address */
|
|
370
371
|
isStatic: boolean;
|
|
371
372
|
}
|
|
372
|
-
declare const Address: MessageFns$2<Address>;
|
|
373
|
+
declare const Address$1: MessageFns$2<Address$1>;
|
|
373
374
|
/** GenerateDepositAddressResponse is the response to the request to generate a deposit address. */
|
|
374
375
|
interface GenerateDepositAddressResponse {
|
|
375
|
-
depositAddress: Address | undefined;
|
|
376
|
+
depositAddress: Address$1 | undefined;
|
|
376
377
|
}
|
|
377
378
|
declare const GenerateDepositAddressResponse: MessageFns$2<GenerateDepositAddressResponse>;
|
|
378
379
|
/** GenerateStaticDepositAddressRequest is the request to generate a static deposit address. */
|
|
@@ -387,7 +388,7 @@ interface GenerateStaticDepositAddressRequest {
|
|
|
387
388
|
declare const GenerateStaticDepositAddressRequest: MessageFns$2<GenerateStaticDepositAddressRequest>;
|
|
388
389
|
/** GenerateStaticDepositAddressResponse is the response to the request to generate a static deposit address. */
|
|
389
390
|
interface GenerateStaticDepositAddressResponse {
|
|
390
|
-
depositAddress: Address | undefined;
|
|
391
|
+
depositAddress: Address$1 | undefined;
|
|
391
392
|
}
|
|
392
393
|
declare const GenerateStaticDepositAddressResponse: MessageFns$2<GenerateStaticDepositAddressResponse>;
|
|
393
394
|
/**
|
|
@@ -459,7 +460,6 @@ interface SigningResult {
|
|
|
459
460
|
declare const SigningResult: MessageFns$2<SigningResult>;
|
|
460
461
|
interface RenewLeafRequest {
|
|
461
462
|
leafId: string;
|
|
462
|
-
ownerIdentityPublicKey: Uint8Array;
|
|
463
463
|
signingJobs?: //
|
|
464
464
|
/**
|
|
465
465
|
* Resets the node transaction timelock and refund transaction timelock
|
|
@@ -485,6 +485,17 @@ interface RenewLeafRequest {
|
|
|
485
485
|
{
|
|
486
486
|
$case: "renewRefundTimelockSigningJob";
|
|
487
487
|
renewRefundTimelockSigningJob: RenewRefundTimelockSigningJob;
|
|
488
|
+
} | //
|
|
489
|
+
/**
|
|
490
|
+
* A special case of refresh for when the node transaction is at 0 and
|
|
491
|
+
* cannot be decremented further. This operation resets the refund
|
|
492
|
+
* transaction's timelock and, similar to renew node, adds an additional
|
|
493
|
+
* node transaction to the transaction chain with zero timelock as well.
|
|
494
|
+
* This case is mostly used for user-created trees from L1 deposits.
|
|
495
|
+
*/
|
|
496
|
+
{
|
|
497
|
+
$case: "renewNodeZeroTimelockSigningJob";
|
|
498
|
+
renewNodeZeroTimelockSigningJob: RenewNodeZeroTimelockSigningJob;
|
|
488
499
|
} | undefined;
|
|
489
500
|
}
|
|
490
501
|
declare const RenewLeafRequest: MessageFns$2<RenewLeafRequest>;
|
|
@@ -523,13 +534,32 @@ interface RenewRefundTimelockSigningJob {
|
|
|
523
534
|
directFromCpfpRefundTxSigningJob: UserSignedTxSigningJob | undefined;
|
|
524
535
|
}
|
|
525
536
|
declare const RenewRefundTimelockSigningJob: MessageFns$2<RenewRefundTimelockSigningJob>;
|
|
537
|
+
interface RenewNodeZeroTimelockSigningJob {
|
|
538
|
+
/**
|
|
539
|
+
* Signing job with the new node transaction. The updated transaction is
|
|
540
|
+
* expected to have a timelock of 0.
|
|
541
|
+
*/
|
|
542
|
+
nodeTxSigningJob: UserSignedTxSigningJob | undefined;
|
|
543
|
+
/**
|
|
544
|
+
* Signing job with the updated refund transaction. This updated transaction
|
|
545
|
+
* must have a timelock of 2000.
|
|
546
|
+
*/
|
|
547
|
+
refundTxSigningJob: UserSignedTxSigningJob | undefined;
|
|
548
|
+
directNodeTxSigningJob: UserSignedTxSigningJob | undefined;
|
|
549
|
+
directRefundTxSigningJob: UserSignedTxSigningJob | undefined;
|
|
550
|
+
directFromCpfpRefundTxSigningJob: UserSignedTxSigningJob | undefined;
|
|
551
|
+
}
|
|
552
|
+
declare const RenewNodeZeroTimelockSigningJob: MessageFns$2<RenewNodeZeroTimelockSigningJob>;
|
|
526
553
|
interface RenewLeafResponse {
|
|
527
554
|
renewResult?: {
|
|
528
|
-
$case: "
|
|
529
|
-
|
|
555
|
+
$case: "renewNodeTimelockResult";
|
|
556
|
+
renewNodeTimelockResult: RenewNodeTimelockResult;
|
|
557
|
+
} | {
|
|
558
|
+
$case: "renewRefundTimelockResult";
|
|
559
|
+
renewRefundTimelockResult: RenewRefundTimelockResult;
|
|
530
560
|
} | {
|
|
531
|
-
$case: "
|
|
532
|
-
|
|
561
|
+
$case: "renewNodeZeroTimelockResult";
|
|
562
|
+
renewNodeZeroTimelockResult: RenewNodeZeroTimelockResult;
|
|
533
563
|
} | undefined;
|
|
534
564
|
}
|
|
535
565
|
declare const RenewLeafResponse: MessageFns$2<RenewLeafResponse>;
|
|
@@ -542,6 +572,11 @@ interface RenewRefundTimelockResult {
|
|
|
542
572
|
node: TreeNode | undefined;
|
|
543
573
|
}
|
|
544
574
|
declare const RenewRefundTimelockResult: MessageFns$2<RenewRefundTimelockResult>;
|
|
575
|
+
interface RenewNodeZeroTimelockResult {
|
|
576
|
+
splitNode: TreeNode | undefined;
|
|
577
|
+
node: TreeNode | undefined;
|
|
578
|
+
}
|
|
579
|
+
declare const RenewNodeZeroTimelockResult: MessageFns$2<RenewNodeZeroTimelockResult>;
|
|
545
580
|
/**
|
|
546
581
|
* NodeSignatureShares is the signature shares for a node on the tree.
|
|
547
582
|
* For each tree node, the verifying key stays the same for both transactions.
|
|
@@ -1144,15 +1179,28 @@ interface RequestedSigningCommitments {
|
|
|
1144
1179
|
}
|
|
1145
1180
|
declare const RequestedSigningCommitments: MessageFns$2<RequestedSigningCommitments>;
|
|
1146
1181
|
interface GetSigningCommitmentsRequest {
|
|
1182
|
+
/** The node IDs for which to get signing commitments. */
|
|
1147
1183
|
nodeIds: string[];
|
|
1184
|
+
/** The number of signing commitments to get per node ID. */
|
|
1148
1185
|
count: number;
|
|
1149
1186
|
}
|
|
1150
1187
|
declare const GetSigningCommitmentsRequest: MessageFns$2<GetSigningCommitmentsRequest>;
|
|
1151
1188
|
interface GetSigningCommitmentsResponse {
|
|
1189
|
+
/**
|
|
1190
|
+
* A list of signing commitments for each requested node ID. The signing commitments will be
|
|
1191
|
+
* ordered in the same order as the requested node IDs, repeated for the number of commitments
|
|
1192
|
+
* requested. For example, if node_ids = [A, B] and count = 2, the response will contain:
|
|
1193
|
+
*
|
|
1194
|
+
* [commitment_A1, commitment_B1, commitment_A2, commitment_B2]
|
|
1195
|
+
*/
|
|
1152
1196
|
signingCommitments: RequestedSigningCommitments[];
|
|
1153
1197
|
}
|
|
1154
1198
|
declare const GetSigningCommitmentsResponse: MessageFns$2<GetSigningCommitmentsResponse>;
|
|
1155
1199
|
interface SigningCommitments {
|
|
1200
|
+
/**
|
|
1201
|
+
* A map of signing operator ID (i.e. 000...01) to the signing commitment provided by that
|
|
1202
|
+
* operator.
|
|
1203
|
+
*/
|
|
1156
1204
|
signingCommitments: {
|
|
1157
1205
|
[key: string]: SigningCommitment$1;
|
|
1158
1206
|
};
|
|
@@ -1183,6 +1231,7 @@ interface InitiatePreimageSwapRequest {
|
|
|
1183
1231
|
transfer: StartUserSignedTransferRequest | undefined;
|
|
1184
1232
|
receiverIdentityPublicKey: Uint8Array;
|
|
1185
1233
|
feeSats: number;
|
|
1234
|
+
transferRequest: StartTransferRequest | undefined;
|
|
1186
1235
|
}
|
|
1187
1236
|
declare const InitiatePreimageSwapRequest: MessageFns$2<InitiatePreimageSwapRequest>;
|
|
1188
1237
|
interface InitiatePreimageSwapResponse {
|
|
@@ -1687,6 +1736,10 @@ declare const SparkServiceDefinition: {
|
|
|
1687
1736
|
readonly responseStream: false;
|
|
1688
1737
|
readonly options: {};
|
|
1689
1738
|
};
|
|
1739
|
+
/**
|
|
1740
|
+
* Gets a specified number of signing commmitments for a set of nodes, which can be used as
|
|
1741
|
+
* part of a transfer package.
|
|
1742
|
+
*/
|
|
1690
1743
|
readonly get_signing_commitments: {
|
|
1691
1744
|
readonly name: "get_signing_commitments";
|
|
1692
1745
|
readonly requestType: MessageFns$2<GetSigningCommitmentsRequest>;
|
|
@@ -2074,6 +2127,10 @@ interface SparkServiceClient<CallOptionsExt = {}> {
|
|
|
2074
2127
|
claim_transfer_tweak_keys(request: DeepPartial$2<ClaimTransferTweakKeysRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
|
|
2075
2128
|
claim_transfer_sign_refunds(request: DeepPartial$2<ClaimTransferSignRefundsRequest>, options?: CallOptions & CallOptionsExt): Promise<ClaimTransferSignRefundsResponse>;
|
|
2076
2129
|
store_preimage_share(request: DeepPartial$2<StorePreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
|
|
2130
|
+
/**
|
|
2131
|
+
* Gets a specified number of signing commmitments for a set of nodes, which can be used as
|
|
2132
|
+
* part of a transfer package.
|
|
2133
|
+
*/
|
|
2077
2134
|
get_signing_commitments(request: DeepPartial$2<GetSigningCommitmentsRequest>, options?: CallOptions & CallOptionsExt): Promise<GetSigningCommitmentsResponse>;
|
|
2078
2135
|
cooperative_exit(request: DeepPartial$2<CooperativeExitRequest>, options?: CallOptions & CallOptionsExt): Promise<CooperativeExitResponse>;
|
|
2079
2136
|
initiate_preimage_swap(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
|
|
@@ -3567,6 +3624,7 @@ type ConfigOptions = MayHaveSspClientOptions & {
|
|
|
3567
3624
|
readonly expectedWithdrawRelativeBlockLocktime?: number;
|
|
3568
3625
|
readonly signerWithPreExistingKeys?: boolean;
|
|
3569
3626
|
readonly console?: ConsoleOptions;
|
|
3627
|
+
readonly events?: Partial<SparkWalletEvents>;
|
|
3570
3628
|
};
|
|
3571
3629
|
declare const WalletConfig: {
|
|
3572
3630
|
LOCAL: Required<ConfigOptions>;
|
|
@@ -3598,6 +3656,7 @@ declare class WalletConfigService implements HasSspClientOptions {
|
|
|
3598
3656
|
getSspBaseUrl(): string;
|
|
3599
3657
|
getSspIdentityPublicKey(): string;
|
|
3600
3658
|
getConsoleOptions(): ConsoleOptions;
|
|
3659
|
+
getEvents(): Partial<SparkWalletEvents>;
|
|
3601
3660
|
}
|
|
3602
3661
|
|
|
3603
3662
|
/** Challenge represents the core challenge data */
|
|
@@ -3702,39 +3761,54 @@ interface RetryOptions {
|
|
|
3702
3761
|
}
|
|
3703
3762
|
type SparkCallOptions = CallOptions & RetryOptions;
|
|
3704
3763
|
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3764
|
+
type ChannelKey = string;
|
|
3765
|
+
type BrowserOrNodeJSChannel = Channel | Channel$1;
|
|
3766
|
+
type SparkClientType = "spark" | "stream" | "tokens";
|
|
3767
|
+
type Address = string;
|
|
3768
|
+
declare abstract class ConnectionManager {
|
|
3769
|
+
private static channelCache;
|
|
3770
|
+
private static channelInflight;
|
|
3771
|
+
private static authTokenCache;
|
|
3772
|
+
private static authInflight;
|
|
3773
|
+
protected makeChannelKey(address: Address, stream?: boolean): ChannelKey;
|
|
3774
|
+
protected static acquireChannel<T extends BrowserOrNodeJSChannel>(key: ChannelKey, create: () => Promise<T>): Promise<T>;
|
|
3775
|
+
protected static releaseChannel(key: ChannelKey): void;
|
|
3776
|
+
private static makeAuthTokenKey;
|
|
3777
|
+
private static getCachedAuthToken;
|
|
3778
|
+
private static setCachedAuthToken;
|
|
3779
|
+
private static invalidateCachedAuthToken;
|
|
3780
|
+
private static getOrCreateAuthToken;
|
|
3781
|
+
protected abstract createChannelWithTLS(address: Address, isStreamClientType?: boolean): Promise<Channel | Channel$1>;
|
|
3782
|
+
protected abstract createGrpcClient<T>(definition: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel | Channel$1, withRetries: boolean, middleware?: ClientMiddleware<RetryOptions$1, {}>, channelKey?: ChannelKey): Promise<T & {
|
|
3783
|
+
close?: () => void;
|
|
3712
3784
|
}>;
|
|
3713
|
-
private
|
|
3714
|
-
private
|
|
3715
|
-
private
|
|
3785
|
+
private config;
|
|
3786
|
+
private clientsByType;
|
|
3787
|
+
private identityPublicKeyHex?;
|
|
3716
3788
|
constructor(config: WalletConfigService);
|
|
3717
3789
|
createClients(): Promise<void>;
|
|
3718
3790
|
closeConnections(): Promise<void>;
|
|
3719
|
-
|
|
3720
|
-
|
|
3791
|
+
private getDefinitionForClientType;
|
|
3792
|
+
protected static isStreamClientType(type: SparkClientType): type is "stream";
|
|
3793
|
+
private getAddressToClientMap;
|
|
3794
|
+
private getOrCreateClientInternal;
|
|
3795
|
+
createSparkStreamClient(address: string): Promise<SparkServiceClient & {
|
|
3721
3796
|
close?: () => void;
|
|
3722
3797
|
}>;
|
|
3723
|
-
createSparkClient(address: string
|
|
3798
|
+
createSparkClient(address: string): Promise<SparkServiceClient & {
|
|
3724
3799
|
close?: () => void;
|
|
3725
3800
|
}>;
|
|
3726
|
-
createSparkTokenClient(address: string
|
|
3801
|
+
createSparkTokenClient(address: string): Promise<SparkTokenServiceClient & {
|
|
3727
3802
|
close?: () => void;
|
|
3728
3803
|
}>;
|
|
3729
|
-
|
|
3730
|
-
private
|
|
3804
|
+
getChannelForClient(clientType: SparkClientType, address: Address): Promise<BrowserOrNodeJSChannel | undefined>;
|
|
3805
|
+
private getIdentityPublicKeyHex;
|
|
3806
|
+
protected authenticate(address: string): Promise<string>;
|
|
3731
3807
|
private createSparkAuthnGrpcConnection;
|
|
3732
|
-
protected createAuthnMiddleware(): (call: ClientMiddlewareCall<
|
|
3733
|
-
protected createMiddleware(address:
|
|
3734
|
-
protected handleMiddlewareError(error: unknown, address: string, call: ClientMiddlewareCall<
|
|
3735
|
-
|
|
3736
|
-
close?: () => void;
|
|
3737
|
-
}>;
|
|
3808
|
+
protected createAuthnMiddleware(): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
3809
|
+
protected createMiddleware(address: Address): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
3810
|
+
protected handleMiddlewareError<Req, Res>(error: unknown, address: string, call: ClientMiddlewareCall<Req, Res>, metadata: Metadata, options: SparkCallOptions): AsyncGenerator<Awaited<Res>, void | Awaited<Res>, undefined>;
|
|
3811
|
+
subscribeToEvents(address: string, signal: AbortSignal): Promise<AsyncIterable<SubscribeToEventsResponse>>;
|
|
3738
3812
|
}
|
|
3739
3813
|
|
|
3740
3814
|
declare class SigningService {
|
|
@@ -3746,6 +3820,12 @@ declare class SigningService {
|
|
|
3746
3820
|
directLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3747
3821
|
directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3748
3822
|
}>;
|
|
3823
|
+
signRefundsForLightning(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, cpfpSigningCommitments: RequestedSigningCommitments[], directSigningCommitments: RequestedSigningCommitments[], directFromCpfpSigningCommitments: RequestedSigningCommitments[], hash: Uint8Array): Promise<{
|
|
3824
|
+
cpfpLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3825
|
+
directLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3826
|
+
directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3827
|
+
}>;
|
|
3828
|
+
signSigningJobs(signingJobs: (SigningJobWithOptionalNonce & RequestedSigningCommitments)[]): Promise<Map<SigningJobType, UserSignedTxSigningJob>>;
|
|
3749
3829
|
}
|
|
3750
3830
|
|
|
3751
3831
|
type LeafKeyTweak = {
|
|
@@ -3766,14 +3846,27 @@ type LeafRefundSigningData = {
|
|
|
3766
3846
|
directFromCpfpRefundSigningNonceCommitment: SigningCommitmentWithOptionalNonce;
|
|
3767
3847
|
vout: number;
|
|
3768
3848
|
};
|
|
3849
|
+
type SigningJobType = "split" | "directSplit" | "node" | "directNode" | "cpfp" | "direct" | "directFromCpfp";
|
|
3850
|
+
type SigningJobWithOptionalNonce = {
|
|
3851
|
+
signingPublicKey: Uint8Array;
|
|
3852
|
+
rawTx: Uint8Array;
|
|
3853
|
+
signingNonceCommitment: SigningCommitmentWithOptionalNonce;
|
|
3854
|
+
type: SigningJobType;
|
|
3855
|
+
parentTxOut: TransactionOutput;
|
|
3856
|
+
leafId: string;
|
|
3857
|
+
keyDerivation: KeyDerivation;
|
|
3858
|
+
verifyingKey: Uint8Array;
|
|
3859
|
+
};
|
|
3769
3860
|
declare class BaseTransferService {
|
|
3770
3861
|
protected readonly config: WalletConfigService;
|
|
3771
3862
|
protected readonly connectionManager: ConnectionManager;
|
|
3772
3863
|
protected readonly signingService: SigningService;
|
|
3773
3864
|
constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
|
|
3774
3865
|
deliverTransferPackage(transfer: Transfer$1, leaves: LeafKeyTweak[], cpfpRefundSignatureMap: Map<string, Uint8Array>, directRefundSignatureMap: Map<string, Uint8Array>, directFromCpfpRefundSignatureMap: Map<string, Uint8Array>): Promise<Transfer$1>;
|
|
3866
|
+
prepareTransferForLightning(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, paymentHash: Uint8Array, expiryTime: Date, transferID: string): Promise<StartTransferRequest>;
|
|
3775
3867
|
sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, sparkInvoice?: SparkAddressFormat): Promise<Transfer$1>;
|
|
3776
3868
|
private prepareTransferPackage;
|
|
3869
|
+
private prepareTransferPackageForLightning;
|
|
3777
3870
|
signRefunds(leafDataMap: Map<string, LeafRefundSigningData>, operatorSigningResults: LeafRefundTxSigningResult[]): Promise<NodeSignatures[]>;
|
|
3778
3871
|
private prepareSendTransferKeyTweaks;
|
|
3779
3872
|
private prepareSingleSendTransferKeyTweak;
|
|
@@ -3816,11 +3909,12 @@ declare class TransferService extends BaseTransferService {
|
|
|
3816
3909
|
claimTransferSignRefunds(transfer: Transfer$1, leafKeys: LeafKeyTweak[], proofMap?: Map<string, Uint8Array[]>): Promise<NodeSignatures[]>;
|
|
3817
3910
|
private finalizeNodeSignatures;
|
|
3818
3911
|
queryPendingTransfersBySender(operatorAddress: string): Promise<QueryTransfersResponse>;
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3912
|
+
renewRefundTxn(node: TreeNode, parentNode: TreeNode): Promise<TreeNode>;
|
|
3913
|
+
renewNodeTxn(node: TreeNode, parentNode: TreeNode): Promise<TreeNode>;
|
|
3914
|
+
private createRenewRefundSigningJobs;
|
|
3915
|
+
private createRenewNodeSigningJobs;
|
|
3916
|
+
renewZeroTimelockNodeTxn(node: TreeNode): Promise<TreeNode>;
|
|
3917
|
+
private createRenewZeroTimelockNodeSigningJobs;
|
|
3824
3918
|
}
|
|
3825
3919
|
|
|
3826
3920
|
/**
|
|
@@ -3851,16 +3945,15 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
|
|
|
3851
3945
|
protected tokenOutputs: TokenOutputsMap;
|
|
3852
3946
|
private claimTransfersInterval;
|
|
3853
3947
|
private tracer;
|
|
3948
|
+
protected abstract buildConnectionManager(config: WalletConfigService): ConnectionManager;
|
|
3854
3949
|
constructor(options?: ConfigOptions, signerArg?: SparkSigner);
|
|
3855
3950
|
static initialize<T extends SparkWallet>(this: new (options?: ConfigOptions, signer?: SparkSigner) => T, { mnemonicOrSeed, accountNumber, signer, options }: SparkWalletProps): Promise<InitWalletResponse<T>>;
|
|
3856
3951
|
private createClientsAndSyncWallet;
|
|
3857
3952
|
private getSspClient;
|
|
3858
3953
|
protected buildSigner(): DefaultSparkSigner;
|
|
3859
|
-
protected buildConnectionManager(config: WalletConfigService): ConnectionManager;
|
|
3860
3954
|
private handleStreamEvent;
|
|
3861
3955
|
protected setupBackgroundStream(): Promise<void>;
|
|
3862
3956
|
getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
|
|
3863
|
-
private checkExtendLeaves;
|
|
3864
3957
|
private verifyKey;
|
|
3865
3958
|
private popOrThrow;
|
|
3866
3959
|
private selectLeaves;
|
|
@@ -4171,15 +4264,7 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
|
|
|
4171
4264
|
private transferWithInvoice;
|
|
4172
4265
|
private buildTweaksByAmount;
|
|
4173
4266
|
private toSendTweak;
|
|
4174
|
-
private
|
|
4175
|
-
/**
|
|
4176
|
-
* Internal method to refresh timelock nodes.
|
|
4177
|
-
*
|
|
4178
|
-
* @param {string} nodeId - The optional ID of the node to refresh. If not provided, all nodes will be checked.
|
|
4179
|
-
* @returns {Promise<void>}
|
|
4180
|
-
* @private
|
|
4181
|
-
*/
|
|
4182
|
-
private checkRefreshTimelockNodes;
|
|
4267
|
+
private checkRenewLeaves;
|
|
4183
4268
|
private claimTransferCore;
|
|
4184
4269
|
private processClaimedTransferResults;
|
|
4185
4270
|
/**
|
|
@@ -4418,13 +4503,6 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
|
|
|
4418
4503
|
nodeTimelock: number;
|
|
4419
4504
|
refundTimelock: number;
|
|
4420
4505
|
}>;
|
|
4421
|
-
/**
|
|
4422
|
-
* Refresh the timelock of a specific node.
|
|
4423
|
-
*
|
|
4424
|
-
* @param {string} nodeId - The ID of the node to refresh
|
|
4425
|
-
* @returns {Promise<void>} Promise that resolves when the timelock is refreshed
|
|
4426
|
-
*/
|
|
4427
|
-
testOnly_expireTimelock(nodeId: string): Promise<void>;
|
|
4428
4506
|
private cleanup;
|
|
4429
4507
|
cleanupConnections(): Promise<void>;
|
|
4430
4508
|
private startPeriodicClaimTransfers;
|
|
@@ -4602,8 +4680,9 @@ declare function filterTokenBalanceForTokenIdentifier(tokenBalances: TokenBalanc
|
|
|
4602
4680
|
declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
|
|
4603
4681
|
|
|
4604
4682
|
declare const DIRECT_TIMELOCK_OFFSET = 50;
|
|
4683
|
+
declare const HTLC_TIMELOCK_OFFSET = 70;
|
|
4684
|
+
declare const DIRECT_HTLC_TIMELOCK_OFFSET = 85;
|
|
4605
4685
|
declare const INITIAL_SEQUENCE: number;
|
|
4606
|
-
declare const INITIAL_DIRECT_SEQUENCE: number;
|
|
4607
4686
|
declare const TEST_UNILATERAL_SEQUENCE: number;
|
|
4608
4687
|
declare const TEST_UNILATERAL_DIRECT_SEQUENCE: number;
|
|
4609
4688
|
declare const DEFAULT_FEE_SATS: number;
|
|
@@ -4612,51 +4691,60 @@ declare const DEFAULT_FEE_SATS: number;
|
|
|
4612
4691
|
* Returns the original amount if it's less than or equal to the fee.
|
|
4613
4692
|
*/
|
|
4614
4693
|
declare function maybeApplyFee(amount: bigint): bigint;
|
|
4615
|
-
declare function
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
txOut: TransactionOutput;
|
|
4619
|
-
parentOutPoint: TransactionInput;
|
|
4620
|
-
applyFee?: boolean;
|
|
4621
|
-
includeAnchor?: boolean;
|
|
4622
|
-
}
|
|
4623
|
-
declare function createNodeTx({ txOut, parentOutPoint, applyFee, includeAnchor, }: CreateNodeTxInput): Transaction;
|
|
4624
|
-
declare function createNodeTxs(txOut: TransactionOutput, txIn: TransactionInput, directTxIn?: TransactionInput): {
|
|
4625
|
-
cpfpNodeTx: Transaction;
|
|
4626
|
-
directNodeTx?: Transaction;
|
|
4694
|
+
declare function createRootNodeTx(parentTx: Transaction, vout: number): {
|
|
4695
|
+
nodeTx: Transaction;
|
|
4696
|
+
directNodeTx: Transaction;
|
|
4627
4697
|
};
|
|
4628
|
-
declare function
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4698
|
+
declare function createZeroTimelockNodeTx(parentTx: Transaction): {
|
|
4699
|
+
nodeTx: Transaction;
|
|
4700
|
+
directNodeTx: Transaction;
|
|
4701
|
+
};
|
|
4702
|
+
declare function createInitialTimelockNodeTx(parentTx: Transaction): {
|
|
4703
|
+
nodeTx: Transaction;
|
|
4704
|
+
directNodeTx: Transaction;
|
|
4705
|
+
};
|
|
4706
|
+
declare function createDecrementedTimelockNodeTx(parentTx: Transaction, currentTx: Transaction): {
|
|
4707
|
+
nodeTx: Transaction;
|
|
4708
|
+
directNodeTx: Transaction;
|
|
4709
|
+
};
|
|
4710
|
+
declare function createTestUnilateralTimelockNodeTx(parentTx: Transaction, nodeTx: Transaction): {
|
|
4711
|
+
nodeTx: Transaction;
|
|
4712
|
+
directNodeTx: Transaction;
|
|
4713
|
+
};
|
|
4714
|
+
declare function getNextHTLCTransactionSequence(currSequence: number, isNodeTx?: boolean): {
|
|
4715
|
+
nextSequence: number;
|
|
4716
|
+
nextDirectSequence: number;
|
|
4717
|
+
};
|
|
4718
|
+
interface RefundTxParams {
|
|
4719
|
+
nodeTx: Transaction;
|
|
4720
|
+
directNodeTx?: Transaction;
|
|
4633
4721
|
receivingPubkey: Uint8Array;
|
|
4634
4722
|
network: Network;
|
|
4635
|
-
shouldCalculateFee: boolean;
|
|
4636
|
-
includeAnchor: boolean;
|
|
4637
4723
|
}
|
|
4638
|
-
|
|
4639
|
-
interface CreateRefundTxsInput {
|
|
4724
|
+
interface RefundTxWithSequenceParams extends RefundTxParams {
|
|
4640
4725
|
sequence: number;
|
|
4641
|
-
directSequence?: number;
|
|
4642
|
-
input: TransactionInput;
|
|
4643
|
-
directInput?: TransactionInput;
|
|
4644
|
-
amountSats: bigint;
|
|
4645
|
-
receivingPubkey: Uint8Array;
|
|
4646
|
-
network: Network;
|
|
4647
4726
|
}
|
|
4648
|
-
|
|
4727
|
+
interface RefundTxWithSequenceAndConnectorOutputParams extends RefundTxWithSequenceParams {
|
|
4728
|
+
connectorOutput: TransactionInput;
|
|
4729
|
+
}
|
|
4730
|
+
interface RefundTxs {
|
|
4649
4731
|
cpfpRefundTx: Transaction;
|
|
4650
4732
|
directRefundTx?: Transaction;
|
|
4651
4733
|
directFromCpfpRefundTx?: Transaction;
|
|
4652
|
-
}
|
|
4653
|
-
declare function
|
|
4734
|
+
}
|
|
4735
|
+
declare function createInitialTimelockRefundTxs(params: RefundTxParams): RefundTxs;
|
|
4736
|
+
declare function createDecrementedTimelockRefundTxs(params: RefundTxWithSequenceParams): RefundTxs;
|
|
4737
|
+
declare function createCurrentTimelockRefundTxs(params: RefundTxWithSequenceParams): RefundTxs;
|
|
4738
|
+
declare function createTestUnilateralRefundTxs(params: RefundTxParams): RefundTxs;
|
|
4739
|
+
declare function createConnectorRefundTxs(params: RefundTxWithSequenceAndConnectorOutputParams): RefundTxs;
|
|
4654
4740
|
declare function getCurrentTimelock(currSequence?: number): number;
|
|
4655
4741
|
declare function getTransactionSequence(currSequence?: number): {
|
|
4656
4742
|
nextSequence: number;
|
|
4657
4743
|
nextDirectSequence: number;
|
|
4658
4744
|
};
|
|
4659
4745
|
declare function checkIfValidSequence(currSequence?: number): void;
|
|
4746
|
+
declare function isZeroTimelock(currSequence: number): boolean;
|
|
4747
|
+
declare function doesTxnNeedRenewed(currSequence: number): boolean;
|
|
4660
4748
|
declare function doesLeafNeedRefresh(currSequence: number, isNodeTx?: boolean): boolean;
|
|
4661
4749
|
declare function getNextTransactionSequence(currSequence: number, isNodeTx?: boolean): {
|
|
4662
4750
|
nextSequence: number;
|
|
@@ -4737,11 +4825,11 @@ type Transport = NonNullable<Parameters<typeof createChannel>[1]>;
|
|
|
4737
4825
|
declare class ConnectionManagerBrowser extends ConnectionManager {
|
|
4738
4826
|
protected transport: Transport;
|
|
4739
4827
|
constructor(config: WalletConfigService, transport?: nice_grpc_web_lib_client_Transport_js.Transport);
|
|
4740
|
-
protected createChannelWithTLS(address: string
|
|
4741
|
-
protected createAuthnMiddleware(): (call: ClientMiddlewareCall<
|
|
4742
|
-
protected createMiddleware(address: string
|
|
4743
|
-
protected createGrpcClient<T>(
|
|
4744
|
-
close: undefined;
|
|
4828
|
+
protected createChannelWithTLS(address: string): Promise<Channel$1>;
|
|
4829
|
+
protected createAuthnMiddleware(): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
4830
|
+
protected createMiddleware(address: string): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
4831
|
+
protected createGrpcClient<T>(definition: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel$1, withRetries: boolean, middleware?: ClientMiddleware<RetryOptions, {}>, channelKey?: string): Promise<T & {
|
|
4832
|
+
close: (() => void) | undefined;
|
|
4745
4833
|
}>;
|
|
4746
4834
|
}
|
|
4747
4835
|
|
|
@@ -4795,4 +4883,4 @@ declare class TokenTransactionService {
|
|
|
4795
4883
|
private createSignaturesForOperators;
|
|
4796
4884
|
}
|
|
4797
4885
|
|
|
4798
|
-
export { AuthenticationError, ConnectionManager as BaseConnectionManager, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, type ConfigOptions, ConfigurationError, ConnectionManagerBrowser as ConnectionManager, type CreateLightningInvoiceParams, DEFAULT_FEE_SATS, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, ReactNativeSparkSigner as DefaultSparkSigner, type DepositParams, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, type FulfillSparkInvoiceResponse, type GroupSparkInvoicesResult,
|
|
4886
|
+
export { AuthenticationError, ConnectionManager as BaseConnectionManager, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, type ConfigOptions, ConfigurationError, ConnectionManagerBrowser as ConnectionManager, type CreateLightningInvoiceParams, DEFAULT_FEE_SATS, DIRECT_HTLC_TIMELOCK_OFFSET, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, ReactNativeSparkSigner as DefaultSparkSigner, type DepositParams, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, type FulfillSparkInvoiceResponse, type GroupSparkInvoicesResult, HTLC_TIMELOCK_OFFSET, INITIAL_SEQUENCE, type InitWalletResponse, InternalValidationError, type InvalidInvoice, LOGGER_NAMES, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, type PayLightningInvoiceParams, RPCError, type RawTokenIdentifierHex, ReactNativeSparkSigner, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, SparkWalletReactNative as SparkWallet, SparkWalletEvent, type SparkWalletEventType, type SparkWalletEvents, type SparkWalletProps, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, type TokenBalanceMap, type TokenInvoice, type TokenMetadataMap, type TokenOutputsMap, TokenTransactionService, type TransferParams, type TransferWithInvoiceOutcome, type TransferWithInvoiceParams, type TxChain, type UserTokenMetadata, type Utxo, ValidationError, type VerifiableSecretShare, WalletConfig, WalletConfigService, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTxs, createCurrentTimelockRefundTxs, createDecrementedTimelockNodeTx, createDecrementedTimelockRefundTxs, createInitialTimelockNodeTx, createInitialTimelockRefundTxs, createRootNodeTx, createSigningCommitment, createSigningNonce, createTestUnilateralRefundTxs, createTestUnilateralTimelockNodeTx, createZeroTimelockNodeTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, doesTxnNeedRenewed, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, encodeSparkAddressWithSignature, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenIdentifier, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromBech32mTokenIdentifier, getNetworkFromSparkAddress, getNetworkFromString, getNextHTLCTransactionSequence, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxEstimatedVbytesSizeByNumberOfInputsOutputs, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isLegacySparkAddress, isSafeForNumber, isTxBroadcast, isValidPublicKey, isValidSparkAddress, isZeroTimelock, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };
|