@buildonspark/spark-sdk 0.3.6 → 0.3.8
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 +16 -0
- package/dist/bare/index.cjs +11107 -10443
- package/dist/bare/index.d.cts +274 -219
- package/dist/bare/index.d.ts +274 -219
- package/dist/bare/index.js +11459 -10792
- package/dist/{chunk-LIZFXQWK.js → chunk-3LPEQGVJ.js} +1 -1
- package/dist/{chunk-J2P3KTQP.js → chunk-5ASXVNTM.js} +1 -1
- package/dist/{chunk-FJ7LTA2O.js → chunk-5HU5W56H.js} +40 -213
- package/dist/{chunk-XPHYQ2L6.js → chunk-FP2CRVQH.js} +6471 -5813
- package/dist/{chunk-EHKP3Y65.js → chunk-FXIESWE6.js} +8 -11
- package/dist/{chunk-IC4IUEOS.js → chunk-VFN34EOX.js} +56 -43
- package/dist/{chunk-XWLR6G5C.js → chunk-XI6FCNYG.js} +1 -1
- package/dist/{client-GOlkXliC.d.ts → client-By-N7oJS.d.ts} +13 -11
- package/dist/{client-AHn11NHe.d.cts → client-pNpGP15j.d.cts} +13 -11
- package/dist/debug.cjs +11179 -10516
- package/dist/debug.d.cts +12 -8
- package/dist/debug.d.ts +12 -8
- 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 +7063 -6395
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +12 -6
- package/dist/index.node.cjs +6598 -6100
- package/dist/index.node.d.cts +8 -7
- package/dist/index.node.d.ts +8 -7
- package/dist/index.node.js +11 -5
- package/dist/{logging-CW3kwBaM.d.cts → logging-DMFVY384.d.ts} +10 -4
- package/dist/{logging-D7ukPwRA.d.ts → logging-DxLp34Xm.d.cts} +10 -4
- package/dist/native/{chunk-X2QXUON7.js → chunk-AFP5QR4O.js} +11 -8
- package/dist/native/{index.cjs → index.react-native.cjs} +7143 -6464
- package/dist/native/{index.d.cts → index.react-native.d.cts} +110 -54
- package/dist/native/{index.d.ts → index.react-native.d.ts} +110 -54
- package/dist/native/{index.js → index.react-native.js} +7162 -6484
- package/dist/native/{wasm-GKEDPGTM.js → wasm-D4TI35NF.js} +1 -1
- package/dist/proto/spark.cjs +56 -43
- package/dist/proto/spark.d.cts +1 -1
- package/dist/proto/spark.d.ts +1 -1
- package/dist/proto/spark.js +1 -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.ts → spark-By6yHsrk.d.cts} +31 -6
- package/dist/{spark-WA_4wcBr.d.cts → spark-By6yHsrk.d.ts} +31 -6
- package/dist/{spark-wallet.browser-Cg4fB-Nm.d.ts → spark-wallet.browser-C1dQknVj.d.ts} +8 -8
- package/dist/{spark-wallet.browser-Db7Y95Kt.d.cts → spark-wallet.browser-CNMo3IvO.d.cts} +8 -8
- package/dist/{spark-wallet.node-HEG2ahNd.d.cts → spark-wallet.node-BZJhJZKq.d.cts} +9 -31
- package/dist/{spark-wallet.node-DB3ZqtJG.d.ts → spark-wallet.node-Og6__NMh.d.ts} +9 -31
- package/dist/tests/test-utils.cjs +8835 -8332
- package/dist/tests/test-utils.d.cts +8 -6
- package/dist/tests/test-utils.d.ts +8 -6
- package/dist/tests/test-utils.js +7 -7
- package/dist/{token-transactions-B2-BO7Oz.d.ts → token-transactions-C7yefB2S.d.ts} +2 -2
- package/dist/{token-transactions-BAN68xwg.d.cts → token-transactions-CLR3rnYi.d.cts} +2 -2
- package/dist/types/index.cjs +56 -43
- 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-jwNvWvpK.d.ts → wallet-config-BoyMVa6n.d.ts} +293 -267
- package/dist/{spark-wallet-NxG55m7K.d.cts → wallet-config-xom-9UFF.d.cts} +293 -267
- package/package.json +16 -6
- package/src/graphql/client.ts +6 -9
- package/src/graphql/mutations/CompleteCoopExit.ts +1 -1
- package/src/graphql/mutations/RequestCoopExit.ts +3 -1
- package/src/graphql/mutations/RequestLightningSend.ts +3 -1
- package/src/graphql/objects/CompleteCoopExitInput.ts +22 -33
- package/src/graphql/objects/RequestCoopExitInput.ts +39 -45
- package/src/graphql/objects/RequestLightningSendInput.ts +31 -39
- package/src/index.react-native.ts +21 -0
- package/src/proto/mock.ts +0 -264
- package/src/proto/spark.ts +94 -51
- package/src/services/config.ts +7 -2
- package/src/services/connection/connection.browser.ts +27 -19
- package/src/services/connection/connection.node.ts +79 -24
- package/src/services/connection/connection.ts +396 -224
- package/src/services/coop-exit.ts +5 -1
- package/src/services/lightning.ts +30 -4
- package/src/services/signing.ts +137 -0
- package/src/services/token-transactions.ts +8 -8
- package/src/services/transfer.ts +116 -1
- package/src/services/wallet-config.ts +6 -0
- package/src/spark-wallet/proto-descriptors.ts +1 -1
- package/src/spark-wallet/spark-wallet.browser.ts +0 -1
- package/src/spark-wallet/spark-wallet.react-native.ts +5 -3
- package/src/spark-wallet/spark-wallet.ts +124 -83
- 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/coop-exit.test.ts +2 -0
- package/src/tests/integration/lightning.test.ts +30 -12
- package/src/tests/integration/ssp/coop-exit-validation.test.ts +5 -6
- package/src/tests/integration/ssp/static_deposit.test.ts +45 -35
- package/src/tests/integration/static_deposit.test.ts +11 -10
- package/src/tests/integration/transfer.test.ts +13 -1
- package/src/tests/isHermeticTest.ts +1 -1
- package/src/tests/optimize.test.ts +45 -0
- package/src/tests/token-outputs.test.ts +60 -1
- package/src/tests/utils/test-faucet.ts +65 -28
- package/src/utils/htlc-transactions.ts +224 -0
- package/src/utils/optimize.ts +226 -0
- package/src/utils/transaction.ts +36 -0
- package/src/native/index.ts +0 -21
package/dist/bare/index.d.cts
CHANGED
|
@@ -3,10 +3,11 @@ import * as btc from '@scure/btc-signer';
|
|
|
3
3
|
import { Transaction } from '@scure/btc-signer';
|
|
4
4
|
import { HDKey } from '@scure/bip32';
|
|
5
5
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
6
|
-
import { CallOptions, ClientMiddlewareCall, Metadata } from 'nice-grpc-common';
|
|
6
|
+
import { CallOptions, ClientMiddleware, ClientMiddlewareCall, Metadata } from 'nice-grpc-common';
|
|
7
|
+
import * as _scure_base from '@scure/base';
|
|
7
8
|
import { Channel } from 'nice-grpc';
|
|
8
9
|
import { Channel as Channel$1, createChannel } from 'nice-grpc-web';
|
|
9
|
-
import
|
|
10
|
+
import { RetryOptions as RetryOptions$1 } from 'nice-grpc-client-middleware-retry';
|
|
10
11
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
11
12
|
import { EventEmitter } from 'eventemitter3';
|
|
12
13
|
import * as nice_grpc_web_lib_client_Transport_js from 'nice-grpc-web/lib/client/Transport.js';
|
|
@@ -962,7 +963,7 @@ interface GenerateDepositAddressRequest {
|
|
|
962
963
|
}
|
|
963
964
|
declare const GenerateDepositAddressRequest: MessageFns$2<GenerateDepositAddressRequest>;
|
|
964
965
|
/** Address is the address of the user's public key + SE's public key. */
|
|
965
|
-
interface Address {
|
|
966
|
+
interface Address$1 {
|
|
966
967
|
/** The p2tr address of the user's public key + SE's public key. */
|
|
967
968
|
address: string;
|
|
968
969
|
/** The verifying key of the address, which is user's public key + SE's public key. */
|
|
@@ -972,10 +973,10 @@ interface Address {
|
|
|
972
973
|
/** Is it a static deposit address */
|
|
973
974
|
isStatic: boolean;
|
|
974
975
|
}
|
|
975
|
-
declare const Address: MessageFns$2<Address>;
|
|
976
|
+
declare const Address$1: MessageFns$2<Address$1>;
|
|
976
977
|
/** GenerateDepositAddressResponse is the response to the request to generate a deposit address. */
|
|
977
978
|
interface GenerateDepositAddressResponse {
|
|
978
|
-
depositAddress: Address | undefined;
|
|
979
|
+
depositAddress: Address$1 | undefined;
|
|
979
980
|
}
|
|
980
981
|
declare const GenerateDepositAddressResponse: MessageFns$2<GenerateDepositAddressResponse>;
|
|
981
982
|
/** GenerateStaticDepositAddressRequest is the request to generate a static deposit address. */
|
|
@@ -990,7 +991,7 @@ interface GenerateStaticDepositAddressRequest {
|
|
|
990
991
|
declare const GenerateStaticDepositAddressRequest: MessageFns$2<GenerateStaticDepositAddressRequest>;
|
|
991
992
|
/** GenerateStaticDepositAddressResponse is the response to the request to generate a static deposit address. */
|
|
992
993
|
interface GenerateStaticDepositAddressResponse {
|
|
993
|
-
depositAddress: Address | undefined;
|
|
994
|
+
depositAddress: Address$1 | undefined;
|
|
994
995
|
}
|
|
995
996
|
declare const GenerateStaticDepositAddressResponse: MessageFns$2<GenerateStaticDepositAddressResponse>;
|
|
996
997
|
/**
|
|
@@ -1062,7 +1063,6 @@ interface SigningResult {
|
|
|
1062
1063
|
declare const SigningResult: MessageFns$2<SigningResult>;
|
|
1063
1064
|
interface RenewLeafRequest {
|
|
1064
1065
|
leafId: string;
|
|
1065
|
-
ownerIdentityPublicKey: Uint8Array;
|
|
1066
1066
|
signingJobs?: //
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Resets the node transaction timelock and refund transaction timelock
|
|
@@ -1128,11 +1128,11 @@ interface RenewRefundTimelockSigningJob {
|
|
|
1128
1128
|
declare const RenewRefundTimelockSigningJob: MessageFns$2<RenewRefundTimelockSigningJob>;
|
|
1129
1129
|
interface RenewLeafResponse {
|
|
1130
1130
|
renewResult?: {
|
|
1131
|
-
$case: "
|
|
1132
|
-
|
|
1131
|
+
$case: "renewNodeTimelockResult";
|
|
1132
|
+
renewNodeTimelockResult: RenewNodeTimelockResult;
|
|
1133
1133
|
} | {
|
|
1134
|
-
$case: "
|
|
1135
|
-
|
|
1134
|
+
$case: "renewRefundTimelockResult";
|
|
1135
|
+
renewRefundTimelockResult: RenewRefundTimelockResult;
|
|
1136
1136
|
} | undefined;
|
|
1137
1137
|
}
|
|
1138
1138
|
declare const RenewLeafResponse: MessageFns$2<RenewLeafResponse>;
|
|
@@ -1747,15 +1747,28 @@ interface RequestedSigningCommitments {
|
|
|
1747
1747
|
}
|
|
1748
1748
|
declare const RequestedSigningCommitments: MessageFns$2<RequestedSigningCommitments>;
|
|
1749
1749
|
interface GetSigningCommitmentsRequest {
|
|
1750
|
+
/** The node IDs for which to get signing commitments. */
|
|
1750
1751
|
nodeIds: string[];
|
|
1752
|
+
/** The number of signing commitments to get per node ID. */
|
|
1751
1753
|
count: number;
|
|
1752
1754
|
}
|
|
1753
1755
|
declare const GetSigningCommitmentsRequest: MessageFns$2<GetSigningCommitmentsRequest>;
|
|
1754
1756
|
interface GetSigningCommitmentsResponse {
|
|
1757
|
+
/**
|
|
1758
|
+
* A list of signing commitments for each requested node ID. The signing commitments will be
|
|
1759
|
+
* ordered in the same order as the requested node IDs, repeated for the number of commitments
|
|
1760
|
+
* requested. For example, if node_ids = [A, B] and count = 2, the response will contain:
|
|
1761
|
+
*
|
|
1762
|
+
* [commitment_A1, commitment_B1, commitment_A2, commitment_B2]
|
|
1763
|
+
*/
|
|
1755
1764
|
signingCommitments: RequestedSigningCommitments[];
|
|
1756
1765
|
}
|
|
1757
1766
|
declare const GetSigningCommitmentsResponse: MessageFns$2<GetSigningCommitmentsResponse>;
|
|
1758
1767
|
interface SigningCommitments {
|
|
1768
|
+
/**
|
|
1769
|
+
* A map of signing operator ID (i.e. 000...01) to the signing commitment provided by that
|
|
1770
|
+
* operator.
|
|
1771
|
+
*/
|
|
1759
1772
|
signingCommitments: {
|
|
1760
1773
|
[key: string]: SigningCommitment;
|
|
1761
1774
|
};
|
|
@@ -1786,6 +1799,7 @@ interface InitiatePreimageSwapRequest {
|
|
|
1786
1799
|
transfer: StartUserSignedTransferRequest | undefined;
|
|
1787
1800
|
receiverIdentityPublicKey: Uint8Array;
|
|
1788
1801
|
feeSats: number;
|
|
1802
|
+
transferRequest: StartTransferRequest | undefined;
|
|
1789
1803
|
}
|
|
1790
1804
|
declare const InitiatePreimageSwapRequest: MessageFns$2<InitiatePreimageSwapRequest>;
|
|
1791
1805
|
interface InitiatePreimageSwapResponse {
|
|
@@ -2290,6 +2304,10 @@ declare const SparkServiceDefinition: {
|
|
|
2290
2304
|
readonly responseStream: false;
|
|
2291
2305
|
readonly options: {};
|
|
2292
2306
|
};
|
|
2307
|
+
/**
|
|
2308
|
+
* Gets a specified number of signing commmitments for a set of nodes, which can be used as
|
|
2309
|
+
* part of a transfer package.
|
|
2310
|
+
*/
|
|
2293
2311
|
readonly get_signing_commitments: {
|
|
2294
2312
|
readonly name: "get_signing_commitments";
|
|
2295
2313
|
readonly requestType: MessageFns$2<GetSigningCommitmentsRequest>;
|
|
@@ -2677,6 +2695,10 @@ interface SparkServiceClient<CallOptionsExt = {}> {
|
|
|
2677
2695
|
claim_transfer_tweak_keys(request: DeepPartial$2<ClaimTransferTweakKeysRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
|
|
2678
2696
|
claim_transfer_sign_refunds(request: DeepPartial$2<ClaimTransferSignRefundsRequest>, options?: CallOptions & CallOptionsExt): Promise<ClaimTransferSignRefundsResponse>;
|
|
2679
2697
|
store_preimage_share(request: DeepPartial$2<StorePreimageShareRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
|
|
2698
|
+
/**
|
|
2699
|
+
* Gets a specified number of signing commmitments for a set of nodes, which can be used as
|
|
2700
|
+
* part of a transfer package.
|
|
2701
|
+
*/
|
|
2680
2702
|
get_signing_commitments(request: DeepPartial$2<GetSigningCommitmentsRequest>, options?: CallOptions & CallOptionsExt): Promise<GetSigningCommitmentsResponse>;
|
|
2681
2703
|
cooperative_exit(request: DeepPartial$2<CooperativeExitRequest>, options?: CallOptions & CallOptionsExt): Promise<CooperativeExitResponse>;
|
|
2682
2704
|
initiate_preimage_swap(request: DeepPartial$2<InitiatePreimageSwapRequest>, options?: CallOptions & CallOptionsExt): Promise<InitiatePreimageSwapResponse>;
|
|
@@ -2822,7 +2844,7 @@ interface ClaimStaticDepositOutput {
|
|
|
2822
2844
|
|
|
2823
2845
|
interface CompleteCoopExitInput {
|
|
2824
2846
|
userOutboundTransferExternalId: string;
|
|
2825
|
-
coopExitRequestId
|
|
2847
|
+
coopExitRequestId?: string | undefined;
|
|
2826
2848
|
}
|
|
2827
2849
|
|
|
2828
2850
|
interface CompleteLeavesSwapInput {
|
|
@@ -2910,11 +2932,12 @@ interface LightningSendFeeEstimateOutput {
|
|
|
2910
2932
|
interface RequestCoopExitInput {
|
|
2911
2933
|
leafExternalIds: string[];
|
|
2912
2934
|
withdrawalAddress: string;
|
|
2913
|
-
idempotencyKey
|
|
2935
|
+
idempotencyKey?: string | undefined;
|
|
2914
2936
|
exitSpeed: ExitSpeed;
|
|
2915
2937
|
withdrawAll: boolean;
|
|
2916
2938
|
feeLeafExternalIds?: string[] | undefined;
|
|
2917
2939
|
feeQuoteId?: string | undefined;
|
|
2940
|
+
userOutboundTransferExternalId?: string | undefined;
|
|
2918
2941
|
}
|
|
2919
2942
|
|
|
2920
2943
|
interface UserLeafInput {
|
|
@@ -2974,12 +2997,13 @@ interface RequestLightningReceiveInput {
|
|
|
2974
2997
|
|
|
2975
2998
|
interface RequestLightningSendInput {
|
|
2976
2999
|
encodedInvoice: string;
|
|
2977
|
-
idempotencyKey
|
|
3000
|
+
idempotencyKey?: string | undefined;
|
|
2978
3001
|
/**
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
**/
|
|
3002
|
+
* The amount you will pay for this invoice in sats. It should ONLY be set when the invoice amount is
|
|
3003
|
+
* zero.
|
|
3004
|
+
**/
|
|
2982
3005
|
amountSats?: number | undefined;
|
|
3006
|
+
userOutboundTransferExternalId?: string | undefined;
|
|
2983
3007
|
}
|
|
2984
3008
|
|
|
2985
3009
|
interface StaticDepositQuoteInput {
|
|
@@ -3036,10 +3060,10 @@ declare class SspClient {
|
|
|
3036
3060
|
getLightningSendFeeEstimate(encodedInvoice: string, amountSats?: number): Promise<LightningSendFeeEstimateOutput | null>;
|
|
3037
3061
|
getCoopExitFeeEstimate({ leafExternalIds, withdrawalAddress, }: CoopExitFeeEstimatesInput): Promise<CoopExitFeeEstimatesOutput | null>;
|
|
3038
3062
|
getCurrentUser(): Promise<void>;
|
|
3039
|
-
completeCoopExit({ userOutboundTransferExternalId,
|
|
3040
|
-
requestCoopExit({ leafExternalIds, withdrawalAddress,
|
|
3063
|
+
completeCoopExit({ userOutboundTransferExternalId, }: CompleteCoopExitInput): Promise<CoopExitRequest | null>;
|
|
3064
|
+
requestCoopExit({ leafExternalIds, withdrawalAddress, exitSpeed, feeLeafExternalIds, feeQuoteId, withdrawAll, userOutboundTransferExternalId, }: RequestCoopExitInput): Promise<CoopExitRequest | null>;
|
|
3041
3065
|
requestLightningReceive({ amountSats, network, paymentHash, expirySecs, memo, includeSparkAddress, receiverIdentityPubkey, descriptionHash, }: RequestLightningReceiveInput): Promise<LightningReceiveRequest | null>;
|
|
3042
|
-
requestLightningSend({ encodedInvoice,
|
|
3066
|
+
requestLightningSend({ encodedInvoice, amountSats, userOutboundTransferExternalId, }: RequestLightningSendInput): Promise<LightningSendRequest | null>;
|
|
3043
3067
|
requestLeaveSwap({ adaptorPubkey, directAdaptorPubkey, directFromCpfpAdaptorPubkey, totalAmountSats, targetAmountSats, feeSats, userLeaves, idempotencyKey, targetAmountSatsList, }: RequestLeavesSwapInput): Promise<LeavesSwapRequest | null>;
|
|
3044
3068
|
completeLeaveSwap({ adaptorSecretKey, directAdaptorSecretKey, directFromCpfpAdaptorSecretKey, userOutboundTransferExternalId, leavesSwapRequestId, }: CompleteLeavesSwapInput): Promise<LeavesSwapRequest | null>;
|
|
3045
3069
|
getLightningReceiveRequest(id: string): Promise<LightningReceiveRequest | null>;
|
|
@@ -3467,6 +3491,174 @@ declare function getNetworkFromAddress(address: string): BitcoinNetwork.MAINNET
|
|
|
3467
3491
|
*/
|
|
3468
3492
|
declare function getNetworkFromString(network?: string): Network;
|
|
3469
3493
|
|
|
3494
|
+
type Bech32mTokenIdentifier = `btkn1${string}` | `btknrt1${string}` | `btknt1${string}` | `btkns1${string}` | `btknl1${string}`;
|
|
3495
|
+
interface Bech32mTokenIdentifierData {
|
|
3496
|
+
tokenIdentifier: Uint8Array;
|
|
3497
|
+
network: NetworkType;
|
|
3498
|
+
}
|
|
3499
|
+
declare function encodeBech32mTokenIdentifier(payload: Bech32mTokenIdentifierData): Bech32mTokenIdentifier;
|
|
3500
|
+
declare function decodeBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier, network?: NetworkType): Bech32mTokenIdentifierData;
|
|
3501
|
+
declare function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier): NetworkType;
|
|
3502
|
+
|
|
3503
|
+
declare const AddressNetwork: Record<NetworkType, string>;
|
|
3504
|
+
declare const LegacyAddressNetwork: Record<NetworkType, string>;
|
|
3505
|
+
type Bech32String = `${string}1${string}`;
|
|
3506
|
+
type SparkAddressFormat = `${(typeof AddressNetwork)[keyof typeof AddressNetwork]}1${string}`;
|
|
3507
|
+
type LegacySparkAddressFormat = `${(typeof LegacyAddressNetwork)[keyof typeof LegacyAddressNetwork]}1${string}`;
|
|
3508
|
+
interface SparkAddressData {
|
|
3509
|
+
identityPublicKey: string;
|
|
3510
|
+
network: NetworkType;
|
|
3511
|
+
sparkInvoiceFields?: SparkInvoiceFields;
|
|
3512
|
+
}
|
|
3513
|
+
interface DecodedSparkAddressData {
|
|
3514
|
+
identityPublicKey: string;
|
|
3515
|
+
network: NetworkType;
|
|
3516
|
+
sparkInvoiceFields?: {
|
|
3517
|
+
version: number;
|
|
3518
|
+
id: string;
|
|
3519
|
+
paymentType?: {
|
|
3520
|
+
type: "tokens";
|
|
3521
|
+
tokenIdentifier?: string;
|
|
3522
|
+
amount?: bigint;
|
|
3523
|
+
} | {
|
|
3524
|
+
type: "sats";
|
|
3525
|
+
amount?: number;
|
|
3526
|
+
};
|
|
3527
|
+
memo?: string;
|
|
3528
|
+
senderPublicKey?: string;
|
|
3529
|
+
expiryTime?: Date;
|
|
3530
|
+
};
|
|
3531
|
+
signature?: string;
|
|
3532
|
+
}
|
|
3533
|
+
declare function encodeSparkAddress(payload: SparkAddressData): LegacySparkAddressFormat;
|
|
3534
|
+
declare function encodeSparkAddressWithSignature(payload: SparkAddressData, signature?: Uint8Array): LegacySparkAddressFormat;
|
|
3535
|
+
declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
|
|
3536
|
+
declare function getNetworkFromSparkAddress(address: string): NetworkType;
|
|
3537
|
+
declare function isLegacySparkAddress(address: string): address is LegacySparkAddressFormat;
|
|
3538
|
+
declare function isValidSparkAddress(address: string): boolean;
|
|
3539
|
+
declare function isValidPublicKey(publicKey: string): void;
|
|
3540
|
+
declare function validateSparkInvoiceFields(sparkInvoiceFields: SparkInvoiceFields): void;
|
|
3541
|
+
declare function validateSparkInvoiceSignature(invoice: SparkAddressFormat): void;
|
|
3542
|
+
declare function toProtoTimestamp(date: Date): {
|
|
3543
|
+
seconds: number;
|
|
3544
|
+
nanos: number;
|
|
3545
|
+
};
|
|
3546
|
+
declare function assertBech32(s: string): asserts s is Bech32String;
|
|
3547
|
+
declare function bech32mDecode(address: string): _scure_base.Bech32Decoded<string>;
|
|
3548
|
+
declare function isSafeForNumber(bi: bigint): boolean;
|
|
3549
|
+
|
|
3550
|
+
type CreateLightningInvoiceParams = {
|
|
3551
|
+
amountSats: number;
|
|
3552
|
+
memo?: string;
|
|
3553
|
+
expirySeconds?: number;
|
|
3554
|
+
includeSparkAddress?: boolean;
|
|
3555
|
+
receiverIdentityPubkey?: string;
|
|
3556
|
+
descriptionHash?: string;
|
|
3557
|
+
};
|
|
3558
|
+
type PayLightningInvoiceParams = {
|
|
3559
|
+
invoice: string;
|
|
3560
|
+
maxFeeSats: number;
|
|
3561
|
+
preferSpark?: boolean;
|
|
3562
|
+
amountSatsToSend?: number;
|
|
3563
|
+
};
|
|
3564
|
+
type TransferParams = {
|
|
3565
|
+
amountSats: number;
|
|
3566
|
+
receiverSparkAddress: string;
|
|
3567
|
+
};
|
|
3568
|
+
type FulfillSparkInvoiceResponse = {
|
|
3569
|
+
satsTransactionSuccess: {
|
|
3570
|
+
invoice: SparkAddressFormat;
|
|
3571
|
+
transferResponse: WalletTransfer;
|
|
3572
|
+
}[];
|
|
3573
|
+
tokenTransactionSuccess: {
|
|
3574
|
+
tokenIdentifier: Bech32mTokenIdentifier;
|
|
3575
|
+
txid: string;
|
|
3576
|
+
}[];
|
|
3577
|
+
satsTransactionErrors: {
|
|
3578
|
+
invoice: string;
|
|
3579
|
+
error: Error;
|
|
3580
|
+
}[];
|
|
3581
|
+
tokenTransactionErrors: {
|
|
3582
|
+
tokenIdentifier: Bech32mTokenIdentifier;
|
|
3583
|
+
error: Error;
|
|
3584
|
+
}[];
|
|
3585
|
+
invalidInvoices: {
|
|
3586
|
+
invoice: string;
|
|
3587
|
+
error: Error;
|
|
3588
|
+
}[];
|
|
3589
|
+
};
|
|
3590
|
+
/**
|
|
3591
|
+
* Token metadata containing essential information about a token.
|
|
3592
|
+
* This is the wallet's internal representation with JavaScript-friendly types.
|
|
3593
|
+
*
|
|
3594
|
+
* rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the bech32m encoded token identifier.
|
|
3595
|
+
*
|
|
3596
|
+
* tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
|
|
3597
|
+
*
|
|
3598
|
+
* @example
|
|
3599
|
+
* ```typescript
|
|
3600
|
+
* const tokenMetadata: UserTokenMetadata = {
|
|
3601
|
+
* rawTokenIdentifier: new Uint8Array([1, 2, 3]),
|
|
3602
|
+
* tokenPublicKey: "0348fbb...",
|
|
3603
|
+
* tokenName: "SparkToken",
|
|
3604
|
+
* tokenTicker: "SPK",
|
|
3605
|
+
* decimals: 8,
|
|
3606
|
+
* maxSupply: 1000000n
|
|
3607
|
+
* };
|
|
3608
|
+
* ```
|
|
3609
|
+
*/
|
|
3610
|
+
type UserTokenMetadata = {
|
|
3611
|
+
/** Raw binary token identifier - This is used to encode the human readable token identifier */
|
|
3612
|
+
rawTokenIdentifier: Uint8Array;
|
|
3613
|
+
/** Public key of the token issuer - Same as issuerPublicKey */
|
|
3614
|
+
tokenPublicKey: string;
|
|
3615
|
+
/** Human-readable name of the token (e.g., SparkToken)*/
|
|
3616
|
+
tokenName: string;
|
|
3617
|
+
/** Short ticker symbol for the token (e.g., "SPK") */
|
|
3618
|
+
tokenTicker: string;
|
|
3619
|
+
/** Number of decimal places for token amounts */
|
|
3620
|
+
decimals: number;
|
|
3621
|
+
/** Maximum supply of tokens that can ever be minted */
|
|
3622
|
+
maxSupply: bigint;
|
|
3623
|
+
};
|
|
3624
|
+
type TokenBalanceMap = Map<Bech32mTokenIdentifier, {
|
|
3625
|
+
balance: bigint;
|
|
3626
|
+
tokenMetadata: UserTokenMetadata;
|
|
3627
|
+
}>;
|
|
3628
|
+
type TokenOutputsMap = Map<Bech32mTokenIdentifier, OutputWithPreviousTransactionData$1[]>;
|
|
3629
|
+
type TokenMetadataMap = Map<Bech32mTokenIdentifier, TokenMetadata>;
|
|
3630
|
+
type InitWalletResponse<T extends SparkWallet = SparkWallet> = {
|
|
3631
|
+
wallet: T;
|
|
3632
|
+
mnemonic: string | undefined;
|
|
3633
|
+
};
|
|
3634
|
+
interface SparkWalletProps {
|
|
3635
|
+
mnemonicOrSeed?: Uint8Array | string;
|
|
3636
|
+
accountNumber?: number;
|
|
3637
|
+
signer?: SparkSigner;
|
|
3638
|
+
options?: ConfigOptions;
|
|
3639
|
+
}
|
|
3640
|
+
declare const SparkWalletEvent: {
|
|
3641
|
+
readonly All: "*";
|
|
3642
|
+
readonly TransferClaimed: "transfer:claimed";
|
|
3643
|
+
readonly DepositConfirmed: "deposit:confirmed";
|
|
3644
|
+
readonly StreamConnected: "stream:connected";
|
|
3645
|
+
readonly StreamDisconnected: "stream:disconnected";
|
|
3646
|
+
readonly StreamReconnecting: "stream:reconnecting";
|
|
3647
|
+
};
|
|
3648
|
+
interface SparkWalletEvents {
|
|
3649
|
+
[SparkWalletEvent.All]: (eventName: string, ...args: unknown[]) => void;
|
|
3650
|
+
/** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
|
|
3651
|
+
[SparkWalletEvent.TransferClaimed]: (transferId: string, updatedBalance: bigint) => void;
|
|
3652
|
+
/** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
|
|
3653
|
+
[SparkWalletEvent.DepositConfirmed]: (depositId: string, updatedBalance: bigint) => void;
|
|
3654
|
+
/** Emitted when the stream is connected */
|
|
3655
|
+
[SparkWalletEvent.StreamConnected]: () => void;
|
|
3656
|
+
/** Emitted when the stream disconnects and fails to reconnect after max attempts */
|
|
3657
|
+
[SparkWalletEvent.StreamDisconnected]: (reason: string) => void;
|
|
3658
|
+
/** Emitted when attempting to reconnect the stream */
|
|
3659
|
+
[SparkWalletEvent.StreamReconnecting]: (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3470
3662
|
type SigningOperator = {
|
|
3471
3663
|
readonly id: number;
|
|
3472
3664
|
readonly identifier: string;
|
|
@@ -3490,13 +3682,14 @@ type ConfigOptions = MayHaveSspClientOptions & {
|
|
|
3490
3682
|
readonly expectedWithdrawRelativeBlockLocktime?: number;
|
|
3491
3683
|
readonly signerWithPreExistingKeys?: boolean;
|
|
3492
3684
|
readonly console?: ConsoleOptions;
|
|
3685
|
+
readonly events?: Partial<SparkWalletEvents>;
|
|
3493
3686
|
};
|
|
3494
3687
|
|
|
3495
3688
|
declare class WalletConfigService implements HasSspClientOptions {
|
|
3496
3689
|
private readonly config;
|
|
3497
3690
|
readonly signer: SparkSigner;
|
|
3498
3691
|
readonly sspClientOptions: SspClientOptions;
|
|
3499
|
-
constructor(options
|
|
3692
|
+
constructor(options: ConfigOptions | undefined, signer: SparkSigner);
|
|
3500
3693
|
private getDefaultConfig;
|
|
3501
3694
|
getCoordinatorAddress(): string;
|
|
3502
3695
|
getSigningOperators(): Readonly<Record<string, SigningOperator>>;
|
|
@@ -3514,6 +3707,7 @@ declare class WalletConfigService implements HasSspClientOptions {
|
|
|
3514
3707
|
getSspBaseUrl(): string;
|
|
3515
3708
|
getSspIdentityPublicKey(): string;
|
|
3516
3709
|
getConsoleOptions(): ConsoleOptions;
|
|
3710
|
+
getEvents(): Partial<SparkWalletEvents>;
|
|
3517
3711
|
}
|
|
3518
3712
|
|
|
3519
3713
|
/** Challenge represents the core challenge data */
|
|
@@ -3618,87 +3812,55 @@ interface RetryOptions {
|
|
|
3618
3812
|
}
|
|
3619
3813
|
type SparkCallOptions = CallOptions & RetryOptions;
|
|
3620
3814
|
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3815
|
+
type ChannelKey = string;
|
|
3816
|
+
type BrowserOrNodeJSChannel = Channel | Channel$1;
|
|
3817
|
+
type SparkClientType = "spark" | "stream" | "tokens";
|
|
3818
|
+
type Address = string;
|
|
3819
|
+
declare abstract class ConnectionManager {
|
|
3820
|
+
private static channelCache;
|
|
3821
|
+
private static channelInflight;
|
|
3822
|
+
private static authTokenCache;
|
|
3823
|
+
private static authInflight;
|
|
3824
|
+
protected makeChannelKey(address: Address, stream?: boolean): ChannelKey;
|
|
3825
|
+
protected static acquireChannel<T extends BrowserOrNodeJSChannel>(key: ChannelKey, create: () => Promise<T>): Promise<T>;
|
|
3826
|
+
protected static releaseChannel(key: ChannelKey): void;
|
|
3827
|
+
private static makeAuthTokenKey;
|
|
3828
|
+
private static getCachedAuthToken;
|
|
3829
|
+
private static setCachedAuthToken;
|
|
3830
|
+
private static invalidateCachedAuthToken;
|
|
3831
|
+
private static getOrCreateAuthToken;
|
|
3832
|
+
protected abstract createChannelWithTLS(address: Address, isStreamClientType?: boolean): Promise<Channel | Channel$1>;
|
|
3833
|
+
protected abstract createGrpcClient<T>(definition: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel | Channel$1, withRetries: boolean, middleware?: ClientMiddleware<RetryOptions$1, {}>, channelKey?: ChannelKey): Promise<T & {
|
|
3834
|
+
close?: () => void;
|
|
3628
3835
|
}>;
|
|
3629
|
-
private
|
|
3630
|
-
private
|
|
3631
|
-
private
|
|
3836
|
+
private config;
|
|
3837
|
+
private clientsByType;
|
|
3838
|
+
private identityPublicKeyHex?;
|
|
3632
3839
|
constructor(config: WalletConfigService);
|
|
3633
3840
|
createClients(): Promise<void>;
|
|
3634
3841
|
closeConnections(): Promise<void>;
|
|
3635
|
-
|
|
3636
|
-
|
|
3842
|
+
private getDefinitionForClientType;
|
|
3843
|
+
protected static isStreamClientType(type: SparkClientType): type is "stream";
|
|
3844
|
+
private getAddressToClientMap;
|
|
3845
|
+
private getOrCreateClientInternal;
|
|
3846
|
+
createSparkStreamClient(address: string): Promise<SparkServiceClient & {
|
|
3637
3847
|
close?: () => void;
|
|
3638
3848
|
}>;
|
|
3639
|
-
createSparkClient(address: string
|
|
3849
|
+
createSparkClient(address: string): Promise<SparkServiceClient & {
|
|
3640
3850
|
close?: () => void;
|
|
3641
3851
|
}>;
|
|
3642
|
-
createSparkTokenClient(address: string
|
|
3852
|
+
createSparkTokenClient(address: string): Promise<SparkTokenServiceClient & {
|
|
3643
3853
|
close?: () => void;
|
|
3644
3854
|
}>;
|
|
3645
|
-
|
|
3646
|
-
private
|
|
3855
|
+
getChannelForClient(clientType: SparkClientType, address: Address): Promise<BrowserOrNodeJSChannel | undefined>;
|
|
3856
|
+
private getIdentityPublicKeyHex;
|
|
3857
|
+
protected authenticate(address: string): Promise<string>;
|
|
3647
3858
|
private createSparkAuthnGrpcConnection;
|
|
3648
|
-
protected createAuthnMiddleware(): (call: ClientMiddlewareCall<
|
|
3649
|
-
protected createMiddleware(address:
|
|
3650
|
-
protected handleMiddlewareError(error: unknown, address: string, call: ClientMiddlewareCall<
|
|
3651
|
-
|
|
3652
|
-
close?: () => void;
|
|
3653
|
-
}>;
|
|
3654
|
-
}
|
|
3655
|
-
|
|
3656
|
-
declare const AddressNetwork: Record<NetworkType, string>;
|
|
3657
|
-
declare const LegacyAddressNetwork: Record<NetworkType, string>;
|
|
3658
|
-
type Bech32String = `${string}1${string}`;
|
|
3659
|
-
type SparkAddressFormat = `${(typeof AddressNetwork)[keyof typeof AddressNetwork]}1${string}`;
|
|
3660
|
-
type LegacySparkAddressFormat = `${(typeof LegacyAddressNetwork)[keyof typeof LegacyAddressNetwork]}1${string}`;
|
|
3661
|
-
interface SparkAddressData {
|
|
3662
|
-
identityPublicKey: string;
|
|
3663
|
-
network: NetworkType;
|
|
3664
|
-
sparkInvoiceFields?: SparkInvoiceFields;
|
|
3665
|
-
}
|
|
3666
|
-
interface DecodedSparkAddressData {
|
|
3667
|
-
identityPublicKey: string;
|
|
3668
|
-
network: NetworkType;
|
|
3669
|
-
sparkInvoiceFields?: {
|
|
3670
|
-
version: number;
|
|
3671
|
-
id: string;
|
|
3672
|
-
paymentType?: {
|
|
3673
|
-
type: "tokens";
|
|
3674
|
-
tokenIdentifier?: string;
|
|
3675
|
-
amount?: bigint;
|
|
3676
|
-
} | {
|
|
3677
|
-
type: "sats";
|
|
3678
|
-
amount?: number;
|
|
3679
|
-
};
|
|
3680
|
-
memo?: string;
|
|
3681
|
-
senderPublicKey?: string;
|
|
3682
|
-
expiryTime?: Date;
|
|
3683
|
-
};
|
|
3684
|
-
signature?: string;
|
|
3859
|
+
protected createAuthnMiddleware(): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
3860
|
+
protected createMiddleware(address: Address): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
3861
|
+
protected handleMiddlewareError<Req, Res>(error: unknown, address: string, call: ClientMiddlewareCall<Req, Res>, metadata: Metadata, options: SparkCallOptions): AsyncGenerator<Awaited<Res>, void | Awaited<Res>, undefined>;
|
|
3862
|
+
subscribeToEvents(address: string, signal: AbortSignal): Promise<AsyncIterable<SubscribeToEventsResponse>>;
|
|
3685
3863
|
}
|
|
3686
|
-
declare function encodeSparkAddress(payload: SparkAddressData): LegacySparkAddressFormat;
|
|
3687
|
-
declare function encodeSparkAddressWithSignature(payload: SparkAddressData, signature?: Uint8Array): LegacySparkAddressFormat;
|
|
3688
|
-
declare function decodeSparkAddress(address: string, network: NetworkType): DecodedSparkAddressData;
|
|
3689
|
-
declare function getNetworkFromSparkAddress(address: string): NetworkType;
|
|
3690
|
-
declare function isLegacySparkAddress(address: string): address is LegacySparkAddressFormat;
|
|
3691
|
-
declare function isValidSparkAddress(address: string): boolean;
|
|
3692
|
-
declare function isValidPublicKey(publicKey: string): void;
|
|
3693
|
-
declare function validateSparkInvoiceFields(sparkInvoiceFields: SparkInvoiceFields): void;
|
|
3694
|
-
declare function validateSparkInvoiceSignature(invoice: SparkAddressFormat): void;
|
|
3695
|
-
declare function toProtoTimestamp(date: Date): {
|
|
3696
|
-
seconds: number;
|
|
3697
|
-
nanos: number;
|
|
3698
|
-
};
|
|
3699
|
-
declare function assertBech32(s: string): asserts s is Bech32String;
|
|
3700
|
-
declare function bech32mDecode(address: string): _scure_base.Bech32Decoded<string>;
|
|
3701
|
-
declare function isSafeForNumber(bi: bigint): boolean;
|
|
3702
3864
|
|
|
3703
3865
|
declare class SigningService {
|
|
3704
3866
|
private readonly config;
|
|
@@ -3709,6 +3871,11 @@ declare class SigningService {
|
|
|
3709
3871
|
directLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3710
3872
|
directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3711
3873
|
}>;
|
|
3874
|
+
signRefundsForLightning(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, cpfpSigningCommitments: RequestedSigningCommitments[], directSigningCommitments: RequestedSigningCommitments[], directFromCpfpSigningCommitments: RequestedSigningCommitments[], hash: Uint8Array): Promise<{
|
|
3875
|
+
cpfpLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3876
|
+
directLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3877
|
+
directFromCpfpLeafSigningJobs: UserSignedTxSigningJob[];
|
|
3878
|
+
}>;
|
|
3712
3879
|
}
|
|
3713
3880
|
|
|
3714
3881
|
type LeafKeyTweak = {
|
|
@@ -3735,8 +3902,10 @@ declare class BaseTransferService {
|
|
|
3735
3902
|
protected readonly signingService: SigningService;
|
|
3736
3903
|
constructor(config: WalletConfigService, connectionManager: ConnectionManager, signingService: SigningService);
|
|
3737
3904
|
deliverTransferPackage(transfer: Transfer, leaves: LeafKeyTweak[], cpfpRefundSignatureMap: Map<string, Uint8Array>, directRefundSignatureMap: Map<string, Uint8Array>, directFromCpfpRefundSignatureMap: Map<string, Uint8Array>): Promise<Transfer>;
|
|
3905
|
+
prepareTransferForLightning(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, paymentHash: Uint8Array, expiryTime: Date, transferID: string): Promise<StartTransferRequest>;
|
|
3738
3906
|
sendTransferWithKeyTweaks(leaves: LeafKeyTweak[], receiverIdentityPubkey: Uint8Array, sparkInvoice?: SparkAddressFormat): Promise<Transfer>;
|
|
3739
3907
|
private prepareTransferPackage;
|
|
3908
|
+
private prepareTransferPackageForLightning;
|
|
3740
3909
|
signRefunds(leafDataMap: Map<string, LeafRefundSigningData>, operatorSigningResults: LeafRefundTxSigningResult[]): Promise<NodeSignatures[]>;
|
|
3741
3910
|
private prepareSendTransferKeyTweaks;
|
|
3742
3911
|
private prepareSingleSendTransferKeyTweak;
|
|
@@ -3786,127 +3955,6 @@ declare class TransferService extends BaseTransferService {
|
|
|
3786
3955
|
testonly_expireTimeLockRefundtx(node: TreeNode): Promise<FinalizeNodeSignaturesResponse>;
|
|
3787
3956
|
}
|
|
3788
3957
|
|
|
3789
|
-
type Bech32mTokenIdentifier = `btkn1${string}` | `btknrt1${string}` | `btknt1${string}` | `btkns1${string}` | `btknl1${string}`;
|
|
3790
|
-
interface Bech32mTokenIdentifierData {
|
|
3791
|
-
tokenIdentifier: Uint8Array;
|
|
3792
|
-
network: NetworkType;
|
|
3793
|
-
}
|
|
3794
|
-
declare function encodeBech32mTokenIdentifier(payload: Bech32mTokenIdentifierData): Bech32mTokenIdentifier;
|
|
3795
|
-
declare function decodeBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier, network?: NetworkType): Bech32mTokenIdentifierData;
|
|
3796
|
-
declare function getNetworkFromBech32mTokenIdentifier(bech32mTokenIdentifier: Bech32mTokenIdentifier): NetworkType;
|
|
3797
|
-
|
|
3798
|
-
type CreateLightningInvoiceParams = {
|
|
3799
|
-
amountSats: number;
|
|
3800
|
-
memo?: string;
|
|
3801
|
-
expirySeconds?: number;
|
|
3802
|
-
includeSparkAddress?: boolean;
|
|
3803
|
-
receiverIdentityPubkey?: string;
|
|
3804
|
-
descriptionHash?: string;
|
|
3805
|
-
};
|
|
3806
|
-
type PayLightningInvoiceParams = {
|
|
3807
|
-
invoice: string;
|
|
3808
|
-
maxFeeSats: number;
|
|
3809
|
-
preferSpark?: boolean;
|
|
3810
|
-
amountSatsToSend?: number;
|
|
3811
|
-
};
|
|
3812
|
-
type TransferParams = {
|
|
3813
|
-
amountSats: number;
|
|
3814
|
-
receiverSparkAddress: string;
|
|
3815
|
-
};
|
|
3816
|
-
type FulfillSparkInvoiceResponse = {
|
|
3817
|
-
satsTransactionSuccess: {
|
|
3818
|
-
invoice: SparkAddressFormat;
|
|
3819
|
-
transferResponse: WalletTransfer;
|
|
3820
|
-
}[];
|
|
3821
|
-
tokenTransactionSuccess: {
|
|
3822
|
-
tokenIdentifier: Bech32mTokenIdentifier;
|
|
3823
|
-
txid: string;
|
|
3824
|
-
}[];
|
|
3825
|
-
satsTransactionErrors: {
|
|
3826
|
-
invoice: string;
|
|
3827
|
-
error: Error;
|
|
3828
|
-
}[];
|
|
3829
|
-
tokenTransactionErrors: {
|
|
3830
|
-
tokenIdentifier: Bech32mTokenIdentifier;
|
|
3831
|
-
error: Error;
|
|
3832
|
-
}[];
|
|
3833
|
-
invalidInvoices: {
|
|
3834
|
-
invoice: string;
|
|
3835
|
-
error: Error;
|
|
3836
|
-
}[];
|
|
3837
|
-
};
|
|
3838
|
-
/**
|
|
3839
|
-
* Token metadata containing essential information about a token.
|
|
3840
|
-
* This is the wallet's internal representation with JavaScript-friendly types.
|
|
3841
|
-
*
|
|
3842
|
-
* rawTokenIdentifier: This is the raw binary token identifier - This is used to encode the bech32m encoded token identifier.
|
|
3843
|
-
*
|
|
3844
|
-
* tokenPublicKey: This is the hex-encoded public key of the token issuer - Same as issuerPublicKey.
|
|
3845
|
-
*
|
|
3846
|
-
* @example
|
|
3847
|
-
* ```typescript
|
|
3848
|
-
* const tokenMetadata: UserTokenMetadata = {
|
|
3849
|
-
* rawTokenIdentifier: new Uint8Array([1, 2, 3]),
|
|
3850
|
-
* tokenPublicKey: "0348fbb...",
|
|
3851
|
-
* tokenName: "SparkToken",
|
|
3852
|
-
* tokenTicker: "SPK",
|
|
3853
|
-
* decimals: 8,
|
|
3854
|
-
* maxSupply: 1000000n
|
|
3855
|
-
* };
|
|
3856
|
-
* ```
|
|
3857
|
-
*/
|
|
3858
|
-
type UserTokenMetadata = {
|
|
3859
|
-
/** Raw binary token identifier - This is used to encode the human readable token identifier */
|
|
3860
|
-
rawTokenIdentifier: Uint8Array;
|
|
3861
|
-
/** Public key of the token issuer - Same as issuerPublicKey */
|
|
3862
|
-
tokenPublicKey: string;
|
|
3863
|
-
/** Human-readable name of the token (e.g., SparkToken)*/
|
|
3864
|
-
tokenName: string;
|
|
3865
|
-
/** Short ticker symbol for the token (e.g., "SPK") */
|
|
3866
|
-
tokenTicker: string;
|
|
3867
|
-
/** Number of decimal places for token amounts */
|
|
3868
|
-
decimals: number;
|
|
3869
|
-
/** Maximum supply of tokens that can ever be minted */
|
|
3870
|
-
maxSupply: bigint;
|
|
3871
|
-
};
|
|
3872
|
-
type TokenBalanceMap = Map<Bech32mTokenIdentifier, {
|
|
3873
|
-
balance: bigint;
|
|
3874
|
-
tokenMetadata: UserTokenMetadata;
|
|
3875
|
-
}>;
|
|
3876
|
-
type TokenOutputsMap = Map<Bech32mTokenIdentifier, OutputWithPreviousTransactionData$1[]>;
|
|
3877
|
-
type TokenMetadataMap = Map<Bech32mTokenIdentifier, TokenMetadata>;
|
|
3878
|
-
type InitWalletResponse<T extends SparkWallet = SparkWallet> = {
|
|
3879
|
-
wallet: T;
|
|
3880
|
-
mnemonic: string | undefined;
|
|
3881
|
-
};
|
|
3882
|
-
interface SparkWalletProps {
|
|
3883
|
-
mnemonicOrSeed?: Uint8Array | string;
|
|
3884
|
-
accountNumber?: number;
|
|
3885
|
-
signer?: SparkSigner;
|
|
3886
|
-
options?: ConfigOptions;
|
|
3887
|
-
}
|
|
3888
|
-
declare const SparkWalletEvent: {
|
|
3889
|
-
readonly All: "*";
|
|
3890
|
-
readonly TransferClaimed: "transfer:claimed";
|
|
3891
|
-
readonly DepositConfirmed: "deposit:confirmed";
|
|
3892
|
-
readonly StreamConnected: "stream:connected";
|
|
3893
|
-
readonly StreamDisconnected: "stream:disconnected";
|
|
3894
|
-
readonly StreamReconnecting: "stream:reconnecting";
|
|
3895
|
-
};
|
|
3896
|
-
interface SparkWalletEvents {
|
|
3897
|
-
[SparkWalletEvent.All]: (eventName: string, ...args: unknown[]) => void;
|
|
3898
|
-
/** Emitted when an incoming transfer is successfully claimed. Includes the transfer ID and new total balance. */
|
|
3899
|
-
[SparkWalletEvent.TransferClaimed]: (transferId: string, updatedBalance: bigint) => void;
|
|
3900
|
-
/** Emitted when a deposit is marked as available. Includes the deposit ID and new total balance. */
|
|
3901
|
-
[SparkWalletEvent.DepositConfirmed]: (depositId: string, updatedBalance: bigint) => void;
|
|
3902
|
-
/** Emitted when the stream is connected */
|
|
3903
|
-
[SparkWalletEvent.StreamConnected]: () => void;
|
|
3904
|
-
/** Emitted when the stream disconnects and fails to reconnect after max attempts */
|
|
3905
|
-
[SparkWalletEvent.StreamDisconnected]: (reason: string) => void;
|
|
3906
|
-
/** Emitted when attempting to reconnect the stream */
|
|
3907
|
-
[SparkWalletEvent.StreamReconnecting]: (attempt: number, maxAttempts: number, delayMs: number, error: string) => void;
|
|
3908
|
-
}
|
|
3909
|
-
|
|
3910
3958
|
/**
|
|
3911
3959
|
* The SparkWallet class is the primary interface for interacting with the Spark network.
|
|
3912
3960
|
* It provides methods for creating and managing wallets, handling deposits, executing transfers,
|
|
@@ -3935,11 +3983,12 @@ declare abstract class SparkWallet extends EventEmitter<SparkWalletEvents> {
|
|
|
3935
3983
|
protected tokenOutputs: TokenOutputsMap;
|
|
3936
3984
|
private claimTransfersInterval;
|
|
3937
3985
|
private tracer;
|
|
3938
|
-
|
|
3986
|
+
protected abstract buildConnectionManager(config: WalletConfigService): ConnectionManager;
|
|
3987
|
+
constructor(options?: ConfigOptions, signerArg?: SparkSigner);
|
|
3939
3988
|
static initialize<T extends SparkWallet>(this: new (options?: ConfigOptions, signer?: SparkSigner) => T, { mnemonicOrSeed, accountNumber, signer, options }: SparkWalletProps): Promise<InitWalletResponse<T>>;
|
|
3940
3989
|
private createClientsAndSyncWallet;
|
|
3941
3990
|
private getSspClient;
|
|
3942
|
-
protected
|
|
3991
|
+
protected buildSigner(): DefaultSparkSigner;
|
|
3943
3992
|
private handleStreamEvent;
|
|
3944
3993
|
protected setupBackgroundStream(): Promise<void>;
|
|
3945
3994
|
getLeaves(isBalanceCheck?: boolean): Promise<TreeNode[]>;
|
|
@@ -4530,11 +4579,11 @@ type Transport = NonNullable<Parameters<typeof createChannel>[1]>;
|
|
|
4530
4579
|
declare class ConnectionManagerBrowser extends ConnectionManager {
|
|
4531
4580
|
protected transport: Transport;
|
|
4532
4581
|
constructor(config: WalletConfigService, transport?: nice_grpc_web_lib_client_Transport_js.Transport);
|
|
4533
|
-
protected createChannelWithTLS(address: string
|
|
4534
|
-
protected createAuthnMiddleware(): (call: ClientMiddlewareCall<
|
|
4535
|
-
protected createMiddleware(address: string
|
|
4536
|
-
protected createGrpcClient<T>(
|
|
4537
|
-
close: undefined;
|
|
4582
|
+
protected createChannelWithTLS(address: string): Promise<Channel$1>;
|
|
4583
|
+
protected createAuthnMiddleware(): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
4584
|
+
protected createMiddleware(address: string): <Req, Res>(call: ClientMiddlewareCall<Req, Res>, options: SparkCallOptions) => AsyncGenerator<Res, Res | void, undefined>;
|
|
4585
|
+
protected createGrpcClient<T>(definition: SparkAuthnServiceDefinition | SparkServiceDefinition | SparkTokenServiceDefinition, channel: Channel$1, withRetries: boolean, middleware?: ClientMiddleware<RetryOptions, {}>, channelKey?: string): Promise<T & {
|
|
4586
|
+
close: (() => void) | undefined;
|
|
4538
4587
|
}>;
|
|
4539
4588
|
}
|
|
4540
4589
|
|
|
@@ -4606,6 +4655,8 @@ declare function filterTokenBalanceForTokenIdentifier(tokenBalances: TokenBalanc
|
|
|
4606
4655
|
declare function getTransferPackageSigningPayload(transferID: string, transferPackage: TransferPackage): Uint8Array;
|
|
4607
4656
|
|
|
4608
4657
|
declare const DIRECT_TIMELOCK_OFFSET = 50;
|
|
4658
|
+
declare const HTLC_TIMELOCK_OFFSET = 70;
|
|
4659
|
+
declare const DIRECT_HTLC_TIMELOCK_OFFSET = 85;
|
|
4609
4660
|
declare const INITIAL_SEQUENCE: number;
|
|
4610
4661
|
declare const INITIAL_DIRECT_SEQUENCE: number;
|
|
4611
4662
|
declare const TEST_UNILATERAL_SEQUENCE: number;
|
|
@@ -4640,6 +4691,10 @@ interface CreateRefundTxInput {
|
|
|
4640
4691
|
includeAnchor: boolean;
|
|
4641
4692
|
}
|
|
4642
4693
|
declare function createRefundTx({ sequence, input, amountSats, receivingPubkey, network, shouldCalculateFee, includeAnchor, }: CreateRefundTxInput): Transaction;
|
|
4694
|
+
declare function getNextHTLCTransactionSequence(currSequence: number, isNodeTx?: boolean): {
|
|
4695
|
+
nextSequence: number;
|
|
4696
|
+
nextDirectSequence: number;
|
|
4697
|
+
};
|
|
4643
4698
|
interface CreateRefundTxsInput {
|
|
4644
4699
|
sequence: number;
|
|
4645
4700
|
directSequence?: number;
|
|
@@ -4732,4 +4787,4 @@ declare class SparkSdkLogger {
|
|
|
4732
4787
|
static setAllEnabled(enabled: boolean): void;
|
|
4733
4788
|
}
|
|
4734
4789
|
|
|
4735
|
-
export { type AggregateFrostParams, AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, ConfigurationError, DEFAULT_FEE_SATS, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, DefaultSparkSigner, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, type IKeyPackage, INITIAL_DIRECT_SEQUENCE, INITIAL_SEQUENCE, InternalValidationError, LOGGER_NAMES, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, RPCError, type SignFrostParams, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, type SparkSigner, SparkWalletBare as SparkWallet, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, TaprootOutputKeysGenerator, TaprootSparkSigner, type TxChain, UnsafeStatelessSparkSigner, type Utxo, ValidationError, type VerifiableSecretShare, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTransactions, createLeafNodeTx, createNodeTx, createNodeTxs, createRefundTx, createRefundTxs, createRootTx, createSigningCommitment, createSigningNonce, createSplitTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, encodeBech32mTokenIdentifier, encodeSigningCommitmentToBytes, encodeSigningNonceToBytes, encodeSparkAddress, encodeSparkAddressWithSignature, evaluatePolynomial, fieldDiv, filterTokenBalanceForTokenIdentifier, generateAdaptorFromSignature, generatePolynomialForSecretSharing, generateSignatureFromExistingAdaptor, getCurrentTimelock, getEphemeralAnchorOutput, getLatestDepositTxId, getNetwork, getNetworkFromAddress, getNetworkFromBech32mTokenIdentifier, getNetworkFromSparkAddress, getNetworkFromString, getNextTransactionSequence, getP2TRAddressFromPkScript, getP2TRAddressFromPublicKey, getP2TRScriptFromPublicKey, getP2WPKHAddressFromPublicKey, getRandomBigInt, getRandomSigningNonce, getSigHashFromTx, getSigningCommitmentFromNonce, getSparkAddressFromTaproot, getTransactionSequence, getTransferPackageSigningPayload, getTxEstimatedVbytesSizeByNumberOfInputsOutputs, getTxFromRawTxBytes, getTxFromRawTxHex, getTxId, getTxIdNoReverse, isEphemeralAnchorOutput, isLegacySparkAddress, isSafeForNumber, isTxBroadcast, isValidPublicKey, isValidSparkAddress, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };
|
|
4790
|
+
export { type AggregateFrostParams, AuthenticationError, type Bech32mTokenIdentifier, type Bech32mTokenIdentifierData, type BroadcastConfig, type BroadcastResult, ConfigurationError, DEFAULT_FEE_SATS, DIRECT_HTLC_TIMELOCK_OFFSET, DIRECT_TIMELOCK_OFFSET, type DecodedSparkAddressData, DefaultSparkSigner, type FeeBumpTxChain, type FeeBumpTxPackage, type FeeRate, HTLC_TIMELOCK_OFFSET, type IKeyPackage, INITIAL_DIRECT_SEQUENCE, INITIAL_SEQUENCE, InternalValidationError, LOGGER_NAMES, type LeafInfo, type LegacySparkAddressFormat, type LoggerName, Network, NetworkError, NetworkToProto, type NetworkType, NotImplementedError, RPCError, type SignFrostParams, type SparkAddressData, type SparkAddressFormat, SparkSDKError, SparkSdkLogger, type SparkSigner, SparkWalletBare as SparkWallet, TEST_UNILATERAL_DIRECT_SEQUENCE, TEST_UNILATERAL_SEQUENCE, TaprootOutputKeysGenerator, TaprootSparkSigner, type TxChain, UnsafeStatelessSparkSigner, type Utxo, ValidationError, type VerifiableSecretShare, addPrivateKeys, addPublicKeys, applyAdaptorToSignature, applyAdditiveTweakToPublicKey, assertBech32, bech32mDecode, bigIntToPrivateKey, checkIfSelectedOutputsAreAvailable, checkIfValidSequence, collectResponses, computeTaprootKeyNoScript, computerLagrangeCoefficients, constructFeeBumpTx, constructUnilateralExitFeeBumpPackages, constructUnilateralExitTxs, createConnectorRefundTransactions, createLeafNodeTx, createNodeTx, createNodeTxs, createRefundTx, createRefundTxs, createRootTx, createSigningCommitment, createSigningNonce, createSplitTx, decodeBech32mTokenIdentifier, decodeBytesToSigningCommitment, decodeBytesToSigningNonce, decodeSparkAddress, doesLeafNeedRefresh, 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, lastKeyWithTarget, maybeApplyFee, modInverse, proofOfPossessionMessageHashForDepositAddress, protoToNetwork, recoverSecret, splitSecret, splitSecretWithProofs, subtractPrivateKeys, subtractPublicKeys, sumAvailableTokens, sumOfPrivateKeys, toProtoTimestamp, validateOutboundAdaptorSignature, validateShare, validateSparkInvoiceFields, validateSparkInvoiceSignature };
|