@arkade-os/sdk 0.5.4 → 0.5.6
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 +103 -17
- package/dist/adapters/expo.cjs +7 -6
- package/dist/adapters/expo.d.cts +4 -3
- package/dist/adapters/expo.d.ts +4 -3
- package/dist/adapters/expo.js +4 -3
- package/dist/{asyncStorageTaskQueue-DTBa8EH7.d.cts → asyncStorageTaskQueue-Bh2n0msM.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-DHMIxY04.d.ts → asyncStorageTaskQueue-CpkstKZ5.d.ts} +2 -2
- package/dist/base-C-Y5t_0F.d.cts +359 -0
- package/dist/base-C-Y5t_0F.d.ts +359 -0
- package/dist/{chunk-6CUP6ZIF.js → chunk-47Z4LEIW.js} +17 -841
- package/dist/chunk-47Z4LEIW.js.map +1 -0
- package/dist/{chunk-DNITZVNG.cjs → chunk-4X67IB2V.cjs} +18 -17
- package/dist/chunk-4X67IB2V.cjs.map +1 -0
- package/dist/{chunk-BTRCN4JJ.js → chunk-C7NY6WSA.js} +64 -4
- package/dist/chunk-C7NY6WSA.js.map +1 -0
- package/dist/{chunk-TUOLZBNC.js → chunk-DJYX73W2.js} +5 -4
- package/dist/chunk-DJYX73W2.js.map +1 -0
- package/dist/chunk-DNFTHG73.js +829 -0
- package/dist/chunk-DNFTHG73.js.map +1 -0
- package/dist/chunk-FDJ734CH.js +882 -0
- package/dist/chunk-FDJ734CH.js.map +1 -0
- package/dist/chunk-FLPWNMX3.cjs +930 -0
- package/dist/chunk-FLPWNMX3.cjs.map +1 -0
- package/dist/{chunk-WXNSISXK.cjs → chunk-HKEPJBTY.cjs} +79 -18
- package/dist/chunk-HKEPJBTY.cjs.map +1 -0
- package/dist/chunk-JFJNB7ZH.cjs +884 -0
- package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
- package/dist/{chunk-GHUUT54D.cjs → chunk-LZAINCGU.cjs} +89 -933
- package/dist/chunk-LZAINCGU.cjs.map +1 -0
- package/dist/{chunk-E6OOJEHL.cjs → chunk-NDQ4LB4X.cjs} +60 -934
- package/dist/chunk-NDQ4LB4X.cjs.map +1 -0
- package/dist/{chunk-AG4TFD6F.js → chunk-QTMK34TP.js} +79 -884
- package/dist/chunk-QTMK34TP.js.map +1 -0
- package/dist/chunk-V3ZLL5VY.js +380 -0
- package/dist/chunk-V3ZLL5VY.js.map +1 -0
- package/dist/{chunk-MWVAWFX6.js → chunk-VWW2ZBPI.js} +4 -4
- package/dist/{chunk-MWVAWFX6.js.map → chunk-VWW2ZBPI.js.map} +1 -1
- package/dist/chunk-X6ZI53DZ.cjs +383 -0
- package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
- package/dist/{chunk-F3FAE7VJ.cjs → chunk-Y3CDDPWI.cjs} +3138 -1764
- package/dist/chunk-Y3CDDPWI.cjs.map +1 -0
- package/dist/{chunk-ZJHLLDBP.js → chunk-YKT4NAQG.js} +2653 -1295
- package/dist/chunk-YKT4NAQG.js.map +1 -0
- package/dist/{chunk-B6VNKGIH.cjs → chunk-YS76JSGP.cjs} +10 -10
- package/dist/{chunk-B6VNKGIH.cjs.map → chunk-YS76JSGP.cjs.map} +1 -1
- package/dist/compiler.cjs +50 -0
- package/dist/compiler.cjs.map +1 -0
- package/dist/compiler.d.cts +38 -0
- package/dist/compiler.d.ts +38 -0
- package/dist/compiler.js +47 -0
- package/dist/compiler.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +11 -9
- package/dist/contracts/handlers/index.d.cts +6 -4
- package/dist/contracts/handlers/index.d.ts +6 -4
- package/dist/contracts/handlers/index.js +4 -2
- package/dist/{delegate-xrSBNybC.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
- package/dist/{delegate-f4_t864Z.d.cts → delegate-iyDum4fw.d.ts} +1 -1
- package/dist/{index-BJDz15ms.d.ts → index-2wKMrT0a.d.ts} +5 -270
- package/dist/{index-BjiVGtp8.d.cts → index-46g577Ka.d.cts} +5 -270
- package/dist/{index-DRwe0UDN.d.cts → index-C66rjxz2.d.ts} +1603 -1721
- package/dist/{index-DRwe0UDN.d.ts → index-Dqk07NwJ.d.cts} +1603 -1721
- package/dist/index.cjs +457 -378
- package/dist/index.d.cts +640 -385
- package/dist/index.d.ts +640 -385
- package/dist/index.js +7 -4
- package/dist/{wallet-jVBDQl6R.d.cts → keyringDescriptorProvider-DiBM4GmB.d.ts} +417 -366
- package/dist/{wallet-Oc3Wd5gv.d.ts → keyringDescriptorProvider-DnaLUC7v.d.cts} +417 -366
- package/dist/program-BARSNg3X.d.ts +286 -0
- package/dist/program-znrWkxE4.d.cts +286 -0
- package/dist/repositories/realm/index.cjs +71 -51
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +20 -9
- package/dist/repositories/realm/index.d.ts +20 -9
- package/dist/repositories/realm/index.js +42 -23
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +81 -56
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +17 -8
- package/dist/repositories/sqlite/index.d.ts +17 -8
- package/dist/repositories/sqlite/index.js +55 -31
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-CDlNeth0.d.ts → taskRunner-BM6IAKlS.d.ts} +2 -2
- package/dist/{taskRunner-BPPU-YHG.d.cts → taskRunner-BmDIZiSl.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +17 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +5 -4
- package/dist/wallet/expo/background.d.ts +5 -4
- package/dist/wallet/expo/background.js +9 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +29 -16
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +12 -7
- package/dist/wallet/expo/index.d.ts +12 -7
- package/dist/wallet/expo/index.js +19 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +12 -9
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -5
- package/dist/worker/expo/index.d.ts +6 -5
- package/dist/worker/expo/index.js +8 -5
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +16 -1
- package/dist/chunk-6CUP6ZIF.js.map +0 -1
- package/dist/chunk-AG4TFD6F.js.map +0 -1
- package/dist/chunk-BTRCN4JJ.js.map +0 -1
- package/dist/chunk-DNITZVNG.cjs.map +0 -1
- package/dist/chunk-E6OOJEHL.cjs.map +0 -1
- package/dist/chunk-F3FAE7VJ.cjs.map +0 -1
- package/dist/chunk-GHUUT54D.cjs.map +0 -1
- package/dist/chunk-TUOLZBNC.js.map +0 -1
- package/dist/chunk-WXNSISXK.cjs.map +0 -1
- package/dist/chunk-ZJHLLDBP.js.map +0 -1
|
@@ -1,311 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
1
|
+
import { a3 as Network, a4 as BatchStartedEvent, a5 as TreeSigningStartedEvent, a6 as TxTree, a7 as TreeNoncesEvent, a8 as BatchFinalizationEvent, a9 as BatchFinalizedEvent, aa as BatchFailedEvent, ab as TreeTxEvent, ac as TreeSignatureEvent, n as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, ad as DescriptorProvider, j as IContractManager, k as GetNewAddressesOptions, l as NewAddress, a as Identity, ae as IReadonlyWallet, af as ReadonlyIdentity, ag as OnchainProvider, x as OperatorProvider, w as IndexerProvider, ah as DelegateProvider, ai as ReadonlyWalletConfig, Y as BatchRegistrationRepository, $ as VirtualTxRepository, aj as ExitCaptureMode, ak as ExitDataSource, h as ActivityRegistry, al as IReadonlyAssetManager, am as ContractSyncState, an as RecipientArkadeAddressContext, G as GetOperatorInfoOptions, O as OperatorInfo, A as ArkadeReader, ao as EsploraProvider, ap as NetworkName, d as WalletBalance, e as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, f as GetSpendableVtxosFilter, aq as ContractWithVtxos, ar as selectPendingRecoveryOutpoints, g as ArkTransaction, i as Activity, E as ExtendedCoin, as as Coin, z as ExtendedVirtualCoin, at as ContractManager, au as ContractManagerConfig, I as IWallet, B as Outpoint, av as SettlementConfig, c as ArkadeBroadcaster, q as IAssetManager, aw as VtxoManager, m as IDelegateManager, S as SettleParams, R as Recipient, ax as SignerSession, ay as Transaction, p as SendOnchainParams, az as SignedIntent, aA as Intent, aB as SignedProof, aC as Proof, o as SendParams, aD as TimeHeight, P as PageRequest, D as PageResult, F as ScriptVtxoCursor, H as ScriptVtxoPageOptions, J as StoredVtxo, K as VtxoRepositoryKey, L as TransactionHistoryPageFilter, M as TransactionHistoryPageCursor, Q as AtomicWalletState, U as WalletState, aE as DescriptorSigningRequest } from './index-C66rjxz2.js';
|
|
3
2
|
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* IndexedDB-based implementation of WalletRepository.
|
|
8
|
-
*/
|
|
9
|
-
declare class IndexedDBWalletRepository implements WalletRepository {
|
|
10
|
-
readonly version: 2;
|
|
11
|
-
private readonly connection;
|
|
12
|
-
/** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
|
|
13
|
-
constructor(dbName?: string, options?: {
|
|
14
|
-
persistentWalletState?: boolean;
|
|
15
|
-
});
|
|
16
|
-
clear(): Promise<void>;
|
|
17
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
18
|
-
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
19
|
-
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
20
|
-
deleteVtxos(address: string): Promise<void>;
|
|
21
|
-
getVtxosForScriptPage(script: string, page: PageRequest<ScriptVtxoCursor>, options?: ScriptVtxoPageOptions): Promise<PageResult<StoredVtxo, ScriptVtxoCursor>>;
|
|
22
|
-
saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
23
|
-
deleteVtxosForScript(script: string): Promise<void>;
|
|
24
|
-
getUtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedCoin, Outpoint>>;
|
|
25
|
-
private pageByAddress;
|
|
26
|
-
saveUtxos(addressOrBatch: string | ReadonlyMap<string, ExtendedCoin[]>, utxos?: ExtendedCoin[]): Promise<void>;
|
|
27
|
-
deleteUtxos(address: string): Promise<void>;
|
|
28
|
-
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
29
|
-
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
30
|
-
deleteTransactions(address: string): Promise<void>;
|
|
31
|
-
readonly atomicWalletState: AtomicWalletState;
|
|
32
|
-
getWalletState(): Promise<WalletState | null>;
|
|
33
|
-
saveWalletState(state: WalletState): Promise<void>;
|
|
34
|
-
private getDB;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A {@link DescriptorProvider} decorator that adds a **keyring**: raw
|
|
39
|
-
* private keys imported from outside the wallet's derivation tree, each
|
|
40
|
-
* addressed by a `tr(<pubkey>)` descriptor.
|
|
41
|
-
*
|
|
42
|
-
* Resolution is union-shaped — `signWithDescriptor` /
|
|
43
|
-
* `signMessageWithDescriptor` serve a descriptor from the wrapped
|
|
44
|
-
* provider's derivation tree *or* from the keyring, whichever owns it —
|
|
45
|
-
* so the wallet's existing descriptor routing
|
|
46
|
-
* (`InputSignerRouter`) signs foreign-key contracts with no changes: an
|
|
47
|
-
* imported contract carrying `metadata.signingDescriptor` is signable by
|
|
48
|
-
* construction rather than throwing `MissingSigningDescriptorError`.
|
|
49
|
-
*
|
|
50
|
-
* Allocation is *not* extended: `getNextSigningDescriptor` always
|
|
51
|
-
* delegates to the wrapped provider. The keyring holds foreign keys the
|
|
52
|
-
* wallet was handed; it never mints receive addresses.
|
|
53
|
-
*
|
|
54
|
-
* Lifecycle: entries persist under
|
|
55
|
-
* `WalletRepository.getWalletState().settings.keyring` (same
|
|
56
|
-
* no-migration pattern as `HDDescriptorProvider`), so an import survives
|
|
57
|
-
* the restarts a recovery spans, and {@link deleteKey} purges it when
|
|
58
|
-
* recovery completes. The repository is the source of truth: the async
|
|
59
|
-
* signing/purge APIs converge on sibling instances' imports and purges
|
|
60
|
-
* (see {@link refresh}), so any tab/worker sharing the repo can complete
|
|
61
|
-
* a recovery another one started.
|
|
62
|
-
*
|
|
63
|
-
* **Keys are stored unencrypted.** This is a deliberate, scoped
|
|
64
|
-
* decision: the intended use is a short-lived, purge-on-completion hold
|
|
65
|
-
* of a key that guards funds already destined for this wallet. At-rest
|
|
66
|
-
* encryption is a possible hardening follow-up. Do not use this to hold
|
|
67
|
-
* long-lived key material.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* const provider = await KeyringDescriptorProvider.create(hdProvider, walletRepo);
|
|
72
|
-
* const descriptor = await provider.importKey(foreignPrivKey);
|
|
73
|
-
* // descriptor: tr(<x-only pubkey hex>)
|
|
74
|
-
* // ... import a contract with metadata.signingDescriptor = descriptor,
|
|
75
|
-
* // let the wallet's recovery machinery settle it, then:
|
|
76
|
-
* await provider.deleteKey(descriptor);
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
declare class KeyringDescriptorProvider implements DescriptorProvider {
|
|
80
|
-
/**
|
|
81
|
-
* The wrapped provider. Exposed so callers that need to reach a
|
|
82
|
-
* concrete provider type behind the decorator (e.g. the wallet's
|
|
83
|
-
* restore path, which branches on `HDDescriptorProvider`) can
|
|
84
|
-
* unwrap it rather than mis-classify the decorator.
|
|
85
|
-
*/
|
|
86
|
-
readonly base: DescriptorProvider;
|
|
87
|
-
private readonly walletRepository;
|
|
88
|
-
/**
|
|
89
|
-
* In-memory mirror of the persisted keyring, keyed by x-only pubkey
|
|
90
|
-
* hex. Required because {@link isOurs} is synchronous while
|
|
91
|
-
* persistence is not. The **repository is the source of truth**: the
|
|
92
|
-
* async APIs write through to it and {@link refresh} re-seeds this
|
|
93
|
-
* mirror from it when a signing request names a foreign key the
|
|
94
|
-
* mirror doesn't know — a sibling instance (another tab/worker on
|
|
95
|
-
* the same repo) may have imported it after this instance was
|
|
96
|
-
* constructed. The sync views ({@link isOurs}, {@link hasKey},
|
|
97
|
-
* {@link listKeyringDescriptors}) answer from the last-known
|
|
98
|
-
* snapshot.
|
|
99
|
-
*/
|
|
100
|
-
private readonly keys;
|
|
101
|
-
private constructor();
|
|
102
|
-
/**
|
|
103
|
-
* Wrap `base` with a keyring, loading any previously imported keys
|
|
104
|
-
* from the repository. Unlike `HDDescriptorProvider.create`, this
|
|
105
|
-
* *does* read at construction: `isOurs` is synchronous and must be
|
|
106
|
-
* able to answer for persisted keys from the first call.
|
|
107
|
-
*/
|
|
108
|
-
static create(base: DescriptorProvider, walletRepository: WalletRepository): Promise<KeyringDescriptorProvider>;
|
|
109
|
-
/**
|
|
110
|
-
* Import a raw private key into the keyring and return its
|
|
111
|
-
* `tr(<x-only pubkey>)` descriptor handle. Idempotent: re-importing
|
|
112
|
-
* the same key returns the same descriptor and leaves storage
|
|
113
|
-
* unchanged.
|
|
114
|
-
*/
|
|
115
|
-
importKey(privateKey: Uint8Array): Promise<string>;
|
|
116
|
-
/**
|
|
117
|
-
* Purge a keyring entry. Returns `true` when an entry was removed,
|
|
118
|
-
* `false` when the descriptor was not in the keyring (already
|
|
119
|
-
* purged, or never ours) — so a repeated purge is a safe no-op.
|
|
120
|
-
*
|
|
121
|
-
* Always goes through storage, never trusting the in-memory mirror:
|
|
122
|
-
* the entry may have been imported by a sibling instance after this
|
|
123
|
-
* one was constructed, and skipping the persistent purge on a memory
|
|
124
|
-
* miss would leave that key at rest forever.
|
|
125
|
-
*/
|
|
126
|
-
deleteKey(descriptor: string): Promise<boolean>;
|
|
127
|
-
/** True iff `descriptor` resolves to a key held in the keyring. */
|
|
128
|
-
hasKey(descriptor: string): boolean;
|
|
129
|
-
/** The `tr(<pubkey>)` descriptors of every key currently held. */
|
|
130
|
-
listKeyringDescriptors(): string[];
|
|
131
|
-
/** Allocation is the wrapped provider's job; the keyring never mints. */
|
|
132
|
-
getNextSigningDescriptor(): Promise<string>;
|
|
133
|
-
/** Ours iff the wrapped provider claims it, or the keyring holds it. */
|
|
134
|
-
isOurs(descriptor: string): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Signs each request with the key its descriptor resolves to.
|
|
137
|
-
* Keyring-owned requests are signed here; every other request is
|
|
138
|
-
* handed to the wrapped provider in a single batched call, so a
|
|
139
|
-
* batch-signing identity behind a `StaticDescriptorProvider` still
|
|
140
|
-
* sees one interaction.
|
|
141
|
-
*
|
|
142
|
-
* Results are returned in request order regardless of how the
|
|
143
|
-
* requests split across the two signers.
|
|
144
|
-
*/
|
|
145
|
-
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
146
|
-
/** Signs a message with the keyring key, or delegates to the base. */
|
|
147
|
-
signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
148
|
-
/**
|
|
149
|
-
* Split requests into keyring-owned and base-delegated buckets.
|
|
150
|
-
* `mayBeStale` is set when a delegated descriptor is foreign-shaped —
|
|
151
|
-
* a sibling instance may have imported its key after this instance
|
|
152
|
-
* seeded the mirror, so the caller should {@link refresh} once and
|
|
153
|
-
* re-split before trusting the delegation.
|
|
154
|
-
*/
|
|
155
|
-
private splitRequests;
|
|
156
|
-
/**
|
|
157
|
-
* True when `descriptor` is a bare `tr(<pubkey>)` the base provider
|
|
158
|
-
* does not own — the only shape a keyring entry can have, so the only
|
|
159
|
-
* kind of miss a {@link refresh} could turn into a hit.
|
|
160
|
-
*/
|
|
161
|
-
private isForeignShaped;
|
|
162
|
-
/**
|
|
163
|
-
* Re-seed the in-memory mirror from the repository, converging on
|
|
164
|
-
* imports and purges made by sibling instances on the same repo.
|
|
165
|
-
* Full replacement, not a merge, so sibling *deletions* propagate
|
|
166
|
-
* too. Corrupt persisted settings throw, same as {@link create}.
|
|
167
|
-
*
|
|
168
|
-
* Only a *miss* triggers a refresh, so that convergence is one-sided:
|
|
169
|
-
* an entry this instance still believes it holds is never
|
|
170
|
-
* revalidated, and a sibling's purge can linger in this mirror until
|
|
171
|
-
* some unrelated foreign-shaped miss re-seeds it. Harmless today —
|
|
172
|
-
* `deleteKey`'s caller also deletes the contract row carrying the
|
|
173
|
-
* descriptor, so no signing request can name the stale entry — but it
|
|
174
|
-
* means the at-rest purge is not a memory purge for siblings.
|
|
175
|
-
*/
|
|
176
|
-
private refresh;
|
|
177
|
-
/**
|
|
178
|
-
* The keyring key for `descriptor`, or `undefined` when the request
|
|
179
|
-
* belongs to the base provider. Base ownership wins on collision:
|
|
180
|
-
* a key already in the derivation tree keeps its established signing
|
|
181
|
-
* path, so importing it cannot reroute existing contracts.
|
|
182
|
-
*/
|
|
183
|
-
private resolveKey;
|
|
184
|
-
/**
|
|
185
|
-
* Read-modify-write the keyring settings through `updateWalletState`,
|
|
186
|
-
* whose in-process mutex plus cross-context Web Lock keep concurrent
|
|
187
|
-
* imports/purges — including ones driven from other tabs/workers
|
|
188
|
-
* sharing the store — from clobbering each other's entries.
|
|
189
|
-
*/
|
|
190
|
-
private mutate;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Capability a wallet exposes so descriptor-blind consumers (Boltz swaps, other plugins) can bind
|
|
195
|
-
* artifacts to the wallet's current HD index and later enumerate every used index. Probed
|
|
196
|
-
* structurally ({@link isHDWalletCapable}) rather than widening `IWallet`, so plugins keep working
|
|
197
|
-
* against older wallets; a static wallet answers "no HD state" through the same methods.
|
|
198
|
-
*/
|
|
199
|
-
interface HDWalletCapable {
|
|
200
|
-
/**
|
|
201
|
-
* The descriptor at the wallet's current receive index, or `undefined` for
|
|
202
|
-
* static / `auto` wallets and HD wallets that have never rotated. Callers
|
|
203
|
-
* fall back to the identity key.
|
|
204
|
-
*/
|
|
205
|
-
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
206
|
-
/**
|
|
207
|
-
* Every descriptor the wallet may hold keys under, ascending by index: the allocation
|
|
208
|
-
* watermark's band plus any descriptor persisted on a contract. Empty for static wallets.
|
|
209
|
-
* `lookAhead` appends that many past the watermark without advancing it, for restore probing.
|
|
210
|
-
*/
|
|
211
|
-
getUsedSigningDescriptors(opts?: {
|
|
212
|
-
lookAhead?: number;
|
|
213
|
-
}): Promise<string[]>;
|
|
214
|
-
/**
|
|
215
|
-
* An {@link Identity} whose keys and signatures are those of `descriptor`; the wallet
|
|
216
|
-
* identity itself when `descriptor` is the identity's own key.
|
|
217
|
-
*
|
|
218
|
-
* Throws {@link ForeignDescriptorError} for a descriptor this wallet cannot sign for — never
|
|
219
|
-
* substitutes another key, which would sign happily and surface only as a rejected tx or a
|
|
220
|
-
* dead script. The returned identity must actually sign (`sign`, `signMessage`,
|
|
221
|
-
* `signerSession`): `contractSigner` refuses a watch-only one as `WalletCannotSignError`,
|
|
222
|
-
* which would otherwise pass every check and throw after the contract is funded.
|
|
223
|
-
*/
|
|
224
|
-
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds no key for the
|
|
228
|
-
* descriptor, so callers can tell "not my key" from transient signing failures.
|
|
229
|
-
*/
|
|
230
|
-
declare class ForeignDescriptorError extends Error {
|
|
231
|
-
readonly descriptor: string;
|
|
232
|
-
readonly name = "ForeignDescriptorError";
|
|
233
|
-
constructor(descriptor: string, options?: {
|
|
234
|
-
cause?: unknown;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Thrown by `Wallet.getNewAddresses({ forceNew: true })` when there is no HD stream to advance
|
|
239
|
-
* (`walletMode: 'static'` / `'auto'`, or a {@link DescriptorProvider} that declined). Typed
|
|
240
|
-
* rather than a silent repeat, which would surface only as two payers sharing a script.
|
|
241
|
-
*/
|
|
242
|
-
declare class WalletCannotAllocateAddressError extends Error {
|
|
243
|
-
readonly name = "WalletCannotAllocateAddressError";
|
|
244
|
-
constructor(reason: string, options?: {
|
|
245
|
-
cause?: unknown;
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
/** Anything that can derive and sign for a descriptor it claims. */
|
|
249
|
-
type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
|
|
250
|
-
/**
|
|
251
|
-
* The identity that signs `descriptor`, or {@link ForeignDescriptorError}. Shared by every
|
|
252
|
-
* {@link HDWalletCapable.signerForDescriptor} so page- and worker-side wallets cannot drift into
|
|
253
|
-
* a signer that passes a pubkey check and then throws on every signature, after funding.
|
|
254
|
-
*/
|
|
255
|
-
declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
|
|
256
|
-
/** Structural type guard for {@link HDWalletCapable}. */
|
|
257
|
-
declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
258
|
-
/**
|
|
259
|
-
* Allocating a *fresh* index — strictly more than {@link HDWalletCapable}'s descriptor awareness.
|
|
260
|
-
* A separate probe because widening that guard would silently demote every wallet implementing
|
|
261
|
-
* only its original surface (including older SDKs') from HD-capable to static.
|
|
262
|
-
*/
|
|
263
|
-
interface HDAllocationCapable {
|
|
264
|
-
/**
|
|
265
|
-
* The signing descriptor a new artifact (swap, invoice, contract) should bind to. **The
|
|
266
|
-
* wallet decides**: an HD wallet allocates a fresh index, advancing the watermark; a static
|
|
267
|
-
* wallet answers with its one `tr(pubkey)` every time. Consumers must not probe the wallet's
|
|
268
|
-
* shape or mint key material; they use the answer with
|
|
269
|
-
* {@link HDWalletCapable.signerForDescriptor}.
|
|
270
|
-
*
|
|
271
|
-
* `undefined` only for implementations that genuinely cannot answer (`Wallet` always
|
|
272
|
-
* answers); callers then fall back to the identity key — never a random one.
|
|
273
|
-
*
|
|
274
|
-
* Unlike {@link HDWalletCapable.getCurrentSigningDescriptor}, which peeks (two artifacts bound
|
|
275
|
-
* to a peek share a key). Per-call uniqueness is a wallet property, so anything deriving
|
|
276
|
-
* per-artifact secrets must check the descriptor's shape, not the wallet's.
|
|
277
|
-
*/
|
|
278
|
-
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
279
|
-
/**
|
|
280
|
-
* Move the allocation watermark to `descriptor`'s index so later allocations cannot reissue
|
|
281
|
-
* it. Monotonic; a static wallet accepts its own descriptor as a no-op.
|
|
282
|
-
*
|
|
283
|
-
* Throws on a descriptor this wallet cannot derive, or an HD descriptor with no parseable
|
|
284
|
-
* trailing index: mapping those to index 0 would let a restored artifact's index be reissued.
|
|
285
|
-
*/
|
|
286
|
-
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
287
|
-
}
|
|
288
|
-
/** Structural type guard for {@link HDAllocationCapable}. */
|
|
289
|
-
declare function isHDAllocationCapable(value: unknown): value is HDAllocationCapable;
|
|
290
|
-
/**
|
|
291
|
-
* Minting addresses to hand out: beyond {@link HDAllocationCapable}'s bare index, the wallet
|
|
292
|
-
* builds the scripts, persists them as watched contracts, and reports the rows. A third probe
|
|
293
|
-
* for the same no-silent-demotion reason.
|
|
294
|
-
*/
|
|
295
|
-
interface AddressAllocationCapable {
|
|
296
|
-
/**
|
|
297
|
-
* Fresh addresses of each requested type from one newly allocated HD index, persisted and
|
|
298
|
-
* watched. An HD wallet burns an index; a wallet with no stream answers with its existing
|
|
299
|
-
* display addresses or, under `forceNew`, throws {@link WalletCannotAllocateAddressError}.
|
|
300
|
-
*
|
|
301
|
-
* Unlike {@link HDAllocationCapable.getNextSigningDescriptor}, allocation and script
|
|
302
|
-
* registration happen together: split across a process boundary, a failed registration
|
|
303
|
-
* leaves a burnt index and an unwatched address.
|
|
304
|
-
*/
|
|
305
|
-
getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
|
|
306
|
-
}
|
|
307
|
-
/** Structural type guard for {@link AddressAllocationCapable}. */
|
|
308
|
-
declare function isAddressAllocationCapable(value: unknown): value is AddressAllocationCapable;
|
|
3
|
+
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
|
+
import { R as RelativeTimelock, A as ArkAddress, C as CSVMultisigTapscript } from './base-C-Y5t_0F.js';
|
|
5
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-iyDum4fw.js';
|
|
309
6
|
|
|
310
7
|
/** Wall-clock floor for `batchExpiry` outside regtest. */
|
|
311
8
|
declare const DEFAULT_MIN_BATCH_EXPIRY_SECONDS = 86400n;
|
|
@@ -371,6 +68,7 @@ declare const ArkErrorName: {
|
|
|
371
68
|
*/
|
|
372
69
|
readonly FORFEIT_CLOSURE_LOCKED: "FORFEIT_CLOSURE_LOCKED";
|
|
373
70
|
readonly INVALID_INTENT_PROOF: "INVALID_INTENT_PROOF";
|
|
71
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
374
72
|
};
|
|
375
73
|
type ArkErrorName = (typeof ArkErrorName)[keyof typeof ArkErrorName];
|
|
376
74
|
/**
|
|
@@ -422,7 +120,7 @@ declare class ServerResponseMismatchError extends Error {
|
|
|
422
120
|
*/
|
|
423
121
|
declare function maybeArkError(error: any): ArkError | undefined;
|
|
424
122
|
|
|
425
|
-
/** Where the {@link
|
|
123
|
+
/** Where the {@link OperatorInfo} used to construct a wallet came from. */
|
|
426
124
|
type ServerInfoSource = "live" | "cache";
|
|
427
125
|
|
|
428
126
|
/**
|
|
@@ -522,6 +220,12 @@ declare namespace Batch {
|
|
|
522
220
|
skipVtxoTreeSigning: boolean;
|
|
523
221
|
eventCallback: (event: SettlementEvent) => Promise<void>;
|
|
524
222
|
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Starts `stream` so the provider subscribes now, before the caller registers an intent whose
|
|
225
|
+
* batch could otherwise start unseen. The returned iterator replays the first event; pass it
|
|
226
|
+
* to {@link join}.
|
|
227
|
+
*/
|
|
228
|
+
function prime(stream: AsyncIterableIterator<SettlementEvent>): AsyncIterableIterator<SettlementEvent>;
|
|
525
229
|
/**
|
|
526
230
|
* Start the state machine that will process the batch events and join a batch.
|
|
527
231
|
* @param eventIterator - The events stream to process.
|
|
@@ -670,23 +374,140 @@ declare class WalletReceiveRotator {
|
|
|
670
374
|
/** Wait for any in-flight rotation to complete (mainly for tests). */
|
|
671
375
|
drain(): Promise<void>;
|
|
672
376
|
/**
|
|
673
|
-
* Run `fn` on the rotation chain. {@link Wallet.rotateServerSigner} uses it because both it
|
|
674
|
-
* and `rotate()` swap `offchainTapscript`; interleaving could tear the visible receive state.
|
|
675
|
-
* The chain advances even if `fn` rejects (the caller still sees the rejection).
|
|
377
|
+
* Run `fn` on the rotation chain. {@link Wallet.rotateServerSigner} uses it because both it
|
|
378
|
+
* and `rotate()` swap `offchainTapscript`; interleaving could tear the visible receive state.
|
|
379
|
+
* The chain advances even if `fn` rejects (the caller still sees the rejection).
|
|
380
|
+
*/
|
|
381
|
+
runExclusive<T>(fn: () => Promise<T>): Promise<T>;
|
|
382
|
+
/**
|
|
383
|
+
* Unsubscribe first so no late event queues work, then drain so an in-flight
|
|
384
|
+
* `createContract` finishes before the contract manager disposes.
|
|
385
|
+
*/
|
|
386
|
+
dispose(): Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Allocate the next descriptor, register it as the new tagged display contract (same
|
|
389
|
+
* default/delegate shape), swap it in, and mark the previous tagged one `inactive` (still
|
|
390
|
+
* watched; it just stops being advertised). The untagged index-0 baseline is never retired.
|
|
391
|
+
*/
|
|
392
|
+
private rotate;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Capability a wallet exposes so descriptor-blind consumers (Boltz swaps, other plugins) can bind
|
|
397
|
+
* artifacts to the wallet's current HD index and later enumerate every used index. Probed
|
|
398
|
+
* structurally ({@link isHDWalletCapable}) rather than widening `IWallet`, so plugins keep working
|
|
399
|
+
* against older wallets; a static wallet answers "no HD state" through the same methods.
|
|
400
|
+
*/
|
|
401
|
+
interface HDWalletCapable {
|
|
402
|
+
/**
|
|
403
|
+
* The descriptor at the wallet's current receive index, or `undefined` for
|
|
404
|
+
* static / `auto` wallets and HD wallets that have never rotated. Callers
|
|
405
|
+
* fall back to the identity key.
|
|
406
|
+
*/
|
|
407
|
+
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
408
|
+
/**
|
|
409
|
+
* Every descriptor the wallet may hold keys under, ascending by index: the allocation
|
|
410
|
+
* watermark's band plus any descriptor persisted on a contract. Empty for static wallets.
|
|
411
|
+
* `lookAhead` appends that many past the watermark without advancing it, for restore probing.
|
|
412
|
+
*/
|
|
413
|
+
getUsedSigningDescriptors(opts?: {
|
|
414
|
+
lookAhead?: number;
|
|
415
|
+
}): Promise<string[]>;
|
|
416
|
+
/**
|
|
417
|
+
* An {@link Identity} whose keys and signatures are those of `descriptor`; the wallet
|
|
418
|
+
* identity itself when `descriptor` is the identity's own key.
|
|
419
|
+
*
|
|
420
|
+
* Throws {@link ForeignDescriptorError} for a descriptor this wallet cannot sign for — never
|
|
421
|
+
* substitutes another key, which would sign happily and surface only as a rejected tx or a
|
|
422
|
+
* dead script. The returned identity must actually sign (`sign`, `signMessage`,
|
|
423
|
+
* `signerSession`): `contractSigner` refuses a watch-only one as `WalletCannotSignError`,
|
|
424
|
+
* which would otherwise pass every check and throw after the contract is funded.
|
|
425
|
+
*/
|
|
426
|
+
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds no key for the
|
|
430
|
+
* descriptor, so callers can tell "not my key" from transient signing failures.
|
|
431
|
+
*/
|
|
432
|
+
declare class ForeignDescriptorError extends Error {
|
|
433
|
+
readonly descriptor: string;
|
|
434
|
+
readonly name = "ForeignDescriptorError";
|
|
435
|
+
constructor(descriptor: string, options?: {
|
|
436
|
+
cause?: unknown;
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Thrown by `Wallet.getNewAddresses({ forceNew: true })` when there is no HD stream to advance
|
|
441
|
+
* (`walletMode: 'static'` / `'auto'`, or a {@link DescriptorProvider} that declined). Typed
|
|
442
|
+
* rather than a silent repeat, which would surface only as two payers sharing a script.
|
|
443
|
+
*/
|
|
444
|
+
declare class WalletCannotAllocateAddressError extends Error {
|
|
445
|
+
readonly name = "WalletCannotAllocateAddressError";
|
|
446
|
+
constructor(reason: string, options?: {
|
|
447
|
+
cause?: unknown;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
/** Anything that can derive and sign for a descriptor it claims. */
|
|
451
|
+
type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
|
|
452
|
+
/**
|
|
453
|
+
* The identity that signs `descriptor`, or {@link ForeignDescriptorError}. Shared by every
|
|
454
|
+
* {@link HDWalletCapable.signerForDescriptor} so page- and worker-side wallets cannot drift into
|
|
455
|
+
* a signer that passes a pubkey check and then throws on every signature, after funding.
|
|
456
|
+
*/
|
|
457
|
+
declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
|
|
458
|
+
/** Structural type guard for {@link HDWalletCapable}. */
|
|
459
|
+
declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
460
|
+
/**
|
|
461
|
+
* Allocating a *fresh* index — strictly more than {@link HDWalletCapable}'s descriptor awareness.
|
|
462
|
+
* A separate probe because widening that guard would silently demote every wallet implementing
|
|
463
|
+
* only its original surface (including older SDKs') from HD-capable to static.
|
|
464
|
+
*/
|
|
465
|
+
interface HDAllocationCapable {
|
|
466
|
+
/**
|
|
467
|
+
* The signing descriptor a new artifact (swap, invoice, contract) should bind to. **The
|
|
468
|
+
* wallet decides**: an HD wallet allocates a fresh index, advancing the watermark; a static
|
|
469
|
+
* wallet answers with its one `tr(pubkey)` every time. Consumers must not probe the wallet's
|
|
470
|
+
* shape or mint key material; they use the answer with
|
|
471
|
+
* {@link HDWalletCapable.signerForDescriptor}.
|
|
472
|
+
*
|
|
473
|
+
* `undefined` only for implementations that genuinely cannot answer (`Wallet` always
|
|
474
|
+
* answers); callers then fall back to the identity key — never a random one.
|
|
475
|
+
*
|
|
476
|
+
* Unlike {@link HDWalletCapable.getCurrentSigningDescriptor}, which peeks (two artifacts bound
|
|
477
|
+
* to a peek share a key). Per-call uniqueness is a wallet property, so anything deriving
|
|
478
|
+
* per-artifact secrets must check the descriptor's shape, not the wallet's.
|
|
676
479
|
*/
|
|
677
|
-
|
|
480
|
+
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
678
481
|
/**
|
|
679
|
-
*
|
|
680
|
-
*
|
|
482
|
+
* Move the allocation watermark to `descriptor`'s index so later allocations cannot reissue
|
|
483
|
+
* it. Monotonic; a static wallet accepts its own descriptor as a no-op.
|
|
484
|
+
*
|
|
485
|
+
* Throws on a descriptor this wallet cannot derive, or an HD descriptor with no parseable
|
|
486
|
+
* trailing index: mapping those to index 0 would let a restored artifact's index be reissued.
|
|
681
487
|
*/
|
|
682
|
-
|
|
488
|
+
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
489
|
+
}
|
|
490
|
+
/** Structural type guard for {@link HDAllocationCapable}. */
|
|
491
|
+
declare function isHDAllocationCapable(value: unknown): value is HDAllocationCapable;
|
|
492
|
+
/**
|
|
493
|
+
* Minting addresses to hand out: beyond {@link HDAllocationCapable}'s bare index, the wallet
|
|
494
|
+
* builds the scripts, persists them as watched contracts, and reports the rows. A third probe
|
|
495
|
+
* for the same no-silent-demotion reason.
|
|
496
|
+
*/
|
|
497
|
+
interface AddressAllocationCapable {
|
|
683
498
|
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
*
|
|
499
|
+
* Fresh addresses of each requested type from one newly allocated HD index, persisted and
|
|
500
|
+
* watched. An HD wallet burns an index; a wallet with no stream answers with its existing
|
|
501
|
+
* display addresses or, under `forceNew`, throws {@link WalletCannotAllocateAddressError}.
|
|
502
|
+
*
|
|
503
|
+
* Unlike {@link HDAllocationCapable.getNextSigningDescriptor}, allocation and script
|
|
504
|
+
* registration happen together: split across a process boundary, a failed registration
|
|
505
|
+
* leaves a burnt index and an unwatched address.
|
|
687
506
|
*/
|
|
688
|
-
|
|
507
|
+
getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
|
|
689
508
|
}
|
|
509
|
+
/** Structural type guard for {@link AddressAllocationCapable}. */
|
|
510
|
+
declare function isAddressAllocationCapable(value: unknown): value is AddressAllocationCapable;
|
|
690
511
|
|
|
691
512
|
/**
|
|
692
513
|
* Cap on HD descriptors getUsedSigningDescriptors() materializes past the watermark (bounds
|
|
@@ -701,6 +522,17 @@ type IncomingFunds = {
|
|
|
701
522
|
newVtxos: ExtendedVirtualCoin[];
|
|
702
523
|
spentVtxos: ExtendedVirtualCoin[];
|
|
703
524
|
};
|
|
525
|
+
/**
|
|
526
|
+
* Capability contract for a wallet that can report newly received funds.
|
|
527
|
+
*
|
|
528
|
+
* Kept as its own interface rather than on the wallet interfaces because not every wallet
|
|
529
|
+
* implements it (the service-worker and Expo wallets do not), matching the repo's
|
|
530
|
+
* capability-interface pattern. Lets helpers depend on just this one method instead of the
|
|
531
|
+
* whole Wallet class.
|
|
532
|
+
*/
|
|
533
|
+
interface NotifiesIncomingFunds {
|
|
534
|
+
notifyIncomingFunds(eventCallback: (coins: IncomingFunds) => void): Promise<() => void>;
|
|
535
|
+
}
|
|
704
536
|
|
|
705
537
|
/**
|
|
706
538
|
* Structural rather than {@link ContractWithVtxos} so the worker's repository-built snapshot
|
|
@@ -715,7 +547,7 @@ type PendingRecoverySnapshot = Parameters<typeof selectPendingRecoveryOutpoints>
|
|
|
715
547
|
interface BoardingUtxoGroup {
|
|
716
548
|
/** Tapscript of the boarding address the coins sit on. */
|
|
717
549
|
tapscript: DefaultVtxo.Script;
|
|
718
|
-
/**
|
|
550
|
+
/** Operator key of that address, normalized x-only hex. */
|
|
719
551
|
serverPubKey: string;
|
|
720
552
|
/** CSV exit timelock decoded from THIS tapscript's exit leaf. */
|
|
721
553
|
csvTimelock: RelativeTimelock;
|
|
@@ -732,10 +564,10 @@ interface BoardingUtxoGroup {
|
|
|
732
564
|
* `Unroll.completeUnroll` is the remedy.
|
|
733
565
|
* - `has-assets` — asset-bearing; the BTC-only sweep would burn the assets.
|
|
734
566
|
* - `sweep-failed` — spendable, but its own sweep was rejected.
|
|
735
|
-
* - `recovery-failed` —
|
|
567
|
+
* - `recovery-failed` — operator-swept and recoverable in principle, but the
|
|
736
568
|
* import that hands it to the wallet's recovery machinery failed.
|
|
737
569
|
*
|
|
738
|
-
*
|
|
570
|
+
* An output the operator swept whose import *succeeds* is not reported here — it lands
|
|
739
571
|
* in {@link ArkadeCashClaimResult.recovering} instead.
|
|
740
572
|
*/
|
|
741
573
|
type ArkadeCashUnclaimedReason = "subdust" | "already-spent" | "exited" | "has-assets" | "sweep-failed" | "recovery-failed";
|
|
@@ -761,7 +593,7 @@ interface ArkadeCashClaimResult {
|
|
|
761
593
|
/** Satoshis swept to this wallet instantly (the thin single-key sweep). */
|
|
762
594
|
swept: number;
|
|
763
595
|
/**
|
|
764
|
-
*
|
|
596
|
+
* Operator-swept outputs imported for recovery. These funds are not in the
|
|
765
597
|
* wallet yet: a swept VTXO can only move through a settlement, so
|
|
766
598
|
* `claimCash` imports it as a signable contract and hands it to the
|
|
767
599
|
* wallet's own recovery machinery, which settles it back (rotation-aware)
|
|
@@ -813,7 +645,7 @@ declare class ArkadeCashOperatorMismatchError extends Error {
|
|
|
813
645
|
activeSignerPubKey: string);
|
|
814
646
|
}
|
|
815
647
|
/**
|
|
816
|
-
* Freshness of provider-backed sync (
|
|
648
|
+
* Freshness of provider-backed sync (operator info source + indexer-sync health). Balances/VTXOs
|
|
817
649
|
* are always served from the repository regardless. `syncing` says a provider sync is in flight
|
|
818
650
|
* right now; optional so adding it breaks no implementer, {@link ReadonlyWallet} always sets it.
|
|
819
651
|
*/
|
|
@@ -849,7 +681,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
849
681
|
protected vtxoSyncOverlapMs?: number;
|
|
850
682
|
protected copySyncOverlapTo(wallet: ReadonlyWallet): void;
|
|
851
683
|
/** Opt-in intent-lifecycle repository; `undefined` ⇒ intent persistence is a no-op. */
|
|
852
|
-
intentRepository?:
|
|
684
|
+
intentRepository?: BatchRegistrationRepository;
|
|
853
685
|
/**
|
|
854
686
|
* **Experimental / inert.** Opt-in virtual-tx repository, exposed so callers can pass it to
|
|
855
687
|
* {@link Unroll.Session.create} as a best-effort raw-tx cache. Normal sync never writes it.
|
|
@@ -879,13 +711,13 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
879
711
|
*/
|
|
880
712
|
protected _boardingTapscript: DefaultVtxo.Script;
|
|
881
713
|
/**
|
|
882
|
-
* Active
|
|
714
|
+
* Active operator signer (x-only); written only by
|
|
883
715
|
* {@link Wallet.setArkServerPublicKeyForRotation} when arkd rotates its signer mid-session.
|
|
884
716
|
*/
|
|
885
717
|
protected _arkServerPublicKey: Bytes;
|
|
886
718
|
/**
|
|
887
|
-
* Whether the LATEST
|
|
888
|
-
* Updated on every {@link
|
|
719
|
+
* Whether the LATEST operator info resolution was live or fell back to the cached snapshot.
|
|
720
|
+
* Updated on every {@link getOperatorInfo} read so recovery (or a fresh fallback) is reflected.
|
|
889
721
|
*/
|
|
890
722
|
protected _serverInfoSource: ServerInfoSource;
|
|
891
723
|
/**
|
|
@@ -897,7 +729,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
897
729
|
get serverInfoSource(): ServerInfoSource;
|
|
898
730
|
/**
|
|
899
731
|
* Composed provider-connection freshness: degraded on `arkade` (`cache`) when the latest
|
|
900
|
-
*
|
|
732
|
+
* operator info resolution fell back, else degraded on `indexer` (`repository`) when an
|
|
901
733
|
* initialized contract manager has, else online. Never forces a `ContractManager` to
|
|
902
734
|
* construct, so it is safe for readonly callers.
|
|
903
735
|
*/
|
|
@@ -919,7 +751,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
919
751
|
*/
|
|
920
752
|
protected _deprecatedSigners: Map<string, bigint>;
|
|
921
753
|
/**
|
|
922
|
-
* Refresh the cached deprecated-signer set from
|
|
754
|
+
* Refresh the cached deprecated-signer set from operator info; feeds
|
|
923
755
|
* {@link pendingRecoveryOutpoints}. Lenient: a malformed entry is skipped, never fatal.
|
|
924
756
|
*/
|
|
925
757
|
refreshDeprecatedSigners(info: {
|
|
@@ -941,7 +773,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
941
773
|
/** Current active server signer (x-only, 32 bytes); changes only on server-signer rotation. */
|
|
942
774
|
get arkServerPublicKey(): Bytes;
|
|
943
775
|
/**
|
|
944
|
-
*
|
|
776
|
+
* Info for the connected operator: live wins, a retryable failure falls back to
|
|
945
777
|
* the boot snapshot, a terminal one propagates. Live because `signerPubkey`,
|
|
946
778
|
* `checkpointTapscript` and `fees` move on rotation, and a covenant built against a
|
|
947
779
|
* superseded signer is unspendable.
|
|
@@ -951,12 +783,14 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
951
783
|
* on N; the provider's `onServerInfoChanged` closes the window. Pass `{ requireLive: true }`
|
|
952
784
|
* before binding the answer into a covenant to fail closed instead of getting the snapshot.
|
|
953
785
|
*
|
|
954
|
-
* @returns The
|
|
955
|
-
* @see
|
|
786
|
+
* @returns The operator's info
|
|
787
|
+
* @see OperatorInfo
|
|
956
788
|
*/
|
|
957
|
-
|
|
789
|
+
getOperatorInfo(opts?: GetOperatorInfoOptions): Promise<OperatorInfo>;
|
|
790
|
+
/** @deprecated Use {@link getOperatorInfo}. */
|
|
791
|
+
getArkadeInfo(opts?: GetOperatorInfoOptions): Promise<OperatorInfo>;
|
|
958
792
|
/**
|
|
959
|
-
* Chain reads against this wallet's
|
|
793
|
+
* Chain reads against this wallet's operator for scripts it does not own, bound to the wallet's
|
|
960
794
|
* own (possibly Expo/injected) `indexerProvider`. `getVtxos` normalizes via
|
|
961
795
|
* {@link getNormalizedVtxos}. A bound object, not the provider, so an `IReadonlyWallet`
|
|
962
796
|
* holder gets these two reads and nothing else.
|
|
@@ -1056,7 +890,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1056
890
|
*/
|
|
1057
891
|
private expiredSignerExclusion;
|
|
1058
892
|
/** The intent store's lock set. Fails open, like every other read of it. */
|
|
1059
|
-
|
|
893
|
+
protected lockedOutpoints(): Promise<Set<string>>;
|
|
1060
894
|
/**
|
|
1061
895
|
* One contract+VTXO read (which may sync against the indexer). Callers needing several views
|
|
1062
896
|
* derive them all from one snapshot so they answer about the same instant.
|
|
@@ -1117,27 +951,38 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1117
951
|
}>;
|
|
1118
952
|
/**
|
|
1119
953
|
* Every boarding tapscript whose UTXOs belong to this wallet (rotation spreads them over
|
|
1120
|
-
* several addresses), deduplicated by scriptPubKey.
|
|
1121
|
-
*
|
|
954
|
+
* several addresses), deduplicated by scriptPubKey. Includes index-0 `default` rows when a
|
|
955
|
+
* baseline boarding script coalesced with one.
|
|
1122
956
|
*
|
|
1123
|
-
* @param allowedSigners - x-only
|
|
957
|
+
* @param allowedSigners - x-only operator keys whose persisted boarding rows are included;
|
|
1124
958
|
* defaults to the current signer (the foreign-ASP guard). Migration widens it to old signers.
|
|
1125
959
|
* The baseline and current display tapscript are included regardless.
|
|
1126
960
|
*/
|
|
1127
961
|
protected getBoardingTapscripts(allowedSigners?: Set<string>): Promise<DefaultVtxo.Script[]>;
|
|
1128
962
|
/**
|
|
1129
|
-
* Fetch and cache
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
963
|
+
* Fetch and cache onchain inputs (UTXOs) received at the boarding addresses
|
|
964
|
+
* of the given signer set, grouped per boarding address so the caller keeps
|
|
965
|
+
* the address↔signer association that {@link ExtendedCoin} cannot carry
|
|
966
|
+
* (it retains only the encoded leaves/tapTree the spend needs, not the
|
|
967
|
+
* `DefaultVtxo.Script` and its `serverPubKey`/CSV delay).
|
|
1132
968
|
*
|
|
1133
|
-
*
|
|
969
|
+
* Per group: `getCoins` (a failure throws), then `ContractManager.syncOnchain`,
|
|
970
|
+
* then the fetched coins minus stored-spent outpoints → {@link extendCoinWithTapscript}.
|
|
971
|
+
* It does not call `getInfo()`; the caller supplies the allowed signer set.
|
|
972
|
+
*
|
|
973
|
+
* @param allowedSigners - x-only-hex operator keys whose boarding addresses to
|
|
1134
974
|
* fetch (passed through to {@link getBoardingTapscripts}).
|
|
975
|
+
* @param skipFailedSigners - x-only-hex server keys whose address lookups may fail: that
|
|
976
|
+
* address is left out of the result and its cache untouched, instead of failing the whole
|
|
977
|
+
* fetch. A lookup under any other signer still rejects.
|
|
1135
978
|
*/
|
|
1136
|
-
getBoardingUtxosForSigners(allowedSigners: Set<string>): Promise<BoardingUtxoGroup[]>;
|
|
979
|
+
getBoardingUtxosForSigners(allowedSigners: Set<string>, skipFailedSigners?: ReadonlySet<string>): Promise<BoardingUtxoGroup[]>;
|
|
980
|
+
/** `undefined` when a lookup under one of `skipFailedSigners` failed or timed out. */
|
|
981
|
+
private fetchBoardingCoins;
|
|
1137
982
|
/**
|
|
1138
983
|
* Fetch and cache boarding UTXOs at current and historical boarding addresses, each annotated
|
|
1139
984
|
* with its own address's tapscript so spends use the right per-index leaves. Current-signer
|
|
1140
|
-
* only: old-signer inputs would make a plain `settle()` the
|
|
985
|
+
* only: old-signer inputs would make a plain `settle()` the operator must reject, so their
|
|
1141
986
|
* recovery goes through the deprecated-signer migration API.
|
|
1142
987
|
*/
|
|
1143
988
|
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
@@ -1148,6 +993,13 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1148
993
|
* stay gone if it fails.
|
|
1149
994
|
*/
|
|
1150
995
|
getSelectableBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
996
|
+
/**
|
|
997
|
+
* @internal {@link getSelectableBoardingUtxos} for every boarding address history shows,
|
|
998
|
+
* current and deprecated signers, grouped by signer. Only the boarding sweep reads it: a
|
|
999
|
+
* unilateral exit needs no operator, so it recovers coins that `settle` must not take.
|
|
1000
|
+
*/
|
|
1001
|
+
getSelectableBoardingUtxoGroups(): Promise<BoardingUtxoGroup[]>;
|
|
1002
|
+
/** Boarding coins from the store, no network call; pending and confirmed spends excluded. */
|
|
1151
1003
|
getStoredBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
1152
1004
|
/**
|
|
1153
1005
|
* Subscribe to onchain and offchain notifications for newly received funds.
|
|
@@ -1202,7 +1054,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1202
1054
|
* @see Wallet.lookAheadConfig
|
|
1203
1055
|
*/
|
|
1204
1056
|
protected lookAheadConfig(): ContractManagerConfig["lookAhead"];
|
|
1205
|
-
/** Readonly wallets never settle, so they neither release nor own
|
|
1057
|
+
/** Readonly wallets never settle, so they neither release nor own batch registrations. */
|
|
1206
1058
|
protected intentReconciliationConfig(): ContractManagerConfig["intentReconciliation"];
|
|
1207
1059
|
private initializeContractManager;
|
|
1208
1060
|
/** Dispose wallet-owned managers and release background resources. */
|
|
@@ -1267,7 +1119,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1267
1119
|
*/
|
|
1268
1120
|
private _serverInfoInFlight;
|
|
1269
1121
|
/**
|
|
1270
|
-
* React to a mid-session
|
|
1122
|
+
* React to a mid-session operator info change (`DIGEST_MISMATCH`): refresh deprecated signers
|
|
1271
1123
|
* first so boarding watch widens immediately, then rotate via {@link rotateServerSigner} only
|
|
1272
1124
|
* if the active signer changed. Old-signer rows stay active. Never throws into the emit loop.
|
|
1273
1125
|
*/
|
|
@@ -1275,7 +1127,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1275
1127
|
/**
|
|
1276
1128
|
* Await an `onServerInfoChanged` handler still applying a rotation. {@link rotateServerSigner}
|
|
1277
1129
|
* persists the new signer's rows *before* committing the tapscripts, so a path that refreshes
|
|
1278
|
-
*
|
|
1130
|
+
* operator info then reads signer-derived state must drain first or it reads torn state and
|
|
1279
1131
|
* races the handler. Resolves once idle; handler rejections are swallowed (already logged).
|
|
1280
1132
|
*
|
|
1281
1133
|
* @internal Invoked by {@link dispose} and the {@link VtxoManager} migration
|
|
@@ -1330,6 +1182,8 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1330
1182
|
*/
|
|
1331
1183
|
private receiveCandidateDeps;
|
|
1332
1184
|
private readonly _signerRouter;
|
|
1185
|
+
private _emulator?;
|
|
1186
|
+
private _cosignMarginBlocks;
|
|
1333
1187
|
/**
|
|
1334
1188
|
* @internal Sole write path for `offchainTapscript`; called by
|
|
1335
1189
|
* {@link WalletReceiveRotator.rotate} after the rotated contract is persisted.
|
|
@@ -1346,14 +1200,14 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1346
1200
|
*/
|
|
1347
1201
|
setArkServerPublicKeyForRotation(serverPubKey: Bytes): void;
|
|
1348
1202
|
/**
|
|
1349
|
-
* Checkpoint output script from the
|
|
1203
|
+
* Checkpoint output script from the operator's `checkpointTapscript`; pinned at construction,
|
|
1350
1204
|
* re-sourced only via {@link setServerUnrollScriptForRotation}.
|
|
1351
1205
|
*/
|
|
1352
1206
|
protected _serverUnrollScript: CSVMultisigTapscript.Type;
|
|
1353
1207
|
get serverUnrollScript(): CSVMultisigTapscript.Type;
|
|
1354
1208
|
/**
|
|
1355
1209
|
* @internal Sole write path for `serverUnrollScript`; called by
|
|
1356
|
-
* {@link Wallet._doRotateServerSigner} with the rotating `
|
|
1210
|
+
* {@link Wallet._doRotateServerSigner} with the rotating `OperatorInfo`'s checkpoint script.
|
|
1357
1211
|
*/
|
|
1358
1212
|
setServerUnrollScriptForRotation(script: CSVMultisigTapscript.Type): void;
|
|
1359
1213
|
/**
|
|
@@ -1463,11 +1317,11 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1463
1317
|
*/
|
|
1464
1318
|
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
1465
1319
|
/**
|
|
1466
|
-
* Mid-session
|
|
1467
|
-
* old-signer receive addresses, and a migration output to one yields
|
|
1320
|
+
* Mid-session operator signer rotation. A wallet built before the rotation keeps deriving
|
|
1321
|
+
* old-signer receive addresses, and a migration output to one yields an output the operator must
|
|
1468
1322
|
* reject, so receive state is re-derived under the new signer first.
|
|
1469
1323
|
*
|
|
1470
|
-
* Same write-path as {@link WalletReceiveRotator.rotate} with the
|
|
1324
|
+
* Same write-path as {@link WalletReceiveRotator.rotate} with the operator key swapped: build the
|
|
1471
1325
|
* new tapscripts, register their rows (carrying signing metadata so a descriptor-backed
|
|
1472
1326
|
* pubkey still signs), and only then commit visible state. Old-signer rows stay `active` for
|
|
1473
1327
|
* the migration pass to drain. Idempotent; serialized against HD receive rotation.
|
|
@@ -1527,7 +1381,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1527
1381
|
/** Public here; `ReadonlyWallet` keeps it protected so a readonly view can't submit. */
|
|
1528
1382
|
readonly arkProvider: OperatorProvider;
|
|
1529
1383
|
/**
|
|
1530
|
-
* Broadcast access bound to this wallet's
|
|
1384
|
+
* Broadcast access bound to this wallet's operator, so a plugin needs only the wallet. Not on
|
|
1531
1385
|
* {@link ReadonlyWallet}: a readonly wallet or `toReadonly()` view must not be able to submit.
|
|
1532
1386
|
*/
|
|
1533
1387
|
getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
|
|
@@ -1622,14 +1476,24 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1622
1476
|
private persistIntentSnapshot;
|
|
1623
1477
|
signInputsByWitnessScript(tx: Transaction): Promise<Transaction>;
|
|
1624
1478
|
signOnchainBoardingTx(tx: Transaction): Promise<Transaction>;
|
|
1479
|
+
/** @see IWallet.cosignOnchainTx */
|
|
1480
|
+
cosignOnchainTx(psbt: string | Transaction): Promise<string>;
|
|
1481
|
+
/** @see IWallet.sendOnchain */
|
|
1482
|
+
sendOnchain(params: SendOnchainParams): Promise<string>;
|
|
1483
|
+
private _buildOnchainSpend;
|
|
1484
|
+
private _cosignOnchainTxImpl;
|
|
1485
|
+
/** Boarding outpoints the automatic cosign sweep should renew now (never unrolled exits); excludes coins an intent has locked. */
|
|
1486
|
+
getOnchainSweepInputs(): Promise<Outpoint[]>;
|
|
1487
|
+
/** Unspent onchain coins from the store; the onchain rows are kept fresh by syncOnchain, not the indexer. */
|
|
1488
|
+
private onchainCoins;
|
|
1625
1489
|
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
1626
1490
|
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedProof<Proof.RegisterMessage>>;
|
|
1627
1491
|
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedProof<Proof.DeleteMessage>>;
|
|
1628
1492
|
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedProof<Proof.GetPendingTxMessage>>;
|
|
1629
1493
|
/**
|
|
1630
|
-
* Finalizes pending transactions by retrieving them from the
|
|
1631
|
-
* Skips the
|
|
1632
|
-
* @param vtxos - Optional list of virtual outputs to use instead of retrieving them from the
|
|
1494
|
+
* Finalizes pending transactions by retrieving them from the operator and finalizing each one.
|
|
1495
|
+
* Skips the operator check entirely when no send was interrupted (no pending tx flag set).
|
|
1496
|
+
* @param vtxos - Optional list of virtual outputs to use instead of retrieving them from the operator
|
|
1633
1497
|
* @returns Array of transaction IDs that were finalized
|
|
1634
1498
|
*/
|
|
1635
1499
|
finalizePendingTxs(vtxos?: ExtendedVirtualCoin[]): Promise<{
|
|
@@ -1637,7 +1501,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1637
1501
|
pending: string[];
|
|
1638
1502
|
}>;
|
|
1639
1503
|
/**
|
|
1640
|
-
*
|
|
1504
|
+
* Operator unroll scripts a pending checkpoint may have been built under: configured, current,
|
|
1641
1505
|
* and one per deprecated signer — else a pre-rotation tx would stay pending forever.
|
|
1642
1506
|
*/
|
|
1643
1507
|
private checkpointUnrollCandidates;
|
|
@@ -1656,11 +1520,11 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1656
1520
|
createCash(amount: number): Promise<string>;
|
|
1657
1521
|
/**
|
|
1658
1522
|
* Claim an ArkadeCash bearer instrument: sweep what can be swept, recover what
|
|
1659
|
-
* was swept by the
|
|
1523
|
+
* was swept by the operator, report the rest.
|
|
1660
1524
|
*
|
|
1661
1525
|
* Every spendable VTXO at the arkadeCash address is swept to this wallet in
|
|
1662
1526
|
* its own offchain transaction, signed with the key carried by the arkadeCash
|
|
1663
|
-
* string.
|
|
1527
|
+
* string. An output the operator already swept at batch expiry cannot move
|
|
1664
1528
|
* through the thin sweep — only a settlement can lift it — so it is
|
|
1665
1529
|
* **imported** as a signable `default` contract (the arkadeCash key is filed
|
|
1666
1530
|
* in the keyring) and handed to the wallet's own recovery machinery, which
|
|
@@ -1672,7 +1536,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1672
1536
|
*
|
|
1673
1537
|
* The arkadeCash string is the recovery token: a claim interrupted between
|
|
1674
1538
|
* submit and finalize is completed by simply re-running `claimCash`, which
|
|
1675
|
-
* drains any pending arkadeCash transaction
|
|
1539
|
+
* drains any pending arkadeCash transaction at the operator before sweeping.
|
|
1676
1540
|
* The import is idempotent, so re-running is always safe.
|
|
1677
1541
|
*
|
|
1678
1542
|
* @param cashStr - The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
@@ -1682,7 +1546,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1682
1546
|
claimCash(cashStr: string): Promise<ArkadeCashClaimResult>;
|
|
1683
1547
|
/**
|
|
1684
1548
|
* Import an arkadeCash instrument as a signable, recovery-only contract so the
|
|
1685
|
-
* wallet's own recovery machinery can settle its
|
|
1549
|
+
* wallet's own recovery machinery can settle its operator-swept outputs back.
|
|
1686
1550
|
*
|
|
1687
1551
|
* Two writes, both idempotent so a re-run (or a resumed claim) is safe:
|
|
1688
1552
|
* - the arkadeCash private key is filed in the keyring, returning its
|
|
@@ -1728,7 +1592,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1728
1592
|
removeRecoveryContract(script: string): Promise<void>;
|
|
1729
1593
|
/**
|
|
1730
1594
|
* Split the VTXOs at an arkadeCash address into three buckets: the ones the
|
|
1731
|
-
* thin sweep can move (`spendable`), the
|
|
1595
|
+
* thin sweep can move (`spendable`), the operator-swept ones that must go
|
|
1732
1596
|
* through a recovery settlement (`recoverable`), and the ones that can
|
|
1733
1597
|
* only be reported (`unclaimed`).
|
|
1734
1598
|
*/
|
|
@@ -1792,7 +1656,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1792
1656
|
*
|
|
1793
1657
|
* Signs whatever it is handed, ungated — see {@link settle} for the trade.
|
|
1794
1658
|
*
|
|
1795
|
-
* @returns The Arkade transaction id and
|
|
1659
|
+
* @returns The Arkade transaction id and operator-signed checkpoint PSBTs (for bookkeeping)
|
|
1796
1660
|
*/
|
|
1797
1661
|
buildAndSubmitOffchainTx(inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[], serverUnrollScript?: CSVMultisigTapscript.Type, options?: {
|
|
1798
1662
|
validUntil?: number;
|
|
@@ -1878,6 +1742,193 @@ interface WaitForIncomingFundsOptions {
|
|
|
1878
1742
|
* }
|
|
1879
1743
|
* ```
|
|
1880
1744
|
*/
|
|
1881
|
-
declare function waitForIncomingFunds(wallet:
|
|
1745
|
+
declare function waitForIncomingFunds(wallet: NotifiesIncomingFunds, options?: WaitForIncomingFundsOptions): Promise<IncomingFunds>;
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* IndexedDB-based implementation of WalletRepository.
|
|
1749
|
+
*/
|
|
1750
|
+
declare class IndexedDBWalletRepository implements WalletRepository {
|
|
1751
|
+
readonly version: 2;
|
|
1752
|
+
private readonly connection;
|
|
1753
|
+
/** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
|
|
1754
|
+
constructor(dbName?: string, options?: {
|
|
1755
|
+
persistentWalletState?: boolean;
|
|
1756
|
+
});
|
|
1757
|
+
clear(): Promise<void>;
|
|
1758
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1759
|
+
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
1760
|
+
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
1761
|
+
deleteVtxos(address: string): Promise<void>;
|
|
1762
|
+
getVtxosForScriptPage(script: string, page: PageRequest<ScriptVtxoCursor>, options?: ScriptVtxoPageOptions): Promise<PageResult<StoredVtxo, ScriptVtxoCursor>>;
|
|
1763
|
+
saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
1764
|
+
deleteVtxosForScript(script: string): Promise<void>;
|
|
1765
|
+
getUtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedCoin, Outpoint>>;
|
|
1766
|
+
private pageByAddress;
|
|
1767
|
+
saveUtxos(addressOrBatch: string | ReadonlyMap<string, ExtendedCoin[]>, utxos?: ExtendedCoin[]): Promise<void>;
|
|
1768
|
+
deleteUtxos(address: string): Promise<void>;
|
|
1769
|
+
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
1770
|
+
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
1771
|
+
deleteTransactions(address: string): Promise<void>;
|
|
1772
|
+
readonly atomicWalletState: AtomicWalletState;
|
|
1773
|
+
getWalletState(): Promise<WalletState | null>;
|
|
1774
|
+
saveWalletState(state: WalletState): Promise<void>;
|
|
1775
|
+
private getDB;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* A {@link DescriptorProvider} decorator that adds a **keyring**: raw
|
|
1780
|
+
* private keys imported from outside the wallet's derivation tree, each
|
|
1781
|
+
* addressed by a `tr(<pubkey>)` descriptor.
|
|
1782
|
+
*
|
|
1783
|
+
* Resolution is union-shaped — `signWithDescriptor` /
|
|
1784
|
+
* `signMessageWithDescriptor` serve a descriptor from the wrapped
|
|
1785
|
+
* provider's derivation tree *or* from the keyring, whichever owns it —
|
|
1786
|
+
* so the wallet's existing descriptor routing
|
|
1787
|
+
* (`InputSignerRouter`) signs foreign-key contracts with no changes: an
|
|
1788
|
+
* imported contract carrying `metadata.signingDescriptor` is signable by
|
|
1789
|
+
* construction rather than throwing `MissingSigningDescriptorError`.
|
|
1790
|
+
*
|
|
1791
|
+
* Allocation is *not* extended: `getNextSigningDescriptor` always
|
|
1792
|
+
* delegates to the wrapped provider. The keyring holds foreign keys the
|
|
1793
|
+
* wallet was handed; it never mints receive addresses.
|
|
1794
|
+
*
|
|
1795
|
+
* Lifecycle: entries persist under
|
|
1796
|
+
* `WalletRepository.getWalletState().settings.keyring` (same
|
|
1797
|
+
* no-migration pattern as `HDDescriptorProvider`), so an import survives
|
|
1798
|
+
* the restarts a recovery spans, and {@link deleteKey} purges it when
|
|
1799
|
+
* recovery completes. The repository is the source of truth: the async
|
|
1800
|
+
* signing/purge APIs converge on sibling instances' imports and purges
|
|
1801
|
+
* (see {@link refresh}), so any tab/worker sharing the repo can complete
|
|
1802
|
+
* a recovery another one started.
|
|
1803
|
+
*
|
|
1804
|
+
* **Keys are stored unencrypted.** This is a deliberate, scoped
|
|
1805
|
+
* decision: the intended use is a short-lived, purge-on-completion hold
|
|
1806
|
+
* of a key that guards funds already destined for this wallet. At-rest
|
|
1807
|
+
* encryption is a possible hardening follow-up. Do not use this to hold
|
|
1808
|
+
* long-lived key material.
|
|
1809
|
+
*
|
|
1810
|
+
* @example
|
|
1811
|
+
* ```ts
|
|
1812
|
+
* const provider = await KeyringDescriptorProvider.create(hdProvider, walletRepo);
|
|
1813
|
+
* const descriptor = await provider.importKey(foreignPrivKey);
|
|
1814
|
+
* // descriptor: tr(<x-only pubkey hex>)
|
|
1815
|
+
* // ... import a contract with metadata.signingDescriptor = descriptor,
|
|
1816
|
+
* // let the wallet's recovery machinery settle it, then:
|
|
1817
|
+
* await provider.deleteKey(descriptor);
|
|
1818
|
+
* ```
|
|
1819
|
+
*/
|
|
1820
|
+
declare class KeyringDescriptorProvider implements DescriptorProvider {
|
|
1821
|
+
/**
|
|
1822
|
+
* The wrapped provider. Exposed so callers that need to reach a
|
|
1823
|
+
* concrete provider type behind the decorator (e.g. the wallet's
|
|
1824
|
+
* restore path, which branches on `HDDescriptorProvider`) can
|
|
1825
|
+
* unwrap it rather than mis-classify the decorator.
|
|
1826
|
+
*/
|
|
1827
|
+
readonly base: DescriptorProvider;
|
|
1828
|
+
private readonly walletRepository;
|
|
1829
|
+
/**
|
|
1830
|
+
* In-memory mirror of the persisted keyring, keyed by x-only pubkey
|
|
1831
|
+
* hex. Required because {@link isOurs} is synchronous while
|
|
1832
|
+
* persistence is not. The **repository is the source of truth**: the
|
|
1833
|
+
* async APIs write through to it and {@link refresh} re-seeds this
|
|
1834
|
+
* mirror from it when a signing request names a foreign key the
|
|
1835
|
+
* mirror doesn't know — a sibling instance (another tab/worker on
|
|
1836
|
+
* the same repo) may have imported it after this instance was
|
|
1837
|
+
* constructed. The sync views ({@link isOurs}, {@link hasKey},
|
|
1838
|
+
* {@link listKeyringDescriptors}) answer from the last-known
|
|
1839
|
+
* snapshot.
|
|
1840
|
+
*/
|
|
1841
|
+
private readonly keys;
|
|
1842
|
+
private constructor();
|
|
1843
|
+
/**
|
|
1844
|
+
* Wrap `base` with a keyring, loading any previously imported keys
|
|
1845
|
+
* from the repository. Unlike `HDDescriptorProvider.create`, this
|
|
1846
|
+
* *does* read at construction: `isOurs` is synchronous and must be
|
|
1847
|
+
* able to answer for persisted keys from the first call.
|
|
1848
|
+
*/
|
|
1849
|
+
static create(base: DescriptorProvider, walletRepository: WalletRepository): Promise<KeyringDescriptorProvider>;
|
|
1850
|
+
/**
|
|
1851
|
+
* Import a raw private key into the keyring and return its
|
|
1852
|
+
* `tr(<x-only pubkey>)` descriptor handle. Idempotent: re-importing
|
|
1853
|
+
* the same key returns the same descriptor and leaves storage
|
|
1854
|
+
* unchanged.
|
|
1855
|
+
*/
|
|
1856
|
+
importKey(privateKey: Uint8Array): Promise<string>;
|
|
1857
|
+
/**
|
|
1858
|
+
* Purge a keyring entry. Returns `true` when an entry was removed,
|
|
1859
|
+
* `false` when the descriptor was not in the keyring (already
|
|
1860
|
+
* purged, or never ours) — so a repeated purge is a safe no-op.
|
|
1861
|
+
*
|
|
1862
|
+
* Always goes through storage, never trusting the in-memory mirror:
|
|
1863
|
+
* the entry may have been imported by a sibling instance after this
|
|
1864
|
+
* one was constructed, and skipping the persistent purge on a memory
|
|
1865
|
+
* miss would leave that key at rest forever.
|
|
1866
|
+
*/
|
|
1867
|
+
deleteKey(descriptor: string): Promise<boolean>;
|
|
1868
|
+
/** True iff `descriptor` resolves to a key held in the keyring. */
|
|
1869
|
+
hasKey(descriptor: string): boolean;
|
|
1870
|
+
/** The `tr(<pubkey>)` descriptors of every key currently held. */
|
|
1871
|
+
listKeyringDescriptors(): string[];
|
|
1872
|
+
/** Allocation is the wrapped provider's job; the keyring never mints. */
|
|
1873
|
+
getNextSigningDescriptor(): Promise<string>;
|
|
1874
|
+
/** Ours iff the wrapped provider claims it, or the keyring holds it. */
|
|
1875
|
+
isOurs(descriptor: string): boolean;
|
|
1876
|
+
/**
|
|
1877
|
+
* Signs each request with the key its descriptor resolves to.
|
|
1878
|
+
* Keyring-owned requests are signed here; every other request is
|
|
1879
|
+
* handed to the wrapped provider in a single batched call, so a
|
|
1880
|
+
* batch-signing identity behind a `StaticDescriptorProvider` still
|
|
1881
|
+
* sees one interaction.
|
|
1882
|
+
*
|
|
1883
|
+
* Results are returned in request order regardless of how the
|
|
1884
|
+
* requests split across the two signers.
|
|
1885
|
+
*/
|
|
1886
|
+
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
1887
|
+
/** Signs a message with the keyring key, or delegates to the base. */
|
|
1888
|
+
signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
1889
|
+
/**
|
|
1890
|
+
* Split requests into keyring-owned and base-delegated buckets.
|
|
1891
|
+
* `mayBeStale` is set when a delegated descriptor is foreign-shaped —
|
|
1892
|
+
* a sibling instance may have imported its key after this instance
|
|
1893
|
+
* seeded the mirror, so the caller should {@link refresh} once and
|
|
1894
|
+
* re-split before trusting the delegation.
|
|
1895
|
+
*/
|
|
1896
|
+
private splitRequests;
|
|
1897
|
+
/**
|
|
1898
|
+
* True when `descriptor` is a bare `tr(<pubkey>)` the base provider
|
|
1899
|
+
* does not own — the only shape a keyring entry can have, so the only
|
|
1900
|
+
* kind of miss a {@link refresh} could turn into a hit.
|
|
1901
|
+
*/
|
|
1902
|
+
private isForeignShaped;
|
|
1903
|
+
/**
|
|
1904
|
+
* Re-seed the in-memory mirror from the repository, converging on
|
|
1905
|
+
* imports and purges made by sibling instances on the same repo.
|
|
1906
|
+
* Full replacement, not a merge, so sibling *deletions* propagate
|
|
1907
|
+
* too. Corrupt persisted settings throw, same as {@link create}.
|
|
1908
|
+
*
|
|
1909
|
+
* Only a *miss* triggers a refresh, so that convergence is one-sided:
|
|
1910
|
+
* an entry this instance still believes it holds is never
|
|
1911
|
+
* revalidated, and a sibling's purge can linger in this mirror until
|
|
1912
|
+
* some unrelated foreign-shaped miss re-seeds it. Harmless today —
|
|
1913
|
+
* `deleteKey`'s caller also deletes the contract row carrying the
|
|
1914
|
+
* descriptor, so no signing request can name the stale entry — but it
|
|
1915
|
+
* means the at-rest purge is not a memory purge for siblings.
|
|
1916
|
+
*/
|
|
1917
|
+
private refresh;
|
|
1918
|
+
/**
|
|
1919
|
+
* The keyring key for `descriptor`, or `undefined` when the request
|
|
1920
|
+
* belongs to the base provider. Base ownership wins on collision:
|
|
1921
|
+
* a key already in the derivation tree keeps its established signing
|
|
1922
|
+
* path, so importing it cannot reroute existing contracts.
|
|
1923
|
+
*/
|
|
1924
|
+
private resolveKey;
|
|
1925
|
+
/**
|
|
1926
|
+
* Read-modify-write the keyring settings through `updateWalletState`,
|
|
1927
|
+
* whose in-process mutex plus cross-context Web Lock keep concurrent
|
|
1928
|
+
* imports/purges — including ones driven from other tabs/workers
|
|
1929
|
+
* sharing the store — from clobbering each other's entries.
|
|
1930
|
+
*/
|
|
1931
|
+
private mutate;
|
|
1932
|
+
}
|
|
1882
1933
|
|
|
1883
|
-
export { type AddressAllocationCapable as A, type BatchExpiryPolicy as B, isArkError as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, isHDAllocationCapable as E, ForeignDescriptorError as F, isHDWalletCapable as G, type HDWalletCapable as H, type IncomingFunds as I, maybeArkError as J, KeyringDescriptorProvider as K, resolveBatchExpiryPolicy as L, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD as M,
|
|
1934
|
+
export { type AddressAllocationCapable as A, type BatchExpiryPolicy as B, isArkError as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, isHDAllocationCapable as E, ForeignDescriptorError as F, isHDWalletCapable as G, type HDWalletCapable as H, type IncomingFunds as I, maybeArkError as J, KeyringDescriptorProvider as K, resolveBatchExpiryPolicy as L, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD as M, type NotifiesIncomingFunds as N, resolveDescriptorSigner as O, type ProviderConnectionState as P, selectVirtualCoins as Q, ReadonlyWallet as R, type ServerInfoSource as S, signingDescriptorIndex as T, strictSigningDescriptorIndex as U, type VtxoReservation as V, Wallet as W, waitForIncomingFunds as X, type HDAllocationCapable as a, type ReceiveRotatorFactory as b, type ReceiveRotatorBootOpts as c, type ReceiveRotatorBoot as d, Batch as e, AbortError as f, ArkError as g, ArkErrorName as h, type ArkadeCashClaimResult as i, ArkadeCashCreateError as j, ArkadeCashOperatorMismatchError as k, type ArkadeCashUnclaimedReason as l, type ArkadeCashUnclaimedVtxo as m, type ArkadeCashVtxoRef as n, type BoardingUtxoGroup as o, IndexedDBWalletRepository as p, type ProviderKind as q, ProviderUnavailableError as r, REGTEST_MIN_BATCH_EXPIRY_SECONDS as s, ServerResponseMismatchError as t, VtxoReservedError as u, type WaitForIncomingFundsOptions as v, WalletCannotAllocateAddressError as w, assertValidBatchExpiry as x, defaultBatchExpiryPolicy as y, isAddressAllocationCapable as z };
|