@arkade-os/sdk 0.5.7 → 0.5.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/README.md +24 -6
- package/dist/adapters/expo.cjs +7 -7
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +4 -4
- package/dist/{asyncStorageTaskQueue-B9byr6ij.d.cts → asyncStorageTaskQueue-B6rFkXzW.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-XP4CCdRY.d.ts → asyncStorageTaskQueue-C0irgPwJ.d.ts} +1 -1
- package/dist/{chunk-MWEDDWFU.js → chunk-2657D67V.js} +9 -7
- package/dist/chunk-2657D67V.js.map +1 -0
- package/dist/{chunk-MWMO2ZQP.js → chunk-3KNSMZWD.js} +24 -13
- package/dist/chunk-3KNSMZWD.js.map +1 -0
- package/dist/{chunk-DNFTHG73.js → chunk-4DUTRRXF.js} +8 -6
- package/dist/chunk-4DUTRRXF.js.map +1 -0
- package/dist/{chunk-MQUATTIM.cjs → chunk-4PSM6ZUC.cjs} +55 -57
- package/dist/chunk-4PSM6ZUC.cjs.map +1 -0
- package/dist/{chunk-FDJ734CH.js → chunk-DPFD5KBK.js} +5 -2
- package/dist/chunk-DPFD5KBK.js.map +1 -0
- package/dist/{chunk-OMPDPBT5.cjs → chunk-DY24A73N.cjs} +296 -240
- package/dist/chunk-DY24A73N.cjs.map +1 -0
- package/dist/{chunk-VMVFRTF4.js → chunk-FUCKDTH7.js} +285 -234
- package/dist/chunk-FUCKDTH7.js.map +1 -0
- package/dist/{chunk-4AJRIM44.js → chunk-GUK33TNC.js} +9 -13
- package/dist/chunk-GUK33TNC.js.map +1 -0
- package/dist/{chunk-RLD7DRSZ.js → chunk-HT35HPXR.js} +19365 -18395
- package/dist/chunk-HT35HPXR.js.map +1 -0
- package/dist/{chunk-3NALVGMJ.cjs → chunk-ODLSVJRU.cjs} +38 -27
- package/dist/chunk-ODLSVJRU.cjs.map +1 -0
- package/dist/{chunk-X6ZI53DZ.cjs → chunk-OMZZQTDM.cjs} +28 -35
- package/dist/chunk-OMZZQTDM.cjs.map +1 -0
- package/dist/{chunk-V3ZLL5VY.js → chunk-PXEFYEKL.js} +22 -29
- package/dist/chunk-PXEFYEKL.js.map +1 -0
- package/dist/{chunk-JFJNB7ZH.cjs → chunk-UPIQZRNJ.cjs} +16 -14
- package/dist/chunk-UPIQZRNJ.cjs.map +1 -0
- package/dist/{chunk-V5WRO3P6.cjs → chunk-UPV4W423.cjs} +14 -18
- package/dist/chunk-UPV4W423.cjs.map +1 -0
- package/dist/{chunk-URGVQ5TQ.cjs → chunk-V2EU5QWF.cjs} +4583 -3610
- package/dist/chunk-V2EU5QWF.cjs.map +1 -0
- package/dist/{chunk-FLPWNMX3.cjs → chunk-WIZCF5IX.cjs} +5 -2
- package/dist/chunk-WIZCF5IX.cjs.map +1 -0
- package/dist/{chunk-MXCB6EVM.cjs → chunk-WZJJZGBT.cjs} +22 -20
- package/dist/chunk-WZJJZGBT.cjs.map +1 -0
- package/dist/{chunk-V2DDN4MV.js → chunk-Z6WDOZZI.js} +10 -12
- package/dist/chunk-Z6WDOZZI.js.map +1 -0
- package/dist/compiler.cjs +4 -4
- package/dist/compiler.d.cts +1 -1
- package/dist/compiler.d.ts +1 -1
- package/dist/compiler.js +3 -3
- package/dist/contracts/handlers/index.cjs +11 -11
- package/dist/contracts/handlers/index.d.cts +3 -4
- package/dist/contracts/handlers/index.d.ts +3 -4
- package/dist/contracts/handlers/index.js +4 -4
- package/dist/{index-18cDMayF.d.ts → index-Bq349_ly.d.cts} +2334 -101
- package/dist/{index-Ccfhdfvj.d.cts → index-D4ahI0W6.d.cts} +2 -3
- package/dist/{index-DDJFHfba.d.cts → index-Mn2POBPj.d.ts} +2334 -101
- package/dist/{index-B_kcptF8.d.ts → index-Yh5y9G4E.d.ts} +2 -3
- package/dist/index.cjs +362 -346
- package/dist/index.d.cts +1505 -1374
- package/dist/index.d.ts +1505 -1374
- package/dist/index.js +7 -7
- package/dist/{program-BARSNg3X.d.ts → program-38A2Twvj.d.ts} +4 -2
- package/dist/{program-znrWkxE4.d.cts → program-DPzf5qsk.d.cts} +4 -2
- package/dist/repositories/realm/index.cjs +40 -40
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +8 -8
- package/dist/repositories/sqlite/index.cjs +38 -38
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +8 -8
- package/dist/{taskRunner-DUafWu0o.d.ts → taskRunner-BYxEgwM5.d.ts} +1 -1
- package/dist/{taskRunner-JYHaLPne.d.cts → taskRunner-Z3LnHfgs.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +17 -17
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +9 -9
- package/dist/wallet/expo/index.cjs +18 -18
- package/dist/wallet/expo/index.d.cts +3 -5
- package/dist/wallet/expo/index.d.ts +3 -5
- package/dist/wallet/expo/index.js +8 -8
- package/dist/worker/expo/index.cjs +12 -12
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +8 -8
- package/package.json +1 -1
- package/dist/chunk-3NALVGMJ.cjs.map +0 -1
- package/dist/chunk-4AJRIM44.js.map +0 -1
- package/dist/chunk-DNFTHG73.js.map +0 -1
- package/dist/chunk-FDJ734CH.js.map +0 -1
- package/dist/chunk-FLPWNMX3.cjs.map +0 -1
- package/dist/chunk-JFJNB7ZH.cjs.map +0 -1
- package/dist/chunk-MQUATTIM.cjs.map +0 -1
- package/dist/chunk-MWEDDWFU.js.map +0 -1
- package/dist/chunk-MWMO2ZQP.js.map +0 -1
- package/dist/chunk-MXCB6EVM.cjs.map +0 -1
- package/dist/chunk-OMPDPBT5.cjs.map +0 -1
- package/dist/chunk-RLD7DRSZ.js.map +0 -1
- package/dist/chunk-URGVQ5TQ.cjs.map +0 -1
- package/dist/chunk-V2DDN4MV.js.map +0 -1
- package/dist/chunk-V3ZLL5VY.js.map +0 -1
- package/dist/chunk-V5WRO3P6.cjs.map +0 -1
- package/dist/chunk-VMVFRTF4.js.map +0 -1
- package/dist/chunk-X6ZI53DZ.cjs.map +0 -1
- package/dist/delegate-gGkUnYpi.d.cts +0 -92
- package/dist/delegate-iyDum4fw.d.ts +0 -92
- package/dist/keyringDescriptorProvider-DL-jAiRO.d.ts +0 -2082
- package/dist/keyringDescriptorProvider-Dtv0JWrT.d.cts +0 -2082
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
2
2
|
import { Transaction as Transaction$1 } from '@scure/btc-signer';
|
|
3
3
|
import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
|
-
import {
|
|
4
|
+
import { R as RelativeTimelock, V as VtxoScript, T as TapLeafScript, A as ArkAddress, C as CSVMultisigTapscript, E as EncodedVtxoScript } from './base-C-Y5t_0F.cjs';
|
|
5
5
|
import { TxOpts } from '@scure/btc-signer/transaction.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -118,6 +118,76 @@ declare class TreeSignerSession implements SignerSession {
|
|
|
118
118
|
private signPartial;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* In-memory single key implementation for Bitcoin transaction signing.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Create from hex string
|
|
127
|
+
* const key = SingleKey.fromHex('your_private_key_hex');
|
|
128
|
+
*
|
|
129
|
+
* // Create from raw bytes
|
|
130
|
+
* const key = SingleKey.fromPrivateKey(privateKeyBytes);
|
|
131
|
+
*
|
|
132
|
+
* // Create random key
|
|
133
|
+
* const randomKey = SingleKey.fromRandomBytes();
|
|
134
|
+
*
|
|
135
|
+
* // Sign a transaction
|
|
136
|
+
* const signedTx = await key.sign(transaction);
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare class SingleKey implements Identity {
|
|
140
|
+
private key;
|
|
141
|
+
private constructor();
|
|
142
|
+
/** Create a signing identity from raw private key bytes. */
|
|
143
|
+
static fromPrivateKey(privateKey: Uint8Array): SingleKey;
|
|
144
|
+
/** Create a signing identity from a hex-encoded private key. */
|
|
145
|
+
static fromHex(privateKeyHex: string): SingleKey;
|
|
146
|
+
/** Create a signing identity with a freshly generated random private key. */
|
|
147
|
+
static fromRandomBytes(): SingleKey;
|
|
148
|
+
/**
|
|
149
|
+
* Export the private key as a hex string.
|
|
150
|
+
*
|
|
151
|
+
* @returns The private key as a hex string
|
|
152
|
+
*/
|
|
153
|
+
toHex(): string;
|
|
154
|
+
sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
|
|
155
|
+
compressedPublicKey(): Promise<Uint8Array>;
|
|
156
|
+
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
157
|
+
signerSession(): SignerSession;
|
|
158
|
+
signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
159
|
+
/**
|
|
160
|
+
* BIP-340 sign `messageHash` with aux_rand = 0, so the signature — and
|
|
161
|
+
* anything derived from it — is reproducible from the key alone.
|
|
162
|
+
*
|
|
163
|
+
* What lets a static wallet derive a swap preimage instead of storing one
|
|
164
|
+
* (see `wallet/contractSecrets.ts`). Deliberately NOT `signMessage`, whose
|
|
165
|
+
* schnorr branch draws a random aux_rand: a preimage derived from that is
|
|
166
|
+
* unrecoverable, and the loss would only surface at claim time.
|
|
167
|
+
*/
|
|
168
|
+
signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
|
|
169
|
+
toReadonly(): Promise<ReadonlySingleKey>;
|
|
170
|
+
}
|
|
171
|
+
declare class ReadonlySingleKey implements ReadonlyIdentity {
|
|
172
|
+
private readonly publicKey;
|
|
173
|
+
/** Create a readonly identity from a compressed public key. */
|
|
174
|
+
constructor(publicKey: Uint8Array);
|
|
175
|
+
/**
|
|
176
|
+
* Create a ReadonlySingleKey from a compressed public key.
|
|
177
|
+
*
|
|
178
|
+
* @param publicKey - 33-byte compressed public key (02/03 prefix + 32-byte x coordinate)
|
|
179
|
+
* @returns A new ReadonlySingleKey instance
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* const pubkey = new Uint8Array(33); // your compressed public key
|
|
183
|
+
* const readonlyKey = ReadonlySingleKey.fromPublicKey(pubkey);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
static fromPublicKey(publicKey: Uint8Array): ReadonlySingleKey;
|
|
187
|
+
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
188
|
+
compressedPublicKey(): Promise<Uint8Array>;
|
|
189
|
+
}
|
|
190
|
+
|
|
121
191
|
/** A signing request that pairs a descriptor with a transaction. */
|
|
122
192
|
interface DescriptorSigningRequest {
|
|
123
193
|
/** Descriptor identifying which key to sign with */
|
|
@@ -1600,6 +1670,7 @@ declare class EsploraProvider implements OnchainProvider {
|
|
|
1600
1670
|
txid?: string;
|
|
1601
1671
|
}[]>;
|
|
1602
1672
|
getTransactions(address: string): Promise<ExplorerTransaction[]>;
|
|
1673
|
+
private getAddressTxs;
|
|
1603
1674
|
/** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
|
|
1604
1675
|
private getAddressStats;
|
|
1605
1676
|
getRawTransaction(txid: string): Promise<Uint8Array>;
|
|
@@ -2215,14 +2286,15 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
|
|
|
2215
2286
|
* fails its batch at submit. The key is a thunk so ordinary recovery never touches the
|
|
2216
2287
|
* identity; full coins carry the confirmation a relative timelock counts from.
|
|
2217
2288
|
*/
|
|
2289
|
+
/** Recovery inputs to skip: refused by their contract right now, or held by `reserveVtxos`. */
|
|
2218
2290
|
private unspendableNow;
|
|
2219
2291
|
/**
|
|
2220
2292
|
* Recover swept/expired virtual outputs by settling them back to the wallet's Arkade address.
|
|
2221
2293
|
*
|
|
2222
2294
|
* Includes preconfirmed subdust when the total reaches the dust threshold; settled outputs
|
|
2223
2295
|
* with a long expiry are NOT recovered, to avoid locking liquidity. Inputs whose contract
|
|
2224
|
-
* refuses a spend right now (an immature VHTLC refund path)
|
|
2225
|
-
* the batch, matching {@link getRecoverableBalance}.
|
|
2296
|
+
* refuses a spend right now (an immature VHTLC refund path), or that `reserveVtxos` holds, are
|
|
2297
|
+
* skipped rather than failing the batch, matching {@link getRecoverableBalance}.
|
|
2226
2298
|
*
|
|
2227
2299
|
* @param eventCallback - Optional callback to receive settlement events
|
|
2228
2300
|
* @returns Settlement transaction ID
|
|
@@ -2749,6 +2821,106 @@ interface VirtualTxRepository extends AsyncDisposable {
|
|
|
2749
2821
|
pruneForSpentVtxo(vtxo: Outpoint): Promise<void>;
|
|
2750
2822
|
}
|
|
2751
2823
|
|
|
2824
|
+
interface StoredVtxoReservation {
|
|
2825
|
+
id: string;
|
|
2826
|
+
outpoints: Outpoint[];
|
|
2827
|
+
}
|
|
2828
|
+
/** Single-writer holds; only the owning application can establish when release is safe. */
|
|
2829
|
+
interface VtxoReservationRepository {
|
|
2830
|
+
readonly version: 1;
|
|
2831
|
+
getReservations(): Promise<StoredVtxoReservation[]>;
|
|
2832
|
+
saveReservation(reservation: StoredVtxoReservation): Promise<void>;
|
|
2833
|
+
deleteReservation(id: string): Promise<void>;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
/**
|
|
2837
|
+
* DefaultVtxo is the default implementation of a VtxoScript.
|
|
2838
|
+
* It contains 1 forfeit path and 1 exit path.
|
|
2839
|
+
* - forfeit = (Alice + Server)
|
|
2840
|
+
* - exit = (Alice) after csvTimelock
|
|
2841
|
+
*/
|
|
2842
|
+
declare namespace DefaultVtxo {
|
|
2843
|
+
/**
|
|
2844
|
+
* Options is the options for the DefaultVtxo.Script class.
|
|
2845
|
+
* csvTimelock is the exit path timelock, default is 144 blocks (1 day).
|
|
2846
|
+
*/
|
|
2847
|
+
interface Options {
|
|
2848
|
+
pubKey: Bytes;
|
|
2849
|
+
serverPubKey: Bytes;
|
|
2850
|
+
csvTimelock: RelativeTimelock;
|
|
2851
|
+
}
|
|
2852
|
+
/**
|
|
2853
|
+
* DefaultVtxo.Script is the class letting to create the vtxo script.
|
|
2854
|
+
* @example
|
|
2855
|
+
* ```typescript
|
|
2856
|
+
* const vtxoScript = new DefaultVtxo.Script({
|
|
2857
|
+
* pubKey: new Uint8Array(32),
|
|
2858
|
+
* serverPubKey: new Uint8Array(32),
|
|
2859
|
+
* csvTimelock: {
|
|
2860
|
+
* value: 605184n,
|
|
2861
|
+
* type: "seconds"
|
|
2862
|
+
* }
|
|
2863
|
+
* });
|
|
2864
|
+
*
|
|
2865
|
+
* console.log("script pub key:", vtxoScript.pkScript)
|
|
2866
|
+
* ```
|
|
2867
|
+
*/
|
|
2868
|
+
class Script extends VtxoScript {
|
|
2869
|
+
readonly options: Options;
|
|
2870
|
+
static readonly DEFAULT_TIMELOCK: RelativeTimelock;
|
|
2871
|
+
readonly forfeitScript: string;
|
|
2872
|
+
readonly exitScript: string;
|
|
2873
|
+
/** Create the default virtual output script with one forfeit path and one exit path. */
|
|
2874
|
+
constructor(options: Options);
|
|
2875
|
+
/** Return the forfeit tapleaf script. */
|
|
2876
|
+
forfeit(): TapLeafScript;
|
|
2877
|
+
/** Return the unilateral exit tapleaf script. */
|
|
2878
|
+
exit(): TapLeafScript;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
/**
|
|
2883
|
+
* DelegateVtxo extends DefaultVtxo with an extra delegate path
|
|
2884
|
+
*/
|
|
2885
|
+
declare namespace DelegateVtxo {
|
|
2886
|
+
/**
|
|
2887
|
+
* Options extends DefaultVtxo.Options and adds a delegatePubKey
|
|
2888
|
+
*/
|
|
2889
|
+
interface Options extends DefaultVtxo.Options {
|
|
2890
|
+
delegatePubKey: Bytes;
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* DelegateVtxo.Script extends DefaultVtxo.Script and adds a delegate path.
|
|
2894
|
+
* @example
|
|
2895
|
+
* ```typescript
|
|
2896
|
+
* const vtxoScript = new DelegateVtxo.Script({
|
|
2897
|
+
* pubKey: new Uint8Array(32),
|
|
2898
|
+
* serverPubKey: new Uint8Array(32),
|
|
2899
|
+
* delegatePubKey: new Uint8Array(32),
|
|
2900
|
+
* csvTimelock: {
|
|
2901
|
+
* value: 605184n,
|
|
2902
|
+
* type: "seconds"
|
|
2903
|
+
* }
|
|
2904
|
+
* });
|
|
2905
|
+
*
|
|
2906
|
+
* console.log("script pub key:", vtxoScript.pkScript)
|
|
2907
|
+
* ```
|
|
2908
|
+
*/
|
|
2909
|
+
class Script extends VtxoScript {
|
|
2910
|
+
readonly options: Options;
|
|
2911
|
+
readonly defaultVtxo: DefaultVtxo.Script;
|
|
2912
|
+
readonly delegateScript: string;
|
|
2913
|
+
/** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
|
|
2914
|
+
constructor(options: Options);
|
|
2915
|
+
/** Return the forfeit tapleaf script. */
|
|
2916
|
+
forfeit(): TapLeafScript;
|
|
2917
|
+
/** Return the unilateral exit tapleaf script. */
|
|
2918
|
+
exit(): TapLeafScript;
|
|
2919
|
+
/** Return the delegate tapleaf script. */
|
|
2920
|
+
delegate(): TapLeafScript;
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2752
2924
|
/** One transaction's participation in one logical action. */
|
|
2753
2925
|
interface GroupMembership {
|
|
2754
2926
|
/**
|
|
@@ -2864,6 +3036,110 @@ declare function assetMintResolver(): ActivityResolver;
|
|
|
2864
3036
|
*/
|
|
2865
3037
|
declare function createDefaultActivityRegistry(): ActivityRegistry;
|
|
2866
3038
|
|
|
3039
|
+
/** Wall-clock floor for `batchExpiry` outside regtest. */
|
|
3040
|
+
declare const DEFAULT_MIN_BATCH_EXPIRY_SECONDS = 86400n;
|
|
3041
|
+
/** Wall-clock floor for `batchExpiry` on regtest (~10 blocks). */
|
|
3042
|
+
declare const REGTEST_MIN_BATCH_EXPIRY_SECONDS = 6000n;
|
|
3043
|
+
/** Bounds applied to a server-supplied `BatchStartedEvent.batchExpiry`. */
|
|
3044
|
+
type BatchExpiryPolicy = {
|
|
3045
|
+
/** Minimum wall-clock delay in seconds, after normalization. */
|
|
3046
|
+
minSeconds: bigint;
|
|
3047
|
+
/**
|
|
3048
|
+
* Reject block-typed timelocks. Mirrors arkd, which allows a block-typed
|
|
3049
|
+
* vtxo tree expiry only on regtest.
|
|
3050
|
+
*/
|
|
3051
|
+
requireSeconds: boolean;
|
|
3052
|
+
/** When advertised by the operator, `batchExpiry` must equal it exactly. */
|
|
3053
|
+
advertisedVtxoTreeExpiry?: bigint;
|
|
3054
|
+
};
|
|
3055
|
+
/**
|
|
3056
|
+
* Default policy for a network.
|
|
3057
|
+
*
|
|
3058
|
+
* Derive it from the locally held {@link Network} — pinned at wallet setup —
|
|
3059
|
+
* rather than from a per-round server field, so the permissive regtest branch
|
|
3060
|
+
* can't be selected by the operator at event time.
|
|
3061
|
+
*/
|
|
3062
|
+
declare function defaultBatchExpiryPolicy(network: Network): BatchExpiryPolicy;
|
|
3063
|
+
/** Resolve a policy for `network`, applying any caller overrides on top. */
|
|
3064
|
+
declare function resolveBatchExpiryPolicy(network: Network, overrides?: Partial<BatchExpiryPolicy>): BatchExpiryPolicy;
|
|
3065
|
+
/**
|
|
3066
|
+
* Check a server-supplied batch expiry against `policy` and return the timelock
|
|
3067
|
+
* to commit to.
|
|
3068
|
+
*
|
|
3069
|
+
* The sweep leaf of the shared batch output is derived from this value, so it
|
|
3070
|
+
* is never reconstructible from anything else the server sends: validating the
|
|
3071
|
+
* tree only proves it is consistent with whatever value was chosen. Callers
|
|
3072
|
+
* must encode the returned timelock rather than re-deriving their own.
|
|
3073
|
+
*
|
|
3074
|
+
* @throws {ServerResponseMismatchError} if the value is out of policy.
|
|
3075
|
+
*/
|
|
3076
|
+
declare function assertValidBatchExpiry(batchExpiry: bigint, policy: BatchExpiryPolicy): RelativeTimelock;
|
|
3077
|
+
|
|
3078
|
+
/**
|
|
3079
|
+
* ArkadeCash is a bearer instrument for the Arkade.
|
|
3080
|
+
* It encodes a private key and contract parameters as a bech32m string,
|
|
3081
|
+
* enabling wallet-to-wallet transfers without address exchange.
|
|
3082
|
+
*
|
|
3083
|
+
* Format: arkadecash1... / tarkadecash1... (bech32m encoded)
|
|
3084
|
+
* Payload: version (1 byte) + private key (32 bytes) + server pubkey (32 bytes) + csv timelock sequence (4 bytes)
|
|
3085
|
+
*/
|
|
3086
|
+
declare class ArkadeCash {
|
|
3087
|
+
readonly csvTimelock: RelativeTimelock;
|
|
3088
|
+
readonly hrp: string;
|
|
3089
|
+
static readonly DefaultHRP = "arkadecash";
|
|
3090
|
+
/** The only prefixes minted or accepted: mainnet and test networks. */
|
|
3091
|
+
static readonly HRPs: readonly string[];
|
|
3092
|
+
static readonly Version = 0;
|
|
3093
|
+
static readonly PayloadLength: number;
|
|
3094
|
+
private readonly _privateKey;
|
|
3095
|
+
private readonly _serverPubKey;
|
|
3096
|
+
private readonly _publicKey;
|
|
3097
|
+
constructor(privateKey: Uint8Array, serverPubKey: Uint8Array, csvTimelock: RelativeTimelock, hrp?: string);
|
|
3098
|
+
/** The note's private key. Returns a fresh copy; mutating it is a no-op. */
|
|
3099
|
+
get privateKey(): Uint8Array;
|
|
3100
|
+
/** The server's public key. Returns a fresh copy; mutating it is a no-op. */
|
|
3101
|
+
get serverPubKey(): Uint8Array;
|
|
3102
|
+
/** The note's public key. Returns a fresh copy; mutating it is a no-op. */
|
|
3103
|
+
get publicKey(): Uint8Array;
|
|
3104
|
+
static generate(serverPubKey: Uint8Array, csvTimelock: RelativeTimelock, hrp?: string): ArkadeCash;
|
|
3105
|
+
static fromString(encoded: string): ArkadeCash;
|
|
3106
|
+
toString(): string;
|
|
3107
|
+
get identity(): SingleKey;
|
|
3108
|
+
get vtxoScript(): DefaultVtxo.Script;
|
|
3109
|
+
address(addressHrp: string): ArkAddress;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
type ArkadeCashAction = "issued" | "claimed";
|
|
3113
|
+
/** One transaction of a voucher and the voucher's share of it, in sats. */
|
|
3114
|
+
interface ArkadeCashTx {
|
|
3115
|
+
txid: string;
|
|
3116
|
+
amount: number;
|
|
3117
|
+
}
|
|
3118
|
+
interface ArkadeCashRecord {
|
|
3119
|
+
id: string;
|
|
3120
|
+
action: ArkadeCashAction;
|
|
3121
|
+
createdAt: number;
|
|
3122
|
+
outcome: string;
|
|
3123
|
+
issues: ArkadeCashTx[];
|
|
3124
|
+
claims: ArkadeCashTx[];
|
|
3125
|
+
}
|
|
3126
|
+
declare class ArkadeCashTracker {
|
|
3127
|
+
readonly records: Map<string, ArkadeCashRecord>;
|
|
3128
|
+
get(id: string): ArkadeCashRecord | undefined;
|
|
3129
|
+
list(): ArkadeCashRecord[];
|
|
3130
|
+
}
|
|
3131
|
+
declare function createArkadeCashTracker(): ArkadeCashTracker;
|
|
3132
|
+
/**
|
|
3133
|
+
* Combine two records of one voucher. Transactions are unioned by txid and the earliest
|
|
3134
|
+
* `createdAt` is kept. A claim outranks an issue for `action` and `outcome`; between records
|
|
3135
|
+
* with the same action, `next` wins.
|
|
3136
|
+
*/
|
|
3137
|
+
declare function mergeArkadeCashRecord(prev: ArkadeCashRecord | undefined, next: ArkadeCashRecord): ArkadeCashRecord;
|
|
3138
|
+
/** Inject a public record, merging it into any record already held for the voucher. */
|
|
3139
|
+
declare function addArkadeCashRecord(records: ArkadeCashTracker, record: ArkadeCashRecord): void;
|
|
3140
|
+
declare function arkadeCashId(cash: ArkadeCash): string;
|
|
3141
|
+
declare function arkadeCashResolver(records: ArkadeCashTracker): ActivityResolver;
|
|
3142
|
+
|
|
2867
3143
|
/**
|
|
2868
3144
|
* A source of unilateral-exit chain data for a set of VTXOs. Sources are tried
|
|
2869
3145
|
* in order by the resolver; a source returns `null` (chain) or omits keys (psbts)
|
|
@@ -2894,6 +3170,211 @@ declare function createExitChainResolver(params: {
|
|
|
2894
3170
|
|
|
2895
3171
|
type ExitCaptureMode = "lite" | "full";
|
|
2896
3172
|
|
|
3173
|
+
declare class ArkError extends Error {
|
|
3174
|
+
readonly code: number;
|
|
3175
|
+
readonly message: string;
|
|
3176
|
+
readonly name: string;
|
|
3177
|
+
readonly metadata?: Record<string, string> | undefined;
|
|
3178
|
+
constructor(code: number, message: string, name: string, metadata?: Record<string, string> | undefined);
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Structured arkd error `name`s the SDK branches on, centralized so call sites don't
|
|
3182
|
+
* hardcode string literals. Not an exhaustive mirror of the server's codes — only the
|
|
3183
|
+
* ones the SDK acts on.
|
|
3184
|
+
*/
|
|
3185
|
+
declare const ArkErrorName: {
|
|
3186
|
+
readonly DIGEST_MISMATCH: "DIGEST_MISMATCH";
|
|
3187
|
+
readonly VTXO_ALREADY_SPENT: "VTXO_ALREADY_SPENT";
|
|
3188
|
+
readonly INVALID_TX_FILTER: "INVALID_TX_FILTER";
|
|
3189
|
+
readonly TX_FILTERS_LIMIT_EXCEEDED: "TX_FILTERS_LIMIT_EXCEEDED";
|
|
3190
|
+
/**
|
|
3191
|
+
* A CLTV closure was spent before its absolute locktime matured. `submitTx` only, with
|
|
3192
|
+
* metadata `{ locktime, current_locktime, type: "height" | "time" }`. Self-healing, so defer
|
|
3193
|
+
* and retry: the server matures a seconds-locktime against the **chain tip block's
|
|
3194
|
+
* timestamp**, not wall clock, so a prompt spend is rejected until a later block lands.
|
|
3195
|
+
*/
|
|
3196
|
+
readonly FORFEIT_CLOSURE_LOCKED: "FORFEIT_CLOSURE_LOCKED";
|
|
3197
|
+
readonly INVALID_INTENT_PROOF: "INVALID_INTENT_PROOF";
|
|
3198
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
3199
|
+
};
|
|
3200
|
+
type ArkErrorName = (typeof ArkErrorName)[keyof typeof ArkErrorName];
|
|
3201
|
+
/**
|
|
3202
|
+
* Type guard for a structured {@link ArkError}, optionally narrowing to a cataloged
|
|
3203
|
+
* {@link ArkErrorName}; for an uncataloged name, add it there or compare `err.name` after the
|
|
3204
|
+
* one-argument form.
|
|
3205
|
+
*
|
|
3206
|
+
* @example
|
|
3207
|
+
* if (isArkError(maybeArkError(err), ArkErrorName.DIGEST_MISMATCH)) { ... }
|
|
3208
|
+
*/
|
|
3209
|
+
declare function isArkError(error: unknown, name?: ArkErrorName): error is ArkError;
|
|
3210
|
+
/**
|
|
3211
|
+
* Which remote dependency an availability failure refers to; labels the
|
|
3212
|
+
* {@link ProviderUnavailableError} message and `ProviderConnectionState`. Deliberately *not* a
|
|
3213
|
+
* field on the error: structured clone across the service-worker `postMessage` boundary keeps
|
|
3214
|
+
* `message`, `stack` and `cause` but drops own-properties and normalizes a custom `name` to
|
|
3215
|
+
* `"Error"`.
|
|
3216
|
+
*/
|
|
3217
|
+
type ProviderKind = "arkade" | "indexer";
|
|
3218
|
+
/**
|
|
3219
|
+
* A remote provider (Arkade operator or its indexer) is temporarily unreachable: transport
|
|
3220
|
+
* failure, timeout, or a 5xx/429. Retryable, unlike terminal config/auth/schema errors, which
|
|
3221
|
+
* stay a plain `Error`/{@link ArkError}. The low-level error is kept as {@link Error.cause}.
|
|
3222
|
+
*/
|
|
3223
|
+
declare class ProviderUnavailableError extends Error {
|
|
3224
|
+
/** Always `true`: this error type only ever wraps retryable conditions. */
|
|
3225
|
+
readonly retryable = true;
|
|
3226
|
+
constructor(message: string, options?: {
|
|
3227
|
+
cause?: unknown;
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
/**
|
|
3231
|
+
* A non-2xx response from a plain HTTP provider (Esplora, an SSE stream), carrying what a caller
|
|
3232
|
+
* needs to back off: the numeric `status` and any `Retry-After` in milliseconds. The status is in
|
|
3233
|
+
* the message too — `statusText` is empty over HTTP/2, and own-properties do not survive the
|
|
3234
|
+
* service-worker boundary (see {@link ProviderKind}) — as `<prefix>: <detail> (<status>)`, so a
|
|
3235
|
+
* caller matching on the prefix still matches.
|
|
3236
|
+
*/
|
|
3237
|
+
declare class HttpResponseError extends Error {
|
|
3238
|
+
readonly status: number;
|
|
3239
|
+
readonly retryAfterMs?: number;
|
|
3240
|
+
/** @param detail - Replaces `statusText`, for a route that reads the body instead. */
|
|
3241
|
+
constructor(prefix: string, response: Response, detail?: string);
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* A response doesn't reconcile with what the SDK submitted or validated (a checkpoint txid not
|
|
3245
|
+
* among those submitted, a commitment tx differing from the one validated at tree signing).
|
|
3246
|
+
* Terminal: the two are equal by construction in a well-formed exchange. `retryable` and `name`
|
|
3247
|
+
* don't cross the SW boundary (see {@link ProviderKind}), so every distinguishing detail belongs
|
|
3248
|
+
* in `message`.
|
|
3249
|
+
*/
|
|
3250
|
+
declare class ServerResponseMismatchError extends Error {
|
|
3251
|
+
readonly retryable = false;
|
|
3252
|
+
constructor(message: string, options?: {
|
|
3253
|
+
cause?: unknown;
|
|
3254
|
+
});
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* Try to convert an error to an ArkError class, returning undefined if the error is not an ArkError
|
|
3258
|
+
* @param error - The error to parse
|
|
3259
|
+
* @returns The parsed ArkError, or undefined if the error is not an ArkError
|
|
3260
|
+
*/
|
|
3261
|
+
declare function maybeArkError(error: any): ArkError | undefined;
|
|
3262
|
+
|
|
3263
|
+
/** Where the {@link OperatorInfo} used to construct a wallet came from. */
|
|
3264
|
+
type ServerInfoSource = "live" | "cache";
|
|
3265
|
+
|
|
3266
|
+
/**
|
|
3267
|
+
* Batch namespace provides utilities for joining and processing batch session.
|
|
3268
|
+
* The batch settlement process involves multiple events, this namespace provides abstractions and types to handle them.
|
|
3269
|
+
* @see https://docs.arkadeos.com/learn/pillars/batch-swaps
|
|
3270
|
+
* @example
|
|
3271
|
+
* ```typescript
|
|
3272
|
+
* // use wallet handler or create a custom one
|
|
3273
|
+
* const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
|
|
3274
|
+
*
|
|
3275
|
+
* const abortController = new AbortController();
|
|
3276
|
+
* // Get event stream from the operator provider
|
|
3277
|
+
* const eventStream = arkProvider.getEventStream(
|
|
3278
|
+
* abortController.signal,
|
|
3279
|
+
* ['your-topic-1', 'your-topic-2']
|
|
3280
|
+
* );
|
|
3281
|
+
*
|
|
3282
|
+
* // Join the batch and process events
|
|
3283
|
+
* try {
|
|
3284
|
+
* const commitmentTxid = await Batch.join(eventStream, handler);
|
|
3285
|
+
* console.log('Batch completed with commitment:', commitmentTxid);
|
|
3286
|
+
* } catch (error) {
|
|
3287
|
+
* console.error('Batch processing failed:', error);
|
|
3288
|
+
* } finally {
|
|
3289
|
+
* abortController.abort();
|
|
3290
|
+
* }
|
|
3291
|
+
* ```
|
|
3292
|
+
*/
|
|
3293
|
+
declare namespace Batch {
|
|
3294
|
+
interface Handler {
|
|
3295
|
+
/**
|
|
3296
|
+
* Called on BatchStarted event.
|
|
3297
|
+
* @returns { skip: boolean } indicating whether the batch should be skipped or not.
|
|
3298
|
+
*/
|
|
3299
|
+
onBatchStarted(event: BatchStartedEvent): Promise<{
|
|
3300
|
+
skip: boolean;
|
|
3301
|
+
}>;
|
|
3302
|
+
/**
|
|
3303
|
+
* Called when tree signing starts.
|
|
3304
|
+
* @param event The tree signing started event.
|
|
3305
|
+
* @param vtxoTree The unsigned virtual output tree, reconstructed from the TreeTxEvent events.
|
|
3306
|
+
* @returns Promise resolving to a boolean indicating whether to continue processing.
|
|
3307
|
+
*/
|
|
3308
|
+
onTreeSigningStarted(event: TreeSigningStartedEvent, vtxoTree: TxTree): Promise<{
|
|
3309
|
+
skip: boolean;
|
|
3310
|
+
}>;
|
|
3311
|
+
/**
|
|
3312
|
+
* Called when tree nonces are received.
|
|
3313
|
+
* @param event The tree nonces event.
|
|
3314
|
+
* @returns Promise resolving to a boolean indicating whether signing is complete.
|
|
3315
|
+
*/
|
|
3316
|
+
onTreeNonces(event: TreeNoncesEvent): Promise<{
|
|
3317
|
+
fullySigned: boolean;
|
|
3318
|
+
}>;
|
|
3319
|
+
/**
|
|
3320
|
+
* Called during batch finalization.
|
|
3321
|
+
* @param event The batch finalization event.
|
|
3322
|
+
* @param vtxoTree The signed virtual output tree, reconstructed from the TreeTxEvent events.
|
|
3323
|
+
* @param connectorTree The connector transaction tree, reconstructed from the TreeTxEvent events.
|
|
3324
|
+
*/
|
|
3325
|
+
onBatchFinalization(event: BatchFinalizationEvent, vtxoTree?: TxTree, connectorTree?: TxTree): Promise<void>;
|
|
3326
|
+
/**
|
|
3327
|
+
* Called when batch finalization completes successfully.
|
|
3328
|
+
*
|
|
3329
|
+
* @param event - Batch finalized event
|
|
3330
|
+
*/
|
|
3331
|
+
onBatchFinalized?(event: BatchFinalizedEvent): Promise<void>;
|
|
3332
|
+
/**
|
|
3333
|
+
* Called when batch processing fails.
|
|
3334
|
+
*
|
|
3335
|
+
* @param event - Batch failed event
|
|
3336
|
+
*/
|
|
3337
|
+
onBatchFailed?(event: BatchFailedEvent): Promise<void>;
|
|
3338
|
+
/**
|
|
3339
|
+
* Called for each virtual output tree transaction chunk received during batch processing.
|
|
3340
|
+
*
|
|
3341
|
+
* @param event - Tree transaction event
|
|
3342
|
+
*/
|
|
3343
|
+
onTreeTxEvent?(event: TreeTxEvent): Promise<void>;
|
|
3344
|
+
/**
|
|
3345
|
+
* Called for each tree signature event received during batch processing.
|
|
3346
|
+
*
|
|
3347
|
+
* @param event - Tree signature event
|
|
3348
|
+
*/
|
|
3349
|
+
onTreeSignatureEvent?(event: TreeSignatureEvent): Promise<void>;
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* Options for the join function.
|
|
3353
|
+
*
|
|
3354
|
+
* @property abortController - Abort controller used to cancel batch processing.
|
|
3355
|
+
* @property skipVtxoTreeSigning - Ignore events related to the virtual output tree musig2 signing session.
|
|
3356
|
+
* @property eventCallback - Callback invoked for each settlement event received while joining the batch.
|
|
3357
|
+
*/
|
|
3358
|
+
type JoinOptions = Partial<{
|
|
3359
|
+
abortController: AbortController;
|
|
3360
|
+
skipVtxoTreeSigning: boolean;
|
|
3361
|
+
eventCallback: (event: SettlementEvent) => Promise<void>;
|
|
3362
|
+
}>;
|
|
3363
|
+
/**
|
|
3364
|
+
* Starts `stream` so the provider subscribes now, before the caller registers an intent whose
|
|
3365
|
+
* batch could otherwise start unseen. The returned iterator replays the first event; pass it
|
|
3366
|
+
* to {@link join}.
|
|
3367
|
+
*/
|
|
3368
|
+
function prime(stream: AsyncIterableIterator<SettlementEvent>): AsyncIterableIterator<SettlementEvent>;
|
|
3369
|
+
/**
|
|
3370
|
+
* Start the state machine that will process the batch events and join a batch.
|
|
3371
|
+
* @param eventIterator - The events stream to process.
|
|
3372
|
+
* @param handler - How to react to events.
|
|
3373
|
+
* @param options - Options.
|
|
3374
|
+
*/
|
|
3375
|
+
function join(eventIterator: AsyncIterableIterator<SettlementEvent>, handler: Handler, options?: JoinOptions): Promise<string>;
|
|
3376
|
+
}
|
|
3377
|
+
|
|
2897
3378
|
/** Delegate identity and fee information returned by `getDelegateInfo`. */
|
|
2898
3379
|
interface DelegateInfo {
|
|
2899
3380
|
/** Delegate public key. */
|
|
@@ -2991,122 +3472,1667 @@ declare class DelegateManagerImpl implements IDelegateManager {
|
|
|
2991
3472
|
}
|
|
2992
3473
|
|
|
2993
3474
|
/**
|
|
2994
|
-
*
|
|
2995
|
-
*
|
|
2996
|
-
* contract (see {@link ContractTapscriptCache}).
|
|
3475
|
+
* Inputs a {@link ReceiveRotatorFactory} gets at boot to find the current display contract or
|
|
3476
|
+
* allocate a fresh descriptor. Allocation only: `resolveBoot` rebuilds the tapscript afterwards.
|
|
2997
3477
|
*/
|
|
2998
|
-
|
|
3478
|
+
interface ReceiveRotatorBootOpts {
|
|
3479
|
+
walletRepository: WalletRepository;
|
|
3480
|
+
contractRepository: ContractRepository;
|
|
3481
|
+
serverPubKey: Uint8Array;
|
|
3482
|
+
/** When set, only this contract family is considered for the current display contract. */
|
|
3483
|
+
expectedContractType?: "default" | "delegate";
|
|
3484
|
+
/**
|
|
3485
|
+
* The wallet's baseline (index-0) x-only receive pubkey, used by {@link
|
|
3486
|
+
* WalletReceiveRotator.defaultBoot} when no tagged receive row exists. Such a wallet never
|
|
3487
|
+
* rotated L2, and the raw watermark can't be used: boarding shares the HD index stream, so a
|
|
3488
|
+
* boarding-only allocation may have advanced it.
|
|
3489
|
+
*/
|
|
3490
|
+
baselineReceivePubKey?: Uint8Array;
|
|
3491
|
+
/** Receives rotation-failure and backoff diagnostics. Defaults to `console`. */
|
|
3492
|
+
logger?: Logger;
|
|
3493
|
+
}
|
|
2999
3494
|
/**
|
|
3000
|
-
*
|
|
3001
|
-
*
|
|
3002
|
-
* cost when annotating large VTXO sets; passing a shared cache across an
|
|
3003
|
-
* annotation batch rebuilds it once per distinct contract instead of once per
|
|
3004
|
-
* VTXO (see #521).
|
|
3495
|
+
* Output of {@link ReceiveRotatorFactory.createReceiveRotator}: the rotator plus the receive
|
|
3496
|
+
* pubkey resolved at boot (existing tagged display contract's, or freshly allocated).
|
|
3005
3497
|
*/
|
|
3006
|
-
|
|
3007
|
-
|
|
3498
|
+
interface ReceiveRotatorBoot {
|
|
3499
|
+
rotator: WalletReceiveRotator;
|
|
3500
|
+
receivePubkey: Uint8Array;
|
|
3501
|
+
}
|
|
3008
3502
|
/**
|
|
3009
|
-
* What
|
|
3010
|
-
*
|
|
3011
|
-
*
|
|
3503
|
+
* What {@link WalletReceiveRotator.resolveBoot} returns: the rotator, the offchain tapscript to
|
|
3504
|
+
* use (rebuilt to the boot pubkey if it differs), and the provider, which the wallet keeps so
|
|
3505
|
+
* spends route per-input signing through {@link DescriptorProvider.signWithDescriptor}.
|
|
3012
3506
|
*/
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3507
|
+
interface ReceiveRotatorBootResult {
|
|
3508
|
+
rotator: WalletReceiveRotator;
|
|
3509
|
+
offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
3510
|
+
provider: DescriptorProvider;
|
|
3511
|
+
}
|
|
3017
3512
|
/**
|
|
3018
|
-
*
|
|
3019
|
-
*
|
|
3513
|
+
* Opt-in {@link DescriptorProvider} extension for providers driving HD receive rotation
|
|
3514
|
+
* (implemented by {@link HDDescriptorProvider}). Kept out of the core interface so
|
|
3515
|
+
* allocate-and-sign providers needn't know the receive lifecycle; without it the wallet uses
|
|
3516
|
+
* {@link WalletReceiveRotator.defaultBoot}.
|
|
3020
3517
|
*/
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3518
|
+
interface ReceiveRotatorFactory {
|
|
3519
|
+
createReceiveRotator(opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot | undefined>;
|
|
3520
|
+
}
|
|
3521
|
+
/**
|
|
3522
|
+
* Parse the trailing HD child index from a materialized signing descriptor
|
|
3523
|
+
* (`tr(...xpub.../0/<index>)`). Returns 0 when absent or unparseable: restore registers the
|
|
3524
|
+
* index-0 baseline untagged, so a missing descriptor legitimately means 0.
|
|
3525
|
+
*/
|
|
3526
|
+
declare function signingDescriptorIndex(descriptor: unknown): number;
|
|
3527
|
+
/**
|
|
3528
|
+
* Strict {@link signingDescriptorIndex}: `undefined` instead of the 0 fallback, for callers
|
|
3529
|
+
* (e.g. watermark moves) where mapping "unparseable" to 0 would silently do nothing.
|
|
3530
|
+
*/
|
|
3531
|
+
declare function strictSigningDescriptorIndex(descriptor: string): number | undefined;
|
|
3532
|
+
/** Minimal logging surface the rotator needs; `console` or any structured logger satisfies it. */
|
|
3533
|
+
interface Logger {
|
|
3534
|
+
error(message: string, ...args: unknown[]): void;
|
|
3535
|
+
}
|
|
3536
|
+
/**
|
|
3537
|
+
* The wallet surface the rotator needs at runtime. An interface to avoid a circular dependency on
|
|
3538
|
+
* `wallet.ts`; `Wallet` satisfies it structurally.
|
|
3539
|
+
*/
|
|
3540
|
+
interface RotatableWallet {
|
|
3541
|
+
readonly defaultContractScript: string;
|
|
3542
|
+
readonly network: {
|
|
3543
|
+
hrp: string;
|
|
3544
|
+
};
|
|
3545
|
+
readonly arkServerPublicKey: Uint8Array;
|
|
3546
|
+
readonly offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
3033
3547
|
/**
|
|
3034
|
-
*
|
|
3035
|
-
*
|
|
3548
|
+
* @internal Sole sanctioned write path for `offchainTapscript` after construction; called
|
|
3549
|
+
* once per rotation after the new display contract is persisted.
|
|
3036
3550
|
*/
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3551
|
+
setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
|
|
3552
|
+
getContractManager(): Promise<IContractManager>;
|
|
3553
|
+
getAddress(): Promise<string>;
|
|
3040
3554
|
}
|
|
3041
|
-
|
|
3042
3555
|
/**
|
|
3043
|
-
*
|
|
3556
|
+
* Owns the wallet's HD receive-rotation lifecycle; exists only when `walletMode` resolves to a
|
|
3557
|
+
* {@link DescriptorProvider}.
|
|
3044
3558
|
*
|
|
3045
|
-
*
|
|
3046
|
-
*
|
|
3047
|
-
*
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
/**
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3559
|
+
* 1. `resolveBoot()` (before Wallet construction): reuse the display contract's pubkey or
|
|
3560
|
+
* allocate the first descriptor.
|
|
3561
|
+
* 2. `install(wallet)`: subscribe to `vtxo_received` and rotate on matching events.
|
|
3562
|
+
* 3. `dispose()`: unsubscribe and drain any in-flight rotation.
|
|
3563
|
+
*
|
|
3564
|
+
* NArk parity: the provider is a pure allocator; the current address comes from the contract
|
|
3565
|
+
* repository, not the provider.
|
|
3566
|
+
*/
|
|
3567
|
+
declare class WalletReceiveRotator {
|
|
3568
|
+
private readonly provider;
|
|
3569
|
+
private unsubscribe?;
|
|
3570
|
+
private chain;
|
|
3571
|
+
/**
|
|
3572
|
+
* Script of the latest tagged display contract, retired by the next `rotate()`. `undefined`
|
|
3573
|
+
* means the untagged index-0 baseline is displayed, which must NOT be deactivated.
|
|
3574
|
+
*/
|
|
3575
|
+
private currentTaggedScript;
|
|
3576
|
+
/** Drives exponential backoff so a broken provider isn't hammered on every inbound VTXO. */
|
|
3577
|
+
private consecutiveFailures;
|
|
3578
|
+
/** Unix ms before which `vtxo_received` events skip rotation; 0 = no backoff. */
|
|
3579
|
+
private nextRotationAllowedAt;
|
|
3580
|
+
private readonly logger;
|
|
3581
|
+
private constructor();
|
|
3061
3582
|
/**
|
|
3062
|
-
*
|
|
3063
|
-
*
|
|
3583
|
+
* Resolve `walletMode` to a provider and build the rotator (via its
|
|
3584
|
+
* {@link ReceiveRotatorFactory}, else {@link defaultBoot}). Returns `undefined` for the
|
|
3585
|
+
* static path.
|
|
3064
3586
|
*
|
|
3065
|
-
*
|
|
3587
|
+
* Resolution errors propagate for `'hd'` and explicit providers (degrading would hide
|
|
3588
|
+
* misconfig); a {@link NonRangeableDescriptorError} is swallowed only under `'auto'`, for
|
|
3589
|
+
* back-compat with identities whose descriptor isn't rangeable.
|
|
3066
3590
|
*/
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
* A single `Discoverable` handler's discovery failure, captured during a
|
|
3071
|
-
* {@link IContractManager.scanContracts} run instead of aborting the loop.
|
|
3072
|
-
*/
|
|
3073
|
-
interface HandlerError {
|
|
3074
|
-
handler: string;
|
|
3075
|
-
/** The failed index, or the first index of a failed `discoverRange` window. */
|
|
3076
|
-
fromIndex: number;
|
|
3077
|
-
/** Inclusive end of a failed `discoverRange` window; absent for a single index. */
|
|
3078
|
-
toIndex?: number;
|
|
3079
|
-
error: unknown;
|
|
3080
|
-
}
|
|
3081
|
-
/** Outcome of a {@link IContractManager.scanContracts} run. */
|
|
3082
|
-
interface ScanResult {
|
|
3591
|
+
static resolveBoot(config: WalletConfig, setup: ReceiveRotatorBootOpts & {
|
|
3592
|
+
offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
3593
|
+
}): Promise<ReceiveRotatorBootResult | undefined>;
|
|
3083
3594
|
/**
|
|
3084
|
-
*
|
|
3085
|
-
*
|
|
3086
|
-
*
|
|
3595
|
+
* Default boot any {@link ReceiveRotatorFactory.createReceiveRotator} can delegate to: take
|
|
3596
|
+
* the current display contract from the repository, else allocate/derive the receive pubkey.
|
|
3597
|
+
* Tapscript construction is deliberately left to `resolveBoot`.
|
|
3087
3598
|
*/
|
|
3088
|
-
|
|
3599
|
+
static defaultBoot(provider: DescriptorProvider, opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot>;
|
|
3089
3600
|
/**
|
|
3090
|
-
*
|
|
3091
|
-
*
|
|
3092
|
-
* scan closed a genuine gap.
|
|
3601
|
+
* Subscribe to `vtxo_received` and rotate whenever the current display contract receives
|
|
3602
|
+
* funds. Old display contracts stay watched, so earlier shared addresses keep crediting.
|
|
3093
3603
|
*/
|
|
3094
|
-
|
|
3095
|
-
/** Per-handler discovery failures. Non-empty implies `truncatedAt` is set. */
|
|
3096
|
-
handlerErrors: HandlerError[];
|
|
3097
|
-
}
|
|
3098
|
-
/** Options for {@link IContractManager.scanContracts}. */
|
|
3099
|
-
interface ScanContractsOptions {
|
|
3100
|
-
/** Default 20. A non-positive / non-integer value throws. */
|
|
3101
|
-
gapLimit?: number;
|
|
3604
|
+
install(wallet: RotatableWallet): Promise<void>;
|
|
3102
3605
|
/**
|
|
3103
|
-
*
|
|
3104
|
-
*
|
|
3105
|
-
* is independent of it. A non-positive / non-integer value throws. Ignored when `hd` is false.
|
|
3606
|
+
* One rotation attempt with exponential backoff. Errors are logged, not rethrown, so `chain`
|
|
3607
|
+
* never rejects and the next `vtxo_received` still runs.
|
|
3106
3608
|
*/
|
|
3107
|
-
|
|
3108
|
-
/**
|
|
3109
|
-
|
|
3609
|
+
private runRotateWithBackoff;
|
|
3610
|
+
/** Wait for any in-flight rotation to complete (mainly for tests). */
|
|
3611
|
+
drain(): Promise<void>;
|
|
3612
|
+
/**
|
|
3613
|
+
* Run `fn` on the rotation chain. {@link Wallet.rotateServerSigner} uses it because both it
|
|
3614
|
+
* and `rotate()` swap `offchainTapscript`; interleaving could tear the visible receive state.
|
|
3615
|
+
* The chain advances even if `fn` rejects (the caller still sees the rejection).
|
|
3616
|
+
*/
|
|
3617
|
+
runExclusive<T>(fn: () => Promise<T>): Promise<T>;
|
|
3618
|
+
/**
|
|
3619
|
+
* Unsubscribe first so no late event queues work, then drain so an in-flight
|
|
3620
|
+
* `createContract` finishes before the contract manager disposes.
|
|
3621
|
+
*/
|
|
3622
|
+
dispose(): Promise<void>;
|
|
3623
|
+
/**
|
|
3624
|
+
* Allocate the next descriptor, register it as the new tagged display contract (same
|
|
3625
|
+
* default/delegate shape), swap it in, and mark the previous tagged one `inactive` (still
|
|
3626
|
+
* watched; it just stops being advertised). The untagged index-0 baseline is never retired.
|
|
3627
|
+
*/
|
|
3628
|
+
private rotate;
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
/**
|
|
3632
|
+
* Capability a wallet exposes so descriptor-blind consumers (Boltz swaps, other plugins) can bind
|
|
3633
|
+
* artifacts to the wallet's current HD index and later enumerate every used index. Probed
|
|
3634
|
+
* structurally ({@link isHDWalletCapable}) rather than widening `IWallet`, so plugins keep working
|
|
3635
|
+
* against older wallets; a static wallet answers "no HD state" through the same methods.
|
|
3636
|
+
*/
|
|
3637
|
+
interface HDWalletCapable {
|
|
3638
|
+
/**
|
|
3639
|
+
* The descriptor at the wallet's current receive index, or `undefined` for
|
|
3640
|
+
* static / `auto` wallets and HD wallets that have never rotated. Callers
|
|
3641
|
+
* fall back to the identity key.
|
|
3642
|
+
*/
|
|
3643
|
+
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
3644
|
+
/**
|
|
3645
|
+
* Every descriptor the wallet may hold keys under, ascending by index: the allocation
|
|
3646
|
+
* watermark's band plus any descriptor persisted on a contract. Empty for static wallets.
|
|
3647
|
+
* `lookAhead` appends that many past the watermark without advancing it, for restore probing.
|
|
3648
|
+
*/
|
|
3649
|
+
getUsedSigningDescriptors(opts?: {
|
|
3650
|
+
lookAhead?: number;
|
|
3651
|
+
}): Promise<string[]>;
|
|
3652
|
+
/**
|
|
3653
|
+
* An {@link Identity} whose keys and signatures are those of `descriptor`; the wallet
|
|
3654
|
+
* identity itself when `descriptor` is the identity's own key.
|
|
3655
|
+
*
|
|
3656
|
+
* Throws {@link ForeignDescriptorError} for a descriptor this wallet cannot sign for — never
|
|
3657
|
+
* substitutes another key, which would sign happily and surface only as a rejected tx or a
|
|
3658
|
+
* dead script. The returned identity must actually sign (`sign`, `signMessage`,
|
|
3659
|
+
* `signerSession`): `contractSigner` refuses a watch-only one as `WalletCannotSignError`,
|
|
3660
|
+
* which would otherwise pass every check and throw after the contract is funded.
|
|
3661
|
+
*/
|
|
3662
|
+
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds no key for the
|
|
3666
|
+
* descriptor, so callers can tell "not my key" from transient signing failures.
|
|
3667
|
+
*/
|
|
3668
|
+
declare class ForeignDescriptorError extends Error {
|
|
3669
|
+
readonly descriptor: string;
|
|
3670
|
+
readonly name = "ForeignDescriptorError";
|
|
3671
|
+
constructor(descriptor: string, options?: {
|
|
3672
|
+
cause?: unknown;
|
|
3673
|
+
});
|
|
3674
|
+
}
|
|
3675
|
+
/**
|
|
3676
|
+
* Thrown by `Wallet.getNewAddresses({ forceNew: true })` when there is no HD stream to advance
|
|
3677
|
+
* (`walletMode: 'static'` / `'auto'`, or a {@link DescriptorProvider} that declined). Typed
|
|
3678
|
+
* rather than a silent repeat, which would surface only as two payers sharing a script.
|
|
3679
|
+
*/
|
|
3680
|
+
declare class WalletCannotAllocateAddressError extends Error {
|
|
3681
|
+
readonly name = "WalletCannotAllocateAddressError";
|
|
3682
|
+
constructor(reason: string, options?: {
|
|
3683
|
+
cause?: unknown;
|
|
3684
|
+
});
|
|
3685
|
+
}
|
|
3686
|
+
/** Anything that can derive and sign for a descriptor it claims. */
|
|
3687
|
+
type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
|
|
3688
|
+
/**
|
|
3689
|
+
* The identity that signs `descriptor`, or {@link ForeignDescriptorError}. Shared by every
|
|
3690
|
+
* {@link HDWalletCapable.signerForDescriptor} so page- and worker-side wallets cannot drift into
|
|
3691
|
+
* a signer that passes a pubkey check and then throws on every signature, after funding.
|
|
3692
|
+
*/
|
|
3693
|
+
declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
|
|
3694
|
+
/** Structural type guard for {@link HDWalletCapable}. */
|
|
3695
|
+
declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
3696
|
+
/**
|
|
3697
|
+
* Allocating a *fresh* index — strictly more than {@link HDWalletCapable}'s descriptor awareness.
|
|
3698
|
+
* A separate probe because widening that guard would silently demote every wallet implementing
|
|
3699
|
+
* only its original surface (including older SDKs') from HD-capable to static.
|
|
3700
|
+
*/
|
|
3701
|
+
interface HDAllocationCapable {
|
|
3702
|
+
/**
|
|
3703
|
+
* The signing descriptor a new artifact (swap, invoice, contract) should bind to. **The
|
|
3704
|
+
* wallet decides**: an HD wallet allocates a fresh index, advancing the watermark; a static
|
|
3705
|
+
* wallet answers with its one `tr(pubkey)` every time. Consumers must not probe the wallet's
|
|
3706
|
+
* shape or mint key material; they use the answer with
|
|
3707
|
+
* {@link HDWalletCapable.signerForDescriptor}.
|
|
3708
|
+
*
|
|
3709
|
+
* `undefined` only for implementations that genuinely cannot answer (`Wallet` always
|
|
3710
|
+
* answers); callers then fall back to the identity key — never a random one.
|
|
3711
|
+
*
|
|
3712
|
+
* Unlike {@link HDWalletCapable.getCurrentSigningDescriptor}, which peeks (two artifacts bound
|
|
3713
|
+
* to a peek share a key). Per-call uniqueness is a wallet property, so anything deriving
|
|
3714
|
+
* per-artifact secrets must check the descriptor's shape, not the wallet's.
|
|
3715
|
+
*/
|
|
3716
|
+
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
3717
|
+
/**
|
|
3718
|
+
* Move the allocation watermark to `descriptor`'s index so later allocations cannot reissue
|
|
3719
|
+
* it. Monotonic; a static wallet accepts its own descriptor as a no-op.
|
|
3720
|
+
*
|
|
3721
|
+
* Throws on a descriptor this wallet cannot derive, or an HD descriptor with no parseable
|
|
3722
|
+
* trailing index: mapping those to index 0 would let a restored artifact's index be reissued.
|
|
3723
|
+
*/
|
|
3724
|
+
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
3725
|
+
}
|
|
3726
|
+
/** Structural type guard for {@link HDAllocationCapable}. */
|
|
3727
|
+
declare function isHDAllocationCapable(value: unknown): value is HDAllocationCapable;
|
|
3728
|
+
/**
|
|
3729
|
+
* Minting addresses to hand out: beyond {@link HDAllocationCapable}'s bare index, the wallet
|
|
3730
|
+
* builds the scripts, persists them as watched contracts, and reports the rows. A third probe
|
|
3731
|
+
* for the same no-silent-demotion reason.
|
|
3732
|
+
*/
|
|
3733
|
+
interface AddressAllocationCapable {
|
|
3734
|
+
/**
|
|
3735
|
+
* Fresh addresses of each requested type from one newly allocated HD index, persisted and
|
|
3736
|
+
* watched. An HD wallet burns an index; a wallet with no stream answers with its existing
|
|
3737
|
+
* display addresses or, under `forceNew`, throws {@link WalletCannotAllocateAddressError}.
|
|
3738
|
+
*
|
|
3739
|
+
* Unlike {@link HDAllocationCapable.getNextSigningDescriptor}, allocation and script
|
|
3740
|
+
* registration happen together: split across a process boundary, a failed registration
|
|
3741
|
+
* leaves a burnt index and an unwatched address.
|
|
3742
|
+
*/
|
|
3743
|
+
getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
|
|
3744
|
+
}
|
|
3745
|
+
/** Structural type guard for {@link AddressAllocationCapable}. */
|
|
3746
|
+
declare function isAddressAllocationCapable(value: unknown): value is AddressAllocationCapable;
|
|
3747
|
+
|
|
3748
|
+
/**
|
|
3749
|
+
* Cap on HD descriptors getUsedSigningDescriptors() materializes past the watermark (bounds
|
|
3750
|
+
* plugin/restore probes; the watermark itself is not moved).
|
|
3751
|
+
*/
|
|
3752
|
+
declare const MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD = 1000;
|
|
3753
|
+
type IncomingFunds = {
|
|
3754
|
+
type: "utxo";
|
|
3755
|
+
coins: Coin[];
|
|
3756
|
+
} | {
|
|
3757
|
+
type: "vtxo";
|
|
3758
|
+
newVtxos: ExtendedVirtualCoin[];
|
|
3759
|
+
spentVtxos: ExtendedVirtualCoin[];
|
|
3760
|
+
};
|
|
3761
|
+
/**
|
|
3762
|
+
* Capability contract for a wallet that can report newly received funds.
|
|
3763
|
+
*
|
|
3764
|
+
* Kept as its own interface rather than on the wallet interfaces because not every wallet
|
|
3765
|
+
* implements it (the service-worker and Expo wallets do not), matching the repo's
|
|
3766
|
+
* capability-interface pattern. Lets helpers depend on just this one method instead of the
|
|
3767
|
+
* whole Wallet class.
|
|
3768
|
+
*/
|
|
3769
|
+
interface NotifiesIncomingFunds {
|
|
3770
|
+
notifyIncomingFunds(eventCallback: (coins: IncomingFunds) => void): Promise<() => void>;
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
/**
|
|
3774
|
+
* Structural rather than {@link ContractWithVtxos} so the worker's repository-built snapshot
|
|
3775
|
+
* (VTXOs without `contractScript`) classifies without a parallel array.
|
|
3776
|
+
*/
|
|
3777
|
+
type PendingRecoverySnapshot = Parameters<typeof selectPendingRecoveryOutpoints>[0];
|
|
3778
|
+
/**
|
|
3779
|
+
* Boarding UTXOs grouped by boarding address, with that address's signer. A flat
|
|
3780
|
+
* {@link ExtendedCoin} can't carry it: it keeps only the encoded leaves, not the owning script's
|
|
3781
|
+
* `serverPubKey` or CSV delay, which deprecated-signer classification needs.
|
|
3782
|
+
*/
|
|
3783
|
+
interface BoardingUtxoGroup {
|
|
3784
|
+
/** Tapscript of the boarding address the coins sit on. */
|
|
3785
|
+
tapscript: DefaultVtxo.Script;
|
|
3786
|
+
/** Operator key of that address, normalized x-only hex. */
|
|
3787
|
+
serverPubKey: string;
|
|
3788
|
+
/** CSV exit timelock decoded from THIS tapscript's exit leaf. */
|
|
3789
|
+
csvTimelock: RelativeTimelock;
|
|
3790
|
+
coins: ExtendedCoin[];
|
|
3791
|
+
}
|
|
3792
|
+
/**
|
|
3793
|
+
* Why a VTXO at an arkadeCash address could neither be swept nor imported for
|
|
3794
|
+
* recovery by {@link Wallet.claimCash}.
|
|
3795
|
+
*
|
|
3796
|
+
* - `subdust` — below dust, so it sits at an OP_RETURN script with no spendable
|
|
3797
|
+
* leaf. Unspendable as cash; `createCash` prevents minting these.
|
|
3798
|
+
* - `already-spent` — someone else claimed it first.
|
|
3799
|
+
* - `exited` — unilaterally exited onchain, so the offchain sweep cannot reach it;
|
|
3800
|
+
* `Unroll.completeUnroll` is the remedy.
|
|
3801
|
+
* - `has-assets` — asset-bearing; the BTC-only sweep would burn the assets.
|
|
3802
|
+
* - `sweep-failed` — spendable, but its own sweep was rejected.
|
|
3803
|
+
* - `recovery-failed` — operator-swept and recoverable in principle, but the
|
|
3804
|
+
* import that hands it to the wallet's recovery machinery failed.
|
|
3805
|
+
*
|
|
3806
|
+
* An output the operator swept whose import *succeeds* is not reported here — it lands
|
|
3807
|
+
* in {@link ArkadeCashClaimResult.recovering} instead.
|
|
3808
|
+
*/
|
|
3809
|
+
type ArkadeCashUnclaimedReason = "subdust" | "already-spent" | "exited" | "has-assets" | "sweep-failed" | "recovery-failed";
|
|
3810
|
+
/** Minimal outpoint + value identifying a VTXO in a claim report. */
|
|
3811
|
+
interface ArkadeCashVtxoRef {
|
|
3812
|
+
txid: string;
|
|
3813
|
+
vout: number;
|
|
3814
|
+
/** Value in satoshis. */
|
|
3815
|
+
value: number;
|
|
3816
|
+
}
|
|
3817
|
+
/** A VTXO {@link Wallet.claimCash} left behind, with the reason why. */
|
|
3818
|
+
interface ArkadeCashUnclaimedVtxo extends ArkadeCashVtxoRef {
|
|
3819
|
+
reason: ArkadeCashUnclaimedReason;
|
|
3820
|
+
}
|
|
3821
|
+
/**
|
|
3822
|
+
* Outcome of {@link Wallet.claimCash}: what was swept instantly, what was
|
|
3823
|
+
* imported for background recovery, and what was left behind.
|
|
3824
|
+
*
|
|
3825
|
+
* The shape is open — further buckets may be added as more of the
|
|
3826
|
+
* non-sweepable states become claimable.
|
|
3827
|
+
*/
|
|
3828
|
+
interface ArkadeCashClaimResult {
|
|
3829
|
+
/**
|
|
3830
|
+
* The Arkade transactions registered by successful sweeps, each with the sats it paid this
|
|
3831
|
+
* wallet.
|
|
3832
|
+
*/
|
|
3833
|
+
claims?: ArkadeCashTx[];
|
|
3834
|
+
/** Satoshis swept to this wallet instantly (the thin single-key sweep). */
|
|
3835
|
+
swept: number;
|
|
3836
|
+
/**
|
|
3837
|
+
* Operator-swept outputs imported for recovery. These funds are not in the
|
|
3838
|
+
* wallet yet: a swept VTXO can only move through a settlement, so
|
|
3839
|
+
* `claimCash` imports it as a signable contract and hands it to the
|
|
3840
|
+
* wallet's own recovery machinery, which settles it back (rotation-aware)
|
|
3841
|
+
* on the normal retry cadence. The amount arrives as a fresh VTXO once
|
|
3842
|
+
* that settlement finalizes.
|
|
3843
|
+
*/
|
|
3844
|
+
recovering: {
|
|
3845
|
+
/** Satoshis imported for recovery. */
|
|
3846
|
+
amount: number;
|
|
3847
|
+
vtxos: ArkadeCashVtxoRef[];
|
|
3848
|
+
};
|
|
3849
|
+
unclaimed: {
|
|
3850
|
+
/** Satoshis left behind. */
|
|
3851
|
+
amount: number;
|
|
3852
|
+
vtxos: ArkadeCashUnclaimedVtxo[];
|
|
3853
|
+
};
|
|
3854
|
+
}
|
|
3855
|
+
/**
|
|
3856
|
+
* Thrown when {@link Wallet.createCash}'s `send` fails after the transaction may already have been
|
|
3857
|
+
* submitted. `cash` carries the private key of the funded output: discard it and the sats may be
|
|
3858
|
+
* stranded. Persist it; {@link Wallet.claimCash} recovers the funds whether or not the send landed.
|
|
3859
|
+
*/
|
|
3860
|
+
declare class ArkadeCashCreateError extends Error {
|
|
3861
|
+
/** The encoded arkadeCash token controlling the funded output. */
|
|
3862
|
+
readonly cash: string;
|
|
3863
|
+
/** The original failure from `send`. */
|
|
3864
|
+
readonly cause: unknown;
|
|
3865
|
+
constructor(
|
|
3866
|
+
/** The encoded arkadeCash token controlling the funded output. */
|
|
3867
|
+
cash: string,
|
|
3868
|
+
/** The original failure from `send`. */
|
|
3869
|
+
cause: unknown);
|
|
3870
|
+
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Thrown by {@link Wallet.claimCash} when the arkadeCash comes from another operator. Its signer
|
|
3873
|
+
* is not the connected operator's active signer, and it is not in the operator's list of
|
|
3874
|
+
* deprecated signers either. Nothing is queried or signed. To claim it, connect to the operator
|
|
3875
|
+
* that issued it.
|
|
3876
|
+
*/
|
|
3877
|
+
declare class ArkadeCashOperatorMismatchError extends Error {
|
|
3878
|
+
/** The signer in the arkadeCash script, x-only hex. */
|
|
3879
|
+
readonly cashSignerPubKey: string;
|
|
3880
|
+
/** The active signer of the connected operator, x-only hex. */
|
|
3881
|
+
readonly activeSignerPubKey: string;
|
|
3882
|
+
constructor(
|
|
3883
|
+
/** The signer in the arkadeCash script, x-only hex. */
|
|
3884
|
+
cashSignerPubKey: string,
|
|
3885
|
+
/** The active signer of the connected operator, x-only hex. */
|
|
3886
|
+
activeSignerPubKey: string);
|
|
3887
|
+
}
|
|
3888
|
+
/**
|
|
3889
|
+
* Freshness of provider-backed sync (operator info source + indexer-sync health). Balances/VTXOs
|
|
3890
|
+
* are always served from the repository regardless. `syncing` says a provider sync is in flight
|
|
3891
|
+
* right now; optional so adding it breaks no implementer, {@link ReadonlyWallet} always sets it.
|
|
3892
|
+
*/
|
|
3893
|
+
type ProviderConnectionState = {
|
|
3894
|
+
mode: "online";
|
|
3895
|
+
syncing?: boolean;
|
|
3896
|
+
source: "live";
|
|
3897
|
+
lastOnlineAt: number;
|
|
3898
|
+
} | {
|
|
3899
|
+
mode: "degraded";
|
|
3900
|
+
syncing?: boolean;
|
|
3901
|
+
source: "cache" | "repository";
|
|
3902
|
+
provider: ProviderKind;
|
|
3903
|
+
reason: string;
|
|
3904
|
+
lastOnlineAt?: number;
|
|
3905
|
+
};
|
|
3906
|
+
declare class ReadonlyWallet implements IReadonlyWallet {
|
|
3907
|
+
readonly identity: ReadonlyIdentity;
|
|
3908
|
+
readonly network: Network;
|
|
3909
|
+
readonly onchainProvider: OnchainProvider;
|
|
3910
|
+
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
3911
|
+
protected readonly arkProvider: Pick<OperatorProvider, "getInfo">;
|
|
3912
|
+
readonly indexerProvider: IndexerProvider;
|
|
3913
|
+
readonly dustAmount: bigint;
|
|
3914
|
+
readonly walletRepository: WalletRepository;
|
|
3915
|
+
readonly contractRepository: ContractRepository;
|
|
3916
|
+
readonly delegateProvider?: DelegateProvider | undefined;
|
|
3917
|
+
protected lazyInitialization: boolean;
|
|
3918
|
+
private boardingLoaded;
|
|
3919
|
+
private _contractManager?;
|
|
3920
|
+
private _contractManagerInitializing?;
|
|
3921
|
+
protected readonly watcherConfig?: ReadonlyWalletConfig["watcherConfig"];
|
|
3922
|
+
protected vtxoSyncOverlapMs?: number;
|
|
3923
|
+
protected copySyncOverlapTo(wallet: ReadonlyWallet): void;
|
|
3924
|
+
/** Opt-in intent-lifecycle repository; `undefined` ⇒ intent persistence is a no-op. */
|
|
3925
|
+
intentRepository?: BatchRegistrationRepository;
|
|
3926
|
+
/**
|
|
3927
|
+
* **Experimental / inert.** Opt-in virtual-tx repository, exposed so callers can pass it to
|
|
3928
|
+
* {@link Unroll.Session.create} as a best-effort raw-tx cache. Normal sync never writes it.
|
|
3929
|
+
*/
|
|
3930
|
+
virtualTxRepository?: VirtualTxRepository;
|
|
3931
|
+
/** Opt-in exit-data capture settings; see {@link StorageConfig.exitDataCapture}. */
|
|
3932
|
+
exitDataCapture?: {
|
|
3933
|
+
mode?: ExitCaptureMode;
|
|
3934
|
+
minExitWorthSats?: number;
|
|
3935
|
+
sources?: ExitDataSource[];
|
|
3936
|
+
};
|
|
3937
|
+
private readonly _assetManager;
|
|
3938
|
+
readonly walletContractTimelocks: RelativeTimelock[];
|
|
3939
|
+
protected _pendingSpendOutpoints: Set<string>;
|
|
3940
|
+
protected _heldOutpoints: Set<string>;
|
|
3941
|
+
/** Activity resolvers consumed by {@link getActivityHistory}. */
|
|
3942
|
+
readonly activity: ActivityRegistry;
|
|
3943
|
+
get assetManager(): IReadonlyAssetManager;
|
|
3944
|
+
/**
|
|
3945
|
+
* Active receive tapscript; written only by {@link Wallet.setOffchainTapscriptForRotation}
|
|
3946
|
+
* (sole intended caller: {@link WalletReceiveRotator.rotate}).
|
|
3947
|
+
*/
|
|
3948
|
+
protected _offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
3949
|
+
/**
|
|
3950
|
+
* Current boarding tapscript (QR / onboarding target); written only by
|
|
3951
|
+
* {@link Wallet.setBoardingTapscriptForRotation}. Static / `auto` wallets never rotate it.
|
|
3952
|
+
*/
|
|
3953
|
+
protected _boardingTapscript: DefaultVtxo.Script;
|
|
3954
|
+
/**
|
|
3955
|
+
* Active operator signer (x-only); written only by
|
|
3956
|
+
* {@link Wallet.setArkServerPublicKeyForRotation} when arkd rotates its signer mid-session.
|
|
3957
|
+
*/
|
|
3958
|
+
protected _arkServerPublicKey: Bytes;
|
|
3959
|
+
/**
|
|
3960
|
+
* Whether the LATEST operator info resolution was live or fell back to the cached snapshot.
|
|
3961
|
+
* Updated on every {@link getOperatorInfo} read so recovery (or a fresh fallback) is reflected.
|
|
3962
|
+
*/
|
|
3963
|
+
protected _serverInfoSource: ServerInfoSource;
|
|
3964
|
+
/**
|
|
3965
|
+
* Epoch-ms of the last live operator contact, or the cached snapshot's `savedAt` when the
|
|
3966
|
+
* latest resolution fell back.
|
|
3967
|
+
*/
|
|
3968
|
+
protected _serverInfoLastOnlineAt?: number;
|
|
3969
|
+
/** @see {@link _serverInfoSource} */
|
|
3970
|
+
get serverInfoSource(): ServerInfoSource;
|
|
3971
|
+
/**
|
|
3972
|
+
* Composed provider-connection freshness: degraded on `arkade` (`cache`) when the latest
|
|
3973
|
+
* operator info resolution fell back, else degraded on `indexer` (`repository`) when an
|
|
3974
|
+
* initialized contract manager has, else online. Never forces a `ContractManager` to
|
|
3975
|
+
* construct, so it is safe for readonly callers.
|
|
3976
|
+
*/
|
|
3977
|
+
getProviderConnectionState(): ProviderConnectionState;
|
|
3978
|
+
/**
|
|
3979
|
+
* The contract manager's sync health **without initializing it** (`online` if none exists),
|
|
3980
|
+
* so unlike {@link getContractManager} it never triggers a remote sync.
|
|
3981
|
+
*/
|
|
3982
|
+
getContractSyncState(): ContractSyncState;
|
|
3983
|
+
protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider,
|
|
3984
|
+
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
3985
|
+
arkProvider: Pick<OperatorProvider, "getInfo">, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider | undefined, watcherConfig?: ReadonlyWalletConfig["watcherConfig"], walletContractTimelocks?: RelativeTimelock[]);
|
|
3986
|
+
/**
|
|
3987
|
+
* x-only hex → cutoff of the operator's deprecated signers, cached for OFFLINE read/watch.
|
|
3988
|
+
* Boarding watch/history fan out over {current} ∪ this set so deposits at addresses minted
|
|
3989
|
+
* under a rotated signer stay watched. Deliberately NOT used by the spend path:
|
|
3990
|
+
* {@link getBoardingUtxos} stays current-signer-only (a deprecated-signer input in a plain
|
|
3991
|
+
* settle() is rejected; recovery goes through the migration API).
|
|
3992
|
+
*/
|
|
3993
|
+
protected _deprecatedSigners: Map<string, bigint>;
|
|
3994
|
+
/**
|
|
3995
|
+
* Refresh the cached deprecated-signer set from operator info; feeds
|
|
3996
|
+
* {@link pendingRecoveryOutpoints}. Lenient: a malformed entry is skipped, never fatal.
|
|
3997
|
+
*/
|
|
3998
|
+
refreshDeprecatedSigners(info: {
|
|
3999
|
+
deprecatedSigners?: readonly {
|
|
4000
|
+
pubkey?: string;
|
|
4001
|
+
cutoffDate?: bigint;
|
|
4002
|
+
}[];
|
|
4003
|
+
}): void;
|
|
4004
|
+
/** Boarding WATCH/HISTORY signer set: current ∪ deprecated (spend stays current-only). */
|
|
4005
|
+
protected watchedBoardingSigners(): Set<string>;
|
|
4006
|
+
/**
|
|
4007
|
+
* `serverPubKey` defaults to the live key; spend paths that snapshot it
|
|
4008
|
+
* against mid-flight rotation pass their snapshot, so the check reads from
|
|
4009
|
+
* one rotation epoch.
|
|
4010
|
+
*/
|
|
4011
|
+
protected recipientAddressContext(serverPubKey?: Bytes): RecipientArkadeAddressContext;
|
|
4012
|
+
/** Currently-active receive tapscript; changes only on receive rotation. */
|
|
4013
|
+
get offchainTapscript(): DefaultVtxo.Script | DelegateVtxo.Script;
|
|
4014
|
+
/** Current active server signer (x-only, 32 bytes); changes only on server-signer rotation. */
|
|
4015
|
+
get arkServerPublicKey(): Bytes;
|
|
4016
|
+
/**
|
|
4017
|
+
* Info for the connected operator: live wins, a retryable failure falls back to
|
|
4018
|
+
* the boot snapshot, a terminal one propagates. Live because `signerPubkey`,
|
|
4019
|
+
* `checkpointTapscript` and `fees` move on rotation, and a covenant built against a
|
|
4020
|
+
* superseded signer is unspendable.
|
|
4021
|
+
*
|
|
4022
|
+
* @remarks Reading does NOT re-pin the wallet ({@link arkServerPublicKey}, {@link dustAmount},
|
|
4023
|
+
* tapscripts), so inside a rotation window this can report epoch N+1 while the wallet spends
|
|
4024
|
+
* on N; the provider's `onServerInfoChanged` closes the window. Pass `{ requireLive: true }`
|
|
4025
|
+
* before binding the answer into a covenant to fail closed instead of getting the snapshot.
|
|
4026
|
+
*
|
|
4027
|
+
* @returns The operator's info
|
|
4028
|
+
* @see OperatorInfo
|
|
4029
|
+
*/
|
|
4030
|
+
getOperatorInfo(opts?: GetOperatorInfoOptions): Promise<OperatorInfo>;
|
|
4031
|
+
/** @deprecated Use {@link getOperatorInfo}. */
|
|
4032
|
+
getArkadeInfo(opts?: GetOperatorInfoOptions): Promise<OperatorInfo>;
|
|
4033
|
+
/**
|
|
4034
|
+
* Chain reads against this wallet's operator for scripts it does not own, bound to the wallet's
|
|
4035
|
+
* own (possibly Expo/injected) `indexerProvider`. `getVtxos` normalizes via
|
|
4036
|
+
* {@link getNormalizedVtxos}. A bound object, not the provider, so an `IReadonlyWallet`
|
|
4037
|
+
* holder gets these two reads and nothing else.
|
|
4038
|
+
*/
|
|
4039
|
+
getArkadeReader(): Promise<ArkadeReader>;
|
|
4040
|
+
/**
|
|
4041
|
+
* Current boarding tapscript (on-chain onboarding target); changes only when a fresh boarding
|
|
4042
|
+
* address is explicitly allocated.
|
|
4043
|
+
*/
|
|
4044
|
+
get boardingTapscript(): DefaultVtxo.Script;
|
|
4045
|
+
/**
|
|
4046
|
+
* Fired after boarding rotation so a live {@link notifyIncomingFunds} watcher re-subscribes
|
|
4047
|
+
* to the fresh address in-session instead of missing deposits until its next re-init.
|
|
4048
|
+
*/
|
|
4049
|
+
private readonly _boardingRotationListeners;
|
|
4050
|
+
/** Register a listener invoked synchronously after each boarding rotation. */
|
|
4051
|
+
protected onBoardingRotation(listener: () => void): () => void;
|
|
4052
|
+
/** A throwing listener is isolated: it can't break the rotation or starve siblings. */
|
|
4053
|
+
protected notifyBoardingRotation(): void;
|
|
4054
|
+
/** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
|
|
4055
|
+
protected static setupWalletConfig(config: ReadonlyWalletConfig, pubKey: Uint8Array): Promise<{
|
|
4056
|
+
arkProvider: OperatorProvider;
|
|
4057
|
+
indexerProvider: IndexerProvider;
|
|
4058
|
+
onchainProvider: OnchainProvider | EsploraProvider;
|
|
4059
|
+
network: Network;
|
|
4060
|
+
networkName: NetworkName;
|
|
4061
|
+
serverPubKey: Uint8Array<ArrayBufferLike>;
|
|
4062
|
+
offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
|
|
4063
|
+
boardingTapscript: DefaultVtxo.Script;
|
|
4064
|
+
dustAmount: bigint;
|
|
4065
|
+
walletRepository: WalletRepository | IndexedDBWalletRepository;
|
|
4066
|
+
contractRepository: ContractRepository;
|
|
4067
|
+
info: OperatorInfo;
|
|
4068
|
+
serverInfoSource: ServerInfoSource;
|
|
4069
|
+
serverInfoLastOnlineAt: number | undefined;
|
|
4070
|
+
delegateProvider: DelegateProvider | undefined;
|
|
4071
|
+
walletContractTimelocks: RelativeTimelock[];
|
|
4072
|
+
}>;
|
|
4073
|
+
/**
|
|
4074
|
+
* Create a readonly wallet for querying balances, addresses, and history.
|
|
4075
|
+
*
|
|
4076
|
+
* @param config - Readonly wallet configuration
|
|
4077
|
+
* @returns A readonly wallet instance
|
|
4078
|
+
*/
|
|
4079
|
+
static create<T extends ReadonlyWallet>(this: {
|
|
4080
|
+
prototype: T;
|
|
4081
|
+
}, config: ReadonlyWalletConfig): Promise<T>;
|
|
4082
|
+
static create(config: ReadonlyWalletConfig): Promise<ReadonlyWallet>;
|
|
4083
|
+
get arkAddress(): ArkAddress;
|
|
4084
|
+
/**
|
|
4085
|
+
* Get the pkScript hex for the wallet's primary offchain address.
|
|
4086
|
+
* For the full wallet-owned script set registered in ContractManager, use getWalletScripts().
|
|
4087
|
+
*/
|
|
4088
|
+
get defaultContractScript(): string;
|
|
4089
|
+
/** Returns the wallet's Arkade address. */
|
|
4090
|
+
getAddress(): Promise<string>;
|
|
4091
|
+
/** Returns the onchain boarding address used to move funds into Arkade. */
|
|
4092
|
+
getBoardingAddress(): Promise<string>;
|
|
4093
|
+
/**
|
|
4094
|
+
* Return the wallet's combined onchain and offchain balances.
|
|
4095
|
+
*/
|
|
4096
|
+
getBalance(): Promise<WalletBalance>;
|
|
4097
|
+
/** Cached balance; inspect connection state and boarding.loaded before displaying zeros. */
|
|
4098
|
+
getStoredBalance(): Promise<WalletBalance>;
|
|
4099
|
+
private balanceFromSnapshot;
|
|
4100
|
+
/**
|
|
4101
|
+
* Return virtual outputs tracked by the wallet, including escrowed, locked and
|
|
4102
|
+
* awaiting-recovery funds. Coin selection must use {@link getSpendableVtxos}: feeding this
|
|
4103
|
+
* into `settle({ inputs })` or `send({ selectedVtxos })` bypasses the generic-spending gate.
|
|
4104
|
+
*
|
|
4105
|
+
* @param filter - Optional flags controlling whether recoverable or unrolled VTXOs are included
|
|
4106
|
+
*/
|
|
4107
|
+
getVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
4108
|
+
/** Cached VTXOs; may be empty before the first sync. Never use for coin selection. */
|
|
4109
|
+
getStoredVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
4110
|
+
/**
|
|
4111
|
+
* @internal The stored VTXOs {@link reserveVtxos} holds, minus any being spent: for renewal,
|
|
4112
|
+
* which skips them, to report the ones it would have renewed. No sync.
|
|
4113
|
+
*/
|
|
4114
|
+
getHeldVtxos(): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
4115
|
+
/** @inheritdoc */
|
|
4116
|
+
getSpendableVtxos(filter?: GetSpendableVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
4117
|
+
/**
|
|
4118
|
+
* Debug-log any explicit input generic selection would have excluded. Explicit-input APIs stay
|
|
4119
|
+
* ungated on purpose (naming an outpoint *is* the intent, and is how an escrowed deposit is
|
|
4120
|
+
* recovered), so this only makes the crossing visible — notably
|
|
4121
|
+
* `settle({ inputs: await wallet.getVtxos() })`. Never throws. Public for worker and plugins.
|
|
4122
|
+
*/
|
|
4123
|
+
logUngatedInputs(source: string, inputs: readonly {
|
|
4124
|
+
txid: string;
|
|
4125
|
+
vout: number;
|
|
4126
|
+
script?: string;
|
|
4127
|
+
}[]): Promise<void>;
|
|
4128
|
+
/**
|
|
4129
|
+
* Past-cutoff-signer contracts as a script-level exclusion: the `pendingRecovery` answer for a
|
|
4130
|
+
* caller-supplied input without a synced snapshot (a swept outpoint is unspendable anyway).
|
|
4131
|
+
*/
|
|
4132
|
+
private expiredSignerExclusion;
|
|
4133
|
+
/** Spending must stop when persisted ownership cannot be read. */
|
|
4134
|
+
protected lockedOutpoints(): Promise<Set<string>>;
|
|
4135
|
+
/**
|
|
4136
|
+
* One contract+VTXO read (which may sync against the indexer). Callers needing several views
|
|
4137
|
+
* derive them all from one snapshot so they answer about the same instant.
|
|
4138
|
+
*/
|
|
4139
|
+
protected contractSnapshot(filter?: GetSpendableVtxosFilter, options?: {
|
|
4140
|
+
unspentOnly?: boolean;
|
|
4141
|
+
}): Promise<ContractWithVtxos[]>;
|
|
4142
|
+
protected contractSnapshotStored(): Promise<ContractWithVtxos[]>;
|
|
4143
|
+
/**
|
|
4144
|
+
* The two exclusion sets the gate is made of, derived from one snapshot so
|
|
4145
|
+
* {@link getSpendableVtxos} and the balance answer about the same instant.
|
|
4146
|
+
*/
|
|
4147
|
+
private spendabilityView;
|
|
4148
|
+
/** The capability probes {@link computeOffchainBalance} needs, over one snapshot. */
|
|
4149
|
+
private balanceCapabilities;
|
|
4150
|
+
/**
|
|
4151
|
+
* Outpoints of not-yet-swept VTXOs whose deprecated signer is past its cutoff (EXPIRED) —
|
|
4152
|
+
* unspendable until they recover; excluded by {@link getBalance} and {@link getSpendableVtxos}.
|
|
4153
|
+
* Takes a fresh (syncing) snapshot; callers that hold one or must not sync use
|
|
4154
|
+
* {@link pendingRecoveryOutpointsIn}.
|
|
4155
|
+
*/
|
|
4156
|
+
pendingRecoveryOutpoints(): Promise<Set<string>>;
|
|
4157
|
+
/** {@link pendingRecoveryOutpoints} over a caller-held snapshot; no I/O of its own. */
|
|
4158
|
+
pendingRecoveryOutpointsIn(snapshot: PendingRecoverySnapshot): Set<string>;
|
|
4159
|
+
private selectPendingRecovery;
|
|
4160
|
+
/**
|
|
4161
|
+
* Return wallet transaction history derived from Arkade state and boarding transactions.
|
|
4162
|
+
*/
|
|
4163
|
+
getTransactionHistory(): Promise<ArkTransaction[]>;
|
|
4164
|
+
/**
|
|
4165
|
+
* Wallet history grouped by registered activity resolvers. With no resolver match,
|
|
4166
|
+
* rows bucket by transaction key so send/change pairs stay together.
|
|
4167
|
+
*/
|
|
4168
|
+
getActivityHistory(): Promise<Activity[]>;
|
|
4169
|
+
/**
|
|
4170
|
+
* Clear the global VTXO sync cursor, forcing a full re-bootstrap on next sync.
|
|
4171
|
+
* Useful for recovery after indexer reprocessing or debugging.
|
|
4172
|
+
*/
|
|
4173
|
+
clearSyncCursor(): Promise<void>;
|
|
4174
|
+
/**
|
|
4175
|
+
* Wipe all locally persisted wallet data (VTXOs, UTXOs, history, sync
|
|
4176
|
+
* cursor, contracts, intents). Create a fresh wallet instance afterward.
|
|
4177
|
+
* Intents are kept while any may still be held by arkd, so a later
|
|
4178
|
+
* reconciliation can release them with their stored proofs.
|
|
4179
|
+
*/
|
|
4180
|
+
clear(): Promise<void>;
|
|
4181
|
+
private clearIntents;
|
|
4182
|
+
/**
|
|
4183
|
+
* On-chain (P2TR) addresses of every boarding tapscript this wallet uses, current plus
|
|
4184
|
+
* historical rotated, so deposits at old addresses still surface; {@link getBoardingAddress}
|
|
4185
|
+
* stays single-valued.
|
|
4186
|
+
*/
|
|
4187
|
+
getBoardingAddresses(): Promise<string[]>;
|
|
4188
|
+
/** Transaction history across the wallet's boarding addresses (current + historical). */
|
|
4189
|
+
getBoardingTxs(): Promise<{
|
|
4190
|
+
boardingTxs: ArkTransaction[];
|
|
4191
|
+
commitmentsToIgnore: Set<string>;
|
|
4192
|
+
}>;
|
|
4193
|
+
/**
|
|
4194
|
+
* Every boarding tapscript whose UTXOs belong to this wallet (rotation spreads them over
|
|
4195
|
+
* several addresses), deduplicated by scriptPubKey. Includes index-0 `default` rows when a
|
|
4196
|
+
* baseline boarding script coalesced with one.
|
|
4197
|
+
*
|
|
4198
|
+
* @param allowedSigners - x-only operator keys whose persisted boarding rows are included;
|
|
4199
|
+
* defaults to the current signer (the foreign-ASP guard). Migration widens it to old signers.
|
|
4200
|
+
* The baseline and current display tapscript are included regardless.
|
|
4201
|
+
*/
|
|
4202
|
+
protected getBoardingTapscripts(allowedSigners?: Set<string>): Promise<DefaultVtxo.Script[]>;
|
|
4203
|
+
/**
|
|
4204
|
+
* Fetch and cache onchain inputs (UTXOs) received at the boarding addresses
|
|
4205
|
+
* of the given signer set, grouped per boarding address so the caller keeps
|
|
4206
|
+
* the address↔signer association that {@link ExtendedCoin} cannot carry
|
|
4207
|
+
* (it retains only the encoded leaves/tapTree the spend needs, not the
|
|
4208
|
+
* `DefaultVtxo.Script` and its `serverPubKey`/CSV delay).
|
|
4209
|
+
*
|
|
4210
|
+
* Per group: `getCoins` (a failure throws), then `ContractManager.syncOnchain`,
|
|
4211
|
+
* then the fetched coins minus stored-spent outpoints → {@link extendCoinWithTapscript}.
|
|
4212
|
+
* It does not call `getInfo()`; the caller supplies the allowed signer set.
|
|
4213
|
+
*
|
|
4214
|
+
* @param allowedSigners - x-only-hex operator keys whose boarding addresses to
|
|
4215
|
+
* fetch (passed through to {@link getBoardingTapscripts}).
|
|
4216
|
+
* @param skipFailedSigners - x-only-hex server keys whose address lookups may fail: that
|
|
4217
|
+
* address is left out of the result and its cache untouched, instead of failing the whole
|
|
4218
|
+
* fetch. A lookup under any other signer still rejects.
|
|
4219
|
+
*/
|
|
4220
|
+
getBoardingUtxosForSigners(allowedSigners: Set<string>, skipFailedSigners?: ReadonlySet<string>): Promise<BoardingUtxoGroup[]>;
|
|
4221
|
+
/** `undefined` when a lookup under one of `skipFailedSigners` failed or timed out. */
|
|
4222
|
+
private fetchBoardingCoins;
|
|
4223
|
+
/**
|
|
4224
|
+
* Fetch and cache boarding UTXOs at current and historical boarding addresses, each annotated
|
|
4225
|
+
* with its own address's tapscript so spends use the right per-index leaves. Current-signer
|
|
4226
|
+
* only: old-signer inputs would make a plain `settle()` the operator must reject, so their
|
|
4227
|
+
* recovery goes through the deprecated-signer migration API.
|
|
4228
|
+
*/
|
|
4229
|
+
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
4230
|
+
/**
|
|
4231
|
+
* @internal {@link getBoardingUtxos} minus those an in-flight settle is spending or an
|
|
4232
|
+
* unresolved intent locks, for SDK picks. The getter itself lists them: callers that mirror it
|
|
4233
|
+
* (the worker's cache and broadcasts, balances) must not see a settle's inputs vanish, and then
|
|
4234
|
+
* stay gone if it fails.
|
|
4235
|
+
*/
|
|
4236
|
+
getSelectableBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
4237
|
+
/**
|
|
4238
|
+
* @internal {@link getSelectableBoardingUtxos} for every boarding address history shows,
|
|
4239
|
+
* current and deprecated signers, grouped by signer. Only the boarding sweep reads it: a
|
|
4240
|
+
* unilateral exit needs no operator, so it recovers coins that `settle` must not take.
|
|
4241
|
+
*/
|
|
4242
|
+
getSelectableBoardingUtxoGroups(): Promise<BoardingUtxoGroup[]>;
|
|
4243
|
+
/** Boarding coins from the store, no network call; pending and confirmed spends excluded. */
|
|
4244
|
+
getStoredBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
4245
|
+
/**
|
|
4246
|
+
* Subscribe to onchain and offchain notifications for newly received funds.
|
|
4247
|
+
*
|
|
4248
|
+
* The onchain watcher tracks every boarding address (current + historical) and re-subscribes
|
|
4249
|
+
* automatically when boarding rotates after subscribing, so deposits to a fresh address fire
|
|
4250
|
+
* within the same session.
|
|
4251
|
+
*
|
|
4252
|
+
* @param eventCallback - Callback invoked when matching funds are detected
|
|
4253
|
+
* @returns A function that stops the subscriptions
|
|
4254
|
+
*/
|
|
4255
|
+
notifyIncomingFunds(eventCallback: (coins: IncomingFunds) => void): Promise<() => void>;
|
|
4256
|
+
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
4257
|
+
fetchPendingTxs(): Promise<string[]>;
|
|
4258
|
+
/**
|
|
4259
|
+
* Get all pkScript hex strings for the wallet's own addresses
|
|
4260
|
+
* (both delegate and non-delegate, current and historical).
|
|
4261
|
+
*/
|
|
4262
|
+
getWalletScripts(): Promise<string[]>;
|
|
4263
|
+
/**
|
|
4264
|
+
* Build a map of scriptHex → VtxoScript for all wallet contracts,
|
|
4265
|
+
* so virtual outputs can be extended with the correct tapscript per contract.
|
|
4266
|
+
*/
|
|
4267
|
+
getScriptMap(): Promise<Map<string, DefaultVtxo.Script | DelegateVtxo.Script>>;
|
|
4268
|
+
/**
|
|
4269
|
+
* Get the ContractManager, which manages the wallet's own receive contracts and external ones
|
|
4270
|
+
* (Boltz swaps, HTLCs, …) with resilient multi-contract watching.
|
|
4271
|
+
*
|
|
4272
|
+
* @example
|
|
4273
|
+
* ```typescript
|
|
4274
|
+
* const manager = await wallet.getContractManager();
|
|
4275
|
+
*
|
|
4276
|
+
* // Create a contract for a Boltz swap
|
|
4277
|
+
* const contract = await manager.createContract({
|
|
4278
|
+
* label: "Boltz Swap",
|
|
4279
|
+
* type: "vhtlc",
|
|
4280
|
+
* params: { ... },
|
|
4281
|
+
* script: swapScript,
|
|
4282
|
+
* address: swapAddress,
|
|
4283
|
+
* });
|
|
4284
|
+
*
|
|
4285
|
+
* // Start watching for events (includes wallet's default address)
|
|
4286
|
+
* const stop = await manager.onContractEvent((event) => {
|
|
4287
|
+
* console.log(`${event.type} on ${event.contractScript}`);
|
|
4288
|
+
* });
|
|
4289
|
+
* ```
|
|
4290
|
+
*/
|
|
4291
|
+
getContractManager(): Promise<ContractManager>;
|
|
4292
|
+
/**
|
|
4293
|
+
* HD look-ahead configuration for the contract manager. Readonly wallets
|
|
4294
|
+
* have no descriptor provider, hence no watermark to look ahead of.
|
|
4295
|
+
* @see Wallet.lookAheadConfig
|
|
4296
|
+
*/
|
|
4297
|
+
protected lookAheadConfig(): ContractManagerConfig["lookAhead"];
|
|
4298
|
+
/** Readonly wallets never settle, so they neither release nor own batch registrations. */
|
|
4299
|
+
protected intentReconciliationConfig(): ContractManagerConfig["intentReconciliation"];
|
|
4300
|
+
private initializeContractManager;
|
|
4301
|
+
/** Dispose wallet-owned managers and release background resources. */
|
|
4302
|
+
dispose(): Promise<void>;
|
|
4303
|
+
/** Async-dispose hook that forwards to `dispose()`. */
|
|
4304
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
4305
|
+
}
|
|
4306
|
+
/**
|
|
4307
|
+
* Main wallet implementation for Bitcoin transactions with Arkade protocol support.
|
|
4308
|
+
*
|
|
4309
|
+
* @example
|
|
4310
|
+
* ```typescript
|
|
4311
|
+
* // Create a wallet with providers
|
|
4312
|
+
* const wallet = await Wallet.create({
|
|
4313
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
4314
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
4315
|
+
* onchainProvider: new EsploraProvider()
|
|
4316
|
+
* });
|
|
4317
|
+
*
|
|
4318
|
+
* // Use custom providers and/or URLs (e.g., for Expo/React Native)
|
|
4319
|
+
* const wallet = await Wallet.create({
|
|
4320
|
+
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
4321
|
+
* operatorProvider: new ExpoOperatorProvider('https://arkade.computer'),
|
|
4322
|
+
* indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
|
|
4323
|
+
* onchainProvider: new EsploraProvider('https://mempool.space/api')
|
|
4324
|
+
* });
|
|
4325
|
+
*
|
|
4326
|
+
* // Get addresses
|
|
4327
|
+
* const arkAddress = await wallet.getAddress();
|
|
4328
|
+
* const boardingAddress = await wallet.getBoardingAddress();
|
|
4329
|
+
*
|
|
4330
|
+
* // Send bitcoin
|
|
4331
|
+
* const txid = await wallet.send({
|
|
4332
|
+
* address: 'ark1q...',
|
|
4333
|
+
* amount: 50000,
|
|
4334
|
+
* });
|
|
4335
|
+
* ```
|
|
4336
|
+
*/
|
|
4337
|
+
declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable, AddressAllocationCapable {
|
|
4338
|
+
readonly forfeitOutputScript: Bytes;
|
|
4339
|
+
readonly forfeitPubkey: Bytes;
|
|
4340
|
+
/** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
|
|
4341
|
+
protected readonly batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined;
|
|
4342
|
+
/** @see WalletConfig.oneShotSubmit */
|
|
4343
|
+
readonly oneShotSubmit: boolean;
|
|
4344
|
+
static MIN_FEE_RATE: number;
|
|
4345
|
+
readonly identity: Identity;
|
|
4346
|
+
private readonly _delegateManager?;
|
|
4347
|
+
private _vtxoManager?;
|
|
4348
|
+
private _vtxoManagerInitializing?;
|
|
4349
|
+
private _walletAssetManager?;
|
|
4350
|
+
/**
|
|
4351
|
+
* HD receive rotator; absent for `static` and SingleKey-under-`auto` wallets. Its subscription
|
|
4352
|
+
* installs lazily on first `getVtxoManager()` so the contract manager is up first.
|
|
4353
|
+
*/
|
|
4354
|
+
private _receiveRotator?;
|
|
4355
|
+
/** Unsubscribe for `onServerInfoChanged` (mid-session signer rotation). */
|
|
4356
|
+
private _serverInfoUnsub?;
|
|
4357
|
+
/**
|
|
4358
|
+
* Tail of the serialized {@link handleServerInfoChanged} chain; {@link dispose} awaits it so an
|
|
4359
|
+
* in-flight rotation settles before the contract manager is torn down.
|
|
4360
|
+
*/
|
|
4361
|
+
private _serverInfoInFlight;
|
|
4362
|
+
/**
|
|
4363
|
+
* React to a mid-session operator info change (`DIGEST_MISMATCH`): refresh deprecated signers
|
|
4364
|
+
* first so boarding watch widens immediately, then rotate via {@link rotateServerSigner} only
|
|
4365
|
+
* if the active signer changed. Old-signer rows stay active. Never throws into the emit loop.
|
|
4366
|
+
*/
|
|
4367
|
+
private handleServerInfoChanged;
|
|
4368
|
+
/**
|
|
4369
|
+
* Await an `onServerInfoChanged` handler still applying a rotation. {@link rotateServerSigner}
|
|
4370
|
+
* persists the new signer's rows *before* committing the tapscripts, so a path that refreshes
|
|
4371
|
+
* operator info then reads signer-derived state must drain first or it reads torn state and
|
|
4372
|
+
* races the handler. Resolves once idle; handler rejections are swallowed (already logged).
|
|
4373
|
+
*
|
|
4374
|
+
* @internal Invoked by {@link dispose} and the {@link VtxoManager} migration
|
|
4375
|
+
* pass; not part of the stable public API.
|
|
4376
|
+
*/
|
|
4377
|
+
settleServerInfoChanges(): Promise<void>;
|
|
4378
|
+
private _receiveRotatorInstalled;
|
|
4379
|
+
/**
|
|
4380
|
+
* Descriptor-aware signer for inputs locked by rotated pubkeys (the rotator's instance).
|
|
4381
|
+
* Undefined for static / non-HD wallets, which only sign with the identity.
|
|
4382
|
+
*/
|
|
4383
|
+
private readonly _descriptorProvider?;
|
|
4384
|
+
/**
|
|
4385
|
+
* Keyring holding foreign private keys imported outside the wallet's
|
|
4386
|
+
* derivation tree (see {@link KeyringDescriptorProvider}). Wraps
|
|
4387
|
+
* {@link _descriptorProvider} (or a {@link StaticDescriptorProvider}
|
|
4388
|
+
* over the wallet identity when there is no HD provider) and is the
|
|
4389
|
+
* descriptor provider {@link _signerRouter} actually signs through, so
|
|
4390
|
+
* a contract carrying `metadata.signingDescriptor` for an imported key
|
|
4391
|
+
* is signable by construction.
|
|
4392
|
+
*
|
|
4393
|
+
* Kept separate from {@link _descriptorProvider} on purpose: the latter
|
|
4394
|
+
* still gates HD boarding/receive rotation (a `!provider` check means
|
|
4395
|
+
* "static wallet, no rotation"), and wrapping it with a keyring for
|
|
4396
|
+
* every wallet would break that gate. The keyring is orthogonal — it
|
|
4397
|
+
* only ever adds foreign signable keys, never receive addresses.
|
|
4398
|
+
*
|
|
4399
|
+
* Populated for every {@link Wallet.create}d wallet; the constructor's
|
|
4400
|
+
* param is optional so the router degrades to {@link _descriptorProvider}
|
|
4401
|
+
* if a caller ever omits it.
|
|
4402
|
+
*/
|
|
4403
|
+
private readonly _keyring?;
|
|
4404
|
+
/**
|
|
4405
|
+
* The built-in HD provider behind any keyring wrapping, or `undefined` when there is none.
|
|
4406
|
+
* Every HD-specific branch goes through this: a wrapped HD provider (a public `walletMode`
|
|
4407
|
+
* shape) fails `instanceof HDDescriptorProvider` and would silently take the non-HD path.
|
|
4408
|
+
*/
|
|
4409
|
+
private get _hdProvider();
|
|
4410
|
+
/** Per-side width of the HD look-ahead band. @see WalletConfig.lookAheadWindow */
|
|
4411
|
+
private readonly _lookAheadWindow;
|
|
4412
|
+
protected intentReconciliationConfig(): ContractManagerConfig["intentReconciliation"];
|
|
4413
|
+
/**
|
|
4414
|
+
* Watch a band of receive scripts around the HD watermark so payments to an externally-issued
|
|
4415
|
+
* address land without a `restore()`. HD only. `candidateDeps` is read at refill time, so a
|
|
4416
|
+
* band rebuilt after {@link rotateServerSigner} fans the new signer set.
|
|
4417
|
+
*/
|
|
4418
|
+
protected lookAheadConfig(): ContractManagerConfig["lookAhead"];
|
|
4419
|
+
/**
|
|
4420
|
+
* Every axis an externally issued receive script could use: an issuer sharing the seed (NArk,
|
|
4421
|
+
* a merchant backend) picks its own contract type. From cached state (no `getInfo`) to stay
|
|
4422
|
+
* synchronous and offline-safe.
|
|
4423
|
+
*/
|
|
4424
|
+
private receiveCandidateDeps;
|
|
4425
|
+
private readonly _signerRouter;
|
|
4426
|
+
private _emulator?;
|
|
4427
|
+
private _cosignMarginBlocks;
|
|
4428
|
+
/**
|
|
4429
|
+
* @internal Sole write path for `offchainTapscript`; called by
|
|
4430
|
+
* {@link WalletReceiveRotator.rotate} after the rotated contract is persisted.
|
|
4431
|
+
*/
|
|
4432
|
+
setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
|
|
4433
|
+
/**
|
|
4434
|
+
* @internal Sole write path for `boardingTapscript`; called by
|
|
4435
|
+
* {@link Wallet.getNewBoardingAddress} after the rotated contract is persisted.
|
|
4436
|
+
*/
|
|
4437
|
+
setBoardingTapscriptForRotation(tapscript: DefaultVtxo.Script): void;
|
|
4438
|
+
/**
|
|
4439
|
+
* @internal Sole write path for `arkServerPublicKey`; called by
|
|
4440
|
+
* {@link Wallet.rotateServerSigner} after the rotated rows are persisted.
|
|
4441
|
+
*/
|
|
4442
|
+
setArkServerPublicKeyForRotation(serverPubKey: Bytes): void;
|
|
4443
|
+
/**
|
|
4444
|
+
* Checkpoint output script from the operator's `checkpointTapscript`; pinned at construction,
|
|
4445
|
+
* re-sourced only via {@link setServerUnrollScriptForRotation}.
|
|
4446
|
+
*/
|
|
4447
|
+
protected _serverUnrollScript: CSVMultisigTapscript.Type;
|
|
4448
|
+
get serverUnrollScript(): CSVMultisigTapscript.Type;
|
|
4449
|
+
/**
|
|
4450
|
+
* @internal Sole write path for `serverUnrollScript`; called by
|
|
4451
|
+
* {@link Wallet._doRotateServerSigner} with the rotating `OperatorInfo`'s checkpoint script.
|
|
4452
|
+
*/
|
|
4453
|
+
setServerUnrollScriptForRotation(script: CSVMultisigTapscript.Type): void;
|
|
4454
|
+
/**
|
|
4455
|
+
* Serializes {@link rotateServerSigner} for static / non-HD wallets so two callers can't both
|
|
4456
|
+
* swap the tapscripts; HD wallets use {@link WalletReceiveRotator.runExclusive} instead.
|
|
4457
|
+
*/
|
|
4458
|
+
private _serverRotationChain;
|
|
4459
|
+
/**
|
|
4460
|
+
* Allocate a *fresh* on-chain boarding address at the next index of the shared HD stream and
|
|
4461
|
+
* make it the displayed one (NArk: `GetNextContract(NextContractPurpose.Boarding)`).
|
|
4462
|
+
* Persists an `active` `boarding` contract tagged {@link WALLET_RECEIVE_SOURCE} so it is
|
|
4463
|
+
* watched, restored at boot and signable per index.
|
|
4464
|
+
*
|
|
4465
|
+
* A static / `auto` wallet returns {@link getBoardingAddress} unchanged (no index burned). A
|
|
4466
|
+
* custom {@link DescriptorProvider} wallet burns an index per call, including via
|
|
4467
|
+
* {@link maybeRotateBoardingAfterBoard} on every settle consuming a boarding UTXO; retired
|
|
4468
|
+
* addresses stay reachable through {@link getBoardingUtxos}.
|
|
4469
|
+
*
|
|
4470
|
+
* @deprecated Use {@link getNewAddresses} — it mints any combination of
|
|
4471
|
+
* address types at one shared index, and reports the contract row behind
|
|
4472
|
+
* each. Note the difference in display behaviour: this method *swaps* the
|
|
4473
|
+
* advertised boarding address, where `getNewAddresses` mints side
|
|
4474
|
+
* addresses and leaves {@link getBoardingAddress} alone. To keep this
|
|
4475
|
+
* method's behaviour, keep calling this method.
|
|
4476
|
+
*/
|
|
4477
|
+
getNewBoardingAddress(): Promise<string>;
|
|
4478
|
+
/**
|
|
4479
|
+
* Allocate a *fresh* address of each requested type, all at **one** new HD index. The way to
|
|
4480
|
+
* issue a second address before the first is paid ({@link getAddress} only advances on
|
|
4481
|
+
* receipt). Each is persisted `active` with its `signingDescriptor`, so it is watched,
|
|
4482
|
+
* counted, and signable via {@link signerForDescriptor}; the look-ahead band slides.
|
|
4483
|
+
*
|
|
4484
|
+
* Rows are deliberately **untagged**: boot adopts the newest {@link WALLET_RECEIVE_SOURCE} row
|
|
4485
|
+
* as the display address, and a side address must not become what the wallet advertises.
|
|
4486
|
+
* {@link getAddress} and {@link getBoardingAddress} are unchanged.
|
|
4487
|
+
*
|
|
4488
|
+
* A wallet with no HD stream (`static` / `auto`) returns its persisted display rows, or with
|
|
4489
|
+
* `forceNew` throws {@link WalletCannotAllocateAddressError} rather than return a stale one.
|
|
4490
|
+
*
|
|
4491
|
+
* @example
|
|
4492
|
+
* ```typescript
|
|
4493
|
+
* const [invoice] = await wallet.getNewAddresses({ forceNew: true });
|
|
4494
|
+
* // hand `invoice.address` to Alice, keep the descriptor with the invoice
|
|
4495
|
+
* const signer = await wallet.signerForDescriptor(invoice.signingDescriptor);
|
|
4496
|
+
* ```
|
|
4497
|
+
*/
|
|
4498
|
+
getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
|
|
4499
|
+
/**
|
|
4500
|
+
* Shared core of {@link getNewAddresses} and {@link getNewBoardingAddress}.
|
|
4501
|
+
*
|
|
4502
|
+
* @param tagSource - Tag rows {@link WALLET_RECEIVE_SOURCE} so boot adopts them as the display
|
|
4503
|
+
* address; only the deprecated boarding allocator passes `true`.
|
|
4504
|
+
*/
|
|
4505
|
+
private allocateAddresses;
|
|
4506
|
+
/**
|
|
4507
|
+
* The wallet's existing display addresses as persisted rows, each minted from the descriptor
|
|
4508
|
+
* that owns its display script ({@link displayDescriptor}) so it signs for `address`.
|
|
4509
|
+
*/
|
|
4510
|
+
private currentAddresses;
|
|
4511
|
+
/**
|
|
4512
|
+
* The descriptor owning the current display script for `type`, from its persisted row. Not
|
|
4513
|
+
* derived from the identity: on a rotated wallet that would pair the address with a signer
|
|
4514
|
+
* holding the wrong key. Falls back to the identity's `tr(pubkey)` when no row carries one
|
|
4515
|
+
* (static / `auto`; index-0 baselines have no `signingDescriptor`).
|
|
4516
|
+
*/
|
|
4517
|
+
private displayDescriptor;
|
|
4518
|
+
/**
|
|
4519
|
+
* Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
|
|
4520
|
+
* sole source of the owner key in both branches, so `address` and `signingDescriptor` can't
|
|
4521
|
+
* drift apart.
|
|
4522
|
+
*/
|
|
4523
|
+
private mintAddress;
|
|
4524
|
+
/**
|
|
4525
|
+
* Boarding contract owned by `pubKey`, keeping the current tapscript's other options
|
|
4526
|
+
* (offchain analogue: {@link buildReceiveContract}).
|
|
4527
|
+
*/
|
|
4528
|
+
private buildBoardingContract;
|
|
4529
|
+
/**
|
|
4530
|
+
* @see HDWalletCapable.getCurrentSigningDescriptor
|
|
4531
|
+
*/
|
|
4532
|
+
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
4533
|
+
/**
|
|
4534
|
+
* @see HDAllocationCapable.getNextSigningDescriptor
|
|
4535
|
+
*
|
|
4536
|
+
* Every `Wallet` answers, so consumers never branch on wallet shape: HD allocates through the
|
|
4537
|
+
* contract manager; otherwise the identity key as `tr(pubkey)`, the same every call.
|
|
4538
|
+
*/
|
|
4539
|
+
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
4540
|
+
/**
|
|
4541
|
+
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
4542
|
+
*/
|
|
4543
|
+
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
4544
|
+
/**
|
|
4545
|
+
* @see HDWalletCapable.getUsedSigningDescriptors
|
|
4546
|
+
*
|
|
4547
|
+
* Union of the watermark band (covers indices allocated for unpersisted things, e.g. swaps)
|
|
4548
|
+
* and descriptors persisted on contracts (covers rows a restore scan wrote).
|
|
4549
|
+
*/
|
|
4550
|
+
getUsedSigningDescriptors(opts?: {
|
|
4551
|
+
lookAhead?: number;
|
|
4552
|
+
}): Promise<string[]>;
|
|
4553
|
+
/**
|
|
4554
|
+
* @see HDWalletCapable.signerForDescriptor
|
|
4555
|
+
*
|
|
4556
|
+
* Fail-loud: a descriptor this wallet can't sign for throws {@link ForeignDescriptorError}
|
|
4557
|
+
* rather than substituting the baseline identity, which would sign with the wrong key.
|
|
4558
|
+
*/
|
|
4559
|
+
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
4560
|
+
/**
|
|
4561
|
+
* Mid-session operator signer rotation. A wallet built before the rotation keeps deriving
|
|
4562
|
+
* old-signer receive addresses, and a migration output to one yields an output the operator must
|
|
4563
|
+
* reject, so receive state is re-derived under the new signer first.
|
|
4564
|
+
*
|
|
4565
|
+
* Same write-path as {@link WalletReceiveRotator.rotate} with the operator key swapped: build the
|
|
4566
|
+
* new tapscripts, register their rows (carrying signing metadata so a descriptor-backed
|
|
4567
|
+
* pubkey still signs), and only then commit visible state. Old-signer rows stay `active` for
|
|
4568
|
+
* the migration pass to drain. Idempotent; serialized against HD receive rotation.
|
|
4569
|
+
*
|
|
4570
|
+
* @internal Invoked by the {@link VtxoManager} migration pass; not part of
|
|
4571
|
+
* the stable public API.
|
|
4572
|
+
*/
|
|
4573
|
+
rotateServerSigner(newServerPubKey: Bytes, checkpointTapscript: string): Promise<void>;
|
|
4574
|
+
private _doRotateServerSigner;
|
|
4575
|
+
/**
|
|
4576
|
+
* Serializes `settle`/`send` so VtxoManager's background renewal can't race user
|
|
4577
|
+
* transactions for the same inputs; with `concurrentSpending`, only until inputs are reserved.
|
|
4578
|
+
*/
|
|
4579
|
+
private _txLock;
|
|
4580
|
+
private readonly _settlingOutpoints;
|
|
4581
|
+
/** Coalesces concurrent {@link restore} calls into one scan; cleared on settle. */
|
|
4582
|
+
private _restoreInFlight?;
|
|
4583
|
+
private _addPendingSpends;
|
|
4584
|
+
private _removePendingSpends;
|
|
4585
|
+
/**
|
|
4586
|
+
* Hold VTXOs so no SDK-chosen spend picks them.
|
|
4587
|
+
* All-or-nothing: throws {@link VtxoReservedError} if any is held or already being spent.
|
|
4588
|
+
*
|
|
4589
|
+
* Without `reservationId`: in-memory, for this instance only, and the holder still spends
|
|
4590
|
+
* them by naming them. With it and a `vtxoReservationRepository`: durable, as in the worker
|
|
4591
|
+
* (see {@link reserveVtxosPersistently}); without a repository it stays in-memory.
|
|
4592
|
+
*/
|
|
4593
|
+
reserveVtxos(outpoints: readonly Outpoint[]): VtxoReservation;
|
|
4594
|
+
reserveVtxos(outpoints: readonly Outpoint[], reservationId: string): Promise<VtxoReservation>;
|
|
4595
|
+
private holdVtxos;
|
|
4596
|
+
private reservationRepository?;
|
|
4597
|
+
/** By id. Two ids name one outpoint only when restored from a store two wallets shared. */
|
|
4598
|
+
private persistentReservations;
|
|
4599
|
+
private persistentReservedOutpoints;
|
|
4600
|
+
private reservationWrites;
|
|
4601
|
+
private reservationQueue;
|
|
4602
|
+
private withReservationWrite;
|
|
4603
|
+
isVtxoReserved(outpoint: Outpoint): boolean;
|
|
4604
|
+
/** Restored before automatic spending. Reusing an owner id must name the same inputs. */
|
|
4605
|
+
reserveVtxosPersistently(outpoints: readonly Outpoint[], id: string): Promise<void>;
|
|
4606
|
+
/**
|
|
4607
|
+
* The owner must establish settlement or non-submission before releasing a durable hold.
|
|
4608
|
+
* With `expected`, releases only while `id` still names those inputs: a stale handle leaves a
|
|
4609
|
+
* newer hold under its id alone.
|
|
4610
|
+
*/
|
|
4611
|
+
releaseVtxoReservation(id: string, expected?: readonly Outpoint[]): Promise<void>;
|
|
4612
|
+
/**
|
|
4613
|
+
* @internal For `AssetManager`: reserves what `fn` submits, hiding it from other picks until
|
|
4614
|
+
* the submit ends. With `concurrentSpending`, `fn` runs under the wallet lock, released once
|
|
4615
|
+
* the inputs are reserved; otherwise `fn` runs unlocked and only the submit takes the lock.
|
|
4616
|
+
*/
|
|
4617
|
+
withSpendLock<T>(fn: (submit: OffchainSubmit) => Promise<T>): Promise<T>;
|
|
4618
|
+
private _withTxLock;
|
|
4619
|
+
private _assertNotInFlight;
|
|
4620
|
+
private _assertNotHeld;
|
|
4621
|
+
/**
|
|
4622
|
+
* Explicitly recover this wallet's contracts and balance on a fresh repo: a gap-limit scan
|
|
4623
|
+
* for HD wallets, the single default pubkey otherwise. Throws on operational failure (a
|
|
4624
|
+
* truncated restore is loud), never because of identity/mode. Idempotent.
|
|
4625
|
+
*
|
|
4626
|
+
* Ordering: scan → advance the HD watermark → inline VTXO pull → only THEN surface handler
|
|
4627
|
+
* errors, so safely-discovered funds are recovered even when one handler failed.
|
|
4628
|
+
*
|
|
4629
|
+
* @param opts.gapLimit - Consecutive-unused-index window. Default 20. A non-positive /
|
|
4630
|
+
* non-integer value throws synchronously.
|
|
4631
|
+
*
|
|
4632
|
+
* @note Concurrent calls coalesce onto the running scan; their `gapLimit` is ignored.
|
|
4633
|
+
*/
|
|
4634
|
+
restore(opts?: {
|
|
4635
|
+
gapLimit?: number;
|
|
4636
|
+
}): Promise<void>;
|
|
4637
|
+
private _runRestore;
|
|
4638
|
+
readonly settlementConfig: SettlementConfig | false;
|
|
4639
|
+
private _concurrentSpending;
|
|
4640
|
+
private _submitsAwaitingFinalize;
|
|
4641
|
+
/** @see WalletConfig.concurrentSpending */
|
|
4642
|
+
get concurrentSpending(): boolean;
|
|
4643
|
+
/** Public here; `ReadonlyWallet` keeps it protected so a readonly view can't submit. */
|
|
4644
|
+
readonly arkProvider: OperatorProvider;
|
|
4645
|
+
/**
|
|
4646
|
+
* Broadcast access bound to this wallet's operator, so a plugin needs only the wallet. Not on
|
|
4647
|
+
* {@link ReadonlyWallet}: a readonly wallet or `toReadonly()` view must not be able to submit.
|
|
4648
|
+
*/
|
|
4649
|
+
getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
|
|
4650
|
+
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider: OperatorProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, serverUnrollScript: CSVMultisigTapscript.Type, forfeitOutputScript: Bytes, forfeitPubkey: Bytes, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[], receiveRotator?: WalletReceiveRotator, descriptorProvider?: DescriptorProvider, keyring?: KeyringDescriptorProvider, lookAheadWindow?: number,
|
|
4651
|
+
/** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
|
|
4652
|
+
batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined,
|
|
4653
|
+
/** @see WalletConfig.oneShotSubmit */
|
|
4654
|
+
oneShotSubmit?: boolean);
|
|
4655
|
+
get assetManager(): IAssetManager;
|
|
4656
|
+
getVtxoManager(): Promise<VtxoManager>;
|
|
4657
|
+
/** Also drops durable holds: a cleared wallet's holds would outlive their owner. */
|
|
4658
|
+
clear(): Promise<void>;
|
|
4659
|
+
dispose(): Promise<void>;
|
|
4660
|
+
/**
|
|
4661
|
+
* Create a full wallet and initialize its background managers.
|
|
4662
|
+
*
|
|
4663
|
+
* @param config - Wallet configuration
|
|
4664
|
+
* @returns A wallet ready to query balances and send transactions
|
|
4665
|
+
* @example
|
|
4666
|
+
* ```typescript
|
|
4667
|
+
* const wallet = await Wallet.create({
|
|
4668
|
+
* identity,
|
|
4669
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
4670
|
+
* });
|
|
4671
|
+
* ```
|
|
4672
|
+
*/
|
|
4673
|
+
static create<T extends Wallet>(this: {
|
|
4674
|
+
prototype: T;
|
|
4675
|
+
}, config: WalletConfig): Promise<T>;
|
|
4676
|
+
static create(config: WalletConfig): Promise<Wallet>;
|
|
4677
|
+
/**
|
|
4678
|
+
* Convert this wallet to a readonly wallet.
|
|
4679
|
+
*
|
|
4680
|
+
* @returns A readonly wallet with the same configuration but readonly identity
|
|
4681
|
+
* @example
|
|
4682
|
+
* ```typescript
|
|
4683
|
+
* const wallet = await Wallet.create({ identity: MnemonicIdentity.fromMnemonic('abandon abandon...'), ... });
|
|
4684
|
+
* const readonlyWallet = await wallet.toReadonly();
|
|
4685
|
+
*
|
|
4686
|
+
* // Can query balance and addresses
|
|
4687
|
+
* const balance = await readonlyWallet.getBalance();
|
|
4688
|
+
* const address = await readonlyWallet.getAddress();
|
|
4689
|
+
*
|
|
4690
|
+
* // But cannot send transactions (type error)
|
|
4691
|
+
* // readonlyWallet.send(...); // TypeScript error
|
|
4692
|
+
* ```
|
|
4693
|
+
*/
|
|
4694
|
+
toReadonly(): Promise<ReadonlyWallet>;
|
|
4695
|
+
/** Returns the delegate manager when delegation support is configured. */
|
|
4696
|
+
getDelegateManager(): Promise<IDelegateManager | undefined>;
|
|
4697
|
+
/**
|
|
4698
|
+
* Settle boarding inputs and/or virtual outputs into a finalized mainnet transaction.
|
|
4699
|
+
*
|
|
4700
|
+
* `params.inputs` is **ungated** (how an escrowed deposit is recovered by hand), so
|
|
4701
|
+
* `settle({ inputs: await wallet.getVtxos() })` bypasses the gate; pass
|
|
4702
|
+
* {@link getSpendableVtxos} to settle "whatever is spendable".
|
|
4703
|
+
*
|
|
4704
|
+
* @param params - Optional settlement inputs and outputs. When omitted, the wallet settles all eligible funds.
|
|
4705
|
+
* @param eventCallback - Optional callback invoked for settlement stream events.
|
|
4706
|
+
* @param hooks - Optional phases for preparation and intent registration.
|
|
4707
|
+
* @returns The finalized Arkade transaction id
|
|
4708
|
+
*/
|
|
4709
|
+
settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void, hooks?: {
|
|
4710
|
+
onPhase?: (phase: "preparing" | "registration_attempt") => void;
|
|
4711
|
+
}): Promise<string>;
|
|
4712
|
+
private _settleImpl;
|
|
4713
|
+
/**
|
|
4714
|
+
* Rotate-on-board: the boarding analogue of {@link WalletReceiveRotator}'s L2 rotation.
|
|
4715
|
+
* Boarding has no on-chain receive event (the watcher sees only the L2 indexer), so a settle
|
|
4716
|
+
* consuming a boarding UTXO (a non-VTXO, non-arknote input) is the trigger. No-op without a
|
|
4717
|
+
* descriptor provider. Best-effort: the settle has committed, so failures are only logged.
|
|
4718
|
+
*/
|
|
4719
|
+
private maybeRotateBoardingAfterBoard;
|
|
4720
|
+
private handleSettlementFinalizationEvent;
|
|
4721
|
+
private unsignableBoardingInputError;
|
|
4722
|
+
/**
|
|
4723
|
+
* Create a batch event handler for settlement flows.
|
|
4724
|
+
*
|
|
4725
|
+
* @param intentId - The intent ID.
|
|
4726
|
+
* @param inputs - Inputs used by the intent.
|
|
4727
|
+
* @param expectedRecipients - Expected recipients to validate in the virtual output tree.
|
|
4728
|
+
* @param session - Optional musig2 signing session. When omitted, signing steps are skipped.
|
|
4729
|
+
*/
|
|
4730
|
+
createBatchHandler(intentId: string, inputs: ExtendedCoin[], expectedRecipients: Recipient[], session?: SignerSession): Batch.Handler;
|
|
4731
|
+
/**
|
|
4732
|
+
* Signing jobs keyed by each input's own `witnessUtxo.script`; inputs without one
|
|
4733
|
+
* (cosigner/connector) are silently omitted.
|
|
4734
|
+
*/
|
|
4735
|
+
private inputSigningJobsFromWitnessUtxos;
|
|
4736
|
+
/**
|
|
4737
|
+
* Persists before registration; later snapshots are best effort.
|
|
4738
|
+
* Preserves fields the event reducer already wrote.
|
|
4739
|
+
*/
|
|
4740
|
+
private persistIntentSnapshot;
|
|
4741
|
+
signInputsByWitnessScript(tx: Transaction): Promise<Transaction>;
|
|
4742
|
+
signOnchainBoardingTx(tx: Transaction): Promise<Transaction>;
|
|
4743
|
+
/** @see IWallet.cosignOnchainTx */
|
|
4744
|
+
cosignOnchainTx(psbt: string | Transaction): Promise<string>;
|
|
4745
|
+
/** @see IWallet.sendOnchain */
|
|
4746
|
+
sendOnchain(params: SendOnchainParams): Promise<string>;
|
|
4747
|
+
private _buildOnchainSpend;
|
|
4748
|
+
private _cosignOnchainTxImpl;
|
|
4749
|
+
/** Boarding outpoints the automatic cosign sweep should renew now (never unrolled exits); excludes coins an intent has locked. */
|
|
4750
|
+
getOnchainSweepInputs(): Promise<Outpoint[]>;
|
|
4751
|
+
/** Unspent onchain coins from the store; the onchain rows are kept fresh by syncOnchain, not the indexer. */
|
|
4752
|
+
private onchainCoins;
|
|
4753
|
+
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
4754
|
+
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedProof<Proof.RegisterMessage>>;
|
|
4755
|
+
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedProof<Proof.DeleteMessage>>;
|
|
4756
|
+
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedProof<Proof.GetPendingTxMessage>>;
|
|
4757
|
+
/**
|
|
4758
|
+
* Finalizes pending transactions by retrieving them from the operator and finalizing each one.
|
|
4759
|
+
* Skips the operator check entirely when no send was interrupted (no pending tx flag set).
|
|
4760
|
+
* @param vtxos - Optional list of virtual outputs to use instead of retrieving them from the operator
|
|
4761
|
+
* @returns Array of transaction IDs that were finalized
|
|
4762
|
+
*/
|
|
4763
|
+
finalizePendingTxs(vtxos?: ExtendedVirtualCoin[]): Promise<{
|
|
4764
|
+
finalized: string[];
|
|
4765
|
+
pending: string[];
|
|
4766
|
+
}>;
|
|
4767
|
+
/**
|
|
4768
|
+
* Operator unroll scripts a pending checkpoint may have been built under: configured, current,
|
|
4769
|
+
* and one per deprecated signer — else a pre-rotation tx would stay pending forever.
|
|
4770
|
+
*/
|
|
4771
|
+
private checkpointUnrollCandidates;
|
|
4772
|
+
private hasPendingTxFlag;
|
|
4773
|
+
private setPendingTxFlag;
|
|
4774
|
+
/**
|
|
4775
|
+
* Create an ArkadeCash bearer instrument: sends `amount` to a DefaultVtxo controlled by a fresh
|
|
4776
|
+
* key and returns the encoded token, claimable via `claimCash()` without sharing an address.
|
|
4777
|
+
*
|
|
4778
|
+
* Short-lived: it carries a private key, so hand it over and claim it promptly. Unclaimed past
|
|
4779
|
+
* its batch expiry it is swept, and `claimCash` can only report it.
|
|
4780
|
+
*
|
|
4781
|
+
* @param amount - Whole sats at or above dust (below dust mints an unspendable OP_RETURN).
|
|
4782
|
+
* @returns The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
4783
|
+
*/
|
|
4784
|
+
createCash(amount: number): Promise<string>;
|
|
4785
|
+
/**
|
|
4786
|
+
* Claim an ArkadeCash bearer instrument: sweep what can be swept, recover what
|
|
4787
|
+
* was swept by the operator, report the rest.
|
|
4788
|
+
*
|
|
4789
|
+
* Every spendable VTXO at the arkadeCash address is swept to this wallet in
|
|
4790
|
+
* its own offchain transaction, signed with the key carried by the arkadeCash
|
|
4791
|
+
* string. An output the operator already swept at batch expiry cannot move
|
|
4792
|
+
* through the thin sweep — only a settlement can lift it — so it is
|
|
4793
|
+
* **imported** as a signable `default` contract (the arkadeCash key is filed
|
|
4794
|
+
* in the keyring) and handed to the wallet's own recovery machinery, which
|
|
4795
|
+
* settles it back on the normal retry cadence. That import is the only
|
|
4796
|
+
* thing `claimCash` persists, and the key is purged once recovery
|
|
4797
|
+
* completes. Anything neither sweepable nor recoverable — subdust, already
|
|
4798
|
+
* claimed, or asset-bearing — is returned in `unclaimed` with a per-VTXO
|
|
4799
|
+
* reason and otherwise ignored.
|
|
4800
|
+
*
|
|
4801
|
+
* The arkadeCash string is the recovery token: a claim interrupted between
|
|
4802
|
+
* submit and finalize is completed by simply re-running `claimCash`, which
|
|
4803
|
+
* drains any pending arkadeCash transaction at the operator before sweeping.
|
|
4804
|
+
* The import is idempotent, so re-running is always safe.
|
|
4805
|
+
*
|
|
4806
|
+
* @param cashStr - The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
4807
|
+
* @returns What was swept instantly, what was imported for recovery, and
|
|
4808
|
+
* what was left behind. The shape is open: further buckets may be added.
|
|
4809
|
+
*/
|
|
4810
|
+
claimCash(cashStr: string): Promise<ArkadeCashClaimResult>;
|
|
4811
|
+
/**
|
|
4812
|
+
* Import an arkadeCash instrument as a signable, recovery-only contract so the
|
|
4813
|
+
* wallet's own recovery machinery can settle its operator-swept outputs back.
|
|
4814
|
+
*
|
|
4815
|
+
* Two writes, both idempotent so a re-run (or a resumed claim) is safe:
|
|
4816
|
+
* - the arkadeCash private key is filed in the keyring, returning its
|
|
4817
|
+
* `tr(<pubkey>)` descriptor;
|
|
4818
|
+
* - a `default` contract for the arkadeCash script is registered carrying that
|
|
4819
|
+
* descriptor as `metadata.signingDescriptor` (so the signer router can
|
|
4820
|
+
* sign the swept inputs) and `metadata.recoveryOnly` (so the contract is
|
|
4821
|
+
* settled in its own isolated intent, never bundled into the wallet's own
|
|
4822
|
+
* renewal/recovery — a persistently rejected input then dents only its
|
|
4823
|
+
* own recovery, never the wallet's funds).
|
|
4824
|
+
*
|
|
4825
|
+
* A row may already exist at the script WITHOUT the recovery flags — the
|
|
4826
|
+
* public `createContract` surface lets a consumer register the cash
|
|
4827
|
+
* address (e.g. to watch a note it issued) — and `createContract`'s
|
|
4828
|
+
* same-type idempotency keeps such a row as-is. It is then promoted:
|
|
4829
|
+
* presenting the bearer key IS the authorization to claim, and left
|
|
4830
|
+
* unflagged the row would feed unsignable swept VTXOs into the wallet's
|
|
4831
|
+
* own settles while being invisible to both the isolated recovery pass
|
|
4832
|
+
* and `removeRecoveryContract`'s purge.
|
|
4833
|
+
*/
|
|
4834
|
+
private importArkadeCashForRecovery;
|
|
4835
|
+
/** Best-effort, non-blocking trigger of the isolated imported-recovery pass. */
|
|
4836
|
+
private kickImportedRecovery;
|
|
4837
|
+
/**
|
|
4838
|
+
* Retire a contract imported for recovery once its funds have been settled
|
|
4839
|
+
* back: purge the keyring key that backed it, then delete the contract row.
|
|
4840
|
+
* Ends the key-at-rest window opened by {@link importArkadeCashForRecovery}.
|
|
4841
|
+
*
|
|
4842
|
+
* Scoped to recovery-only contracts as a safety guard — it will not touch a
|
|
4843
|
+
* regular wallet contract — and idempotent: a second call (the contract
|
|
4844
|
+
* already gone) is a no-op. Invoked by the isolated recovery pass in
|
|
4845
|
+
* `VtxoManager` (see its `RecoveryContractCapableWallet` capability).
|
|
4846
|
+
*
|
|
4847
|
+
* The write order is load-bearing; do not swap it. The two repositories
|
|
4848
|
+
* cannot be written atomically, so one of them leaks on a partial failure.
|
|
4849
|
+
* Purging the key first leaves a contract row with a dangling descriptor:
|
|
4850
|
+
* visible, harmless, and retried to completion by the next recovery pass
|
|
4851
|
+
* (its VTXOs read back spent, so nothing is signed). The reverse leaves an
|
|
4852
|
+
* unencrypted key that nothing references — the descriptor lived only in
|
|
4853
|
+
* the row just deleted — so no retry can ever find it, breaking the
|
|
4854
|
+
* purge-on-completion bound that justifies storing it in the clear.
|
|
4855
|
+
*/
|
|
4856
|
+
removeRecoveryContract(script: string): Promise<void>;
|
|
4857
|
+
/**
|
|
4858
|
+
* Correlate an imported voucher's settlement with the voucher record. This
|
|
4859
|
+
* is deliberately kept on wallet state rather than being inferred from the
|
|
4860
|
+
* generic recovery row, which has no safe public correlation key. The
|
|
4861
|
+
* imported contract carries no cash id, so its script is the join key:
|
|
4862
|
+
* the script is the voucher id.
|
|
4863
|
+
*/
|
|
4864
|
+
correlateArkadeCashRecovery(cashId: string, txid: string, amount: number, outcome?: string): Promise<void>;
|
|
4865
|
+
/**
|
|
4866
|
+
* Split the VTXOs at an arkadeCash address into three buckets: the ones the
|
|
4867
|
+
* thin sweep can move (`spendable`), the operator-swept ones that must go
|
|
4868
|
+
* through a recovery settlement (`recoverable`), and the ones that can
|
|
4869
|
+
* only be reported (`unclaimed`).
|
|
4870
|
+
*/
|
|
4871
|
+
private classifyCashVtxos;
|
|
4872
|
+
/** Read every page of an unfiltered VTXO query for the given scripts. */
|
|
4873
|
+
private fetchAllVtxos;
|
|
4874
|
+
/**
|
|
4875
|
+
* Complete sweeps a previous `claimCash` registered but never finalized: a thin
|
|
4876
|
+
* {@link finalizePendingTxs} signed with the arkadeCash key. A drained tx pays whoever
|
|
4877
|
+
* registered it, so finalizing is still right, but only value paid to `myPkScript` counts.
|
|
4878
|
+
*
|
|
4879
|
+
* @param vtxos - VTXOs at the cash contract's own pkScript, spent included; any other
|
|
4880
|
+
* outpoint (subdust above all) would invalidate the proof.
|
|
4881
|
+
* @returns Txs finalized, sats paid to this wallet, and the outpoints consumed to pay it.
|
|
4882
|
+
*/
|
|
4883
|
+
private finalizePendingCashTxs;
|
|
4884
|
+
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
4885
|
+
private arkTxAmountPaidTo;
|
|
4886
|
+
/**
|
|
4887
|
+
* Send BTC and/or assets to one or more recipients, passed either as
|
|
4888
|
+
* variadic `Recipient`s or as a single `SendParams` object — the latter
|
|
4889
|
+
* also carries the virtual outputs to spend.
|
|
4890
|
+
*
|
|
4891
|
+
* @param args - Recipients, or a `SendParams` object
|
|
4892
|
+
* @returns Promise resolving to the Arkade transaction ID
|
|
4893
|
+
* @see SendParams
|
|
4894
|
+
*
|
|
4895
|
+
* @example
|
|
4896
|
+
* ```typescript
|
|
4897
|
+
* const txid = await wallet.send({
|
|
4898
|
+
* address: 'ark1q...',
|
|
4899
|
+
* amount: 1000, // (optional, default to dust) btc amount to send to the output
|
|
4900
|
+
* assets: [{ assetId: 'abc123...', amount: 50n }] // (optional) list of assets to send
|
|
4901
|
+
* });
|
|
4902
|
+
*
|
|
4903
|
+
* // choosing the inputs as well as the outputs
|
|
4904
|
+
* const txid = await wallet.send({
|
|
4905
|
+
* recipients: [{ address: 'ark1q...', amount: 1000 }],
|
|
4906
|
+
* selectedVtxos: mine, // spent as given, nothing added
|
|
4907
|
+
* });
|
|
4908
|
+
* ```
|
|
4909
|
+
*/
|
|
4910
|
+
send(...args: [SendParams] | [Recipient, ...Recipient[]]): Promise<string>;
|
|
4911
|
+
private _sendImpl;
|
|
4912
|
+
/**
|
|
4913
|
+
* Shared submit/persist tail of `send` and {@link sendSelectedVtxosToSelf}; callers own coin
|
|
4914
|
+
* selection, outputs and the synchronous epoch snapshot.
|
|
4915
|
+
*/
|
|
4916
|
+
private _submitOffchainSpend;
|
|
4917
|
+
/**
|
|
4918
|
+
* @internal Migration primitive for {@link VtxoManager}: spend the wallet's own
|
|
4919
|
+
* deprecated-signer VTXOs into one full-value output on the *active* signer, via the Ark send
|
|
4920
|
+
* path (not `settle`) so arkd builds checkpoints against the active epoch. No boarding inputs.
|
|
4921
|
+
* The caller must already be on the active signer and have sized the batch. Preserves all
|
|
4922
|
+
* input assets; records no `TxSent` history.
|
|
4923
|
+
*/
|
|
4924
|
+
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
|
|
4925
|
+
/**
|
|
4926
|
+
* Build an offchain transaction from the given inputs and outputs,
|
|
4927
|
+
* sign it, submit to the operator provider, and finalize.
|
|
4928
|
+
*
|
|
4929
|
+
* Signs whatever it is handed, ungated — see {@link settle} for the trade.
|
|
4930
|
+
*
|
|
4931
|
+
* @returns The Arkade transaction id and operator-signed checkpoint PSBTs (for bookkeeping)
|
|
4932
|
+
*/
|
|
4933
|
+
buildAndSubmitOffchainTx(inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[], serverUnrollScript?: CSVMultisigTapscript.Type, options?: {
|
|
4934
|
+
validUntil?: number;
|
|
4935
|
+
}): Promise<{
|
|
4936
|
+
arkTxid: string;
|
|
4937
|
+
signedCheckpointTxs: string[];
|
|
4938
|
+
}>;
|
|
4939
|
+
private _buildAndSubmitOffchainTx;
|
|
4940
|
+
private updateDbAfterOffchainTx;
|
|
4941
|
+
private updateDbAfterSettle;
|
|
4942
|
+
}
|
|
4943
|
+
/**
|
|
4944
|
+
* Select virtual outputs to reach a target amount, prioritizing those closer to expiry
|
|
4945
|
+
* @param coins List of virtual outputs to select from
|
|
4946
|
+
* @param targetAmount Target amount to reach in satoshis
|
|
4947
|
+
* @returns Selected virtual outputs and change amount
|
|
4948
|
+
*/
|
|
4949
|
+
declare function selectVirtualCoins(coins: ExtendedVirtualCoin[], targetAmount: number): {
|
|
4950
|
+
inputs: ExtendedVirtualCoin[];
|
|
4951
|
+
changeAmount: bigint;
|
|
4952
|
+
};
|
|
4953
|
+
/**
|
|
4954
|
+
* Raised when a wait is cancelled through its `AbortSignal` or `timeoutMs`. `name` is
|
|
4955
|
+
* `"AbortError"`, so DOM and SDK aborts can be handled identically.
|
|
4956
|
+
*/
|
|
4957
|
+
declare class AbortError extends Error {
|
|
4958
|
+
constructor(message?: string);
|
|
4959
|
+
}
|
|
4960
|
+
/**
|
|
4961
|
+
* A VTXO named for a spend or a hold is held, or already being spent by another operation.
|
|
4962
|
+
* Match on `name`, not `instanceof`: only the name survives the service-worker boundary.
|
|
4963
|
+
*/
|
|
4964
|
+
declare class VtxoReservedError extends Error {
|
|
4965
|
+
readonly outpoints: readonly string[];
|
|
4966
|
+
readonly holder: "in-flight" | "held";
|
|
4967
|
+
readonly name = "VtxoReservedError";
|
|
4968
|
+
constructor(outpoints: readonly string[], holder: "in-flight" | "held");
|
|
4969
|
+
}
|
|
4970
|
+
/** A hold excluding its inputs from automatic selection. */
|
|
4971
|
+
interface VtxoReservation {
|
|
4972
|
+
readonly outpoints: readonly Outpoint[];
|
|
4973
|
+
/** Idempotent. */
|
|
4974
|
+
release(): void | Promise<void>;
|
|
4975
|
+
}
|
|
4976
|
+
/** @internal Submits an Arkade transaction for {@link Wallet.withSpendLock}'s caller. */
|
|
4977
|
+
type OffchainSubmit = (inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[]) => Promise<{
|
|
4978
|
+
arkTxid: string;
|
|
4979
|
+
signedCheckpointTxs: string[];
|
|
4980
|
+
}>;
|
|
4981
|
+
/** Options for {@link waitForIncomingFunds}. */
|
|
4982
|
+
interface WaitForIncomingFundsOptions {
|
|
4983
|
+
/**
|
|
4984
|
+
* Cancels the wait. On abort the underlying subscription is stopped and
|
|
4985
|
+
* the returned promise rejects — with the signal's `reason` when the
|
|
4986
|
+
* caller supplied an `Error`, otherwise an {@link AbortError}.
|
|
4987
|
+
*/
|
|
4988
|
+
signal?: AbortSignal;
|
|
4989
|
+
/**
|
|
4990
|
+
* Cancels the wait after this many milliseconds, rejecting with an
|
|
4991
|
+
* {@link AbortError}. Equivalent to passing an `AbortSignal.timeout`
|
|
4992
|
+
* signal, without requiring that API on the target platform.
|
|
4993
|
+
*/
|
|
4994
|
+
timeoutMs?: number;
|
|
4995
|
+
}
|
|
4996
|
+
/**
|
|
4997
|
+
* Wait for incoming funds to the wallet.
|
|
4998
|
+
*
|
|
4999
|
+
* Keeps live network watchers open until it settles. **Cancel it if you won't await it to
|
|
5000
|
+
* completion** (`signal` / `timeoutMs`): a `Promise.race` against a timer abandons the loser
|
|
5001
|
+
* without stopping its watchers, and in a loop stacks subscriptions until the process exits.
|
|
5002
|
+
*
|
|
5003
|
+
* @param wallet - The wallet to wait for incoming funds
|
|
5004
|
+
* @param options - Cancellation options; see {@link WaitForIncomingFundsOptions}
|
|
5005
|
+
* @returns A promise that resolves the next new coins received by the wallet's address
|
|
5006
|
+
* @throws {AbortError} If cancelled via `signal` or `timeoutMs`
|
|
5007
|
+
* @example
|
|
5008
|
+
* ```typescript
|
|
5009
|
+
* // Wake early on a deposit, but give up after 30s and release the watchers.
|
|
5010
|
+
* try {
|
|
5011
|
+
* const funds = await waitForIncomingFunds(wallet, { timeoutMs: 30_000 })
|
|
5012
|
+
* } catch (e) {
|
|
5013
|
+
* if ((e as Error).name !== "AbortError") throw e
|
|
5014
|
+
* }
|
|
5015
|
+
* ```
|
|
5016
|
+
*/
|
|
5017
|
+
declare function waitForIncomingFunds(wallet: NotifiesIncomingFunds, options?: WaitForIncomingFundsOptions): Promise<IncomingFunds>;
|
|
5018
|
+
|
|
5019
|
+
/**
|
|
5020
|
+
* Tapscript fields derived purely from a contract's params. They are identical
|
|
5021
|
+
* for every VTXO locked to the same contract, so they can be memoized per
|
|
5022
|
+
* contract (see {@link ContractTapscriptCache}).
|
|
5023
|
+
*/
|
|
5024
|
+
type ContractTapscripts = Pick<ExtendedVirtualCoin, "forfeitTapLeafScript" | "proofTapLeafScript" | "tapTree">;
|
|
5025
|
+
/**
|
|
5026
|
+
* Cache of per-contract tapscript data, keyed by `contract.script`. Building
|
|
5027
|
+
* the taproot tree via `handler.createScript(contract.params)` is the dominant
|
|
5028
|
+
* cost when annotating large VTXO sets; passing a shared cache across an
|
|
5029
|
+
* annotation batch rebuilds it once per distinct contract instead of once per
|
|
5030
|
+
* VTXO (see #521).
|
|
5031
|
+
*/
|
|
5032
|
+
type ContractTapscriptCache = Map<string, ContractTapscripts>;
|
|
5033
|
+
declare function getRandomId(): string;
|
|
5034
|
+
/**
|
|
5035
|
+
* What a recipient Arkade address must match. An address failing either check
|
|
5036
|
+
* belongs to another network or operator, so this wallet's operator cannot
|
|
5037
|
+
* create the VTXO where the recipient's wallet expects it.
|
|
5038
|
+
*/
|
|
5039
|
+
type RecipientArkadeAddressContext = {
|
|
5040
|
+
hrp: string;
|
|
5041
|
+
signerSet: SignerSet;
|
|
5042
|
+
};
|
|
5043
|
+
/**
|
|
5044
|
+
* The embedded server key may be the current signer or a deprecated signer
|
|
5045
|
+
* whose rotation cutoff has not passed.
|
|
5046
|
+
*/
|
|
5047
|
+
declare function assertRecipientArkadeAddress(encoded: string, address: ArkAddress, context: RecipientArkadeAddressContext): void;
|
|
5048
|
+
|
|
5049
|
+
/** Minimal indexer surface the reconciler needs. */
|
|
5050
|
+
type IntentReconcilerIndexer = Pick<IndexerProvider, "getVtxos">;
|
|
5051
|
+
interface IntentReconciliationDeps {
|
|
5052
|
+
intentRepository: BatchRegistrationRepository;
|
|
5053
|
+
indexerProvider: IntentReconcilerIndexer;
|
|
5054
|
+
/**
|
|
5055
|
+
* Replays an intent's stored delete proof against arkd. Absent ⇒ an unresolved, unexpired
|
|
5056
|
+
* intent stays locked, since arkd never expires a queued intent on its own.
|
|
5057
|
+
*/
|
|
5058
|
+
deleteIntent?: (intent: SignedProof<Proof.DeleteMessage>) => Promise<void>;
|
|
5059
|
+
/**
|
|
5060
|
+
* Whether a live settlement in this wallet is spending the outpoint. An intent with an
|
|
5061
|
+
* in-flight input belongs to that settlement and is skipped.
|
|
5062
|
+
*/
|
|
5063
|
+
isOutpointInFlight?: (outpoint: Outpoint) => boolean;
|
|
5064
|
+
/** Injectable clock (tests). Defaults to `Date.now`. */
|
|
5065
|
+
now?: () => number;
|
|
5066
|
+
}
|
|
5067
|
+
|
|
5068
|
+
/**
|
|
5069
|
+
* An input for {@link IContractManager.assertSpendableNow}.
|
|
5070
|
+
*
|
|
5071
|
+
* Prefer passing a full {@link VirtualCoin}: a relative (CSV) timelock is measured from the
|
|
5072
|
+
* coin's own confirmation (`status.block_height` / `status.block_time`). The bare shape still
|
|
5073
|
+
* answers every absolute (CLTV) question.
|
|
5074
|
+
*/
|
|
5075
|
+
type AssertSpendableInput = {
|
|
5076
|
+
txid: string;
|
|
5077
|
+
vout: number;
|
|
5078
|
+
script: string;
|
|
5079
|
+
};
|
|
5080
|
+
type RefreshVtxosOptions = {
|
|
5081
|
+
/** Narrow the refresh to these scripts. A subset query, so the sync cursor does not advance. */
|
|
5082
|
+
scripts?: string[];
|
|
5083
|
+
/** Time window overriding the cursor-derived one. The cursor never advances on a window. */
|
|
5084
|
+
after?: number;
|
|
5085
|
+
/** @see after */
|
|
5086
|
+
before?: number;
|
|
5087
|
+
/**
|
|
5088
|
+
* When true and `scripts` is not set, refresh every repository contract rather than the
|
|
5089
|
+
* watcher's watched set. A superset, so the cursor still advances (absent `after`/`before`).
|
|
5090
|
+
*
|
|
5091
|
+
* @defaultValue `false`
|
|
5092
|
+
*/
|
|
5093
|
+
includeInactive?: boolean;
|
|
5094
|
+
};
|
|
5095
|
+
/**
|
|
5096
|
+
* A single `Discoverable` handler's discovery failure, captured during a
|
|
5097
|
+
* {@link IContractManager.scanContracts} run instead of aborting the loop.
|
|
5098
|
+
*/
|
|
5099
|
+
interface HandlerError {
|
|
5100
|
+
handler: string;
|
|
5101
|
+
/** The failed index, or the first index of a failed `discoverRange` window. */
|
|
5102
|
+
fromIndex: number;
|
|
5103
|
+
/** Inclusive end of a failed `discoverRange` window; absent for a single index. */
|
|
5104
|
+
toIndex?: number;
|
|
5105
|
+
error: unknown;
|
|
5106
|
+
}
|
|
5107
|
+
/** Outcome of a {@link IContractManager.scanContracts} run. */
|
|
5108
|
+
interface ScanResult {
|
|
5109
|
+
/**
|
|
5110
|
+
* Highest HD index at which any handler confirmed a contract (`-1` if none), including hits
|
|
5111
|
+
* past {@link ScanResult.truncatedAt}. Safe to record unconditionally (the watermark is a
|
|
5112
|
+
* monotonic max); withholding it risks re-issuing a funded index as a fresh address.
|
|
5113
|
+
*/
|
|
5114
|
+
highestConfirmedUsedIndex: number;
|
|
5115
|
+
/**
|
|
5116
|
+
* First index a handler failed at (neither hit nor confirmed miss). Indices `>= truncatedAt`
|
|
5117
|
+
* are unverified and the caller must retry; scanning is idempotent. `undefined` when the
|
|
5118
|
+
* scan closed a genuine gap.
|
|
5119
|
+
*/
|
|
5120
|
+
truncatedAt?: number;
|
|
5121
|
+
/** Per-handler discovery failures. Non-empty implies `truncatedAt` is set. */
|
|
5122
|
+
handlerErrors: HandlerError[];
|
|
5123
|
+
}
|
|
5124
|
+
/** Options for {@link IContractManager.scanContracts}. */
|
|
5125
|
+
interface ScanContractsOptions {
|
|
5126
|
+
/** Default 20. A non-positive / non-integer value throws. */
|
|
5127
|
+
gapLimit?: number;
|
|
5128
|
+
/**
|
|
5129
|
+
* HD indices probed per window (default {@link DEFAULT_SCAN_BATCH}); also the width a
|
|
5130
|
+
* {@link Discoverable.discoverRange} handler collapses into one request. The discovered set
|
|
5131
|
+
* is independent of it. A non-positive / non-integer value throws. Ignored when `hd` is false.
|
|
5132
|
+
*/
|
|
5133
|
+
batchSize?: number;
|
|
5134
|
+
/** HD mode → gap loop guided by the gap counter; false → probe only index 0. */
|
|
5135
|
+
hd: boolean;
|
|
3110
5136
|
/** Materialize the descriptor at an HD index. A throw here is fatal and propagates. */
|
|
3111
5137
|
materialize: (index: number) => string;
|
|
3112
5138
|
/** Read-only context injected into every `discoverAt` call. */
|
|
@@ -3179,6 +5205,8 @@ interface IContractManager extends Disposable {
|
|
|
3179
5205
|
* {@link getSyncState}.
|
|
3180
5206
|
*/
|
|
3181
5207
|
whenBooted?(): Promise<void>;
|
|
5208
|
+
/** Retries pending batch recovery, retaining the wallet's active-settlement guard. */
|
|
5209
|
+
reconcilePendingBatchRegistrations?(): Promise<void>;
|
|
3182
5210
|
/**
|
|
3183
5211
|
* Stamp raw virtual outputs with their contract's tapscripts (forfeit, intent, tap tree).
|
|
3184
5212
|
* Throws when a vtxo's script has no registered contract, so the wallet never silently stamps
|
|
@@ -3595,6 +5623,7 @@ declare class ContractManager implements IContractManager {
|
|
|
3595
5623
|
* sync invariant, so failures are logged.
|
|
3596
5624
|
*/
|
|
3597
5625
|
private reconcileStaleIntents;
|
|
5626
|
+
reconcilePendingBatchRegistrations(): Promise<void>;
|
|
3598
5627
|
/** @see IContractManager.refillLookAhead */
|
|
3599
5628
|
refillLookAhead(): Promise<void>;
|
|
3600
5629
|
/** @see IContractManager.getNextSigningDescriptor */
|
|
@@ -3853,6 +5882,37 @@ declare class ContractManager implements IContractManager {
|
|
|
3853
5882
|
[Symbol.asyncDispose](): Promise<void>;
|
|
3854
5883
|
}
|
|
3855
5884
|
|
|
5885
|
+
/**
|
|
5886
|
+
* IndexedDB-based implementation of WalletRepository.
|
|
5887
|
+
*/
|
|
5888
|
+
declare class IndexedDBWalletRepository implements WalletRepository {
|
|
5889
|
+
readonly version: 2;
|
|
5890
|
+
private readonly connection;
|
|
5891
|
+
/** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
|
|
5892
|
+
constructor(dbName?: string, options?: {
|
|
5893
|
+
persistentWalletState?: boolean;
|
|
5894
|
+
});
|
|
5895
|
+
clear(): Promise<void>;
|
|
5896
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
5897
|
+
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
5898
|
+
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
5899
|
+
deleteVtxos(address: string): Promise<void>;
|
|
5900
|
+
getVtxosForScriptPage(script: string, page: PageRequest<ScriptVtxoCursor>, options?: ScriptVtxoPageOptions): Promise<PageResult<StoredVtxo, ScriptVtxoCursor>>;
|
|
5901
|
+
saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
5902
|
+
deleteVtxosForScript(script: string): Promise<void>;
|
|
5903
|
+
getUtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedCoin, Outpoint>>;
|
|
5904
|
+
private pageByAddress;
|
|
5905
|
+
saveUtxos(addressOrBatch: string | ReadonlyMap<string, ExtendedCoin[]>, utxos?: ExtendedCoin[]): Promise<void>;
|
|
5906
|
+
deleteUtxos(address: string): Promise<void>;
|
|
5907
|
+
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
5908
|
+
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
5909
|
+
deleteTransactions(address: string): Promise<void>;
|
|
5910
|
+
readonly atomicWalletState: AtomicWalletState;
|
|
5911
|
+
getWalletState(): Promise<WalletState | null>;
|
|
5912
|
+
saveWalletState(state: WalletState): Promise<void>;
|
|
5913
|
+
private getDB;
|
|
5914
|
+
}
|
|
5915
|
+
|
|
3856
5916
|
/**
|
|
3857
5917
|
* Contract lifecycle state. Governs receive-address selection only: `inactive` does **not**
|
|
3858
5918
|
* unsubscribe (a retired receive address can still be paid; coverage follows
|
|
@@ -4263,9 +6323,11 @@ interface ContractWatcherConfig {
|
|
|
4263
6323
|
*/
|
|
4264
6324
|
reconnectDelayMs?: number;
|
|
4265
6325
|
/**
|
|
4266
|
-
* Maximum delay for reconnection and subscription update retries (ms).
|
|
6326
|
+
* Maximum delay for reconnection and subscription update retries (ms). The reconnect ladder
|
|
6327
|
+
* starts over once a connection has stayed up for 30 seconds, or this long if lower; a stream
|
|
6328
|
+
* the server refused never counts.
|
|
4267
6329
|
*
|
|
4268
|
-
* @defaultValue `
|
|
6330
|
+
* @defaultValue `60_000` (60 seconds)
|
|
4269
6331
|
*/
|
|
4270
6332
|
maxReconnectDelayMs?: number;
|
|
4271
6333
|
/**
|
|
@@ -4328,6 +6390,7 @@ declare class ContractWatcher {
|
|
|
4328
6390
|
private eventCallback?;
|
|
4329
6391
|
private connectionState;
|
|
4330
6392
|
private reconnectAttempts;
|
|
6393
|
+
private connectedAt?;
|
|
4331
6394
|
private reconnectTimeoutId?;
|
|
4332
6395
|
private failsafePollIntervalId?;
|
|
4333
6396
|
/** See {@link withCoalescedSubscription}. */
|
|
@@ -4395,6 +6458,13 @@ declare class ContractWatcher {
|
|
|
4395
6458
|
*/
|
|
4396
6459
|
private reportEventSourceUnavailable;
|
|
4397
6460
|
private scheduleReconnect;
|
|
6461
|
+
/**
|
|
6462
|
+
* Equal jitter over the exponential backoff, never shorter than a `Retry-After` the server
|
|
6463
|
+
* asked for (clamped like the rate gate's own cooldown, so a bogus header cannot park the
|
|
6464
|
+
* stream). Without jitter the clients one restart dropped all return in the same instant, so
|
|
6465
|
+
* a dominant `Retry-After` is spread over half its own length too.
|
|
6466
|
+
*/
|
|
6467
|
+
private nextReconnectDelay;
|
|
4398
6468
|
/** Replays repository state — only what a sync stored; watch-only scripts poll the indexer. */
|
|
4399
6469
|
private startFailsafePolling;
|
|
4400
6470
|
private pollAllContracts;
|
|
@@ -4719,6 +6789,8 @@ type StorageConfig = {
|
|
|
4719
6789
|
* pending intent that instance is not settling itself.
|
|
4720
6790
|
*/
|
|
4721
6791
|
intentRepository?: BatchRegistrationRepository;
|
|
6792
|
+
/** Persistent external holds, restored before automatic wallet spending starts. */
|
|
6793
|
+
vtxoReservationRepository?: VtxoReservationRepository;
|
|
4722
6794
|
/**
|
|
4723
6795
|
* Optional virtual-tx (exit-branch) repository. When set, the wallet captures each received
|
|
4724
6796
|
* VTXO's exit branch into it and prunes it on spend (both best-effort, see
|
|
@@ -5366,6 +7438,11 @@ interface IWallet extends IReadonlyWallet {
|
|
|
5366
7438
|
* a wallet with `WalletCannotSignError` before anything is funded.
|
|
5367
7439
|
*/
|
|
5368
7440
|
identity: Identity;
|
|
7441
|
+
/**
|
|
7442
|
+
* Durable when the wallet has a reservation repository (always in the worker), else local to
|
|
7443
|
+
* this instance. A durable hold needs a caller-persisted id until its release resolves.
|
|
7444
|
+
*/
|
|
7445
|
+
reserveVtxos?(outpoints: readonly Outpoint[], reservationId: string): VtxoReservation | Promise<VtxoReservation>;
|
|
5369
7446
|
/**
|
|
5370
7447
|
* Settle boarding inputs and/or preconfirmed virtual outputs into settled virtual outputs.
|
|
5371
7448
|
*
|
|
@@ -5601,6 +7678,162 @@ declare const collectUtxos: (repository: Pick<WalletRepository, "getUtxosPage">,
|
|
|
5601
7678
|
declare const collectTransactionHistory: (repository: Pick<WalletRepository, "getTransactionHistoryPage">, address: string) => Promise<ArkTransaction[]>;
|
|
5602
7679
|
declare function collectScriptVtxos(repository: WalletRepository, script: string, options?: ScriptVtxoPageOptions): Promise<ExtendedVirtualCoin[]>;
|
|
5603
7680
|
|
|
7681
|
+
/**
|
|
7682
|
+
* A {@link DescriptorProvider} decorator that adds a **keyring**: raw
|
|
7683
|
+
* private keys imported from outside the wallet's derivation tree, each
|
|
7684
|
+
* addressed by a `tr(<pubkey>)` descriptor.
|
|
7685
|
+
*
|
|
7686
|
+
* Resolution is union-shaped — `signWithDescriptor` /
|
|
7687
|
+
* `signMessageWithDescriptor` serve a descriptor from the wrapped
|
|
7688
|
+
* provider's derivation tree *or* from the keyring, whichever owns it —
|
|
7689
|
+
* so the wallet's existing descriptor routing
|
|
7690
|
+
* (`InputSignerRouter`) signs foreign-key contracts with no changes: an
|
|
7691
|
+
* imported contract carrying `metadata.signingDescriptor` is signable by
|
|
7692
|
+
* construction rather than throwing `MissingSigningDescriptorError`.
|
|
7693
|
+
*
|
|
7694
|
+
* Allocation is *not* extended: `getNextSigningDescriptor` always
|
|
7695
|
+
* delegates to the wrapped provider. The keyring holds foreign keys the
|
|
7696
|
+
* wallet was handed; it never mints receive addresses.
|
|
7697
|
+
*
|
|
7698
|
+
* Lifecycle: entries persist under
|
|
7699
|
+
* `WalletRepository.getWalletState().settings.keyring` (same
|
|
7700
|
+
* no-migration pattern as `HDDescriptorProvider`), so an import survives
|
|
7701
|
+
* the restarts a recovery spans, and {@link deleteKey} purges it when
|
|
7702
|
+
* recovery completes. The repository is the source of truth: the async
|
|
7703
|
+
* signing/purge APIs converge on sibling instances' imports and purges
|
|
7704
|
+
* (see {@link refresh}), so any tab/worker sharing the repo can complete
|
|
7705
|
+
* a recovery another one started.
|
|
7706
|
+
*
|
|
7707
|
+
* **Keys are stored unencrypted.** This is a deliberate, scoped
|
|
7708
|
+
* decision: the intended use is a short-lived, purge-on-completion hold
|
|
7709
|
+
* of a key that guards funds already destined for this wallet. At-rest
|
|
7710
|
+
* encryption is a possible hardening follow-up. Do not use this to hold
|
|
7711
|
+
* long-lived key material.
|
|
7712
|
+
*
|
|
7713
|
+
* @example
|
|
7714
|
+
* ```ts
|
|
7715
|
+
* const provider = await KeyringDescriptorProvider.create(hdProvider, walletRepo);
|
|
7716
|
+
* const descriptor = await provider.importKey(foreignPrivKey);
|
|
7717
|
+
* // descriptor: tr(<x-only pubkey hex>)
|
|
7718
|
+
* // ... import a contract with metadata.signingDescriptor = descriptor,
|
|
7719
|
+
* // let the wallet's recovery machinery settle it, then:
|
|
7720
|
+
* await provider.deleteKey(descriptor);
|
|
7721
|
+
* ```
|
|
7722
|
+
*/
|
|
7723
|
+
declare class KeyringDescriptorProvider implements DescriptorProvider {
|
|
7724
|
+
/**
|
|
7725
|
+
* The wrapped provider. Exposed so callers that need to reach a
|
|
7726
|
+
* concrete provider type behind the decorator (e.g. the wallet's
|
|
7727
|
+
* restore path, which branches on `HDDescriptorProvider`) can
|
|
7728
|
+
* unwrap it rather than mis-classify the decorator.
|
|
7729
|
+
*/
|
|
7730
|
+
readonly base: DescriptorProvider;
|
|
7731
|
+
private readonly walletRepository;
|
|
7732
|
+
/**
|
|
7733
|
+
* In-memory mirror of the persisted keyring, keyed by x-only pubkey
|
|
7734
|
+
* hex. Required because {@link isOurs} is synchronous while
|
|
7735
|
+
* persistence is not. The **repository is the source of truth**: the
|
|
7736
|
+
* async APIs write through to it and {@link refresh} re-seeds this
|
|
7737
|
+
* mirror from it when a signing request names a foreign key the
|
|
7738
|
+
* mirror doesn't know — a sibling instance (another tab/worker on
|
|
7739
|
+
* the same repo) may have imported it after this instance was
|
|
7740
|
+
* constructed. The sync views ({@link isOurs}, {@link hasKey},
|
|
7741
|
+
* {@link listKeyringDescriptors}) answer from the last-known
|
|
7742
|
+
* snapshot.
|
|
7743
|
+
*/
|
|
7744
|
+
private readonly keys;
|
|
7745
|
+
private constructor();
|
|
7746
|
+
/**
|
|
7747
|
+
* Wrap `base` with a keyring, loading any previously imported keys
|
|
7748
|
+
* from the repository. Unlike `HDDescriptorProvider.create`, this
|
|
7749
|
+
* *does* read at construction: `isOurs` is synchronous and must be
|
|
7750
|
+
* able to answer for persisted keys from the first call.
|
|
7751
|
+
*/
|
|
7752
|
+
static create(base: DescriptorProvider, walletRepository: WalletRepository): Promise<KeyringDescriptorProvider>;
|
|
7753
|
+
/**
|
|
7754
|
+
* Import a raw private key into the keyring and return its
|
|
7755
|
+
* `tr(<x-only pubkey>)` descriptor handle. Idempotent: re-importing
|
|
7756
|
+
* the same key returns the same descriptor and leaves storage
|
|
7757
|
+
* unchanged.
|
|
7758
|
+
*/
|
|
7759
|
+
importKey(privateKey: Uint8Array): Promise<string>;
|
|
7760
|
+
/**
|
|
7761
|
+
* Purge a keyring entry. Returns `true` when an entry was removed,
|
|
7762
|
+
* `false` when the descriptor was not in the keyring (already
|
|
7763
|
+
* purged, or never ours) — so a repeated purge is a safe no-op.
|
|
7764
|
+
*
|
|
7765
|
+
* Always goes through storage, never trusting the in-memory mirror:
|
|
7766
|
+
* the entry may have been imported by a sibling instance after this
|
|
7767
|
+
* one was constructed, and skipping the persistent purge on a memory
|
|
7768
|
+
* miss would leave that key at rest forever.
|
|
7769
|
+
*/
|
|
7770
|
+
deleteKey(descriptor: string): Promise<boolean>;
|
|
7771
|
+
/** True iff `descriptor` resolves to a key held in the keyring. */
|
|
7772
|
+
hasKey(descriptor: string): boolean;
|
|
7773
|
+
/** The `tr(<pubkey>)` descriptors of every key currently held. */
|
|
7774
|
+
listKeyringDescriptors(): string[];
|
|
7775
|
+
/** Allocation is the wrapped provider's job; the keyring never mints. */
|
|
7776
|
+
getNextSigningDescriptor(): Promise<string>;
|
|
7777
|
+
/** Ours iff the wrapped provider claims it, or the keyring holds it. */
|
|
7778
|
+
isOurs(descriptor: string): boolean;
|
|
7779
|
+
/**
|
|
7780
|
+
* Signs each request with the key its descriptor resolves to.
|
|
7781
|
+
* Keyring-owned requests are signed here; every other request is
|
|
7782
|
+
* handed to the wrapped provider in a single batched call, so a
|
|
7783
|
+
* batch-signing identity behind a `StaticDescriptorProvider` still
|
|
7784
|
+
* sees one interaction.
|
|
7785
|
+
*
|
|
7786
|
+
* Results are returned in request order regardless of how the
|
|
7787
|
+
* requests split across the two signers.
|
|
7788
|
+
*/
|
|
7789
|
+
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
7790
|
+
/** Signs a message with the keyring key, or delegates to the base. */
|
|
7791
|
+
signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
7792
|
+
/**
|
|
7793
|
+
* Split requests into keyring-owned and base-delegated buckets.
|
|
7794
|
+
* `mayBeStale` is set when a delegated descriptor is foreign-shaped —
|
|
7795
|
+
* a sibling instance may have imported its key after this instance
|
|
7796
|
+
* seeded the mirror, so the caller should {@link refresh} once and
|
|
7797
|
+
* re-split before trusting the delegation.
|
|
7798
|
+
*/
|
|
7799
|
+
private splitRequests;
|
|
7800
|
+
/**
|
|
7801
|
+
* True when `descriptor` is a bare `tr(<pubkey>)` the base provider
|
|
7802
|
+
* does not own — the only shape a keyring entry can have, so the only
|
|
7803
|
+
* kind of miss a {@link refresh} could turn into a hit.
|
|
7804
|
+
*/
|
|
7805
|
+
private isForeignShaped;
|
|
7806
|
+
/**
|
|
7807
|
+
* Re-seed the in-memory mirror from the repository, converging on
|
|
7808
|
+
* imports and purges made by sibling instances on the same repo.
|
|
7809
|
+
* Full replacement, not a merge, so sibling *deletions* propagate
|
|
7810
|
+
* too. Corrupt persisted settings throw, same as {@link create}.
|
|
7811
|
+
*
|
|
7812
|
+
* Only a *miss* triggers a refresh, so that convergence is one-sided:
|
|
7813
|
+
* an entry this instance still believes it holds is never
|
|
7814
|
+
* revalidated, and a sibling's purge can linger in this mirror until
|
|
7815
|
+
* some unrelated foreign-shaped miss re-seeds it. Harmless today —
|
|
7816
|
+
* `deleteKey`'s caller also deletes the contract row carrying the
|
|
7817
|
+
* descriptor, so no signing request can name the stale entry — but it
|
|
7818
|
+
* means the at-rest purge is not a memory purge for siblings.
|
|
7819
|
+
*/
|
|
7820
|
+
private refresh;
|
|
7821
|
+
/**
|
|
7822
|
+
* The keyring key for `descriptor`, or `undefined` when the request
|
|
7823
|
+
* belongs to the base provider. Base ownership wins on collision:
|
|
7824
|
+
* a key already in the derivation tree keeps its established signing
|
|
7825
|
+
* path, so importing it cannot reroute existing contracts.
|
|
7826
|
+
*/
|
|
7827
|
+
private resolveKey;
|
|
7828
|
+
/**
|
|
7829
|
+
* Read-modify-write the keyring settings through `updateWalletState`,
|
|
7830
|
+
* whose in-process mutex plus cross-context Web Lock keep concurrent
|
|
7831
|
+
* imports/purges — including ones driven from other tabs/workers
|
|
7832
|
+
* sharing the store — from clobbering each other's entries.
|
|
7833
|
+
*/
|
|
7834
|
+
private mutate;
|
|
7835
|
+
}
|
|
7836
|
+
|
|
5604
7837
|
interface Identity extends ReadonlyIdentity {
|
|
5605
7838
|
/** Returns a signer session used for musig2 tree signing flows. */
|
|
5606
7839
|
signerSession(): SignerSession;
|
|
@@ -5654,4 +7887,4 @@ declare function isBatchSignable(identity: Identity): identity is BatchSignableI
|
|
|
5654
7887
|
*/
|
|
5655
7888
|
declare function isSigningIdentity(value: unknown): value is Identity;
|
|
5656
7889
|
|
|
5657
|
-
export { type VirtualTxRepository as $, type ArkadeReader as A, type Outpoint as B, type ContractRepository as C, type PageResult as D, type ExtendedCoin as E, type ScriptVtxoCursor as F, type GetOperatorInfoOptions as G, type ScriptVtxoPageOptions as H, type IWallet as I, type StoredVtxo as J, type VtxoRepositoryKey as K, type TransactionHistoryPageFilter as L, type TransactionHistoryPageCursor as M, type NormalizedExtendedVirtualCoin as N, type OperatorInfo as O, type PageRequest as P, type AtomicWalletState as Q, type Recipient as R, type SettleParams as S, type TxNotificationEvent as T, type WalletState as U, type VirtualCoin as V, type WalletRepository as W, type ContractFilter as X, type BatchRegistrationRepository as Y, type BatchRegistration as Z, type BatchRegistrationPageFilter as _, type Identity as a, type WatchedScript as a$, type VirtualTx as a0, type VtxoBranch as a1, ChainedTxType as a2, Transaction as a3, type SignerSession as a4, type ReadonlyIdentity as a5, type Network as a6, type ActivityResolver as a7, type BatchStartedEvent as a8, type TreeSigningStartedEvent as a9, type SignedIntent as aA, Intent as aB, type SignedProof as aC, Proof as aD, type TimeHeight as aE, type DescriptorSigningRequest as aF, type IntentFeeConfig as aG, type OffchainInput as aH, FeeAmount as aI, type OnchainInput as aJ, type FeeOutput as aK, type ArkadeInfo as aL, type ContractWatcherConfig as aM, type Asset as aN, type FeeInfo as aO, type GetVtxosOptions as aP, type PaginationOptions as aQ, type CreateContractParams as aR, type GetContractsFilter as aS, type GetSpendablePathsOptions as aT, type GetAllSpendingPathsOptions as aU, type InputExpiryFloor as aV, type IssuanceParams as aW, type ReissuanceParams as aX, type BurnParams as aY, type RenewVtxosOptions as aZ, type NormalizedVtxoPage as a_, TxTree as aa, type TreeNoncesEvent as ab, type BatchFinalizationEvent as ac, type BatchFinalizedEvent as ad, type BatchFailedEvent as ae, type TreeTxEvent as af, type TreeSignatureEvent as ag, type DescriptorProvider as ah, type IReadonlyWallet as ai, type OnchainProvider as aj, type DelegateProvider as ak, type ReadonlyWalletConfig as al, type ExitCaptureMode as am, type ExitDataSource as an, type IReadonlyAssetManager as ao, type ContractSyncState as ap, type RecipientArkadeAddressContext as aq, EsploraProvider as ar, type NetworkName as as, type ContractWithVtxos as at, selectPendingRecoveryOutpoints as au, type Coin as av, ContractManager as aw, type ContractManagerConfig as ax, type SettlementConfig as ay, VtxoManager as az, type WalletConfig as b, type ExitChainResolver as b$, type PathSelection as b0, type ContractEvent as b1, type AssetDetails as b2, type IssuanceResult as b3, type DelegateInfo as b4, type MigrationGlobalSkipReason as b5, type MigrationLegSkipReason as b6, type SignerStatus as b7, type StorageConfig as b8, type IVtxoManager as b9, ChainTxType as bA, type CommitmentTx as bB, type ConnectorTreeNode as bC, type ContractBalance as bD, type ContractEventCallback as bE, type ContractHandler as bF, type ContractScope as bG, type ContractState as bH, type ContractVtxo as bI, ContractWatcher as bJ, type ContractWatcherEventCallback as bK, DEFAULT_ARKADE_EMULATOR_URL as bL, DEFAULT_VTXO_PAGE_SIZE as bM, DelegateManagerImpl as bN, type DelegateOptions as bO, type DeprecatedSignerMigrationReport as bP, type DeprecatedSignerReport as bQ, DigestMismatchError as bR, type Discoverable as bS, type DiscoveredContract as bT, type DiscoveryDeps as bU, ESPLORA_URL as bV, type EmulatorInfo as bW, type EventSourceCapable as bX, type EventSourceFactory as bY, type EventSourceLike as bZ, EventSourceUnavailableError as b_, type SendBitcoinParams as ba, type ExplorerTransaction as bb, type TreeNonces as bc, type TreePartialSigs as bd, type PendingTx as be, type EmulatorProvider as bf, type Status as bg, type ChainTx as bh, type ArkadeService as bi, type ContractVtxoEvent as bj, type ExtendedContractVtxo as bk, type ResolvedArkadeService as bl, resolveArkadeService as bm, type PathContext as bn, type ActivityIntent as bo, type ArkIntent as bp, type ArkIntentState as bq, type AssetMetadata as br, BATCH_REGISTRATION_TERMINAL_STATES as bs, BITCOIN_EMULATOR_PUBKEY as bt, type BaseWalletConfig as bu, type BatchInfo as bv, type BatchRegistrationFilter as bw, type BatchRegistrationState as bx, type BatchSignableIdentity as by, type CandidateDeps as bz, type ArkadeBroadcaster as c, assertRecipientArkadeAddress as c$, type GetArkadeInfoOptions as c0, type GetUtxosOptions as c1, type GroupMembership as c2, type HandlerError as c3, INTENT_TERMINAL_STATES as c4, IndexerTxType as c5, type IndexerUtxo as c6, IndexerUtxosUnsupportedError as c7, type IntentCoin as c8, type IntentFilter as c9, RestEmulatorProvider as cA, type ScanContractsOptions as cB, type ScanResult as cC, type ScheduledSession as cD, SettlementEventType as cE, type SignRequest as cF, type SignerClassification as cG, type SignerSet as cH, type SubscriptionFilter as cI, type SubscriptionResponse as cJ, type SweepTxNotification as cK, type TapLeaves as cL, TreeSignerSession as cM, type Tx as cN, type TxHistoryRecord as cO, type TxKey as cP, type TxNotification as cQ, type TxTag as cR, type TxTreeNode as cS, TxType as cT, type Vtxo as cU, type VtxoChain as cV, type VtxoType as cW, type WalletMode as cX, type WithPrevTx as cY, assertAllowedSighashTypes as cZ, assertPageRequest as c_, type IntentPageFilter as ca, type IntentRepository as cb, type KnownMetadata as cc, MAX_PAGE_SIZE as cd, MUTINYNET_EMULATOR_PUBKEY as ce, type MigrateDeprecatedSignerOptions as cf, type MigrationLegReport as cg, type MigrationVtxoRef as ch, type NewAddressType as ci, type Nonces as cj, OnchainCosignAmbiguousError as ck, OnchainCosignRejectedError as cl, OnchainCosignUnsupportedError as cm, type Output as cn, type PageResponse as co, PartialSig as cp, type PrevTxSource as cq, PrevTxUnavailableError as cr, type ProofInput as cs, type ProviderClass as ct, REGTEST_EMULATOR_PUBKEY as cu, type RawTxSource as cv, type RenewalSplit as cw, type RenewalSplitContext as cx, RestArkProvider as cy, RestDelegateProvider as cz, type WalletBalance as d, assetMintResolver as d0, attachPrevArkTxs as d1, attachPrevoutTxs as d2, boardingResolver as d3, canRecoverOnchain as d4, canSpendOffchain as d5, canSweepOnchain as d6, classifyAgainstSignerSet as d7, classifyContractSigner as d8, collabExitResolver as d9, isSubdust as dA, isTerminalBatchRegistrationState as dB, isTerminalIntentState as dC, isVirtualCoin as dD, isVtxoExpiringSoon as dE, isVtxoSpent as dF, iteratePages as dG, networkFromArkadeInfo as dH, networkFromOperatorInfo as dI, networks as dJ, pageResult as dK, resolveEmulatorPubkey as dL, resolveEventSource as dM, resolvePrevTxs as dN, signerSetFromInfo as dO, toOffchainInputFeeParams as dP, toXOnlySignerHex as dQ, withPrevTxs as dR, type TapscriptDeriving as dS, collectBatchRegistrations as da, collectContracts as db, collectIntents as dc, collectPages as dd, collectScriptVtxos as de, collectTransactionHistory as df, collectUtxos as dg, collectVtxos as dh, configureEventSource as di, createDefaultActivityRegistry as dj, createExitChainResolver as dk, defaultEmulatorPubkey as dl, getAllNormalizedVtxos as dm, getConfiguredEventSource as dn, getNetwork as dp, getNormalizedVtxos as dq, getRandomId as dr, hasCandidates as ds, isBatchSignable as dt, isContractVtxoEvent as du, isCooperativelyMigratable as dv, isDiscoverable as dw, isEventSourceUnavailableError as dx, isPastExpiry as dy, isSigningIdentity as dz, type GetVtxosFilter as e, type GetSpendableVtxosFilter as f, type ArkTransaction as g, ActivityRegistry as h, type Activity as i, type IContractManager as j, type GetNewAddressesOptions as k, type NewAddress as l, type IDelegateManager as m, type SettlementEvent as n, type SendParams as o, type SendOnchainParams as p, type IAssetManager as q, RestOperatorProvider as r, RestIndexerProvider as s, type SubscriptionEvent as t, type SubscriptionHeartbeat as u, type ArkProvider as v, type IndexerProvider as w, type OperatorProvider as x, type Contract as y, type ExtendedVirtualCoin as z };
|
|
7890
|
+
export { type WalletState as $, type AddressAllocationCapable as A, type OperatorProvider as B, type ContractRepository as C, type Contract as D, type ExtendedCoin as E, type ExtendedVirtualCoin as F, type GetOperatorInfoOptions as G, type HDWalletCapable as H, type IWallet as I, type PageRequest as J, type Outpoint as K, type PageResult as L, type ScriptVtxoCursor as M, type NormalizedExtendedVirtualCoin as N, type OperatorInfo as O, type ProviderConnectionState as P, type ScriptVtxoPageOptions as Q, type Recipient as R, type SettleParams as S, type TxNotificationEvent as T, type StoredVtxo as U, type VirtualCoin as V, type WalletRepository as W, type VtxoRepositoryKey as X, type TransactionHistoryPageFilter as Y, type TransactionHistoryPageCursor as Z, type AtomicWalletState as _, type HDAllocationCapable as a, type Coin as a$, type ContractFilter as a0, type BatchRegistrationRepository as a1, type BatchRegistration as a2, type BatchRegistrationPageFilter as a3, type VirtualTxRepository as a4, type VirtualTx as a5, type VtxoBranch as a6, ChainedTxType as a7, type DescriptorProvider as a8, Transaction as a9, type NormalizedVtxoPage as aA, type ContractSyncState as aB, type ContractWithVtxos as aC, type WatchedScript as aD, type PathSelection as aE, type ContractEvent as aF, type AssetDetails as aG, type IssuanceResult as aH, type DelegateInfo as aI, type MigrationGlobalSkipReason as aJ, type MigrationLegSkipReason as aK, type SignerStatus as aL, type NetworkName as aM, ReadonlyWallet as aN, type SettlementConfig as aO, type ContractWatcherConfig as aP, type Asset as aQ, type FeeInfo as aR, type ReceiveRotatorFactory as aS, type ReceiveRotatorBootOpts as aT, type ReceiveRotatorBoot as aU, type IReadonlyWallet as aV, type IReadonlyAssetManager as aW, type StorageConfig as aX, type VtxoReservation as aY, type IVtxoManager as aZ, type Network as a_, type SignerSession as aa, type ReadonlyIdentity as ab, type DescriptorSigningRequest as ac, type IntentFeeConfig as ad, type OffchainInput as ae, FeeAmount as af, type OnchainInput as ag, type FeeOutput as ah, type VtxoReservationRepository as ai, type StoredVtxoReservation as aj, type ArkadeCashTx as ak, type ArkadeInfo as al, type OnchainProvider as am, type ArkadeCashRecord as an, type ArkadeCashClaimResult as ao, type GetVtxosOptions as ap, type PaginationOptions as aq, type CreateContractParams as ar, type GetContractsFilter as as, type GetSpendablePathsOptions as at, type GetAllSpendingPathsOptions as au, type InputExpiryFloor as av, type IssuanceParams as aw, type ReissuanceParams as ax, type BurnParams as ay, type RenewVtxosOptions as az, type Identity as b, DefaultVtxo as b$, type SendBitcoinParams as b0, type ExplorerTransaction as b1, type SignedProof as b2, Proof as b3, type TreeNonces as b4, type TreePartialSigs as b5, type PendingTx as b6, type EmulatorProvider as b7, type Status as b8, type BatchExpiryPolicy as b9, type BaseWalletConfig as bA, type BatchFailedEvent as bB, type BatchFinalizationEvent as bC, type BatchFinalizedEvent as bD, type BatchInfo as bE, type BatchRegistrationFilter as bF, type BatchRegistrationState as bG, type BatchSignableIdentity as bH, type BatchStartedEvent as bI, type BoardingUtxoGroup as bJ, type CandidateDeps as bK, ChainTxType as bL, type CommitmentTx as bM, type ConnectorTreeNode as bN, type ContractBalance as bO, type ContractEventCallback as bP, type ContractHandler as bQ, ContractManager as bR, type ContractManagerConfig as bS, type ContractScope as bT, type ContractState as bU, type ContractVtxo as bV, ContractWatcher as bW, type ContractWatcherEventCallback as bX, DEFAULT_ARKADE_EMULATOR_URL as bY, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as bZ, DEFAULT_VTXO_PAGE_SIZE as b_, Batch as ba, type ChainTx as bb, TxTree as bc, type ArkadeService as bd, type ContractVtxoEvent as be, type ExtendedContractVtxo as bf, type ResolvedArkadeService as bg, resolveArkadeService as bh, type PathContext as bi, AbortError as bj, type ActivityIntent as bk, type ActivityResolver as bl, ArkError as bm, ArkErrorName as bn, type ArkIntent as bo, type ArkIntentState as bp, ArkadeCash as bq, type ArkadeCashAction as br, ArkadeCashCreateError as bs, ArkadeCashOperatorMismatchError as bt, type ArkadeCashUnclaimedReason as bu, type ArkadeCashUnclaimedVtxo as bv, type ArkadeCashVtxoRef as bw, type AssetMetadata as bx, BATCH_REGISTRATION_TERMINAL_STATES as by, BITCOIN_EMULATOR_PUBKEY as bz, Wallet as c, ReadonlySingleKey as c$, DelegateManagerImpl as c0, type DelegateOptions as c1, type DelegateProvider as c2, DelegateVtxo as c3, type DeprecatedSignerMigrationReport as c4, type DeprecatedSignerReport as c5, DigestMismatchError as c6, type Discoverable as c7, type DiscoveredContract as c8, type DiscoveryDeps as c9, type IntentRepository as cA, KeyringDescriptorProvider as cB, type KnownMetadata as cC, MAX_PAGE_SIZE as cD, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD as cE, MUTINYNET_EMULATOR_PUBKEY as cF, type MigrateDeprecatedSignerOptions as cG, type MigrationLegReport as cH, type MigrationVtxoRef as cI, type NewAddressType as cJ, type Nonces as cK, type NotifiesIncomingFunds as cL, OnchainCosignAmbiguousError as cM, OnchainCosignRejectedError as cN, OnchainCosignUnsupportedError as cO, type Output as cP, type PageResponse as cQ, PartialSig as cR, type PrevTxSource as cS, PrevTxUnavailableError as cT, type ProofInput as cU, type ProviderClass as cV, type ProviderKind as cW, ProviderUnavailableError as cX, REGTEST_EMULATOR_PUBKEY as cY, REGTEST_MIN_BATCH_EXPIRY_SECONDS as cZ, type RawTxSource as c_, ESPLORA_URL as ca, type EmulatorInfo as cb, EsploraProvider as cc, type EventSourceCapable as cd, type EventSourceFactory as ce, type EventSourceLike as cf, EventSourceUnavailableError as cg, type ExitCaptureMode as ch, type ExitChainResolver as ci, type ExitDataSource as cj, ForeignDescriptorError as ck, type GetArkadeInfoOptions as cl, type GetUtxosOptions as cm, type GroupMembership as cn, type HandlerError as co, HttpResponseError as cp, INTENT_TERMINAL_STATES as cq, type IncomingFunds as cr, IndexedDBWalletRepository as cs, IndexerTxType as ct, type IndexerUtxo as cu, IndexerUtxosUnsupportedError as cv, Intent as cw, type IntentCoin as cx, type IntentFilter as cy, type IntentPageFilter as cz, type WalletConfig as d, collectContracts as d$, type ReadonlyWalletConfig as d0, type RecipientArkadeAddressContext as d1, type RenewalSplit as d2, type RenewalSplitContext as d3, RestArkProvider as d4, RestDelegateProvider as d5, RestEmulatorProvider as d6, type ScanContractsOptions as d7, type ScanResult as d8, type ScheduledSession as d9, type Vtxo as dA, type VtxoChain as dB, VtxoManager as dC, VtxoReservedError as dD, type VtxoType as dE, type WaitForIncomingFundsOptions as dF, WalletCannotAllocateAddressError as dG, type WalletMode as dH, type WithPrevTx as dI, addArkadeCashRecord as dJ, arkadeCashId as dK, arkadeCashResolver as dL, assertAllowedSighashTypes as dM, assertPageRequest as dN, assertRecipientArkadeAddress as dO, assertValidBatchExpiry as dP, assetMintResolver as dQ, attachPrevArkTxs as dR, attachPrevoutTxs as dS, boardingResolver as dT, canRecoverOnchain as dU, canSpendOffchain as dV, canSweepOnchain as dW, classifyAgainstSignerSet as dX, classifyContractSigner as dY, collabExitResolver as dZ, collectBatchRegistrations as d_, type ServerInfoSource as da, ServerResponseMismatchError as db, SettlementEventType as dc, type SignRequest as dd, type SignedIntent as de, type SignerClassification as df, type SignerSet as dg, SingleKey as dh, type SubscriptionFilter as di, type SubscriptionResponse as dj, type SweepTxNotification as dk, type TapLeaves as dl, type TimeHeight as dm, type TreeNoncesEvent as dn, type TreeSignatureEvent as dp, TreeSignerSession as dq, type TreeSigningStartedEvent as dr, type TreeTxEvent as ds, type Tx as dt, type TxHistoryRecord as du, type TxKey as dv, type TxNotification as dw, type TxTag as dx, type TxTreeNode as dy, TxType as dz, type ArkadeReader as e, collectIntents as e0, collectPages as e1, collectScriptVtxos as e2, collectTransactionHistory as e3, collectUtxos as e4, collectVtxos as e5, configureEventSource as e6, createArkadeCashTracker as e7, createDefaultActivityRegistry as e8, createExitChainResolver as e9, maybeArkError as eA, mergeArkadeCashRecord as eB, networkFromArkadeInfo as eC, networkFromOperatorInfo as eD, networks as eE, pageResult as eF, resolveBatchExpiryPolicy as eG, resolveDescriptorSigner as eH, resolveEmulatorPubkey as eI, resolveEventSource as eJ, resolvePrevTxs as eK, selectVirtualCoins as eL, signerSetFromInfo as eM, signingDescriptorIndex as eN, strictSigningDescriptorIndex as eO, toOffchainInputFeeParams as eP, toXOnlySignerHex as eQ, waitForIncomingFunds as eR, withPrevTxs as eS, type TapscriptDeriving as eT, defaultBatchExpiryPolicy as ea, defaultEmulatorPubkey as eb, getAllNormalizedVtxos as ec, getConfiguredEventSource as ed, getNetwork as ee, getNormalizedVtxos as ef, getRandomId as eg, hasCandidates as eh, isAddressAllocationCapable as ei, isArkError as ej, isBatchSignable as ek, isContractVtxoEvent as el, isCooperativelyMigratable as em, isDiscoverable as en, isEventSourceUnavailableError as eo, isHDAllocationCapable as ep, isHDWalletCapable as eq, isPastExpiry as er, isSigningIdentity as es, isSubdust as et, isTerminalBatchRegistrationState as eu, isTerminalIntentState as ev, isVirtualCoin as ew, isVtxoExpiringSoon as ex, isVtxoSpent as ey, iteratePages as ez, type ArkadeBroadcaster as f, type WalletBalance as g, type GetVtxosFilter as h, type GetSpendableVtxosFilter as i, type ArkTransaction as j, ActivityRegistry as k, type Activity as l, type IContractManager as m, type GetNewAddressesOptions as n, type NewAddress as o, type IDelegateManager as p, type SettlementEvent as q, type SendParams as r, type SendOnchainParams as s, type IAssetManager as t, RestOperatorProvider as u, RestIndexerProvider as v, type SubscriptionEvent as w, type SubscriptionHeartbeat as x, type ArkProvider as y, type IndexerProvider as z };
|