@arkade-os/sdk 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -50
- package/dist/adapters/expo.cjs +10 -5
- package/dist/adapters/expo.d.cts +13 -8
- package/dist/adapters/expo.d.ts +13 -8
- package/dist/adapters/expo.js +4 -3
- package/dist/{asyncStorageTaskQueue-C9PkPcW_.d.cts → asyncStorageTaskQueue-BbH-THYJ.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-B3U5gQ-i.d.ts → asyncStorageTaskQueue-BlvkJyTa.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-OPX2HRWM.js → chunk-4I53THL6.js} +210 -937
- package/dist/chunk-4I53THL6.js.map +1 -0
- package/dist/{chunk-5WRA66RV.cjs → chunk-5SYUEVJH.cjs} +10 -10
- package/dist/chunk-5SYUEVJH.cjs.map +1 -0
- package/dist/{chunk-6FL4N4S2.js → chunk-7GIKLFHC.js} +83 -20
- package/dist/chunk-7GIKLFHC.js.map +1 -0
- package/dist/{chunk-BYPBVHVA.cjs → chunk-AMH7Q3DF.cjs} +61 -935
- package/dist/chunk-AMH7Q3DF.cjs.map +1 -0
- package/dist/{chunk-P7B4LQ3H.js → chunk-BCA6D255.js} +18 -842
- package/dist/chunk-BCA6D255.js.map +1 -0
- package/dist/{chunk-T7C3E2HL.js → chunk-CE46RS6L.js} +20 -39
- package/dist/chunk-CE46RS6L.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-Y4BL3YYX.js → chunk-FVVXCDNE.js} +4 -4
- package/dist/chunk-FVVXCDNE.js.map +1 -0
- package/dist/{chunk-ZPF4I3K2.cjs → chunk-HQQ4NRXI.cjs} +29 -47
- package/dist/chunk-HQQ4NRXI.cjs.map +1 -0
- package/dist/chunk-JFJNB7ZH.cjs +884 -0
- package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
- package/dist/{chunk-KW7ZEWYS.cjs → chunk-KCL5AVML.cjs} +223 -985
- package/dist/chunk-KCL5AVML.cjs.map +1 -0
- package/dist/{chunk-HAQAWBYG.js → chunk-OO2KEK64.js} +2860 -1366
- package/dist/chunk-OO2KEK64.js.map +1 -0
- package/dist/{chunk-OUTWUYJ4.cjs → chunk-T254PXSN.cjs} +3337 -1824
- package/dist/chunk-T254PXSN.cjs.map +1 -0
- package/dist/chunk-V3ZLL5VY.js +380 -0
- package/dist/chunk-V3ZLL5VY.js.map +1 -0
- package/dist/chunk-X6ZI53DZ.cjs +383 -0
- package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
- package/dist/{chunk-ZMSM3NOH.cjs → chunk-XWUCNMPN.cjs} +98 -34
- package/dist/chunk-XWUCNMPN.cjs.map +1 -0
- 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-Cd28gxpM.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
- package/dist/{delegate-ByfKszb6.d.cts → delegate-iyDum4fw.d.ts} +1 -1
- package/dist/{index-B6X2E7W_.d.ts → index-BWwVnJhU.d.cts} +7 -272
- package/dist/{index-DgH_0j14.d.cts → index-Bx-iArDs.d.ts} +7 -272
- package/dist/{index-BURzbRup.d.cts → index-DCml4QJn.d.ts} +1090 -1140
- package/dist/{index-BURzbRup.d.ts → index-DkyzIzKL.d.cts} +1090 -1140
- package/dist/index.cjs +470 -371
- package/dist/index.d.cts +687 -410
- package/dist/index.d.ts +687 -410
- package/dist/index.js +7 -4
- package/dist/{wallet-BnmhohgZ.d.ts → keyringDescriptorProvider-CS4w4PWd.d.ts} +427 -372
- package/dist/{wallet-BjQugVUt.d.cts → keyringDescriptorProvider-CmHXrIXd.d.cts} +427 -372
- package/dist/program-BARSNg3X.d.ts +286 -0
- package/dist/program-znrWkxE4.d.cts +286 -0
- package/dist/repositories/realm/index.cjs +100 -51
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +25 -10
- package/dist/repositories/realm/index.d.ts +25 -10
- package/dist/repositories/realm/index.js +72 -24
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +222 -131
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +36 -17
- package/dist/repositories/sqlite/index.d.ts +36 -17
- package/dist/repositories/sqlite/index.js +196 -107
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-BaNCSxqK.d.ts → taskRunner-DgMLSk_O.d.ts} +4 -4
- package/dist/{taskRunner-i56-drQV.d.cts → taskRunner-buh6aFpG.d.cts} +4 -4
- 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 +10 -7
- 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 +20 -7
- 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-5WRA66RV.cjs.map +0 -1
- package/dist/chunk-6FL4N4S2.js.map +0 -1
- package/dist/chunk-BYPBVHVA.cjs.map +0 -1
- package/dist/chunk-HAQAWBYG.js.map +0 -1
- package/dist/chunk-KW7ZEWYS.cjs.map +0 -1
- package/dist/chunk-OPX2HRWM.js.map +0 -1
- package/dist/chunk-OUTWUYJ4.cjs.map +0 -1
- package/dist/chunk-P7B4LQ3H.js.map +0 -1
- package/dist/chunk-T7C3E2HL.js.map +0 -1
- package/dist/chunk-Y4BL3YYX.js.map +0 -1
- package/dist/chunk-ZMSM3NOH.cjs.map +0 -1
- package/dist/chunk-ZPF4I3K2.cjs.map +0 -1
|
@@ -1,307 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a4 as Network, a5 as BatchStartedEvent, a6 as TreeSigningStartedEvent, a7 as TxTree, a8 as TreeNoncesEvent, a9 as BatchFinalizationEvent, aa as BatchFinalizedEvent, ab as BatchFailedEvent, ac as TreeTxEvent, ad as TreeSignatureEvent, o as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, ae as DescriptorProvider, k as IContractManager, l as GetNewAddressesOptions, m as NewAddress, a as Identity, af as IReadonlyWallet, ag as ReadonlyIdentity, ah as OnchainProvider, O as OperatorProvider, x as IndexerProvider, ai as DelegateProvider, aj as ReadonlyWalletConfig, ak as IntentRepository, a0 as VirtualTxRepository, al as ExitCaptureMode, am as ExitDataSource, i as ActivityRegistry, an as IReadonlyAssetManager, ao as ContractSyncState, ap as RecipientArkadeAddressContext, G as GetOperatorInfoOptions, A as ArkadeInfo, c as ArkadeReader, aq as EsploraProvider, ar as NetworkName, as as OperatorInfo, e as WalletBalance, f as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, g as GetSpendableVtxosFilter, at as ContractWithVtxos, au as selectPendingRecoveryOutpoints, h as ArkTransaction, j as Activity, E as ExtendedCoin, av as Coin, z as ExtendedVirtualCoin, aw as ContractManager, ax as ContractManagerConfig, I as IWallet, B as Outpoint, ay as SettlementConfig, d as ArkadeBroadcaster, r as IAssetManager, az as VtxoManager, n as IDelegateManager, S as SettleParams, R as Recipient, aA as SignerSession, aB as Transaction, q as SendOnchainParams, aC as SignedIntent, aD as Intent, aE as SignedProof, aF as Proof, p as SendParams, aG 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, aH as DescriptorSigningRequest } from './index-DkyzIzKL.cjs';
|
|
2
|
+
import { R as RelativeTimelock, A as ArkAddress, C as CSVMultisigTapscript } from './base-C-Y5t_0F.cjs';
|
|
3
3
|
import { Bytes } from '@scure/btc-signer/utils.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
|
-
constructor(dbName?: string);
|
|
13
|
-
clear(): Promise<void>;
|
|
14
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
15
|
-
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
16
|
-
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
17
|
-
deleteVtxos(address: string): Promise<void>;
|
|
18
|
-
getVtxosForScriptPage(script: string, page: PageRequest<ScriptVtxoCursor>, options?: ScriptVtxoPageOptions): Promise<PageResult<StoredVtxo, ScriptVtxoCursor>>;
|
|
19
|
-
saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
20
|
-
deleteVtxosForScript(script: string): Promise<void>;
|
|
21
|
-
getUtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedCoin, Outpoint>>;
|
|
22
|
-
private pageByAddress;
|
|
23
|
-
saveUtxos(addressOrBatch: string | ReadonlyMap<string, ExtendedCoin[]>, utxos?: ExtendedCoin[]): Promise<void>;
|
|
24
|
-
deleteUtxos(address: string): Promise<void>;
|
|
25
|
-
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
26
|
-
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
27
|
-
deleteTransactions(address: string): Promise<void>;
|
|
28
|
-
getWalletState(): Promise<WalletState | null>;
|
|
29
|
-
saveWalletState(state: WalletState): Promise<void>;
|
|
30
|
-
private getDB;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A {@link DescriptorProvider} decorator that adds a **keyring**: raw
|
|
35
|
-
* private keys imported from outside the wallet's derivation tree, each
|
|
36
|
-
* addressed by a `tr(<pubkey>)` descriptor.
|
|
37
|
-
*
|
|
38
|
-
* Resolution is union-shaped — `signWithDescriptor` /
|
|
39
|
-
* `signMessageWithDescriptor` serve a descriptor from the wrapped
|
|
40
|
-
* provider's derivation tree *or* from the keyring, whichever owns it —
|
|
41
|
-
* so the wallet's existing descriptor routing
|
|
42
|
-
* (`InputSignerRouter`) signs foreign-key contracts with no changes: an
|
|
43
|
-
* imported contract carrying `metadata.signingDescriptor` is signable by
|
|
44
|
-
* construction rather than throwing `MissingSigningDescriptorError`.
|
|
45
|
-
*
|
|
46
|
-
* Allocation is *not* extended: `getNextSigningDescriptor` always
|
|
47
|
-
* delegates to the wrapped provider. The keyring holds foreign keys the
|
|
48
|
-
* wallet was handed; it never mints receive addresses.
|
|
49
|
-
*
|
|
50
|
-
* Lifecycle: entries persist under
|
|
51
|
-
* `WalletRepository.getWalletState().settings.keyring` (same
|
|
52
|
-
* no-migration pattern as `HDDescriptorProvider`), so an import survives
|
|
53
|
-
* the restarts a recovery spans, and {@link deleteKey} purges it when
|
|
54
|
-
* recovery completes. The repository is the source of truth: the async
|
|
55
|
-
* signing/purge APIs converge on sibling instances' imports and purges
|
|
56
|
-
* (see {@link refresh}), so any tab/worker sharing the repo can complete
|
|
57
|
-
* a recovery another one started.
|
|
58
|
-
*
|
|
59
|
-
* **Keys are stored unencrypted.** This is a deliberate, scoped
|
|
60
|
-
* decision: the intended use is a short-lived, purge-on-completion hold
|
|
61
|
-
* of a key that guards funds already destined for this wallet. At-rest
|
|
62
|
-
* encryption is a possible hardening follow-up. Do not use this to hold
|
|
63
|
-
* long-lived key material.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* const provider = await KeyringDescriptorProvider.create(hdProvider, walletRepo);
|
|
68
|
-
* const descriptor = await provider.importKey(foreignPrivKey);
|
|
69
|
-
* // descriptor: tr(<x-only pubkey hex>)
|
|
70
|
-
* // ... import a contract with metadata.signingDescriptor = descriptor,
|
|
71
|
-
* // let the wallet's recovery machinery settle it, then:
|
|
72
|
-
* await provider.deleteKey(descriptor);
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
declare class KeyringDescriptorProvider implements DescriptorProvider {
|
|
76
|
-
/**
|
|
77
|
-
* The wrapped provider. Exposed so callers that need to reach a
|
|
78
|
-
* concrete provider type behind the decorator (e.g. the wallet's
|
|
79
|
-
* restore path, which branches on `HDDescriptorProvider`) can
|
|
80
|
-
* unwrap it rather than mis-classify the decorator.
|
|
81
|
-
*/
|
|
82
|
-
readonly base: DescriptorProvider;
|
|
83
|
-
private readonly walletRepository;
|
|
84
|
-
/**
|
|
85
|
-
* In-memory mirror of the persisted keyring, keyed by x-only pubkey
|
|
86
|
-
* hex. Required because {@link isOurs} is synchronous while
|
|
87
|
-
* persistence is not. The **repository is the source of truth**: the
|
|
88
|
-
* async APIs write through to it and {@link refresh} re-seeds this
|
|
89
|
-
* mirror from it when a signing request names a foreign key the
|
|
90
|
-
* mirror doesn't know — a sibling instance (another tab/worker on
|
|
91
|
-
* the same repo) may have imported it after this instance was
|
|
92
|
-
* constructed. The sync views ({@link isOurs}, {@link hasKey},
|
|
93
|
-
* {@link listKeyringDescriptors}) answer from the last-known
|
|
94
|
-
* snapshot.
|
|
95
|
-
*/
|
|
96
|
-
private readonly keys;
|
|
97
|
-
private constructor();
|
|
98
|
-
/**
|
|
99
|
-
* Wrap `base` with a keyring, loading any previously imported keys
|
|
100
|
-
* from the repository. Unlike `HDDescriptorProvider.create`, this
|
|
101
|
-
* *does* read at construction: `isOurs` is synchronous and must be
|
|
102
|
-
* able to answer for persisted keys from the first call.
|
|
103
|
-
*/
|
|
104
|
-
static create(base: DescriptorProvider, walletRepository: WalletRepository): Promise<KeyringDescriptorProvider>;
|
|
105
|
-
/**
|
|
106
|
-
* Import a raw private key into the keyring and return its
|
|
107
|
-
* `tr(<x-only pubkey>)` descriptor handle. Idempotent: re-importing
|
|
108
|
-
* the same key returns the same descriptor and leaves storage
|
|
109
|
-
* unchanged.
|
|
110
|
-
*/
|
|
111
|
-
importKey(privateKey: Uint8Array): Promise<string>;
|
|
112
|
-
/**
|
|
113
|
-
* Purge a keyring entry. Returns `true` when an entry was removed,
|
|
114
|
-
* `false` when the descriptor was not in the keyring (already
|
|
115
|
-
* purged, or never ours) — so a repeated purge is a safe no-op.
|
|
116
|
-
*
|
|
117
|
-
* Always goes through storage, never trusting the in-memory mirror:
|
|
118
|
-
* the entry may have been imported by a sibling instance after this
|
|
119
|
-
* one was constructed, and skipping the persistent purge on a memory
|
|
120
|
-
* miss would leave that key at rest forever.
|
|
121
|
-
*/
|
|
122
|
-
deleteKey(descriptor: string): Promise<boolean>;
|
|
123
|
-
/** True iff `descriptor` resolves to a key held in the keyring. */
|
|
124
|
-
hasKey(descriptor: string): boolean;
|
|
125
|
-
/** The `tr(<pubkey>)` descriptors of every key currently held. */
|
|
126
|
-
listKeyringDescriptors(): string[];
|
|
127
|
-
/** Allocation is the wrapped provider's job; the keyring never mints. */
|
|
128
|
-
getNextSigningDescriptor(): Promise<string>;
|
|
129
|
-
/** Ours iff the wrapped provider claims it, or the keyring holds it. */
|
|
130
|
-
isOurs(descriptor: string): boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Signs each request with the key its descriptor resolves to.
|
|
133
|
-
* Keyring-owned requests are signed here; every other request is
|
|
134
|
-
* handed to the wrapped provider in a single batched call, so a
|
|
135
|
-
* batch-signing identity behind a `StaticDescriptorProvider` still
|
|
136
|
-
* sees one interaction.
|
|
137
|
-
*
|
|
138
|
-
* Results are returned in request order regardless of how the
|
|
139
|
-
* requests split across the two signers.
|
|
140
|
-
*/
|
|
141
|
-
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
142
|
-
/** Signs a message with the keyring key, or delegates to the base. */
|
|
143
|
-
signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
144
|
-
/**
|
|
145
|
-
* Split requests into keyring-owned and base-delegated buckets.
|
|
146
|
-
* `mayBeStale` is set when a delegated descriptor is foreign-shaped —
|
|
147
|
-
* a sibling instance may have imported its key after this instance
|
|
148
|
-
* seeded the mirror, so the caller should {@link refresh} once and
|
|
149
|
-
* re-split before trusting the delegation.
|
|
150
|
-
*/
|
|
151
|
-
private splitRequests;
|
|
152
|
-
/**
|
|
153
|
-
* True when `descriptor` is a bare `tr(<pubkey>)` the base provider
|
|
154
|
-
* does not own — the only shape a keyring entry can have, so the only
|
|
155
|
-
* kind of miss a {@link refresh} could turn into a hit.
|
|
156
|
-
*/
|
|
157
|
-
private isForeignShaped;
|
|
158
|
-
/**
|
|
159
|
-
* Re-seed the in-memory mirror from the repository, converging on
|
|
160
|
-
* imports and purges made by sibling instances on the same repo.
|
|
161
|
-
* Full replacement, not a merge, so sibling *deletions* propagate
|
|
162
|
-
* too. Corrupt persisted settings throw, same as {@link create}.
|
|
163
|
-
*
|
|
164
|
-
* Only a *miss* triggers a refresh, so that convergence is one-sided:
|
|
165
|
-
* an entry this instance still believes it holds is never
|
|
166
|
-
* revalidated, and a sibling's purge can linger in this mirror until
|
|
167
|
-
* some unrelated foreign-shaped miss re-seeds it. Harmless today —
|
|
168
|
-
* `deleteKey`'s caller also deletes the contract row carrying the
|
|
169
|
-
* descriptor, so no signing request can name the stale entry — but it
|
|
170
|
-
* means the at-rest purge is not a memory purge for siblings.
|
|
171
|
-
*/
|
|
172
|
-
private refresh;
|
|
173
|
-
/**
|
|
174
|
-
* The keyring key for `descriptor`, or `undefined` when the request
|
|
175
|
-
* belongs to the base provider. Base ownership wins on collision:
|
|
176
|
-
* a key already in the derivation tree keeps its established signing
|
|
177
|
-
* path, so importing it cannot reroute existing contracts.
|
|
178
|
-
*/
|
|
179
|
-
private resolveKey;
|
|
180
|
-
/**
|
|
181
|
-
* Read-modify-write the keyring settings through `updateWalletState`,
|
|
182
|
-
* whose in-process mutex plus cross-context Web Lock keep concurrent
|
|
183
|
-
* imports/purges — including ones driven from other tabs/workers
|
|
184
|
-
* sharing the store — from clobbering each other's entries.
|
|
185
|
-
*/
|
|
186
|
-
private mutate;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Capability a wallet exposes so descriptor-blind consumers (Boltz swaps, other plugins) can bind
|
|
191
|
-
* artifacts to the wallet's current HD index and later enumerate every used index. Probed
|
|
192
|
-
* structurally ({@link isHDWalletCapable}) rather than widening `IWallet`, so plugins keep working
|
|
193
|
-
* against older wallets; a static wallet answers "no HD state" through the same methods.
|
|
194
|
-
*/
|
|
195
|
-
interface HDWalletCapable {
|
|
196
|
-
/**
|
|
197
|
-
* The descriptor at the wallet's current receive index, or `undefined` for
|
|
198
|
-
* static / `auto` wallets and HD wallets that have never rotated. Callers
|
|
199
|
-
* fall back to the identity key.
|
|
200
|
-
*/
|
|
201
|
-
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
202
|
-
/**
|
|
203
|
-
* Every descriptor the wallet may hold keys under, ascending by index: the allocation
|
|
204
|
-
* watermark's band plus any descriptor persisted on a contract. Empty for static wallets.
|
|
205
|
-
* `lookAhead` appends that many past the watermark without advancing it, for restore probing.
|
|
206
|
-
*/
|
|
207
|
-
getUsedSigningDescriptors(opts?: {
|
|
208
|
-
lookAhead?: number;
|
|
209
|
-
}): Promise<string[]>;
|
|
210
|
-
/**
|
|
211
|
-
* An {@link Identity} whose keys and signatures are those of `descriptor`; the wallet
|
|
212
|
-
* identity itself when `descriptor` is the identity's own key.
|
|
213
|
-
*
|
|
214
|
-
* Throws {@link ForeignDescriptorError} for a descriptor this wallet cannot sign for — never
|
|
215
|
-
* substitutes another key, which would sign happily and surface only as a rejected tx or a
|
|
216
|
-
* dead script. The returned identity must actually sign (`sign`, `signMessage`,
|
|
217
|
-
* `signerSession`): `contractSigner` refuses a watch-only one as `WalletCannotSignError`,
|
|
218
|
-
* which would otherwise pass every check and throw after the contract is funded.
|
|
219
|
-
*/
|
|
220
|
-
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds no key for the
|
|
224
|
-
* descriptor, so callers can tell "not my key" from transient signing failures.
|
|
225
|
-
*/
|
|
226
|
-
declare class ForeignDescriptorError extends Error {
|
|
227
|
-
readonly descriptor: string;
|
|
228
|
-
readonly name = "ForeignDescriptorError";
|
|
229
|
-
constructor(descriptor: string, options?: {
|
|
230
|
-
cause?: unknown;
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Thrown by `Wallet.getNewAddresses({ forceNew: true })` when there is no HD stream to advance
|
|
235
|
-
* (`walletMode: 'static'` / `'auto'`, or a {@link DescriptorProvider} that declined). Typed
|
|
236
|
-
* rather than a silent repeat, which would surface only as two payers sharing a script.
|
|
237
|
-
*/
|
|
238
|
-
declare class WalletCannotAllocateAddressError extends Error {
|
|
239
|
-
readonly name = "WalletCannotAllocateAddressError";
|
|
240
|
-
constructor(reason: string, options?: {
|
|
241
|
-
cause?: unknown;
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
/** Anything that can derive and sign for a descriptor it claims. */
|
|
245
|
-
type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
|
|
246
|
-
/**
|
|
247
|
-
* The identity that signs `descriptor`, or {@link ForeignDescriptorError}. Shared by every
|
|
248
|
-
* {@link HDWalletCapable.signerForDescriptor} so page- and worker-side wallets cannot drift into
|
|
249
|
-
* a signer that passes a pubkey check and then throws on every signature, after funding.
|
|
250
|
-
*/
|
|
251
|
-
declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
|
|
252
|
-
/** Structural type guard for {@link HDWalletCapable}. */
|
|
253
|
-
declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
|
|
254
|
-
/**
|
|
255
|
-
* Allocating a *fresh* index — strictly more than {@link HDWalletCapable}'s descriptor awareness.
|
|
256
|
-
* A separate probe because widening that guard would silently demote every wallet implementing
|
|
257
|
-
* only its original surface (including older SDKs') from HD-capable to static.
|
|
258
|
-
*/
|
|
259
|
-
interface HDAllocationCapable {
|
|
260
|
-
/**
|
|
261
|
-
* The signing descriptor a new artifact (swap, invoice, contract) should bind to. **The
|
|
262
|
-
* wallet decides**: an HD wallet allocates a fresh index, advancing the watermark; a static
|
|
263
|
-
* wallet answers with its one `tr(pubkey)` every time. Consumers must not probe the wallet's
|
|
264
|
-
* shape or mint key material; they use the answer with
|
|
265
|
-
* {@link HDWalletCapable.signerForDescriptor}.
|
|
266
|
-
*
|
|
267
|
-
* `undefined` only for implementations that genuinely cannot answer (`Wallet` always
|
|
268
|
-
* answers); callers then fall back to the identity key — never a random one.
|
|
269
|
-
*
|
|
270
|
-
* Unlike {@link HDWalletCapable.getCurrentSigningDescriptor}, which peeks (two artifacts bound
|
|
271
|
-
* to a peek share a key). Per-call uniqueness is a wallet property, so anything deriving
|
|
272
|
-
* per-artifact secrets must check the descriptor's shape, not the wallet's.
|
|
273
|
-
*/
|
|
274
|
-
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
275
|
-
/**
|
|
276
|
-
* Move the allocation watermark to `descriptor`'s index so later allocations cannot reissue
|
|
277
|
-
* it. Monotonic; a static wallet accepts its own descriptor as a no-op.
|
|
278
|
-
*
|
|
279
|
-
* Throws on a descriptor this wallet cannot derive, or an HD descriptor with no parseable
|
|
280
|
-
* trailing index: mapping those to index 0 would let a restored artifact's index be reissued.
|
|
281
|
-
*/
|
|
282
|
-
advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
|
|
283
|
-
}
|
|
284
|
-
/** Structural type guard for {@link HDAllocationCapable}. */
|
|
285
|
-
declare function isHDAllocationCapable(value: unknown): value is HDAllocationCapable;
|
|
286
|
-
/**
|
|
287
|
-
* Minting addresses to hand out: beyond {@link HDAllocationCapable}'s bare index, the wallet
|
|
288
|
-
* builds the scripts, persists them as watched contracts, and reports the rows. A third probe
|
|
289
|
-
* for the same no-silent-demotion reason.
|
|
290
|
-
*/
|
|
291
|
-
interface AddressAllocationCapable {
|
|
292
|
-
/**
|
|
293
|
-
* Fresh addresses of each requested type from one newly allocated HD index, persisted and
|
|
294
|
-
* watched. An HD wallet burns an index; a wallet with no stream answers with its existing
|
|
295
|
-
* display addresses or, under `forceNew`, throws {@link WalletCannotAllocateAddressError}.
|
|
296
|
-
*
|
|
297
|
-
* Unlike {@link HDAllocationCapable.getNextSigningDescriptor}, allocation and script
|
|
298
|
-
* registration happen together: split across a process boundary, a failed registration
|
|
299
|
-
* leaves a burnt index and an unwatched address.
|
|
300
|
-
*/
|
|
301
|
-
getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
|
|
302
|
-
}
|
|
303
|
-
/** Structural type guard for {@link AddressAllocationCapable}. */
|
|
304
|
-
declare function isAddressAllocationCapable(value: unknown): value is AddressAllocationCapable;
|
|
4
|
+
import { TransactionOutput } from '@scure/btc-signer/psbt.js';
|
|
5
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-gGkUnYpi.cjs';
|
|
305
6
|
|
|
306
7
|
/** Wall-clock floor for `batchExpiry` outside regtest. */
|
|
307
8
|
declare const DEFAULT_MIN_BATCH_EXPIRY_SECONDS = 86400n;
|
|
@@ -367,6 +68,7 @@ declare const ArkErrorName: {
|
|
|
367
68
|
*/
|
|
368
69
|
readonly FORFEIT_CLOSURE_LOCKED: "FORFEIT_CLOSURE_LOCKED";
|
|
369
70
|
readonly INVALID_INTENT_PROOF: "INVALID_INTENT_PROOF";
|
|
71
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
370
72
|
};
|
|
371
73
|
type ArkErrorName = (typeof ArkErrorName)[keyof typeof ArkErrorName];
|
|
372
74
|
/**
|
|
@@ -431,7 +133,7 @@ type ServerInfoSource = "live" | "cache";
|
|
|
431
133
|
* const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
|
|
432
134
|
*
|
|
433
135
|
* const abortController = new AbortController();
|
|
434
|
-
* // Get event stream from the
|
|
136
|
+
* // Get event stream from the operator provider
|
|
435
137
|
* const eventStream = arkProvider.getEventStream(
|
|
436
138
|
* abortController.signal,
|
|
437
139
|
* ['your-topic-1', 'your-topic-2']
|
|
@@ -518,6 +220,12 @@ declare namespace Batch {
|
|
|
518
220
|
skipVtxoTreeSigning: boolean;
|
|
519
221
|
eventCallback: (event: SettlementEvent) => Promise<void>;
|
|
520
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>;
|
|
521
229
|
/**
|
|
522
230
|
* Start the state machine that will process the batch events and join a batch.
|
|
523
231
|
* @param eventIterator - The events stream to process.
|
|
@@ -666,23 +374,140 @@ declare class WalletReceiveRotator {
|
|
|
666
374
|
/** Wait for any in-flight rotation to complete (mainly for tests). */
|
|
667
375
|
drain(): Promise<void>;
|
|
668
376
|
/**
|
|
669
|
-
* Run `fn` on the rotation chain. {@link Wallet.rotateServerSigner} uses it because both it
|
|
670
|
-
* and `rotate()` swap `offchainTapscript`; interleaving could tear the visible receive state.
|
|
671
|
-
* 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.
|
|
672
479
|
*/
|
|
673
|
-
|
|
480
|
+
getNextSigningDescriptor(): Promise<string | undefined>;
|
|
674
481
|
/**
|
|
675
|
-
*
|
|
676
|
-
*
|
|
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.
|
|
677
487
|
*/
|
|
678
|
-
|
|
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 {
|
|
679
498
|
/**
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
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.
|
|
683
506
|
*/
|
|
684
|
-
|
|
507
|
+
getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
|
|
685
508
|
}
|
|
509
|
+
/** Structural type guard for {@link AddressAllocationCapable}. */
|
|
510
|
+
declare function isAddressAllocationCapable(value: unknown): value is AddressAllocationCapable;
|
|
686
511
|
|
|
687
512
|
/**
|
|
688
513
|
* Cap on HD descriptors getUsedSigningDescriptors() materializes past the watermark (bounds
|
|
@@ -697,6 +522,17 @@ type IncomingFunds = {
|
|
|
697
522
|
newVtxos: ExtendedVirtualCoin[];
|
|
698
523
|
spentVtxos: ExtendedVirtualCoin[];
|
|
699
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
|
+
}
|
|
700
536
|
|
|
701
537
|
/**
|
|
702
538
|
* Structural rather than {@link ContractWithVtxos} so the worker's repository-built snapshot
|
|
@@ -711,7 +547,7 @@ type PendingRecoverySnapshot = Parameters<typeof selectPendingRecoveryOutpoints>
|
|
|
711
547
|
interface BoardingUtxoGroup {
|
|
712
548
|
/** Tapscript of the boarding address the coins sit on. */
|
|
713
549
|
tapscript: DefaultVtxo.Script;
|
|
714
|
-
/**
|
|
550
|
+
/** Operator key of that address, normalized x-only hex. */
|
|
715
551
|
serverPubKey: string;
|
|
716
552
|
/** CSV exit timelock decoded from THIS tapscript's exit leaf. */
|
|
717
553
|
csvTimelock: RelativeTimelock;
|
|
@@ -728,10 +564,10 @@ interface BoardingUtxoGroup {
|
|
|
728
564
|
* `Unroll.completeUnroll` is the remedy.
|
|
729
565
|
* - `has-assets` — asset-bearing; the BTC-only sweep would burn the assets.
|
|
730
566
|
* - `sweep-failed` — spendable, but its own sweep was rejected.
|
|
731
|
-
* - `recovery-failed` —
|
|
567
|
+
* - `recovery-failed` — operator-swept and recoverable in principle, but the
|
|
732
568
|
* import that hands it to the wallet's recovery machinery failed.
|
|
733
569
|
*
|
|
734
|
-
*
|
|
570
|
+
* An output the operator swept whose import *succeeds* is not reported here — it lands
|
|
735
571
|
* in {@link ArkadeCashClaimResult.recovering} instead.
|
|
736
572
|
*/
|
|
737
573
|
type ArkadeCashUnclaimedReason = "subdust" | "already-spent" | "exited" | "has-assets" | "sweep-failed" | "recovery-failed";
|
|
@@ -757,7 +593,7 @@ interface ArkadeCashClaimResult {
|
|
|
757
593
|
/** Satoshis swept to this wallet instantly (the thin single-key sweep). */
|
|
758
594
|
swept: number;
|
|
759
595
|
/**
|
|
760
|
-
*
|
|
596
|
+
* Operator-swept outputs imported for recovery. These funds are not in the
|
|
761
597
|
* wallet yet: a swept VTXO can only move through a settlement, so
|
|
762
598
|
* `claimCash` imports it as a signable contract and hands it to the
|
|
763
599
|
* wallet's own recovery machinery, which settles it back (rotation-aware)
|
|
@@ -809,7 +645,7 @@ declare class ArkadeCashOperatorMismatchError extends Error {
|
|
|
809
645
|
activeSignerPubKey: string);
|
|
810
646
|
}
|
|
811
647
|
/**
|
|
812
|
-
* Freshness of provider-backed sync (
|
|
648
|
+
* Freshness of provider-backed sync (operator info source + indexer-sync health). Balances/VTXOs
|
|
813
649
|
* are always served from the repository regardless. `syncing` says a provider sync is in flight
|
|
814
650
|
* right now; optional so adding it breaks no implementer, {@link ReadonlyWallet} always sets it.
|
|
815
651
|
*/
|
|
@@ -831,7 +667,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
831
667
|
readonly network: Network;
|
|
832
668
|
readonly onchainProvider: OnchainProvider;
|
|
833
669
|
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
834
|
-
protected readonly arkProvider: Pick<
|
|
670
|
+
protected readonly arkProvider: Pick<OperatorProvider, "getInfo">;
|
|
835
671
|
readonly indexerProvider: IndexerProvider;
|
|
836
672
|
readonly dustAmount: bigint;
|
|
837
673
|
readonly walletRepository: WalletRepository;
|
|
@@ -875,13 +711,13 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
875
711
|
*/
|
|
876
712
|
protected _boardingTapscript: DefaultVtxo.Script;
|
|
877
713
|
/**
|
|
878
|
-
* Active
|
|
714
|
+
* Active operator signer (x-only); written only by
|
|
879
715
|
* {@link Wallet.setArkServerPublicKeyForRotation} when arkd rotates its signer mid-session.
|
|
880
716
|
*/
|
|
881
717
|
protected _arkServerPublicKey: Bytes;
|
|
882
718
|
/**
|
|
883
|
-
* Whether the LATEST
|
|
884
|
-
* 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.
|
|
885
721
|
*/
|
|
886
722
|
protected _serverInfoSource: ServerInfoSource;
|
|
887
723
|
/**
|
|
@@ -893,7 +729,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
893
729
|
get serverInfoSource(): ServerInfoSource;
|
|
894
730
|
/**
|
|
895
731
|
* Composed provider-connection freshness: degraded on `arkade` (`cache`) when the latest
|
|
896
|
-
*
|
|
732
|
+
* operator info resolution fell back, else degraded on `indexer` (`repository`) when an
|
|
897
733
|
* initialized contract manager has, else online. Never forces a `ContractManager` to
|
|
898
734
|
* construct, so it is safe for readonly callers.
|
|
899
735
|
*/
|
|
@@ -905,7 +741,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
905
741
|
getContractSyncState(): ContractSyncState;
|
|
906
742
|
protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider,
|
|
907
743
|
/** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
|
|
908
|
-
arkProvider: Pick<
|
|
744
|
+
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[]);
|
|
909
745
|
/**
|
|
910
746
|
* x-only hex → cutoff of the operator's deprecated signers, cached for OFFLINE read/watch.
|
|
911
747
|
* Boarding watch/history fan out over {current} ∪ this set so deposits at addresses minted
|
|
@@ -915,7 +751,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
915
751
|
*/
|
|
916
752
|
protected _deprecatedSigners: Map<string, bigint>;
|
|
917
753
|
/**
|
|
918
|
-
* Refresh the cached deprecated-signer set from
|
|
754
|
+
* Refresh the cached deprecated-signer set from operator info; feeds
|
|
919
755
|
* {@link pendingRecoveryOutpoints}. Lenient: a malformed entry is skipped, never fatal.
|
|
920
756
|
*/
|
|
921
757
|
refreshDeprecatedSigners(info: {
|
|
@@ -937,7 +773,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
937
773
|
/** Current active server signer (x-only, 32 bytes); changes only on server-signer rotation. */
|
|
938
774
|
get arkServerPublicKey(): Bytes;
|
|
939
775
|
/**
|
|
940
|
-
*
|
|
776
|
+
* Info for the connected operator: live wins, a retryable failure falls back to
|
|
941
777
|
* the boot snapshot, a terminal one propagates. Live because `signerPubkey`,
|
|
942
778
|
* `checkpointTapscript` and `fees` move on rotation, and a covenant built against a
|
|
943
779
|
* superseded signer is unspendable.
|
|
@@ -947,12 +783,14 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
947
783
|
* on N; the provider's `onServerInfoChanged` closes the window. Pass `{ requireLive: true }`
|
|
948
784
|
* before binding the answer into a covenant to fail closed instead of getting the snapshot.
|
|
949
785
|
*
|
|
950
|
-
* @returns The
|
|
786
|
+
* @returns The operator's info
|
|
951
787
|
* @see ArkadeInfo
|
|
952
788
|
*/
|
|
953
|
-
|
|
789
|
+
getOperatorInfo(opts?: GetOperatorInfoOptions): Promise<ArkadeInfo>;
|
|
790
|
+
/** @deprecated Use {@link getOperatorInfo}. */
|
|
791
|
+
getArkadeInfo(opts?: GetOperatorInfoOptions): Promise<ArkadeInfo>;
|
|
954
792
|
/**
|
|
955
|
-
* 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
|
|
956
794
|
* own (possibly Expo/injected) `indexerProvider`. `getVtxos` normalizes via
|
|
957
795
|
* {@link getNormalizedVtxos}. A bound object, not the provider, so an `IReadonlyWallet`
|
|
958
796
|
* holder gets these two reads and nothing else.
|
|
@@ -974,7 +812,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
974
812
|
protected notifyBoardingRotation(): void;
|
|
975
813
|
/** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
|
|
976
814
|
protected static setupWalletConfig(config: ReadonlyWalletConfig, pubKey: Uint8Array): Promise<{
|
|
977
|
-
arkProvider:
|
|
815
|
+
arkProvider: OperatorProvider;
|
|
978
816
|
indexerProvider: IndexerProvider;
|
|
979
817
|
onchainProvider: OnchainProvider | EsploraProvider;
|
|
980
818
|
network: Network;
|
|
@@ -985,7 +823,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
985
823
|
dustAmount: bigint;
|
|
986
824
|
walletRepository: WalletRepository | IndexedDBWalletRepository;
|
|
987
825
|
contractRepository: ContractRepository;
|
|
988
|
-
info:
|
|
826
|
+
info: OperatorInfo;
|
|
989
827
|
serverInfoSource: ServerInfoSource;
|
|
990
828
|
serverInfoLastOnlineAt: number | undefined;
|
|
991
829
|
delegateProvider: DelegateProvider | undefined;
|
|
@@ -1052,7 +890,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1052
890
|
*/
|
|
1053
891
|
private expiredSignerExclusion;
|
|
1054
892
|
/** The intent store's lock set. Fails open, like every other read of it. */
|
|
1055
|
-
|
|
893
|
+
protected lockedOutpoints(): Promise<Set<string>>;
|
|
1056
894
|
/**
|
|
1057
895
|
* One contract+VTXO read (which may sync against the indexer). Callers needing several views
|
|
1058
896
|
* derive them all from one snapshot so they answer about the same instant.
|
|
@@ -1113,27 +951,38 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1113
951
|
}>;
|
|
1114
952
|
/**
|
|
1115
953
|
* Every boarding tapscript whose UTXOs belong to this wallet (rotation spreads them over
|
|
1116
|
-
* several addresses), deduplicated by scriptPubKey.
|
|
1117
|
-
*
|
|
954
|
+
* several addresses), deduplicated by scriptPubKey. Includes index-0 `default` rows when a
|
|
955
|
+
* baseline boarding script coalesced with one.
|
|
1118
956
|
*
|
|
1119
|
-
* @param allowedSigners - x-only
|
|
957
|
+
* @param allowedSigners - x-only operator keys whose persisted boarding rows are included;
|
|
1120
958
|
* defaults to the current signer (the foreign-ASP guard). Migration widens it to old signers.
|
|
1121
959
|
* The baseline and current display tapscript are included regardless.
|
|
1122
960
|
*/
|
|
1123
961
|
protected getBoardingTapscripts(allowedSigners?: Set<string>): Promise<DefaultVtxo.Script[]>;
|
|
1124
962
|
/**
|
|
1125
|
-
* Fetch and cache
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
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).
|
|
1128
968
|
*
|
|
1129
|
-
*
|
|
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
|
|
1130
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.
|
|
1131
978
|
*/
|
|
1132
|
-
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;
|
|
1133
982
|
/**
|
|
1134
983
|
* Fetch and cache boarding UTXOs at current and historical boarding addresses, each annotated
|
|
1135
984
|
* with its own address's tapscript so spends use the right per-index leaves. Current-signer
|
|
1136
|
-
* 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
|
|
1137
986
|
* recovery goes through the deprecated-signer migration API.
|
|
1138
987
|
*/
|
|
1139
988
|
getBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
@@ -1144,6 +993,13 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1144
993
|
* stay gone if it fails.
|
|
1145
994
|
*/
|
|
1146
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. */
|
|
1147
1003
|
getStoredBoardingUtxos(): Promise<ExtendedCoin[]>;
|
|
1148
1004
|
/**
|
|
1149
1005
|
* Subscribe to onchain and offchain notifications for newly received funds.
|
|
@@ -1198,7 +1054,7 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1198
1054
|
* @see Wallet.lookAheadConfig
|
|
1199
1055
|
*/
|
|
1200
1056
|
protected lookAheadConfig(): ContractManagerConfig["lookAhead"];
|
|
1201
|
-
/** Readonly wallets never settle, so they neither release nor own
|
|
1057
|
+
/** Readonly wallets never settle, so they neither release nor own batch registrations. */
|
|
1202
1058
|
protected intentReconciliationConfig(): ContractManagerConfig["intentReconciliation"];
|
|
1203
1059
|
private initializeContractManager;
|
|
1204
1060
|
/** Dispose wallet-owned managers and release background resources. */
|
|
@@ -1214,14 +1070,14 @@ declare class ReadonlyWallet implements IReadonlyWallet {
|
|
|
1214
1070
|
* // Create a wallet with providers
|
|
1215
1071
|
* const wallet = await Wallet.create({
|
|
1216
1072
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
1217
|
-
*
|
|
1073
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
1218
1074
|
* onchainProvider: new EsploraProvider()
|
|
1219
1075
|
* });
|
|
1220
1076
|
*
|
|
1221
1077
|
* // Use custom providers and/or URLs (e.g., for Expo/React Native)
|
|
1222
1078
|
* const wallet = await Wallet.create({
|
|
1223
1079
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
|
|
1224
|
-
*
|
|
1080
|
+
* operatorProvider: new ExpoOperatorProvider('https://arkade.computer'),
|
|
1225
1081
|
* indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
|
|
1226
1082
|
* onchainProvider: new EsploraProvider('https://mempool.space/api')
|
|
1227
1083
|
* });
|
|
@@ -1263,7 +1119,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1263
1119
|
*/
|
|
1264
1120
|
private _serverInfoInFlight;
|
|
1265
1121
|
/**
|
|
1266
|
-
* React to a mid-session
|
|
1122
|
+
* React to a mid-session operator info change (`DIGEST_MISMATCH`): refresh deprecated signers
|
|
1267
1123
|
* first so boarding watch widens immediately, then rotate via {@link rotateServerSigner} only
|
|
1268
1124
|
* if the active signer changed. Old-signer rows stay active. Never throws into the emit loop.
|
|
1269
1125
|
*/
|
|
@@ -1271,7 +1127,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1271
1127
|
/**
|
|
1272
1128
|
* Await an `onServerInfoChanged` handler still applying a rotation. {@link rotateServerSigner}
|
|
1273
1129
|
* persists the new signer's rows *before* committing the tapscripts, so a path that refreshes
|
|
1274
|
-
*
|
|
1130
|
+
* operator info then reads signer-derived state must drain first or it reads torn state and
|
|
1275
1131
|
* races the handler. Resolves once idle; handler rejections are swallowed (already logged).
|
|
1276
1132
|
*
|
|
1277
1133
|
* @internal Invoked by {@link dispose} and the {@link VtxoManager} migration
|
|
@@ -1326,6 +1182,8 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1326
1182
|
*/
|
|
1327
1183
|
private receiveCandidateDeps;
|
|
1328
1184
|
private readonly _signerRouter;
|
|
1185
|
+
private _emulator?;
|
|
1186
|
+
private _cosignMarginBlocks;
|
|
1329
1187
|
/**
|
|
1330
1188
|
* @internal Sole write path for `offchainTapscript`; called by
|
|
1331
1189
|
* {@link WalletReceiveRotator.rotate} after the rotated contract is persisted.
|
|
@@ -1342,7 +1200,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1342
1200
|
*/
|
|
1343
1201
|
setArkServerPublicKeyForRotation(serverPubKey: Bytes): void;
|
|
1344
1202
|
/**
|
|
1345
|
-
* Checkpoint output script from the
|
|
1203
|
+
* Checkpoint output script from the operator's `checkpointTapscript`; pinned at construction,
|
|
1346
1204
|
* re-sourced only via {@link setServerUnrollScriptForRotation}.
|
|
1347
1205
|
*/
|
|
1348
1206
|
protected _serverUnrollScript: CSVMultisigTapscript.Type;
|
|
@@ -1459,11 +1317,11 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1459
1317
|
*/
|
|
1460
1318
|
signerForDescriptor(descriptor: string): Promise<Identity>;
|
|
1461
1319
|
/**
|
|
1462
|
-
* Mid-session
|
|
1463
|
-
* 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
|
|
1464
1322
|
* reject, so receive state is re-derived under the new signer first.
|
|
1465
1323
|
*
|
|
1466
|
-
* Same write-path as {@link WalletReceiveRotator.rotate} with the
|
|
1324
|
+
* Same write-path as {@link WalletReceiveRotator.rotate} with the operator key swapped: build the
|
|
1467
1325
|
* new tapscripts, register their rows (carrying signing metadata so a descriptor-backed
|
|
1468
1326
|
* pubkey still signs), and only then commit visible state. Old-signer rows stay `active` for
|
|
1469
1327
|
* the migration pass to drain. Idempotent; serialized against HD receive rotation.
|
|
@@ -1521,13 +1379,13 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1521
1379
|
/** @see WalletConfig.concurrentSpending */
|
|
1522
1380
|
get concurrentSpending(): boolean;
|
|
1523
1381
|
/** Public here; `ReadonlyWallet` keeps it protected so a readonly view can't submit. */
|
|
1524
|
-
readonly arkProvider:
|
|
1382
|
+
readonly arkProvider: OperatorProvider;
|
|
1525
1383
|
/**
|
|
1526
|
-
* 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
|
|
1527
1385
|
* {@link ReadonlyWallet}: a readonly wallet or `toReadonly()` view must not be able to submit.
|
|
1528
1386
|
*/
|
|
1529
1387
|
getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
|
|
1530
|
-
protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider:
|
|
1388
|
+
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,
|
|
1531
1389
|
/** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
|
|
1532
1390
|
batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined,
|
|
1533
1391
|
/** @see WalletConfig.oneShotSubmit */
|
|
@@ -1544,7 +1402,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1544
1402
|
* ```typescript
|
|
1545
1403
|
* const wallet = await Wallet.create({
|
|
1546
1404
|
* identity,
|
|
1547
|
-
*
|
|
1405
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
1548
1406
|
* });
|
|
1549
1407
|
* ```
|
|
1550
1408
|
*/
|
|
@@ -1618,14 +1476,24 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1618
1476
|
private persistIntentSnapshot;
|
|
1619
1477
|
signInputsByWitnessScript(tx: Transaction): Promise<Transaction>;
|
|
1620
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;
|
|
1621
1489
|
safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
|
|
1622
|
-
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<
|
|
1623
|
-
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<
|
|
1624
|
-
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<
|
|
1490
|
+
makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedProof<Proof.RegisterMessage>>;
|
|
1491
|
+
makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedProof<Proof.DeleteMessage>>;
|
|
1492
|
+
makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedProof<Proof.GetPendingTxMessage>>;
|
|
1625
1493
|
/**
|
|
1626
|
-
* Finalizes pending transactions by retrieving them from the
|
|
1627
|
-
* Skips the
|
|
1628
|
-
* @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
|
|
1629
1497
|
* @returns Array of transaction IDs that were finalized
|
|
1630
1498
|
*/
|
|
1631
1499
|
finalizePendingTxs(vtxos?: ExtendedVirtualCoin[]): Promise<{
|
|
@@ -1633,7 +1501,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1633
1501
|
pending: string[];
|
|
1634
1502
|
}>;
|
|
1635
1503
|
/**
|
|
1636
|
-
*
|
|
1504
|
+
* Operator unroll scripts a pending checkpoint may have been built under: configured, current,
|
|
1637
1505
|
* and one per deprecated signer — else a pre-rotation tx would stay pending forever.
|
|
1638
1506
|
*/
|
|
1639
1507
|
private checkpointUnrollCandidates;
|
|
@@ -1652,11 +1520,11 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1652
1520
|
createCash(amount: number): Promise<string>;
|
|
1653
1521
|
/**
|
|
1654
1522
|
* Claim an ArkadeCash bearer instrument: sweep what can be swept, recover what
|
|
1655
|
-
* was swept by the
|
|
1523
|
+
* was swept by the operator, report the rest.
|
|
1656
1524
|
*
|
|
1657
1525
|
* Every spendable VTXO at the arkadeCash address is swept to this wallet in
|
|
1658
1526
|
* its own offchain transaction, signed with the key carried by the arkadeCash
|
|
1659
|
-
* string.
|
|
1527
|
+
* string. An output the operator already swept at batch expiry cannot move
|
|
1660
1528
|
* through the thin sweep — only a settlement can lift it — so it is
|
|
1661
1529
|
* **imported** as a signable `default` contract (the arkadeCash key is filed
|
|
1662
1530
|
* in the keyring) and handed to the wallet's own recovery machinery, which
|
|
@@ -1668,7 +1536,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1668
1536
|
*
|
|
1669
1537
|
* The arkadeCash string is the recovery token: a claim interrupted between
|
|
1670
1538
|
* submit and finalize is completed by simply re-running `claimCash`, which
|
|
1671
|
-
* drains any pending arkadeCash transaction
|
|
1539
|
+
* drains any pending arkadeCash transaction at the operator before sweeping.
|
|
1672
1540
|
* The import is idempotent, so re-running is always safe.
|
|
1673
1541
|
*
|
|
1674
1542
|
* @param cashStr - The encoded arkadeCash string (e.g., "arkadecash1...")
|
|
@@ -1678,7 +1546,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1678
1546
|
claimCash(cashStr: string): Promise<ArkadeCashClaimResult>;
|
|
1679
1547
|
/**
|
|
1680
1548
|
* Import an arkadeCash instrument as a signable, recovery-only contract so the
|
|
1681
|
-
* wallet's own recovery machinery can settle its
|
|
1549
|
+
* wallet's own recovery machinery can settle its operator-swept outputs back.
|
|
1682
1550
|
*
|
|
1683
1551
|
* Two writes, both idempotent so a re-run (or a resumed claim) is safe:
|
|
1684
1552
|
* - the arkadeCash private key is filed in the keyring, returning its
|
|
@@ -1724,7 +1592,7 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1724
1592
|
removeRecoveryContract(script: string): Promise<void>;
|
|
1725
1593
|
/**
|
|
1726
1594
|
* Split the VTXOs at an arkadeCash address into three buckets: the ones the
|
|
1727
|
-
* thin sweep can move (`spendable`), the
|
|
1595
|
+
* thin sweep can move (`spendable`), the operator-swept ones that must go
|
|
1728
1596
|
* through a recovery settlement (`recoverable`), and the ones that can
|
|
1729
1597
|
* only be reported (`unclaimed`).
|
|
1730
1598
|
*/
|
|
@@ -1784,11 +1652,11 @@ declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable,
|
|
|
1784
1652
|
sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
|
|
1785
1653
|
/**
|
|
1786
1654
|
* Build an offchain transaction from the given inputs and outputs,
|
|
1787
|
-
* sign it, submit to the
|
|
1655
|
+
* sign it, submit to the operator provider, and finalize.
|
|
1788
1656
|
*
|
|
1789
1657
|
* Signs whatever it is handed, ungated — see {@link settle} for the trade.
|
|
1790
1658
|
*
|
|
1791
|
-
* @returns The Arkade transaction id and
|
|
1659
|
+
* @returns The Arkade transaction id and operator-signed checkpoint PSBTs (for bookkeeping)
|
|
1792
1660
|
*/
|
|
1793
1661
|
buildAndSubmitOffchainTx(inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[], serverUnrollScript?: CSVMultisigTapscript.Type, options?: {
|
|
1794
1662
|
validUntil?: number;
|
|
@@ -1874,6 +1742,193 @@ interface WaitForIncomingFundsOptions {
|
|
|
1874
1742
|
* }
|
|
1875
1743
|
* ```
|
|
1876
1744
|
*/
|
|
1877
|
-
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
|
+
}
|
|
1878
1933
|
|
|
1879
|
-
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 };
|