@tari-project/ootle 0.1.0

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.
@@ -0,0 +1,1982 @@
1
+ import { AllocatableAddressType } from '@tari-project/ootle-ts-bindings';
2
+ import { Amount } from '@tari-project/ootle-ts-bindings';
3
+ import { ClaimBurnOutputData } from '@tari-project/ootle-ts-bindings';
4
+ import { ClaimedOutputTombstoneAddress } from '@tari-project/ootle-ts-bindings';
5
+ import { ComponentAddress } from '@tari-project/ootle-ts-bindings';
6
+ import { ConfidentialWithdrawProof } from '@tari-project/ootle-ts-bindings';
7
+ import { Decision } from '@tari-project/ootle-ts-bindings';
8
+ import { ExecuteResult } from '@tari-project/ootle-ts-bindings';
9
+ import { FinalizeOutcome } from '@tari-project/ootle-ts-bindings';
10
+ import { FinalizeResult } from '@tari-project/ootle-ts-bindings';
11
+ import { GetSubstatesRequest } from '@tari-project/ootle-ts-bindings';
12
+ import { GetSubstatesResponse } from '@tari-project/ootle-ts-bindings';
13
+ import { GetTemplateDefinitionResponse } from '@tari-project/ootle-ts-bindings';
14
+ import { IndexerGetSubstateRequest } from '@tari-project/ootle-ts-bindings';
15
+ import { IndexerGetSubstateResponse } from '@tari-project/ootle-ts-bindings';
16
+ import { IndexerGetTransactionResultResponse } from '@tari-project/ootle-ts-bindings';
17
+ import { IndexerSubmitTransactionRequest } from '@tari-project/ootle-ts-bindings';
18
+ import { IndexerSubmitTransactionResponse } from '@tari-project/ootle-ts-bindings';
19
+ import { IndexerTransactionFinalizedResult } from '@tari-project/ootle-ts-bindings';
20
+ import { Instruction } from '@tari-project/ootle-ts-bindings';
21
+ import { InstructionArg } from '@tari-project/ootle-ts-bindings';
22
+ import { ListRecentTransactionsRequest } from '@tari-project/ootle-ts-bindings';
23
+ import { ListRecentTransactionsResponse } from '@tari-project/ootle-ts-bindings';
24
+ import { MinotariBurnClaimProof } from '@tari-project/ootle-ts-bindings';
25
+ import { NonFungibleAddress } from '@tari-project/ootle-ts-bindings';
26
+ import { OutputBody } from '@tari-project/ootle-ts-bindings';
27
+ import { PublishedTemplateAddress } from '@tari-project/ootle-ts-bindings';
28
+ import { RejectReason } from '@tari-project/ootle-ts-bindings';
29
+ import { ResourceAddress } from '@tari-project/ootle-ts-bindings';
30
+ import { RistrettoPublicKeyBytes } from '@tari-project/ootle-ts-bindings';
31
+ import { StealthTransferStatement as StealthTransferStatement_2 } from '@tari-project/ootle-ts-bindings';
32
+ import { SubstateId } from '@tari-project/ootle-ts-bindings';
33
+ import { SubstateRequirement } from '@tari-project/ootle-ts-bindings';
34
+ import { Transaction } from '@tari-project/ootle-ts-bindings';
35
+ import { TransactionEnvelope } from '@tari-project/ootle-ts-bindings';
36
+ import { TransactionSignature } from '@tari-project/ootle-ts-bindings';
37
+ import { TransactionV1 } from '@tari-project/ootle-ts-bindings';
38
+ import { UnsealedTransactionV1 } from '@tari-project/ootle-ts-bindings';
39
+ import { UnsignedTransactionV1 } from '@tari-project/ootle-ts-bindings';
40
+ import { UtxoAddress } from '@tari-project/ootle-ts-bindings';
41
+ import { ValidatorFeePoolAddress } from '@tari-project/ootle-ts-bindings';
42
+ import { VaultId } from '@tari-project/ootle-ts-bindings';
43
+ import { WorkspaceOffsetId } from '@tari-project/ootle-ts-bindings';
44
+
45
+ /**
46
+ * Fluent builder for common account component invocations.
47
+ * Mirrors `AccountInvokeBuilder` from the Rust ootle-rs crate.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const tx = new AccountInvokeBuilder(network)
52
+ * .feeTransactionPayFromComponent(accountAddress, 1000n)
53
+ * .publicTransfer(accountAddress, resourceAddress, 500n, recipientAddress)
54
+ * .build();
55
+ * ```
56
+ */
57
+ export declare class AccountInvokeBuilder {
58
+ private builder;
59
+ constructor(network: Network | number);
60
+ /**
61
+ * Declares the transaction's substate inputs (e.g. the source account and its
62
+ * vaults) so the indexer resolves their versions before submission.
63
+ */
64
+ withInputs(inputs: SubstateRequirement[]): this;
65
+ /**
66
+ * Adds a fee instruction paying from the account's default vault.
67
+ */
68
+ feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: bigint): this;
69
+ /**
70
+ * Transfers `amount` of `resource` from `sourceAccount` to `destinationAddress`.
71
+ * Mirrors `AccountInvokeBuilder::public_transfer` from ootle-rs.
72
+ */
73
+ publicTransfer(sourceAccount: ComponentAddress, resourceAddress: ResourceAddress, amount: bigint, destinationAddress: string): this;
74
+ /**
75
+ * Publishes a compiled template WASM blob (standard-base64 encoded).
76
+ * Mirrors `AccountInvokeBuilder::publish_template` from ootle-rs.
77
+ *
78
+ * `sourceAccount` is the fee payer; declare it via {@link feeTransactionPayFromComponent}
79
+ * and {@link withInputs}. Pass `workspaceBucket` to capture the new template address
80
+ * for a follow-up instruction.
81
+ */
82
+ publishTemplate(_sourceAccount: ComponentAddress, templateBinaryBase64: string, workspaceBucket?: string): this;
83
+ build(): UnsignedTransactionWithBlobs;
84
+ }
85
+
86
+ export { Amount }
87
+
88
+ /**
89
+ * CBOR-encode an `Amount` (u128) as the `[lo_u64, hi_u64]` pair the runtime
90
+ * deserialises via `tari_bor`.
91
+ *
92
+ * @throws {InvalidArgumentError} if `value` is negative or overflows u128.
93
+ */
94
+ export declare function amountLiteral(value: bigint): InstructionArg;
95
+
96
+ /**
97
+ * Asserts that `bytes` has exactly `length` bytes; otherwise throws with a
98
+ * descriptive message. Returns `bytes` so the assertion can be used inline in a
99
+ * property initialiser or destructuring expression.
100
+ *
101
+ * Message format deliberately mirrors the existing stealth-side inline checks
102
+ * (e.g. `Mask must be 32 bytes, got 31`).
103
+ *
104
+ * @throws {InvalidArgumentError} when the length does not match.
105
+ */
106
+ export declare function assertByteLength(bytes: Uint8Array, length: number, name: string): Uint8Array;
107
+
108
+ /**
109
+ * Standard TypeScript exhaustiveness helper. Use at the bottom of a `switch` over
110
+ * a discriminated union (or any branch the type system has narrowed to `never`)
111
+ * to assert at compile-time that every case is handled — and throw at runtime if
112
+ * an unhandled value sneaks past the type checker.
113
+ */
114
+ export declare function assertUnreachable(x: never, hint?: string): never;
115
+
116
+ /**
117
+ * The post-{@link WalletStealthAuthorizer.prepare} handle.
118
+ *
119
+ * Owns the hydrated spec, the resolved stealth inputs, and the single seal keypair shared
120
+ * across one-time authorizations and the seal signature. Constructed only via
121
+ * {@link WalletStealthAuthorizer.prepare} — there is no way to obtain one without preparing
122
+ * first, so {@link seal} / {@link createAuthorizations} no longer need a `prepared` guard.
123
+ */
124
+ export declare class AuthorizedTransfer {
125
+ private readonly wallet;
126
+ private readonly crypto;
127
+ private readonly spec;
128
+ private readonly resolvedInputs;
129
+ private readonly mustSignWithAccountKey;
130
+ /**
131
+ * The single seal keypair, generated once and shared across the one-time spend-key
132
+ * authorizations (which hash the tx with its public key) and the final {@link seal}. Every
133
+ * signature must be over the same tx hash, which depends on this exact seal public key.
134
+ */
135
+ private readonly sealKeypair;
136
+ /** Extra signatures appended via {@link addSignature} before sealing. */
137
+ private readonly extraSignatures;
138
+ /**
139
+ * Memoized one-time spend-key authorizations — see {@link createAuthorizations} for the
140
+ * lifecycle and why memoization (not recomputation) is required.
141
+ */
142
+ private cachedAuthorizations?;
143
+ constructor(params: AuthorizedTransferParams);
144
+ /** The shared seal signer public key (fixed for this transfer's lifetime). */
145
+ getSealPublicKey(): Uint8Array;
146
+ /** The hydrated, post-`prepare` spec (balance proof filled, instruction patched). */
147
+ getSpec(): StealthTransferSpec;
148
+ /**
149
+ * Produce the one-time spend-key authorizations for the stealth inputs (empty for a
150
+ * revealed-only transfer).
151
+ *
152
+ * For each resolved input, picks the owner's signer from the wallet and calls its
153
+ * `addStealthSignature(unsignedJson, publicNonce, sealPublicKey, { crypto })` — which
154
+ * derives the one-time spend scalar via `stealthDhSecret` and signs the tx hash. The
155
+ * secret stays in the signer (never pulled into the transfer).
156
+ *
157
+ * Uses this transfer's shared seal public key ({@link getSealPublicKey}) — the same one
158
+ * {@link seal} uses — so every signature is over the same tx hash. The tx hashed is
159
+ * `spec.unsignedTx` (already resolved by the builder); {@link seal} does not re-resolve,
160
+ * so the hashes match.
161
+ *
162
+ * **Memoized.** The authorizations are computed on the first call and cached; every
163
+ * subsequent call — including the internal one from {@link seal} — returns the *same*
164
+ * array, never re-signing with a fresh random nonce. Calling this before {@link seal}
165
+ * cannot double-count, because {@link seal} reuses the cache. Callers therefore must
166
+ * **not** feed these one-time authorizations to {@link addSignature} — they are
167
+ * auto-included exactly once at seal time.
168
+ *
169
+ * @throws {KeyProviderNotFoundError} if a stealth-input owner has no signer registered.
170
+ * @throws {SignerError} if a stealth-input owner's signer cannot produce one-time
171
+ * stealth signatures (lacks `addStealthSignature`).
172
+ */
173
+ createAuthorizations(): Promise<TransactionAuthorization[]>;
174
+ /**
175
+ * Sign each resolved stealth input with its owner's one-time spend key (fresh random
176
+ * nonce per signature). Called **once** via {@link createAuthorizations}'s memoization —
177
+ * never directly — so the random-nonce signatures are produced a single time.
178
+ */
179
+ private computeAuthorizations;
180
+ /**
181
+ * Append an extra signature for a **genuine external co-signer** to be included when
182
+ * sealing. The account-key signature is added automatically at {@link seal} unless
183
+ * `mustSignWithAccountKey` is `false`.
184
+ *
185
+ * Do **NOT** pass the per-input one-time spend-key authorizations here — they are
186
+ * produced (memoized) by {@link createAuthorizations} and auto-included by {@link seal}
187
+ * exactly once. Re-adding them via this method would double-count them in the sealed tx,
188
+ * which the engine rejects.
189
+ */
190
+ addSignature(signature: TransactionSignature): this;
191
+ /**
192
+ * Sign and seal the (prepared) transfer into a `TransactionEnvelope`.
193
+ *
194
+ * Composes, over a SINGLE shared seal keypair:
195
+ * - the account-key signature (unless `mustSignWithAccountKey` is `false`);
196
+ * - the per-input **one-time spend-key authorizations** — included **exactly once** per
197
+ * stealth input via {@link createAuthorizations}'s memoized cache, whether or not the
198
+ * caller invoked {@link createAuthorizations} first; callers must NOT also re-add them
199
+ * via {@link addSignature};
200
+ * - any {@link addSignature} extras (e.g. genuine external co-signers).
201
+ *
202
+ * All of these — and the seal signature itself — hash the tx with the same seal public
203
+ * key, so every signature verifies against the same hash. The tx is **not** re-resolved
204
+ * here (the builder already resolved it in `prepare()`); re-resolving could change the
205
+ * hash and invalidate the already-computed one-time authorizations.
206
+ *
207
+ * @throws {KeyProviderNotFoundError} when a stealth-input owner has no signer registered.
208
+ * @throws {SignerError} when a stealth-input signer cannot produce one-time signatures.
209
+ */
210
+ seal(): Promise<TransactionEnvelope>;
211
+ }
212
+
213
+ /**
214
+ * Parameters for the {@link AuthorizedTransfer} constructor. Kept internal — the only
215
+ * construction path is via {@link WalletStealthAuthorizer.prepare}.
216
+ */
217
+ declare interface AuthorizedTransferParams {
218
+ wallet: OotleWallet;
219
+ crypto: StealthCryptoProvider;
220
+ spec: StealthTransferSpec;
221
+ resolvedInputs: ResolvedStealthInput[];
222
+ mustSignWithAccountKey: boolean;
223
+ sealKeypair: SealKeypair;
224
+ }
225
+
226
+ /**
227
+ * The balance-proof Schnorr signature `(public_nonce, signature)`. For a
228
+ * fully-revealed transfer this pair is normally omitted on the envelope.
229
+ */
230
+ export declare class BalanceProofSignature {
231
+ private readonly _publicNonce;
232
+ private readonly _signature;
233
+ constructor(publicNonce: Uint8Array, signature: Uint8Array);
234
+ /** 32-byte public nonce (defensive copy). */
235
+ get publicNonce(): Uint8Array;
236
+ /** 32-byte signature scalar (defensive copy). */
237
+ get signature(): Uint8Array;
238
+ toJSON(): BalanceProofSignatureJson;
239
+ static fromJSON(json: BalanceProofSignatureJson): BalanceProofSignature;
240
+ }
241
+
242
+ /** Wire shape of a {@link BalanceProofSignature}. */
243
+ declare interface BalanceProofSignatureJson {
244
+ public_nonce: string;
245
+ signature: string;
246
+ }
247
+
248
+ /** CBOR-encode a `bool` as a CBOR boolean primitive. */
249
+ export declare function boolLiteral(value: boolean): InstructionArg;
250
+
251
+ /**
252
+ * Assemble a TransactionSignature from a 32-byte public key and a Schnorr
253
+ * `(public_nonce, signature)` pair. Asserts the 32-byte length on all three
254
+ * inputs at the trust boundary so length regressions surface here, not deeper.
255
+ */
256
+ export declare function buildTransactionSignature(publicKey: Uint8Array, sig: {
257
+ public_nonce: Uint8Array;
258
+ signature: Uint8Array;
259
+ }): TransactionSignature;
260
+
261
+ /**
262
+ * Internal base for 32-byte stealth-domain carriers (`Mask`, `StealthInput`).
263
+ * Asserts the 32-byte length at construction and defensively copies on the way
264
+ * in; subclasses inherit `toBytes()` / `toHex()` which return fresh copies.
265
+ *
266
+ * Exported for cross-file extension by `StealthInput` in `./statements`; not
267
+ * part of the public package surface (not re-exported from `./types`).
268
+ */
269
+ declare abstract class Bytes32 {
270
+ private readonly bytes;
271
+ protected constructor(bytes: Uint8Array, fieldName: string);
272
+ toBytes(): Uint8Array;
273
+ toHex(): string;
274
+ }
275
+
276
+ /** CBOR-encode a `Vec<u8>` as a CBOR byte string. */
277
+ export declare function bytesLiteral(value: Uint8Array): InstructionArg;
278
+
279
+ /**
280
+ * CBOR-encode a `ClaimedOutputTombstoneAddress` as `Tag(136, bytes(32))`.
281
+ * Accepts either the `tombstone_<hex>` form or the bare 64-hex-char tail.
282
+ *
283
+ * @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
284
+ */
285
+ export declare function claimedOutputTombstoneAddressLiteral(address: ClaimedOutputTombstoneAddress): InstructionArg;
286
+
287
+ /**
288
+ * @throws {InvalidArgumentError} if `result` carries an unrecognised `final_decision`
289
+ * variant (an indexer protocol mismatch — defence-in-depth).
290
+ */
291
+ export declare function classifyOutcome(result: IndexerTransactionFinalizedResult): {
292
+ outcome: FinalizeOutcome | "Reject";
293
+ reason?: string;
294
+ } | null;
295
+
296
+ /**
297
+ * Extract the 32-byte commitment from a UTXO substate id.
298
+ *
299
+ * A UTXO id has the form `utxo_{resourceHex}_{commitmentHex}`; the commitment is the
300
+ * **trailing** hex segment. Returns `null` if the id is not a UTXO id (wrong prefix,
301
+ * e.g. a component/vault id) or the trailing segment is not exactly 32 bytes of hex.
302
+ *
303
+ * The commitment is **never** in the output body — always derive it from the id.
304
+ *
305
+ * @param substateId - The full substate id string.
306
+ * @returns The 32-byte commitment, or `null` if `substateId` is not a valid UTXO id.
307
+ */
308
+ export declare function commitmentOf(substateId: string): Uint8Array | null;
309
+
310
+ /**
311
+ * The only outcome a `PendingTransaction.watch()` can resolve to: a successful
312
+ * commit. Every non-commit verdict (Reject, FeeIntentCommit, timeout, cancel)
313
+ * throws instead, so the return type is narrowed to this rather than the full
314
+ * {@link TransactionOutcome} union.
315
+ */
316
+ export declare interface CommitOutcome {
317
+ outcome: "Commit";
318
+ }
319
+
320
+ /**
321
+ * CBOR-encode a `ComponentAddress` as `Tag(128, bytes(32))`. Accepts either the
322
+ * `component_<hex>` form or the bare 64-hex-char tail.
323
+ *
324
+ * @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
325
+ */
326
+ export declare function componentAddressLiteral(address: ComponentAddress): InstructionArg;
327
+
328
+ /**
329
+ * Construct an {@link Output}, applying the conventional defaults and validating
330
+ * the amount.
331
+ *
332
+ * @throws {InvalidArgumentError} if `amount <= 0n`.
333
+ */
334
+ export declare function createOutput(init: OutputInit): Output;
335
+
336
+ /**
337
+ * Raised when the WASM crypto bridge fails (AEAD decryption, balance-proof
338
+ * verification, scalar parsing, …). `context` is a short label identifying which
339
+ * bridge call failed; the original bridge error chains via `cause`.
340
+ */
341
+ export declare class CryptoBridgeError extends OotleError {
342
+ readonly context?: string;
343
+ constructor(message: string, options?: ErrorOptions & {
344
+ context?: string;
345
+ });
346
+ }
347
+
348
+ export { Decision }
349
+
350
+ /**
351
+ * The result of decrypting an owned output via the AEAD path (`unblindOutput`).
352
+ *
353
+ * Maps from the WASM `DecryptedOutputResult { mask: Uint8Array, value: bigint,
354
+ * memo_json: string | undefined }`. Per the verified 0.32 ABI, `memo` is the
355
+ * **JSON-encoded `Memo` string** (`U256` / `Message` / `Bytes` / `PayRefAndBytes`),
356
+ * not raw bytes — callers parse it if needed.
357
+ */
358
+ export declare interface DecryptedData {
359
+ /** Recovered output blinding factor. */
360
+ mask: Mask;
361
+ /** Recovered µTari amount. */
362
+ value: bigint;
363
+ /** The JSON-encoded `Memo` string, if present. */
364
+ memo?: string;
365
+ }
366
+
367
+ /**
368
+ * Decrypt an output's encrypted data given its raw commitment + ciphertext bytes.
369
+ *
370
+ * Derives the AEAD key (`deriveAeadKey(viewSecret, senderPublicNonce)`) and unblinds.
371
+ * **Throws** (via `unblindOutput`) when the output is not owned — callers that scan a
372
+ * batch should prefer {@link decryptOwnedUtxo}, which swallows that throw.
373
+ *
374
+ * @param crypto - The crypto seam (real WASM or a fake).
375
+ * @param commitment - The output's 32-byte Pedersen commitment.
376
+ * @param encryptedData - The raw ciphertext bytes.
377
+ * @param options - The sender public nonce, recipient view secret, and `skipMemo` flag.
378
+ * @returns The decrypted value / mask / memo.
379
+ */
380
+ export declare function decryptInputData(crypto: StealthCryptoProvider, commitment: Uint8Array, encryptedData: Uint8Array, options: DecryptInputOptions): Promise<DecryptedData>;
381
+
382
+ /** Inputs to {@link decryptInputData}. All byte fields are raw `Uint8Array`. */
383
+ export declare interface DecryptInputOptions {
384
+ /** The output's sender public nonce (the substate body `public_nonce`, as bytes). */
385
+ senderPublicNonce: Uint8Array;
386
+ /** The recipient's 32-byte view secret. */
387
+ viewSecret: Uint8Array;
388
+ /** When `true`, the memo is not decrypted. */
389
+ skipMemo: boolean;
390
+ }
391
+
392
+ /**
393
+ * The recipient owner-read: try to decrypt a fetched UTXO substate with a view secret.
394
+ *
395
+ * Parses the substate (commitment from the id, `public_nonce` + `encrypted_data` from
396
+ * the body), derives the AEAD key, and unblinds. Returns the {@link DecryptedData} for
397
+ * an owned UTXO, or `null` when the substate is not a live stealth UTXO **or** the
398
+ * decrypt throws (the "not ours" signal). This lets a recipient scan many substates in
399
+ * a loop without a try/catch at each call site.
400
+ *
401
+ * @param crypto - The crypto seam (real WASM or a fake).
402
+ * @param viewSecret - The recipient's 32-byte view secret.
403
+ * @param substate - The fetched substate response.
404
+ * @param substateId - The substate id the response was fetched by (source of the commitment).
405
+ * @returns The decrypted output if owned, else `null`.
406
+ */
407
+ export declare function decryptOwnedUtxo(crypto: StealthCryptoProvider, viewSecret: Uint8Array, substate: IndexerGetSubstateResponse, substateId: string): Promise<DecryptedData | null>;
408
+
409
+ /**
410
+ * Returns a known default indexer URL for the given network.
411
+ * Mirrors `default_indexer_url()` from the Rust ootle-rs crate.
412
+ *
413
+ * @throws {InvalidArgumentError} for networks where no default URL is configured.
414
+ */
415
+ export declare function defaultIndexerUrl(network: Network): string;
416
+
417
+ /** The wallet has no default signer to sign / seal with. */
418
+ export declare class DefaultSignerNotSetError extends WalletError {
419
+ }
420
+
421
+ /**
422
+ * Opaque carrier for an output's ciphertext bytes (the AEAD-encrypted value/mask/memo
423
+ * payload). Treated as opaque here: the stealth module never inspects the plaintext
424
+ * structure, only carries the bytes across the JSON boundary.
425
+ */
426
+ export declare class EncryptedData {
427
+ private readonly bytes;
428
+ constructor(bytes: Uint8Array);
429
+ /** Parse a hex string into `EncryptedData` (variable length). */
430
+ static fromHex(hex: string): EncryptedData;
431
+ /** Raw ciphertext bytes (defensive copy). */
432
+ toBytes(): Uint8Array;
433
+ /** Hex encoding. */
434
+ toHex(): string;
435
+ }
436
+
437
+ export { ExecuteResult }
438
+
439
+ /**
440
+ * Fluent builder for common faucet component invocations.
441
+ * Mirrors `FaucetInvokeBuilder` from the Rust ootle-rs crate.
442
+ *
443
+ * @example
444
+ * ```ts
445
+ * const tx = new FaucetInvokeBuilder(network, faucetAddress)
446
+ * .feeTransactionPayFromComponent(accountAddress, 1000n)
447
+ * .takeFaucetFunds(accountAddress, 10_000n)
448
+ * .build();
449
+ * ```
450
+ */
451
+ export declare class FaucetInvokeBuilder {
452
+ private builder;
453
+ private readonly faucetAddress;
454
+ constructor(network: Network | number, faucetAddress: ComponentAddress);
455
+ feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: bigint): this;
456
+ /**
457
+ * Takes `amount` of funds from the faucet and deposits them into `destinationAccount`.
458
+ * Mirrors `FaucetInvokeBuilder::take_faucet_funds` from ootle-rs.
459
+ */
460
+ takeFaucetFunds(destinationAccount: ComponentAddress, amount: bigint): this;
461
+ /**
462
+ * Takes the maximum available funds from the faucet into `destinationAccount`.
463
+ * Mirrors `FaucetInvokeBuilder::take_max_faucet_funds` from ootle-rs.
464
+ */
465
+ takeMaxFaucetFunds(destinationAccount: ComponentAddress): this;
466
+ /**
467
+ * Publishes a template from the faucet component address.
468
+ * Mirrors `FaucetInvokeBuilder::publish_template` from ootle-rs.
469
+ */
470
+ publishTemplate(templateAddress: PublishedTemplateAddress, workspaceBucket?: string): this;
471
+ build(): UnsignedTransactionWithBlobs;
472
+ }
473
+
474
+ export { FinalizeOutcome }
475
+
476
+ export { FinalizeResult }
477
+
478
+ /**
479
+ * Decodes a hex string into bytes.
480
+ *
481
+ * Strict: rejects odd-length input and any character outside `[0-9a-fA-F]`.
482
+ * Returns an empty `Uint8Array` for an empty input.
483
+ *
484
+ * @throws {InvalidArgumentError} if `hex` has odd length or contains non-hex characters.
485
+ */
486
+ export declare function fromHexStr(hex: string): Uint8Array;
487
+
488
+ /**
489
+ * Faucet / public-stealth convenience: build a **complete** {@link StealthTransferStatement}
490
+ * for a transfer that has no stealth inputs (e.g. a faucet minting confidential outputs, or
491
+ * any revealed → stealth transfer that doesn't need the full {@link StealthTransfer} builder).
492
+ *
493
+ * Generates the outputs statement, uses a zero (`Mask.zero()`) input mask over an empty
494
+ * revealed-only inputs statement, signs the balance proof, and returns a ready-to-embed
495
+ * statement (`balanceProof` filled). The output mask is non-zero (there is ≥1 stealth
496
+ * output), so the proof is real — not the omitted all-zeros case.
497
+ *
498
+ * For multi-step transfers with revealed change / fee, prefer the {@link StealthTransfer}
499
+ * builder + {@link WalletStealthAuthorizer}; this is the one-shot helper.
500
+ *
501
+ * @param crypto - The crypto seam (real WASM or a fake).
502
+ * @param specs - The stealth outputs to create (must be non-empty).
503
+ * @param revealed - The revealed (un-confidential) output amount (0 for fully-stealth).
504
+ * @returns A complete transfer statement.
505
+ * @throws {InvalidArgumentError} if `specs` is empty.
506
+ */
507
+ export declare function generateOutputsStatement(crypto: StealthCryptoProvider, specs: Output[], revealed: bigint): Promise<StealthTransferStatement>;
508
+
509
+ /**
510
+ * Generate a fresh seal keypair (a thin wrapper over the WASM `generateKeypair`).
511
+ *
512
+ * Exposed so a caller that needs the seal **public key before sealing** can fix the
513
+ * keypair once and thread the same public key through other signatures that hash with
514
+ * it (the stealth one-time authorizations — see {@link signTransaction}'s `sealKeypair`
515
+ * parameter). Keeps `@tari-project/ootle-wasm` out of the `stealth/` module.
516
+ */
517
+ export declare function generateSealKeypair(): SealKeypair;
518
+
519
+ export { GetSubstatesRequest }
520
+
521
+ export { GetSubstatesResponse }
522
+
523
+ export { GetTemplateDefinitionResponse }
524
+
525
+ /**
526
+ * Fetch `account` and return the list of vault ids it references (depth-first,
527
+ * unique). Returns an empty array if the component does not exist or holds no
528
+ * vaults.
529
+ */
530
+ export declare function getVaultIdsForAccount(provider: Provider, account: ComponentAddress): Promise<string[]>;
531
+
532
+ /**
533
+ * Raised when the indexer transport fails or returns a non-success response.
534
+ *
535
+ * `status` is the HTTP status if the request reached the indexer (else `undefined`,
536
+ * e.g. a connection-layer failure). `body` is the raw response body when
537
+ * available, and `url` is the request URL. The original transport error chains via
538
+ * `cause`.
539
+ */
540
+ export declare class IndexerClientError extends OotleError {
541
+ readonly status?: number;
542
+ readonly body?: string;
543
+ readonly url?: string;
544
+ constructor(message: string, options?: ErrorOptions & {
545
+ status?: number;
546
+ body?: string;
547
+ url?: string;
548
+ });
549
+ }
550
+
551
+ export { IndexerGetSubstateRequest }
552
+
553
+ export { IndexerGetSubstateResponse }
554
+
555
+ export { IndexerGetTransactionResultResponse }
556
+
557
+ export { IndexerSubmitTransactionRequest }
558
+
559
+ export { IndexerSubmitTransactionResponse }
560
+
561
+ export { IndexerTransactionFinalizedResult }
562
+
563
+ export { Instruction }
564
+
565
+ export { InstructionArg }
566
+
567
+ /**
568
+ * CBOR-encode a plain integer (Rust `u8`…`u128` / `i8`…`i128`) as a bare CBOR
569
+ * integer. Distinct from {@link amountLiteral}, which encodes the `Amount` type
570
+ * as a two-element array.
571
+ *
572
+ * @throws {InvalidArgumentError} if the magnitude exceeds the 64-bit CBOR
573
+ * integer range (128-bit bignum encoding is not supported).
574
+ */
575
+ export declare function intLiteral(value: bigint): InstructionArg;
576
+
577
+ /** Raised when builder / helper inputs fail TS-side validation or state-machine checks. */
578
+ export declare class InvalidArgumentError extends OotleError {
579
+ }
580
+
581
+ /**
582
+ * Type guard for the native `StealthTransfer` {@link Instruction} variant. Used by the
583
+ * authorizer to locate the single stealth instruction it must patch.
584
+ */
585
+ export declare function isStealthTransferInstruction(instruction: Instruction): instruction is StealthTransferInstruction;
586
+
587
+ /**
588
+ * Walk the JSON-rendered `tari_bor::Value` of a component's state and yield every
589
+ * 32-byte payload of a `Tag(VAULT_ID, Bytes(..))` node — i.e. every vault id the
590
+ * component references. Depth-first, unique by hex payload.
591
+ *
592
+ * The engine emits values that don't map cleanly to JSON via a `{"@cbor": …}`
593
+ * sentinel object; this walker handles `tag`, `map`, and `bytes` sentinels and
594
+ * recurses through plain text-keyed maps and arrays.
595
+ */
596
+ export declare function iterVaultIdsInState(value: unknown): Generator<string>;
597
+
598
+ /**
599
+ * The wallet has no signer registered for the given address.
600
+ *
601
+ * `address` is intentionally typed as `unknown`: the wallet may register key
602
+ * providers under any keying shape (a `ComponentAddress`, a `ResourceAddress`, …),
603
+ * and the typed error should not pollute the consumer's downstream signature.
604
+ */
605
+ export declare class KeyProviderNotFoundError extends WalletError {
606
+ readonly address: unknown;
607
+ constructor(message: string, options: ErrorOptions & {
608
+ address: unknown;
609
+ });
610
+ }
611
+
612
+ /**
613
+ * CBOR-encode a value into an `InstructionArg::Literal` by its JavaScript type:
614
+ * `bigint` → `Amount`, `string` → CBOR text, `boolean` → CBOR bool,
615
+ * `Uint8Array` → CBOR byte string. For tagged on-chain addresses use
616
+ * {@link resourceAddressLiteral} / {@link componentAddressLiteral} instead — a
617
+ * raw address string would be encoded as plain text, not a tagged object key.
618
+ *
619
+ * @throws {InvalidArgumentError} if `value` is not one of the supported types.
620
+ */
621
+ export declare function literalArg(value: bigint | string | boolean | Uint8Array): InstructionArg;
622
+
623
+ /**
624
+ * A 32-byte blinding factor (Pedersen-commitment mask).
625
+ *
626
+ * Use {@link Mask.zero} for the faucet / revealed-only path (an all-zero scalar).
627
+ */
628
+ export declare class Mask extends Bytes32 {
629
+ constructor(bytes: Uint8Array);
630
+ /** All-zero 32-byte mask, for the faucet / revealed-only path. */
631
+ static zero(): Mask;
632
+ /** Wrap raw 32 bytes into a `Mask` (validates length, defensive copy in the ctor). */
633
+ static fromBytes(bytes: Uint8Array): Mask;
634
+ /** Parse a 64-char hex string into a `Mask` (validates length). */
635
+ static fromHex(hex: string): Mask;
636
+ }
637
+
638
+ /**
639
+ * CBOR-encode a `Metadata` map as `Tag(129, Map<text, text>)`. Keys are emitted
640
+ * sorted to match the runtime's `BTreeMap` ordering.
641
+ */
642
+ export declare function metadataLiteral(entries: Record<string, string> | Map<string, string>): InstructionArg;
643
+
644
+ /**
645
+ * Encodes a µTari amount as a BOR-CBOR-encoded hex `Literal` instruction argument.
646
+ *
647
+ * Delegates to {@link amountLiteral}: the runtime's `InstructionArg::Literal` carries
648
+ * a hex string whose bytes are a `tari_bor::encode(value)` CBOR payload, **not** the
649
+ * decimal-string form. Keeping the public type as `bigint` preserves precision for
650
+ * values above `Number.MAX_SAFE_INTEGER`.
651
+ *
652
+ * @throws {InvalidArgumentError} if `amount` is negative or overflows u128.
653
+ */
654
+ export declare function microTariLiteral(amount: bigint): InstructionArg;
655
+
656
+ /**
657
+ * Canonical µTari → decimal-string encoding used wherever the bindings expect a
658
+ * string-encoded amount on the wire (e.g. structural `toJSON()` views of stealth
659
+ * statements). **Not** the BOR-CBOR `Literal` form — use {@link microTariLiteral}
660
+ * / {@link amountLiteral} for instruction arguments.
661
+ *
662
+ * @throws {InvalidArgumentError} if `amount` is negative.
663
+ */
664
+ export declare function microTariString(amount: bigint): string;
665
+
666
+ /**
667
+ * A NamedArg is either:
668
+ * - `{ Workspace: string }` — a named workspace reference resolved by the builder to a numeric ID
669
+ * - `InstructionArg` — a fully-formed `{ Workspace: WorkspaceOffsetId }` or `{ Literal: string }`
670
+ */
671
+ export declare type NamedArg = {
672
+ Workspace: string;
673
+ } | InstructionArg;
674
+
675
+ /**
676
+ * Tari network identifiers. Values match the Rust `Network` byte representation.
677
+ */
678
+ export declare enum Network {
679
+ MainNet = 0,
680
+ StageNet = 1,
681
+ NextNet = 2,
682
+ LocalNet = 16,
683
+ Igor = 36,
684
+ Esmeralda = 38
685
+ }
686
+
687
+ /**
688
+ * CBOR-encode a `NonFungibleAddress` as `Tag(130, [ResourceAddress, NonFungibleId])`.
689
+ * The inner pair is minicbor's struct-as-array layout; the `NonFungibleId` enum
690
+ * is its two-element `[variant_index, [field]]` form.
691
+ *
692
+ * @throws {InvalidArgumentError} if the resource address or id payload is malformed.
693
+ */
694
+ export declare function nonFungibleAddressLiteral(address: NonFungibleAddress): InstructionArg;
695
+
696
+ /** Base class for every exception thrown by the Ootle SDK. */
697
+ export declare abstract class OotleError extends Error {
698
+ constructor(message: string, options?: ErrorOptions);
699
+ }
700
+
701
+ /**
702
+ * A wallet that manages multiple key providers (one per component address) and
703
+ * can sign transactions on behalf of any registered signer.
704
+ *
705
+ * Mirrors `OotleWallet` from the Rust ootle-rs crate.
706
+ *
707
+ * @example
708
+ * ```ts
709
+ * const wallet = new OotleWallet();
710
+ * wallet.registerKeyProvider(myAddress, mySecretKeyWallet);
711
+ * wallet.setDefaultSigner(myAddress);
712
+ *
713
+ * const signed = await wallet.authorizeTransaction(unsignedTx);
714
+ * ```
715
+ */
716
+ export declare class OotleWallet implements Signer {
717
+ private keyProviders;
718
+ private defaultSignerAddress;
719
+ constructor();
720
+ /**
721
+ * Registers a key provider (a `Signer`) for the given component address.
722
+ *
723
+ * Stealth capabilities (`getViewSecret`/`addStealthSignature`) are optional methods on
724
+ * `Signer` (see {@link Signer}); the stealth spend authorizer uses them when present.
725
+ */
726
+ registerKeyProvider(address: string, provider: Signer): this;
727
+ /**
728
+ * Sets the address used when `signTransaction` is called without specifying a signer.
729
+ *
730
+ * @throws {KeyProviderNotFoundError} when no key provider has been registered for
731
+ * `address`.
732
+ */
733
+ setDefaultSigner(address: string): this;
734
+ /**
735
+ * Returns the default signer address, or throws if none is set.
736
+ *
737
+ * @throws {DefaultSignerNotSetError} when no default signer is configured.
738
+ */
739
+ getAddress(): Promise<string>;
740
+ /**
741
+ * @throws {DefaultSignerNotSetError} when no default signer is configured.
742
+ * @throws {KeyProviderNotFoundError} when the default address has no registered provider.
743
+ */
744
+ getPublicKey(): Promise<Uint8Array>;
745
+ /**
746
+ * Signs using the default signer.
747
+ *
748
+ * @throws {DefaultSignerNotSetError} when no default signer is configured.
749
+ * @throws {KeyProviderNotFoundError} when the default address has no registered provider.
750
+ */
751
+ signTransaction(unsignedTx: UnsignedTransactionV1, sealPublicKey: Uint8Array): Promise<TransactionSignature[]>;
752
+ /**
753
+ * Generates `TransactionAuthorization` (signatures) for a specific registered signer.
754
+ * Mirrors `OotleWallet::authorize_transaction` from ootle-rs.
755
+ *
756
+ * @throws {KeyProviderNotFoundError} when no provider is registered for `signerAddress`.
757
+ */
758
+ authorizeTransaction(signerAddress: string, unsignedTx: UnsignedTransactionV1, sealPublicKey: Uint8Array): Promise<TransactionAuthorization>;
759
+ /**
760
+ * Collects authorizations from all registered key providers.
761
+ * Useful when a transaction requires multiple signers.
762
+ */
763
+ authorizeTransactionAll(unsignedTx: UnsignedTransactionV1, sealPublicKey: Uint8Array): Promise<TransactionAuthorization[]>;
764
+ /**
765
+ * Returns the key provider for a specific address, if registered.
766
+ */
767
+ getKeyProvider(address: string): Signer | undefined;
768
+ /**
769
+ * Returns all registered signer addresses.
770
+ */
771
+ getSignerAddresses(): string[];
772
+ private getSignerOrThrow;
773
+ private requireKeyProvider;
774
+ }
775
+
776
+ /** Raised when an in-flight operation was cancelled by the caller. */
777
+ export declare class OperationCancelledError extends OotleError {
778
+ }
779
+
780
+ /**
781
+ * A stealth output to create.
782
+ *
783
+ * Use {@link createOutput} to construct one with the conventional defaults
784
+ * (`payTo = { StealthPublicKey: {} }`, `minimumValuePromise = 0n`) and
785
+ * validation (rejects `amount <= 0n`).
786
+ */
787
+ export declare interface Output {
788
+ /** Destination account address (a string component/account address). */
789
+ destination: string;
790
+ /** µTari amount to send (must be `> 0n`). */
791
+ amount: bigint;
792
+ /** Resource being transferred. */
793
+ resourceAddress: ResourceAddress;
794
+ /** Resource view key — set only for resources with a viewable balance. */
795
+ resourceViewKey?: Uint8Array;
796
+ /** Optional structured memo attached to the output. */
797
+ memo?: object;
798
+ /** Spend condition for the output; defaults to `{ StealthPublicKey: {} }`. */
799
+ payTo: object;
800
+ /** Minimum value promise (range-proof lower bound); defaults to `0n`. */
801
+ minimumValuePromise: bigint;
802
+ }
803
+
804
+ /** Fields callers supply to {@link createOutput}; `payTo` and `minimumValuePromise` are defaulted. */
805
+ export declare interface OutputInit {
806
+ destination: string;
807
+ amount: bigint;
808
+ resourceAddress: ResourceAddress;
809
+ resourceViewKey?: Uint8Array;
810
+ memo?: object;
811
+ payTo?: object;
812
+ minimumValuePromise?: bigint;
813
+ }
814
+
815
+ /** A parsed, spendable UTXO: its commitment (from the id) plus the on-chain output body. */
816
+ export declare interface ParsedUtxo {
817
+ /** 32-byte Pedersen commitment, derived from the substate id via {@link commitmentOf}. */
818
+ commitment: Uint8Array;
819
+ /** The on-chain output body (`public_nonce`, `encrypted_data`, ...). */
820
+ body: OutputBody;
821
+ }
822
+
823
+ /**
824
+ * A parsed workspace key string into an object with name and optional offset.
825
+ *
826
+ * Examples:
827
+ * "bucket" -> { name: "bucket", offset: null }
828
+ * "bucket.0" -> { name: "bucket", offset: 0 }
829
+ */
830
+ export declare interface ParsedWorkspaceKey {
831
+ name: string;
832
+ offset: number | null;
833
+ }
834
+
835
+ /**
836
+ * Parse a fetched substate into a {@link ParsedUtxo}, or `null` when it is not a
837
+ * live, spendable stealth UTXO.
838
+ *
839
+ * Returns `null` when:
840
+ * - the substate is not the `Utxo` arm of {@link SubstateValue} (e.g. a component/vault),
841
+ * - the UTXO has been spent (`output === null`),
842
+ * - the UTXO is frozen (`is_frozen === true`),
843
+ * - or the substate id does not yield a valid 32-byte commitment.
844
+ *
845
+ * @param substate - The fetched substate response.
846
+ * @param substateId - The substate id the response was fetched by (source of the commitment).
847
+ */
848
+ export declare function parseSubstateUtxo(substate: IndexerGetSubstateResponse, substateId: string): ParsedUtxo | null;
849
+
850
+ /**
851
+ * Parses a workspace key string, supporting dot-notation offsets.
852
+ *
853
+ * @example
854
+ * parseWorkspaceStringKey("bucket") // { name: "bucket", offset: null }
855
+ * parseWorkspaceStringKey("bucket.0") // { name: "bucket", offset: 0 }
856
+ * parseWorkspaceStringKey("bucket.1") // { name: "bucket", offset: 1 }
857
+ *
858
+ * @throws {InvalidArgumentError} if the key contains more than one dot, or if the
859
+ * suffix after the dot is empty / non-numeric / negative.
860
+ */
861
+ export declare function parseWorkspaceStringKey(key: string): ParsedWorkspaceKey;
862
+
863
+ /**
864
+ * Patch the single stealth instruction in `unsignedTx` with a (hydrated) statement.
865
+ *
866
+ * Locates the sole `StealthTransfer` instruction (throws if there is not exactly one) and
867
+ * replaces its `statement` field with the byte-exact compact JSON of `statement` (via the
868
+ * single encoding seam in `instruction.ts`). Returns a new `UnsignedTransactionV1` — the
869
+ * input is not mutated.
870
+ *
871
+ * @throws {InvalidArgumentError} when there is no StealthTransfer instruction (not a
872
+ * stealth tx) or more than one (malformed).
873
+ */
874
+ export declare function patchStealthStatement(unsignedTx: UnsignedTransactionV1, statement: StealthTransferStatement): UnsignedTransactionV1;
875
+
876
+ /**
877
+ * A Provider reads chain state and submits transactions. It has no signing capability.
878
+ * The canonical implementation is IndexerProvider, which talks to the indexer REST API.
879
+ */
880
+ export declare interface Provider {
881
+ /** Returns the network this provider is connected to. */
882
+ network(): Network;
883
+ /** Fetches a single substate by ID and optional version. */
884
+ getSubstate(substateId: string, version?: number | null): Promise<IndexerGetSubstateResponse>;
885
+ /**
886
+ * Fetches a stealth UTXO substate by resource address + 32-byte commitment.
887
+ *
888
+ * The provider owns the `utxo_{resourceHex}_{commitmentHex}` id format; callers pass
889
+ * the resource and commitment and never string the id themselves. Returns `null` when
890
+ * the UTXO does not exist (already spent / never created), instead of throwing.
891
+ */
892
+ getStealthUtxo(resourceAddress: string, commitment: Uint8Array): Promise<IndexerGetSubstateResponse | null>;
893
+ /** Fetches multiple substates by ID in a single request. */
894
+ fetchSubstates(requests: SubstateId[]): Promise<GetSubstatesResponse>;
895
+ /** Returns the ABI definition for a published template. */
896
+ getTemplateDefinition(templateAddress: string): Promise<GetTemplateDefinitionResponse>;
897
+ /**
898
+ * Submits a BOR+base64-encoded transaction envelope to the network.
899
+ * Encoding is performed by `sealTransaction` in `transaction.ts`.
900
+ */
901
+ submitTransaction(envelope: TransactionEnvelope): Promise<IndexerSubmitTransactionResponse>;
902
+ /** Polls for the result of a previously submitted transaction. */
903
+ getTransactionResult(transactionId: string): Promise<IndexerGetTransactionResultResponse>;
904
+ /**
905
+ * Resolves unversioned inputs by fetching their current version from the indexer.
906
+ * Returns the same list with `version` filled in for any entry that had `version: null`.
907
+ */
908
+ resolveInputs(inputs: SubstateRequirement[]): Promise<SubstateRequirement[]>;
909
+ /** Lists recent transactions. */
910
+ listRecentTransactions(params: ListRecentTransactionsRequest): Promise<ListRecentTransactionsResponse>;
911
+ }
912
+
913
+ /**
914
+ * CBOR-encode a `RistrettoPublicKeyBytes` as a 32-byte CBOR byte string. A
915
+ * compressed Ristretto point is *not* a tagged value — it is a bare byte string,
916
+ * the same shape {@link bytesLiteral} produces. Accepts a 64-hex-char string or
917
+ * a 32-byte `Uint8Array`; this wrapper exists so the public-key intent and the
918
+ * length check are explicit at the call site.
919
+ *
920
+ * @throws {InvalidArgumentError} if the key is not exactly 32 bytes.
921
+ */
922
+ export declare function publicKeyLiteral(value: RistrettoPublicKeyBytes | Uint8Array): InstructionArg;
923
+
924
+ /**
925
+ * A stealth input resolved during {@link WalletStealthAuthorizer.prepare}: the input being
926
+ * spent, its owner address (the one-time signer), the recovered blinding mask, and the
927
+ * sender public nonce read from the fetched UTXO body (the DH counterparty for one-time
928
+ * signing). Insertion-ordered, matching `spec.inputs`.
929
+ */
930
+ declare interface ResolvedStealthInput {
931
+ ownerAddr: string;
932
+ input: StealthInput;
933
+ mask: Mask;
934
+ /** The fetched UTXO's sender public nonce (`OutputBody.public_nonce`), raw bytes. */
935
+ publicNonce: Uint8Array;
936
+ }
937
+
938
+ /**
939
+ * Resolves unversioned inputs in the unsigned transaction by fetching their current
940
+ * version from the provider.
941
+ */
942
+ export declare function resolveTransaction(provider: Provider, unsignedTx: UnsignedTransactionV1): Promise<UnsignedTransactionV1>;
943
+
944
+ /**
945
+ * CBOR-encode a `ResourceAddress` as `Tag(131, bytes(32))`. Accepts either the
946
+ * `resource_<hex>` form or the bare 64-hex-char tail.
947
+ *
948
+ * @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
949
+ */
950
+ export declare function resourceAddressLiteral(address: ResourceAddress): InstructionArg;
951
+
952
+ /**
953
+ * A seal keypair: the throwaway key the seal signature is produced with.
954
+ *
955
+ * Both fields are expected to be exactly 32 bytes. The length invariant is
956
+ * enforced at the trust boundary (in {@link signTransaction}) rather than via
957
+ * a branded type — see the README scope decision on asserted-`Uint8Array` as
958
+ * the default for non-stealth 32-byte values.
959
+ */
960
+ export declare interface SealKeypair {
961
+ secret_key: Uint8Array;
962
+ public_key: Uint8Array;
963
+ }
964
+
965
+ /**
966
+ * BOR-encodes a {@link SignedTransaction} into a TransactionEnvelope.
967
+ *
968
+ * Encodes the byte-exact `sealedJson` directly (never the parsed `transaction` view), so
969
+ * u64 amounts above 2^53 are not corrupted by a `JSON.parse` → `JSON.stringify` round-trip.
970
+ */
971
+ export declare function sealTransaction(signed: SignedTransaction): TransactionEnvelope;
972
+
973
+ /**
974
+ * Like `sendTransaction` but sets `dry_run = true` on the transaction before
975
+ * submitting, so the network simulates execution without committing state.
976
+ */
977
+ export declare function sendDryRun(provider: Provider, signers: Signer | Signer[], unsignedTx: UnsignedTransactionV1, watchOpts?: WatchOptions): Promise<IndexerGetTransactionResultResponse>;
978
+
979
+ /**
980
+ * All-in-one convenience function: resolve → sign → encode → submit → watch.
981
+ */
982
+ export declare function sendTransaction(provider: Provider, signers: Signer | Signer[], unsignedTx: UnsignedTransactionV1, watchOpts?: WatchOptions): Promise<IndexerGetTransactionResultResponse>;
983
+
984
+ /**
985
+ * Serialize an unsigned transaction to the JSON string handed to WASM (`addTransactionSigner`,
986
+ * `sealTransaction`) and to one-time stealth-signature hashing.
987
+ *
988
+ * Identical to `JSON.stringify(unsignedTx)` for any fragment-free transaction — so existing
989
+ * transaction hashes do not shift — but a stealth `statement` is carried as a
990
+ * {@link RawJsonFragment} whose byte-exact `toCompactJson()` string must survive verbatim. Its
991
+ * u64 amounts are bare JSON numbers exceeding 2^53; `JSON.stringify` cannot emit them
992
+ * losslessly. We therefore stringify each carrier as a unique placeholder, then splice the raw
993
+ * fragment in place of the quoted placeholder, never round-tripping the amounts through a JS
994
+ * number.
995
+ */
996
+ export declare function serializeUnsignedTx(unsignedTx: UnsignedTransactionV1): string;
997
+
998
+ /**
999
+ * Sign the balance proof over an inputs + outputs statement pair.
1000
+ *
1001
+ * A transfer with **no stealth inputs** uses `inputMask = Mask.zero()`; a
1002
+ * **fully-revealed** transfer omits the balance proof entirely (not called here).
1003
+ *
1004
+ * @returns The `(public_nonce, signature)` balance-proof signature.
1005
+ */
1006
+ export declare function signBalanceProof(crypto: StealthCryptoProvider, inputMask: Mask, outputMask: Mask, inputsStatement: StealthInputsStatement, outputsStatement: StealthOutputsStatement): Promise<BalanceProofSignature>;
1007
+
1008
+ /**
1009
+ * A signed transaction produced by {@link signTransaction}, ready to be sealed.
1010
+ *
1011
+ * Carries the byte-exact `sealedJson` string emitted by WASM **alongside** a parsed
1012
+ * {@link Transaction} view. The two are intentionally separate:
1013
+ *
1014
+ * - `sealedJson` is the **canonical artifact**. It preserves u64 amounts that exceed
1015
+ * `Number.MAX_SAFE_INTEGER` (e.g. a confidential output's `minimum_value_promise`),
1016
+ * which the engine emits as bare JSON numbers. {@link sealTransaction} BOR-encodes
1017
+ * this string directly — it never re-stringifies the parsed object.
1018
+ * - `transaction` is a **convenience view for inspection only**. It is the result of
1019
+ * `JSON.parse(sealedJson)`, so any bare integer above 2^53 has already been rounded.
1020
+ * Re-serialising it (`JSON.stringify`) and submitting that is lossy — always seal via
1021
+ * `sealedJson`.
1022
+ */
1023
+ export declare interface SignedTransaction {
1024
+ /** The byte-exact sealed-transaction JSON from WASM — the canonical bytes to BOR-encode. */
1025
+ readonly sealedJson: string;
1026
+ /**
1027
+ * Parsed view of {@link sealedJson} for inspection. Lossy for u64 amounts > 2^53 — do
1028
+ * NOT re-serialise this for submission; seal via {@link sealedJson} instead.
1029
+ */
1030
+ readonly transaction: Transaction;
1031
+ }
1032
+
1033
+ /**
1034
+ * A Signer is responsible only for signing. It has no read or submit capability.
1035
+ * Implementations include SecretKeyWallet (local WASM signing) and WalletDaemonSigner (remote daemon).
1036
+ */
1037
+ export declare interface Signer {
1038
+ /** Returns the component address derived from this signer's public key. */
1039
+ getAddress(): Promise<string>;
1040
+ /** Returns the raw public key bytes for this signer. */
1041
+ getPublicKey(): Promise<Uint8Array>;
1042
+ /**
1043
+ * Signs the given unsigned transaction and returns the collected signatures.
1044
+ *
1045
+ * `sealPublicKey` is mixed into the transaction hash
1046
+ * (`hashUnsignedTransaction(JSON.stringify(tx), sealPublicKey)`) so every signature in the
1047
+ * final envelope verifies against the SAME hash — the engine's seal verification enforces
1048
+ * this. Implementations MUST hash with the supplied `sealPublicKey`, not their own.
1049
+ */
1050
+ signTransaction(transaction: UnsignedTransactionV1, sealPublicKey: Uint8Array): Promise<TransactionSignature[]>;
1051
+ /**
1052
+ * Returns the view-only secret for stealth scanning/spending, if this signer holds one.
1053
+ *
1054
+ * **Optional** — a signer may not hold a view secret (e.g. `EphemeralKeySigner` has no
1055
+ * view key; `WalletDaemonSigner` keeps it server-side). The spend authorizer treats this
1056
+ * as a fallback: it takes the view secret explicitly from the transfer spec and only
1057
+ * calls this when the spec does not carry one.
1058
+ */
1059
+ getViewSecret?(): Promise<Uint8Array>;
1060
+ /**
1061
+ * Produces a one-time spend-key signature for a stealth input.
1062
+ *
1063
+ * The signer derives the one-time spend scalar (`c + k`) for the owned stealth UTXO via
1064
+ * `ctx.crypto.stealthDhSecret(...)` and signs the transaction hash with it.
1065
+ *
1066
+ * **Optional** — only signers that hold the owner secret (e.g. `SecretKeyWallet`) can
1067
+ * implement this. Daemon-delegated stealth is server-side and out of scope here.
1068
+ *
1069
+ * @param unsignedJson - The (compact) JSON of the unsigned transaction to hash + sign.
1070
+ * @param publicNonce - The stealth output's sender public nonce (the DH counterparty).
1071
+ * @param sealPublicKey - The seal signer's public key, mixed into the transaction hash
1072
+ * (mirrors the `hashUnsignedTransaction` arg used by {@link Signer.signTransaction}).
1073
+ * @param ctx - Injected crypto seam, so the signer never imports WASM directly.
1074
+ */
1075
+ addStealthSignature?(unsignedJson: string, publicNonce: Uint8Array, sealPublicKey: Uint8Array, ctx: {
1076
+ crypto: SignerStealthCrypto;
1077
+ }): Promise<TransactionSignature>;
1078
+ }
1079
+
1080
+ /** Raised when a {@link Signer} fails to sign, seal, or expose required material. */
1081
+ export declare class SignerError extends OotleError {
1082
+ }
1083
+
1084
+ /**
1085
+ * The exact subset of `StealthCryptoProvider` that {@link Signer.addStealthSignature} needs.
1086
+ *
1087
+ * Defined here alongside `Signer` so the stealth-agnostic core never depends on the stealth
1088
+ * module's full surface. The wider `StealthCryptoProvider` is structurally a supertype, so
1089
+ * `WasmStealthCrypto` and `FakeStealthCrypto` flow through as-is.
1090
+ */
1091
+ export declare interface SignerStealthCrypto {
1092
+ stealthDhSecret(networkByte: number, ownerSecret: Uint8Array, publicNonce: Uint8Array): Promise<Uint8Array>;
1093
+ }
1094
+
1095
+ /**
1096
+ * Collects signatures from all provided signers and assembles a signed transaction.
1097
+ *
1098
+ * Returns a {@link SignedTransaction} carrying the byte-exact `sealedJson` (the canonical
1099
+ * bytes {@link sealTransaction} BOR-encodes) plus a parsed `transaction` view for
1100
+ * inspection. The sealed JSON is **not** round-tripped through `JSON.parse`/`JSON.stringify`
1101
+ * on its way to the envelope, so u64 amounts above 2^53 (e.g. a confidential output's
1102
+ * `minimum_value_promise`) survive byte-exact.
1103
+ *
1104
+ * @param sealKeypair - Optional pre-generated seal keypair. When omitted, a fresh one is
1105
+ * generated internally (the default for the plain transaction flow). The stealth spend
1106
+ * authorizer passes one so the **same** seal public key flows into its one-time
1107
+ * spend-key authorizations (which hash the tx with the seal public key) and into this
1108
+ * final seal — otherwise those signatures would be over a different hash and fail to
1109
+ * verify.
1110
+ */
1111
+ export declare function signTransaction(signers: Signer[], unsignedTx: UnsignedTransactionV1, sealKeypair?: SealKeypair): Promise<SignedTransaction>;
1112
+
1113
+ /**
1114
+ * Carry a {@link StealthTransferStatement} into an instruction as a byte-exact raw JSON
1115
+ * fragment.
1116
+ *
1117
+ * The statement's u64 amounts are bare JSON numbers that routinely exceed 2^53; `JSON.parse`
1118
+ * would round them and break the signed proofs. We therefore embed the canonical
1119
+ * {@link StealthTransferStatement.toCompactJson} string verbatim under {@link RAW_JSON_FRAGMENT}
1120
+ * and let {@link serializeUnsignedTx} splice it into the serialized transaction at signing /
1121
+ * sealing / hashing time — never round-tripping it through a JS number. The engine still
1122
+ * deserialises `statement` as a struct (not a string); the splice produces exactly that.
1123
+ *
1124
+ * Nothing reads the statement object structurally after it is set (the serializers stringify
1125
+ * it wholesale and {@link patchStealthStatement} replaces the whole field), so the documented
1126
+ * cast to the binding's structured type is sound.
1127
+ */
1128
+ export declare function statementAsWire(statement: StealthTransferStatement): StealthTransferStatement_2;
1129
+
1130
+ /**
1131
+ * The single seam that hides all `@tari-project/ootle-wasm` crypto behind a
1132
+ * typed, byte/bigint interface returning the SDK's domain types.
1133
+ *
1134
+ * Every higher layer depends on **this interface**, never on raw WASM, so
1135
+ * tests can inject a {@link FakeStealthCrypto fake}. The only real
1136
+ * implementation is {@link WasmStealthCrypto}.
1137
+ *
1138
+ * All methods are **async even though the WASM is synchronous** to leave room
1139
+ * for a future off-thread / worker-backed provider without churning call sites.
1140
+ */
1141
+ export declare interface StealthCryptoProvider {
1142
+ /**
1143
+ * Build the outputs (sender) side of a transfer: one witness per spec, aggregated
1144
+ * into a canonical WASM outputs-statement plus the summed output mask.
1145
+ *
1146
+ * @param specs - The outputs to create (incl. change).
1147
+ * @param revealedOutputAmount - The un-confidential (revealed) µTari output amount.
1148
+ * @returns The WASM-produced {@link StealthOutputsStatement} and the aggregated
1149
+ * `outputMask` for the balance proof.
1150
+ */
1151
+ generateOutputsStatement(specs: Output[], revealedOutputAmount: bigint): Promise<{
1152
+ statement: StealthOutputsStatement;
1153
+ outputMask: Mask;
1154
+ }>;
1155
+ /**
1156
+ * Build the inputs (spend) side of a transfer as canonical WASM wire JSON.
1157
+ *
1158
+ * @param inputs - The stealth inputs being spent (empty for a revealed-only spend).
1159
+ * @param revealedAmount - The un-confidential (revealed) µTari input amount.
1160
+ * @returns A {@link StealthInputsStatement} carrying the WASM-produced `statementJson`.
1161
+ */
1162
+ buildInputsStatement(inputs: StealthInput[], revealedAmount: bigint): Promise<StealthInputsStatement>;
1163
+ /**
1164
+ * Sign the balance proof over the two statements' canonical wire JSONs.
1165
+ *
1166
+ * A transfer with **no stealth inputs** passes `inputMask = Mask.zero()`.
1167
+ *
1168
+ * @returns The `(public_nonce, signature)` balance-proof signature.
1169
+ */
1170
+ generateBalanceProofSignature(inputMask: Mask, outputMask: Mask, inputsStatementJson: string, outputsStatementJson: string): Promise<BalanceProofSignature>;
1171
+ /**
1172
+ * Optional client-side pre-flight check of a balance-proof signature. The
1173
+ * engine is authoritative at submission — implement as a cheap debug aid only.
1174
+ */
1175
+ validateBalanceProofSignature?(proof: BalanceProofSignature, inputsStatementJson: string, outputsStatementJson: string): Promise<boolean>;
1176
+ /**
1177
+ * Derive the 32-byte AEAD encryption key for an output's encrypted data via DH+KDF.
1178
+ *
1179
+ * - Receivers: `(viewSecret, sender_public_nonce)`.
1180
+ * - Senders: `(sender_secret_nonce, recipient_view_pub)`.
1181
+ *
1182
+ * Split from {@link unblindOutput} to mirror the WASM (`encryptedDataDhKdfAead` then
1183
+ * `unblindOutput`).
1184
+ */
1185
+ deriveAeadKey(privateKey: Uint8Array, publicKey: Uint8Array): Promise<Uint8Array>;
1186
+ /**
1187
+ * Decrypt an owned output using a precomputed AEAD key (from {@link deriveAeadKey}).
1188
+ *
1189
+ * **Throws** on AEAD failure / commitment mismatch — i.e. the output is *not owned*.
1190
+ * The receive helper catches this to mean "skip this UTXO".
1191
+ *
1192
+ * @param commitment - The output's 32-byte Pedersen commitment (from its substate id).
1193
+ * @param encryptedData - The raw ciphertext bytes.
1194
+ * @param aeadKey - The 32-byte AEAD key from {@link deriveAeadKey}.
1195
+ * @param skipMemo - When `true`, the memo is not decrypted.
1196
+ */
1197
+ unblindOutput(commitment: Uint8Array, encryptedData: Uint8Array, aeadKey: Uint8Array, skipMemo: boolean): Promise<DecryptedData>;
1198
+ /**
1199
+ * Aggregate input commitment masks into a single scalar. `masks` must be
1200
+ * non-empty; the revealed-only case (no stealth inputs) must short-circuit
1201
+ * to `Mask.zero()` at the caller instead of calling this method.
1202
+ */
1203
+ aggregateInputMasks(masks: Mask[]): Promise<Mask>;
1204
+ /**
1205
+ * Derive the one-time stealth spend scalar (`c + k`) via DH for an owned stealth UTXO.
1206
+ *
1207
+ * @param networkByte - The network byte (see `Network`).
1208
+ * @param ownerSecret - The owner's secret key.
1209
+ * @param publicNonce - The output's sender public nonce.
1210
+ * @returns The 32-byte spend scalar.
1211
+ */
1212
+ stealthDhSecret(networkByte: number, ownerSecret: Uint8Array, publicNonce: Uint8Array): Promise<Uint8Array>;
1213
+ /**
1214
+ * Structurally validate a complete transfer envelope (balance proof filled). **Throws**
1215
+ * on invalid. This is a client pre-flight (`view_key = null`); the engine is
1216
+ * authoritative for viewable-resource validation at submission.
1217
+ */
1218
+ validateTransfer(statement: StealthTransferStatement): Promise<void>;
1219
+ }
1220
+
1221
+ /**
1222
+ * A stealth input being spent, identified by its 32-byte Pedersen commitment.
1223
+ */
1224
+ export declare class StealthInput extends Bytes32 {
1225
+ constructor(commitment: Uint8Array);
1226
+ /** 32-byte commitment (defensive copy). */
1227
+ get commitment(): Uint8Array;
1228
+ toJSON(): StealthInputJson;
1229
+ static fromJSON(json: StealthInputJson): StealthInput;
1230
+ }
1231
+
1232
+ /** Wire shape of a {@link StealthInput}. */
1233
+ declare interface StealthInputJson {
1234
+ commitment: string;
1235
+ }
1236
+
1237
+ /**
1238
+ * The inputs side of a stealth transfer: the commitments being spent plus the
1239
+ * revealed (un-confidential) input amount.
1240
+ *
1241
+ * **The signed/wire JSON is produced by WASM**, not hand-rolled. This type
1242
+ * carries `(inputs, revealedAmount)` plus an optional cached `statementJson`
1243
+ * (the WASM-produced wire string). Its `toJSON()` is a **debug/structural**
1244
+ * view only — it is NOT the signed wire payload; the crypto seam fills and
1245
+ * reads `statementJson` for that.
1246
+ */
1247
+ export declare class StealthInputsStatement {
1248
+ readonly inputs: StealthInput[];
1249
+ readonly revealedAmount: bigint;
1250
+ /** Cached WASM-produced wire JSON (the canonical signed payload), once computed. */
1251
+ statementJson?: string;
1252
+ constructor(inputs: StealthInput[], revealedAmount: bigint, statementJson?: string);
1253
+ /** Revealed-only inputs statement (no confidential inputs). */
1254
+ static revealedOnly(amount: bigint): StealthInputsStatement;
1255
+ /**
1256
+ * Structural view (NOT the signed wire payload — see class docs). Amounts are
1257
+ * decimal strings to keep `bigint` out of JSON.
1258
+ */
1259
+ toJSON(): {
1260
+ inputs: StealthInputJson[];
1261
+ revealed_amount: string;
1262
+ };
1263
+ static fromJSON(json: {
1264
+ inputs: StealthInputJson[];
1265
+ revealed_amount: string;
1266
+ }): StealthInputsStatement;
1267
+ }
1268
+
1269
+ /**
1270
+ * The outputs side of a stealth transfer.
1271
+ *
1272
+ * Carries the **WASM-produced** wire payload verbatim. The internal field
1273
+ * names of that JSON are owned by the engine and are not modelled here.
1274
+ */
1275
+ export declare class StealthOutputsStatement {
1276
+ /** The canonical, WASM-produced outputs-statement wire JSON. */
1277
+ readonly statementJson: string;
1278
+ constructor(statementJson: string);
1279
+ /** Parse the carried JSON into a plain object view (the engine owns the shape). */
1280
+ parsed(): unknown;
1281
+ /** The carried wire JSON string is already canonical. */
1282
+ toJSON(): string;
1283
+ /** Reconstruct from a wire JSON string. */
1284
+ static fromJSON(statementJson: string): StealthOutputsStatement;
1285
+ }
1286
+
1287
+ /**
1288
+ * Fluent builder for a confidential (stealth) transfer.
1289
+ *
1290
+ * Supports the full input/output matrix: spend revealed input (withdraw from a vault)
1291
+ * and/or one or more confidential UTXOs ({@link spendStealthInput}), emit one or more
1292
+ * stealth outputs (+ optional revealed change), and a fee. The balance equation
1293
+ * (revealed-in + stealth-in == stealth-out + revealed-out) must hold; the stealth-input
1294
+ * value is carried by each input's mask, recovered by the authorizer.
1295
+ *
1296
+ * @example
1297
+ * ```ts
1298
+ * const spec = await new StealthTransfer(provider, resourceAddress)
1299
+ * .spendRevealedInput(account, 5n * TARI)
1300
+ * .toStealthOutput(createOutput({ destination, amount: 3n * TARI, resourceAddress }))
1301
+ * .toRevealedOutput(1n * TARI) // revealed change back to `account`
1302
+ * .payFeeFromRevealed(1n * TARI)
1303
+ * .prepare();
1304
+ * ```
1305
+ */
1306
+ export declare class StealthTransfer {
1307
+ private readonly provider;
1308
+ private readonly crypto;
1309
+ private builder;
1310
+ private readonly state;
1311
+ /** Guards against a second {@link prepare} re-emitting instructions into the same builder. */
1312
+ private prepared;
1313
+ /**
1314
+ * @param provider - Read-only chain access (used by {@link prepare} to resolve inputs).
1315
+ * @param resourceAddress - The resource being transferred.
1316
+ * @param crypto - Injectable crypto seam; defaults to {@link WasmStealthCrypto}. Tests
1317
+ * pass a {@link FakeStealthCrypto} for WASM-free runs.
1318
+ */
1319
+ constructor(provider: Provider, resourceAddress: ResourceAddress, crypto?: StealthCryptoProvider);
1320
+ /**
1321
+ * Withdraw `amount` of the transfer's resource from `account`'s revealed vault.
1322
+ *
1323
+ * All revealed input must come from a single account (the fee/change source). Calling
1324
+ * this more than once accumulates the amount but the account must be the same.
1325
+ *
1326
+ * @throws {InvalidArgumentError} if `amount` is not `> 0`, or a different source
1327
+ * account is supplied on a second call.
1328
+ */
1329
+ spendRevealedInput(account: ComponentAddress, amount: bigint): this;
1330
+ /** Add a stealth output to create (repeatable). */
1331
+ toStealthOutput(spec: Output): this;
1332
+ /**
1333
+ * Add revealed (un-confidential) change, returned to the revealed source account.
1334
+ *
1335
+ * @throws {InvalidArgumentError} if `amount` is not `> 0`.
1336
+ */
1337
+ toRevealedOutput(amount: bigint): this;
1338
+ /**
1339
+ * Pay the transaction fee from the revealed source account (max `amount`).
1340
+ *
1341
+ * @throws {InvalidArgumentError} if no source account is set, or `amount` is not `> 0`.
1342
+ */
1343
+ payFeeFromRevealed(amount: bigint): this;
1344
+ /** Escape hatch over the inner {@link TransactionBuilder} (e.g. extra instructions). */
1345
+ withBuilder(fn: (b: TransactionBuilder) => TransactionBuilder): this;
1346
+ /**
1347
+ * Spend a confidential UTXO owned by `ownerAddr`, identified by its 32-byte
1348
+ * `commitment`.
1349
+ *
1350
+ * Repeatable: each call adds another stealth input. Inputs are keyed by their
1351
+ * **commitment hex alone** and de-duplicated — a second call with the same commitment
1352
+ * throws, **regardless of the owner label**. A commitment uniquely identifies a UTXO
1353
+ * within the builder's single resource and a UTXO has exactly one owner, so the same
1354
+ * commitment under two different owner labels is still the same UTXO; accepting it twice
1355
+ * would register the substate id twice and emit the commitment twice in the inputs
1356
+ * statement — a self-double-spend the engine rejects. The owner address is recorded
1357
+ * alongside the input so the authorizer can pick the one-time spend signer for each.
1358
+ *
1359
+ * The input's value contributes to the balance equation via its **mask** (recovered by
1360
+ * the authorizer when it unblinds the UTXO), so the builder does not need the amount
1361
+ * here — only the commitment.
1362
+ *
1363
+ * @throws {InvalidArgumentError} if `commitment` is not 32 bytes, or the same
1364
+ * commitment is added twice (under any owner).
1365
+ */
1366
+ spendStealthInput(ownerAddr: string, commitment: Uint8Array): this;
1367
+ /**
1368
+ * Assemble the unsigned transaction and the (incomplete) transfer statement.
1369
+ *
1370
+ * 1. validate (≥1 input, ≥1 stealth output);
1371
+ * 2. generate the outputs statement (+ aggregated output mask) via the crypto seam;
1372
+ * 3. build the inputs statement (concatenated commitments + revealed input
1373
+ * amount) and assemble an incomplete {@link StealthTransferStatement}
1374
+ * (`balanceProof: undefined`);
1375
+ * 4. emit instructions: revealed `withdraw` → `saveVar` → the native
1376
+ * `StealthTransfer` instruction (+ deposit the revealed-change bucket);
1377
+ * 5. register the revealed source account + every vault it references as tx
1378
+ * inputs (otherwise the engine rejects `withdraw` / `pay_fee` with
1379
+ * `SubstateNotFound`);
1380
+ * 6. register each stealth input's UTXO substate id as a tx input so it is
1381
+ * resolved / locked alongside the revealed inputs;
1382
+ * 7. resolve substate versions via the provider;
1383
+ * 8. return the {@link StealthTransferSpec}.
1384
+ *
1385
+ * Stealth-input **values** are carried by their masks (recovered later by the
1386
+ * authorizer), not as amounts — there is no balance-equation check here when stealth
1387
+ * inputs are present, because the builder does not know their values; the balance proof
1388
+ * (which the authorizer signs over the recovered masks) is the authoritative check.
1389
+ *
1390
+ * @throws {InvalidArgumentError} if the builder is invalid (no inputs, no outputs,
1391
+ * no stealth output, unbalanced revealed-only transfer, or revealed change without
1392
+ * a revealed source) or `prepare` has already been called once.
1393
+ */
1394
+ prepare(): Promise<StealthTransferSpec>;
1395
+ /**
1396
+ * Build the ordered, de-duplicated list of addresses that must authorize the tx: the
1397
+ * revealed source account first (if any), then each distinct stealth-input owner in the
1398
+ * order it was first added.
1399
+ */
1400
+ private collectRequiredSigners;
1401
+ /**
1402
+ * Validate the builder before assembly: at least one input (revealed and/or stealth) and
1403
+ * at least one stealth output, plus — for the revealed-only path — the balance equation
1404
+ * `revealedInput.amount == stealthOut + revealedOut`.
1405
+ *
1406
+ * The fee is withdrawn separately by the fee instruction, not from the transferred
1407
+ * amount. When stealth inputs are present, the per-input values are unknown to the builder
1408
+ * (carried by masks), so the arithmetic check is **skipped** — the balance proof the
1409
+ * authorizer signs is authoritative. We still surface obvious wiring mistakes early.
1410
+ */
1411
+ private validate;
1412
+ /**
1413
+ * Emit the instruction sequence into the inner builder:
1414
+ * (revealed `withdraw` → `saveVar`)? → native `StealthTransfer` → deposit revealed change?
1415
+ *
1416
+ * The revealed `withdraw` and the `revealed_input_bucket` are emitted **only** when there
1417
+ * is a revealed input amount; a stealth-input-only transfer passes a `null` bucket. The
1418
+ * fee instruction (if any) was already added by {@link payFeeFromRevealed}.
1419
+ */
1420
+ private emitInstructions;
1421
+ }
1422
+
1423
+ /** The narrowed shape of the native `StealthTransfer` instruction variant. */
1424
+ export declare type StealthTransferInstruction = Extract<Instruction, {
1425
+ StealthTransfer: unknown;
1426
+ }>;
1427
+
1428
+ /**
1429
+ * Encode the native `StealthTransfer` instruction. See the file header for the on-chain
1430
+ * contract and the (probe-verified) statement-encoding rationale.
1431
+ *
1432
+ * The `revealed_input_bucket` references the saved withdraw bucket by name; the builder
1433
+ * declared that name via `saveVar`, so the {@link WorkspaceOffsetId} `{ id, offset: null }`
1434
+ * is resolved here against the same name → numeric id mapping the builder uses.
1435
+ *
1436
+ * @param init - The resource, revealed-input bucket name, and statement.
1437
+ * @param resolveBucket - Maps a workspace var name to its {@link WorkspaceOffsetId}. The
1438
+ * builder owns the name → id mapping; pass a resolver so this seam stays builder-agnostic.
1439
+ */
1440
+ export declare function stealthTransferInstruction(init: StealthTransferInstructionInit, resolveBucket: (name: string) => WorkspaceOffsetId): Instruction;
1441
+
1442
+ /** Inputs to {@link stealthTransferInstruction}. */
1443
+ export declare interface StealthTransferInstructionInit {
1444
+ /** The resource being transferred. */
1445
+ resourceAddress: ResourceAddress;
1446
+ /**
1447
+ * Workspace var name of the revealed-input bucket (from the `withdraw` + `saveVar`), or
1448
+ * `null`/omitted for a stealth-input-only transfer.
1449
+ */
1450
+ revealedInputBucket: string | null;
1451
+ /** The transfer statement (may be incomplete — `balanceProof` undefined — at build time). */
1452
+ statement: StealthTransferStatement;
1453
+ }
1454
+
1455
+ /**
1456
+ * The output of {@link StealthTransfer.prepare}: an unsigned transaction carrying the
1457
+ * on-chain stealth instruction and an **incomplete** statement (`balanceProof:
1458
+ * undefined`), plus the metadata the authorizer needs to finish it.
1459
+ */
1460
+ export declare interface StealthTransferSpec {
1461
+ /** The unsigned transaction with substate versions resolved. */
1462
+ unsignedTx: UnsignedTransactionV1;
1463
+ /** The (incomplete) transfer statement; the authorizer fills `balanceProof`. */
1464
+ statement: StealthTransferStatement;
1465
+ /** The aggregated output blinding mask, needed to sign the balance proof. */
1466
+ outputMask: Mask;
1467
+ /** The builder state (resource, inputs, amounts) — consumed by the authorizer. */
1468
+ state: StealthTransferState;
1469
+ /**
1470
+ * Addresses that must authorize the transaction. The revealed source account (when there
1471
+ * is revealed input) is required first, followed by each distinct stealth-input owner
1472
+ * (in first-seen order) — those owners supply the one-time spend-key authorizations.
1473
+ */
1474
+ requiredSigners: string[];
1475
+ /**
1476
+ * Ordered list of stealth inputs being spent, each paired with its owner address. Order
1477
+ * matches the order `spendStealthInput` was called — required for the input-mask
1478
+ * aggregation and inputs-statement build to agree on ordering.
1479
+ */
1480
+ inputs: Array<{
1481
+ input: StealthInput;
1482
+ owner: string;
1483
+ }>;
1484
+ }
1485
+
1486
+ /** Mutable internal state accumulated by a {@link StealthTransfer} builder. */
1487
+ export declare interface StealthTransferState {
1488
+ resource: ResourceAddress;
1489
+ /**
1490
+ * The revealed-source account and the total amount withdrawn from it, or `null` for a
1491
+ * stealth-input-only spend. Coupling the source and amount in one tagged field encodes the
1492
+ * invariant — a revealed input always has a source — in the type system, so consumers can
1493
+ * narrow without "unreachable" guards.
1494
+ */
1495
+ revealedInput: {
1496
+ source: ComponentAddress;
1497
+ amount: bigint;
1498
+ } | null;
1499
+ /**
1500
+ * Stealth UTXOs to spend, keyed by their **commitment hex alone** (insertion-ordered,
1501
+ * duplicates rejected). A commitment uniquely identifies a UTXO within the builder's
1502
+ * single resource, and a UTXO has exactly one owner — so keying by commitment (not
1503
+ * owner+commitment) prevents the same UTXO being registered twice under different owner
1504
+ * labels, which the engine would reject as a self-double-spend. Each value carries the
1505
+ * input alongside its owner address (the one-time spend signer). The `Map` preserves
1506
+ * insertion order so the masks aggregate and the inputs statement is built in the
1507
+ * **same** order — required for the balance proof to verify.
1508
+ */
1509
+ inputsToSpend: Map<string, {
1510
+ input: StealthInput;
1511
+ owner: string;
1512
+ }>;
1513
+ outputs: Output[];
1514
+ revealedOutputAmount: bigint;
1515
+ }
1516
+
1517
+ /**
1518
+ * The top-level stealth-transfer envelope assembled **in TS**.
1519
+ *
1520
+ * Combines the WASM-produced inputs/outputs statement JSONs with the balance-proof
1521
+ * `(public_nonce, signature)`. `balanceProof` is `undefined` until the authorizer
1522
+ * fills it in.
1523
+ *
1524
+ * Two distinct serialisations, intentionally separate:
1525
+ *
1526
+ * 1. **{@link toJSON} / {@link fromJSON}** — a purely *structural*, symmetric,
1527
+ * lossless round-trip used by tests and any TS-only persistence. It does NOT
1528
+ * re-parse WASM statement strings into JS numbers; the outputs side is carried as
1529
+ * its raw wire string.
1530
+ * 2. **{@link toCompactJson}** — the *signed wire form*. It embeds the
1531
+ * WASM-produced statement strings **byte-exact** by string concatenation of raw
1532
+ * canonical fragments — it **never** `JSON.parse`s a WASM string (raw u64 µTari
1533
+ * amounts routinely exceed 2^53, so parse→number→re-stringify silently corrupts
1534
+ * them and breaks the signature). This is the form fed to
1535
+ * `validateStealthTransfer` and any hashing/signing path.
1536
+ *
1537
+ * The **byte-exactness of the WASM fragments** in {@link toCompactJson} is
1538
+ * non-negotiable: the engine validates against the exact bytes signed.
1539
+ */
1540
+ export declare class StealthTransferStatement {
1541
+ readonly inputsStatement: StealthInputsStatement;
1542
+ readonly outputsStatement: StealthOutputsStatement;
1543
+ balanceProof?: BalanceProofSignature;
1544
+ constructor(inputsStatement: StealthInputsStatement, outputsStatement: StealthOutputsStatement, balanceProof?: BalanceProofSignature);
1545
+ /**
1546
+ * Structural view of the envelope (debug / lossless round-trip — NOT the signed
1547
+ * wire form; see {@link toCompactJson}). The inputs side is the inputs statement's
1548
+ * structural `toJSON()`; the outputs side is its **raw wire string**, carried
1549
+ * verbatim (never parsed). `balance_proof` is omitted when undefined.
1550
+ */
1551
+ toJSON(): StealthTransferStatementJson;
1552
+ /**
1553
+ * The **signed wire form**: a single canonical compact JSON string in which the
1554
+ * WASM-produced statement fragments are embedded byte-exact.
1555
+ *
1556
+ * Built by concatenating raw canonical fragments — it never `JSON.parse`s a WASM
1557
+ * statement string, so raw u64 µTari amounts (which can exceed 2^53) survive
1558
+ * uncorrupted. The inputs fragment prefers the cached WASM `statementJson` (the
1559
+ * canonical signed bytes); it falls back to `JSON.stringify` of the structural
1560
+ * inputs view only when no WASM string is present (the revealed-only / test case).
1561
+ * The outputs fragment is always the raw WASM `statementJson` string. The
1562
+ * balance-proof object is small, all-hex (no large integers), so it routes through
1563
+ * `JSON.stringify` safely.
1564
+ *
1565
+ * @throws {InvalidArgumentError} if either statement fragment is not a JSON object.
1566
+ */
1567
+ toCompactJson(): string;
1568
+ /** Reconstruct from the structural {@link toJSON} shape. Symmetric and lossless. */
1569
+ static fromJSON(json: StealthTransferStatementJson): StealthTransferStatement;
1570
+ }
1571
+
1572
+ /**
1573
+ * Structural wire shape of a {@link StealthTransferStatement} envelope.
1574
+ *
1575
+ * This is the **debug / round-trip** shape produced by `toJSON()` and consumed by
1576
+ * `fromJSON()` — it is symmetric and lossless for a TS-only envelope. It is **NOT**
1577
+ * the signed wire form: see {@link StealthTransferStatement.toCompactJson}.
1578
+ *
1579
+ * - `inputs` is the structural inputs-statement view (`{ inputs, revealed_amount }`).
1580
+ * - `outputs` is the **raw `StealthOutputsStatement` wire string** (carried verbatim),
1581
+ * never a parsed object — parsing-then-restringifying WASM u64 amounts is lossy.
1582
+ */
1583
+ declare interface StealthTransferStatementJson {
1584
+ inputs: {
1585
+ inputs: StealthInputJson[];
1586
+ revealed_amount: string;
1587
+ };
1588
+ outputs: string;
1589
+ balance_proof?: BalanceProofSignatureJson;
1590
+ }
1591
+
1592
+ /**
1593
+ * Compose a stealth UTXO substate id from a resource address and a 32-byte commitment.
1594
+ *
1595
+ * The id format is `utxo_{resourceHex}_{commitmentHex}`, where `resourceHex` is the
1596
+ * resource address with its `resource_` prefix stripped (a bare hex string is accepted
1597
+ * verbatim). This is the inverse of {@link commitmentOf} and matches the id the
1598
+ * `IndexerProvider.getStealthUtxo` fetch composes, so the spend builder can register a
1599
+ * stealth input as a tx input **without** reaching into the concrete indexer client.
1600
+ *
1601
+ * @param resourceAddress - The resource address (`resource_<hex>`) or a bare hex string.
1602
+ * @param commitment - The output's 32-byte Pedersen commitment.
1603
+ * @returns The `utxo_{resourceHex}_{commitmentHex}` substate id.
1604
+ */
1605
+ export declare function stealthUtxoSubstateId(resourceAddress: string, commitment: Uint8Array): string;
1606
+
1607
+ /** CBOR-encode a `String` as a CBOR text string. */
1608
+ export declare function stringLiteral(value: string): InstructionArg;
1609
+
1610
+ /**
1611
+ * Submits an encoded transaction envelope and returns the transaction ID.
1612
+ */
1613
+ export declare function submitTransaction(provider: Provider, envelope: TransactionEnvelope): Promise<string>;
1614
+
1615
+ export { SubstateId }
1616
+
1617
+ export { SubstateRequirement }
1618
+
1619
+ /**
1620
+ * Native TARI (XTR) token resource address (object key `[1u8; 32]`). Used for
1621
+ * all native-token transfers and stealth confidential outputs.
1622
+ */
1623
+ export declare const TARI_RESOURCE_ADDRESS = "resource_0101010101010101010101010101010101010101010101010101010101010101";
1624
+
1625
+ /** A function that can be called on a published template. */
1626
+ export declare interface TariFunctionDefinition {
1627
+ templateAddress: PublishedTemplateAddress;
1628
+ functionName: string;
1629
+ args?: NamedArg[];
1630
+ }
1631
+
1632
+ /** A method that can be called on a component. */
1633
+ export declare interface TariMethodDefinition {
1634
+ methodName: string;
1635
+ args?: NamedArg[];
1636
+ /** Call by component address. Mutually exclusive with `fromWorkspace`. */
1637
+ componentAddress?: ComponentAddress;
1638
+ /** Call the component stored under this workspace key. Mutually exclusive with `componentAddress`. */
1639
+ fromWorkspace?: string;
1640
+ }
1641
+
1642
+ /**
1643
+ * CBOR-encode a `PublishedTemplateAddress` as `Tag(137, bytes(32))`. Accepts
1644
+ * either the `template_<hex>` form or the bare 64-hex-char tail.
1645
+ *
1646
+ * @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
1647
+ */
1648
+ export declare function templateAddressLiteral(address: PublishedTemplateAddress): InstructionArg;
1649
+
1650
+ /**
1651
+ * Implemented by types that can produce a component address string.
1652
+ * Mirrors the `ToAccountAddress` trait from ootle-rs.
1653
+ */
1654
+ export declare interface ToAccountAddress {
1655
+ toAccountAddress(): string;
1656
+ }
1657
+
1658
+ export declare function toHexStr(uint8: Uint8Array): string;
1659
+
1660
+ export { Transaction }
1661
+
1662
+ /**
1663
+ * The result of authorizing a transaction: a set of signatures from one signer.
1664
+ * Mirrors `TransactionAuthorization` from the Rust ootle-rs crate.
1665
+ */
1666
+ export declare interface TransactionAuthorization {
1667
+ signerAddress: string;
1668
+ signatures: TransactionSignature[];
1669
+ }
1670
+
1671
+ /**
1672
+ * Fluent builder for constructing UnsignedTransactionV1 objects.
1673
+ *
1674
+ * Only `buildUnsignedTransaction()` is exposed — signing is handled separately
1675
+ * via the `Signer` interface and `signTransaction` flow function.
1676
+ */
1677
+ export declare class TransactionBuilder {
1678
+ private unsignedTransaction;
1679
+ private allocatedIds;
1680
+ private currentId;
1681
+ constructor(network: Network | number);
1682
+ static new(network: Network | number): TransactionBuilder;
1683
+ callFunction<T extends TariFunctionDefinition>(func: T, args: Exclude<T["args"], undefined>): this;
1684
+ /**
1685
+ * @throws {InvalidArgumentError} if `method` provides neither `componentAddress`
1686
+ * nor `fromWorkspace`, or if `fromWorkspace` references an undefined variable.
1687
+ */
1688
+ callMethod<T extends TariMethodDefinition>(method: T, args: Exclude<T["args"], undefined>): this;
1689
+ createAccount(ownerPublicKey: string, workspaceBucket?: string): this;
1690
+ createProof(account: ComponentAddress, resourceAddress: ResourceAddress): this;
1691
+ claimBurn(claim: MinotariBurnClaimProof, output_data: ClaimBurnOutputData): this;
1692
+ allocateAddress(allocatableType: AllocatableAddressType, workspaceIdName: string): this;
1693
+ /**
1694
+ * Saves the last instruction output to a named workspace variable.
1695
+ * The variable can be referenced by subsequent instructions using `{ Workspace: "name" }`.
1696
+ */
1697
+ saveVar(name: string): this;
1698
+ /**
1699
+ * Adds a fee instruction that calls `pay_fee` on the given component.
1700
+ * The component must call `vault.pay_fee` and reveal enough confidential XTR.
1701
+ */
1702
+ feeTransactionPayFromComponent(componentAddress: ComponentAddress, maxFee: bigint): this;
1703
+ /**
1704
+ * NOT IMPLEMENTED — always throws. A confidential `pay_fee` needs a
1705
+ * `ConfidentialWithdrawProof` `Literal` that requires `tari_bor` struct encoding
1706
+ * the TS SDK does not yet provide. Use {@link feeTransactionPayFromComponent} for
1707
+ * revealed-fee payment.
1708
+ *
1709
+ * @throws {InvalidArgumentError} always.
1710
+ */
1711
+ feeTransactionPayFromComponentConfidential(_componentAddress: ComponentAddress, _proof: ConfidentialWithdrawProof): this;
1712
+ dropAllProofsInWorkspace(): this;
1713
+ /**
1714
+ * Publishes a compiled WASM template. The binary is stored as a transaction
1715
+ * blob and referenced by index from the `PublishTemplate` instruction.
1716
+ *
1717
+ * @param binaryBase64 the template WASM, standard-base64 encoded
1718
+ * @param metadataHash optional multihash of off-chain CBOR metadata
1719
+ */
1720
+ publishTemplate(binaryBase64: string, metadataHash?: string | null): this;
1721
+ addInstruction(instruction: Instruction): this;
1722
+ addFeeInstruction(instruction: Instruction): this;
1723
+ withInstructions(instructions: Instruction[]): this;
1724
+ withFeeInstructions(instructions: Instruction[]): this;
1725
+ withFeeInstructionsBuilder(builder: (b: TransactionBuilder) => TransactionBuilder): this;
1726
+ addInput(input: SubstateRequirement): this;
1727
+ withInputs(inputs: SubstateRequirement[]): this;
1728
+ withMinEpoch(minEpoch: number): this;
1729
+ withMaxEpoch(maxEpoch: number): this;
1730
+ withUnsignedTransaction(unsignedTransaction: UnsignedTransactionV1): this;
1731
+ /**
1732
+ * Resolves a workspace variable name (supporting dot-notation offsets, e.g. `"bucket.0"`)
1733
+ * to its `WorkspaceOffsetId`. The variable must have been declared by a prior `saveVar`
1734
+ * (or other allocating call). Use this when constructing an `Instruction` that takes a
1735
+ * `WorkspaceOffsetId` directly (e.g. the native `StealthTransfer` variant's
1736
+ * `revealed_input_bucket`), where the builder's automatic `{ Workspace: "name" }` arg
1737
+ * resolution does not apply.
1738
+ *
1739
+ * @throws {InvalidArgumentError} if no workspace variable with that name has been defined.
1740
+ */
1741
+ resolveWorkspaceOffsetId(name: string): WorkspaceOffsetId;
1742
+ buildUnsignedTransaction(): UnsignedTransactionWithBlobs;
1743
+ private addNamedId;
1744
+ private requireNamedId;
1745
+ private getOffsetIdFromWorkspaceName;
1746
+ private resolveArgs;
1747
+ }
1748
+
1749
+ export { TransactionEnvelope }
1750
+
1751
+ /**
1752
+ * The classified result of a finalized transaction.
1753
+ *
1754
+ * - `"Commit"` — all instructions committed successfully.
1755
+ * - `"FeeIntentCommit"` — fee instructions committed but execution was aborted
1756
+ * (the network accepted the fee intent but rejected the rest).
1757
+ * - `"Reject"` — the entire transaction was rejected.
1758
+ */
1759
+ export declare interface TransactionOutcome {
1760
+ outcome: FinalizeOutcome | "Reject";
1761
+ reason?: string;
1762
+ }
1763
+
1764
+ /**
1765
+ * Raised when consensus rejects a transaction.
1766
+ *
1767
+ * `txId` is the rejected transaction's identifier; `reason` is the human-readable
1768
+ * reason (the indexer's `abort_details` string or a `JSON.stringify` of the abort
1769
+ * variant when no string was supplied). `rejectReason` is the structured engine
1770
+ * reject reason if available — currently optional because the indexer's
1771
+ * `Decision.Abort` carries the lighter `AbortReason` shape, not the full
1772
+ * `RejectReason`. Callers should branch on `reason` (string) for most cases.
1773
+ */
1774
+ export declare class TransactionRejectedError extends OotleError {
1775
+ readonly txId: string;
1776
+ readonly reason: string;
1777
+ readonly rejectReason?: RejectReason;
1778
+ constructor(message: string, options: ErrorOptions & {
1779
+ txId: string;
1780
+ reason: string;
1781
+ rejectReason?: RejectReason;
1782
+ });
1783
+ }
1784
+
1785
+ export { TransactionSignature }
1786
+
1787
+ /** Raised when polling / SSE both timed out before the transaction finalized. */
1788
+ export declare class TransactionTimeoutError extends OotleError {
1789
+ readonly txId: string;
1790
+ constructor(message: string, options: ErrorOptions & {
1791
+ txId: string;
1792
+ });
1793
+ }
1794
+
1795
+ export { TransactionV1 }
1796
+
1797
+ export { UnsealedTransactionV1 }
1798
+
1799
+ export { UnsignedTransactionV1 }
1800
+
1801
+ /**
1802
+ * `UnsignedTransactionV1` with the `blobs` list: standard-base64 payloads
1803
+ * referenced from instructions by index (see {@link TransactionBuilder.publishTemplate}).
1804
+ */
1805
+ export declare type UnsignedTransactionWithBlobs = UnsignedTransactionV1 & {
1806
+ blobs: string[];
1807
+ };
1808
+
1809
+ /**
1810
+ * CBOR-encode a `UtxoAddress` as `Tag(141, [ResourceAddress, UtxoId])`, where the
1811
+ * `UtxoId` is the 32-byte commitment byte string.
1812
+ *
1813
+ * @throws {InvalidArgumentError} if the resource address or id is not 32 bytes.
1814
+ */
1815
+ export declare function utxoAddressLiteral(address: UtxoAddress): InstructionArg;
1816
+
1817
+ /**
1818
+ * CBOR-encode a `ValidatorFeePoolAddress` as `Tag(138, bytes(32))`. Accepts
1819
+ * either the `vnfp_<hex>` form or the bare 64-hex-char tail.
1820
+ *
1821
+ * @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
1822
+ */
1823
+ export declare function validatorFeePoolAddressLiteral(address: ValidatorFeePoolAddress): InstructionArg;
1824
+
1825
+ /**
1826
+ * CBOR-encode a `VaultId` as `Tag(132, bytes(32))`. Accepts either the
1827
+ * `vault_<hex>` form or the bare 64-hex-char tail.
1828
+ *
1829
+ * @throws {InvalidArgumentError} if the address body is not 32 bytes (64 hex chars).
1830
+ */
1831
+ export declare function vaultIdLiteral(address: VaultId): InstructionArg;
1832
+
1833
+ /** Base class for errors raised by {@link OotleWallet} operations. */
1834
+ export declare class WalletError extends OotleError {
1835
+ }
1836
+
1837
+ /**
1838
+ * Authorizes a {@link StealthTransferSpec} produced by {@link StealthTransfer}: unblinds any
1839
+ * stealth inputs, signs the balance proof, hydrates + patches the statement, then returns an
1840
+ * {@link AuthorizedTransfer} that produces one-time spend-key authorizations and seals the
1841
+ * envelope. Handles both the revealed-only path and the full stealth-input spend path.
1842
+ */
1843
+ export declare class WalletStealthAuthorizer {
1844
+ private readonly wallet;
1845
+ private readonly spec;
1846
+ private readonly crypto;
1847
+ private readonly mustSignWithAccountKey;
1848
+ private readonly viewSecret?;
1849
+ private constructor();
1850
+ /**
1851
+ * Build an authorizer from a builder spec.
1852
+ *
1853
+ * @param wallet - The multi-signer wallet (supplies the account-key + one-time signatures).
1854
+ * @param spec - The spec from {@link StealthTransfer.prepare}.
1855
+ * @param options - Optional `viewSecret`, account-signature toggle, crypto seam.
1856
+ */
1857
+ static fromSpec(wallet: OotleWallet, spec: StealthTransferSpec, options?: WalletStealthAuthorizerOptions): WalletStealthAuthorizer;
1858
+ /**
1859
+ * Hydrate + sign the transfer:
1860
+ * 1. resolve each stealth input — fetch its UTXO, unblind it to recover the mask, and
1861
+ * remember the sender public nonce (revealed-only → no inputs, no fetch);
1862
+ * 2. aggregate the input masks (`Mask.zero()` when there are no stealth inputs);
1863
+ * 3. sign the balance proof over the (already-canonical) inputs/outputs statement JSONs;
1864
+ * 4. build the complete (hydrated) statement and pre-flight `validateTransfer`;
1865
+ * 5. patch the unsigned tx's sole stealth instruction with the hydrated statement.
1866
+ *
1867
+ * Returns an {@link AuthorizedTransfer} that owns the hydrated state and can produce
1868
+ * one-time spend-key authorizations or seal the envelope. The authorizer is not mutated.
1869
+ *
1870
+ * @param provider - Read-only chain access (fetches the input UTXOs).
1871
+ */
1872
+ prepare(provider: Provider): Promise<AuthorizedTransfer>;
1873
+ /**
1874
+ * Resolve the view secret used to unblind stealth inputs: prefer the explicit one passed
1875
+ * to {@link fromSpec}; else fall back to the wallet's default signer `getViewSecret?.()`.
1876
+ *
1877
+ * @throws {WalletError} a clear, actionable error when neither is available **and**
1878
+ * there are stealth inputs to unblind (the revealed-only path never needs it).
1879
+ */
1880
+ private resolveViewSecret;
1881
+ /** The wallet's default signer address, or `""` if none is set (so view-secret resolution fails clearly). */
1882
+ private safeDefaultAddress;
1883
+ /**
1884
+ * Fetch + unblind each stealth input, in `spec.inputs` order.
1885
+ *
1886
+ * For each input: `getStealthUtxo` → `parseSubstateUtxo` (commitment + body) →
1887
+ * `decryptInputData(..., { senderPublicNonce, viewSecret, skipMemo: true })` to recover
1888
+ * the mask. The sender public nonce is read from the **fetched UTXO body**, not the spec
1889
+ * (the spec only carries the commitment), and kept for one-time signing.
1890
+ *
1891
+ * `skipMemo: true` — spending only needs the mask + value, not the memo (vs the
1892
+ * receive-side `decryptOwnedUtxo`, which decrypts the memo).
1893
+ */
1894
+ private resolveStealthInputs;
1895
+ }
1896
+
1897
+ /** Options for {@link WalletStealthAuthorizer.fromSpec}. */
1898
+ export declare interface WalletStealthAuthorizerOptions {
1899
+ /**
1900
+ * The owner/recipient 32-byte view secret, needed to unblind stealth inputs. **Optional**:
1901
+ * the revealed-only path never uses it; for stealth-input transfers it is taken here first,
1902
+ * else falls back to the wallet's default signer `getViewSecret?.()` (only `SecretKeyWallet`
1903
+ * supplies one). If neither is available and there are stealth inputs, `prepare` throws.
1904
+ */
1905
+ viewSecret?: Uint8Array;
1906
+ /**
1907
+ * Whether to append the account-key Schnorr signature when sealing. Defaults to `true`.
1908
+ * Set `false` to omit it (e.g. the account already authorized out-of-band).
1909
+ */
1910
+ mustSignWithAccountKey?: boolean;
1911
+ /**
1912
+ * Injectable crypto seam; defaults to {@link WasmStealthCrypto}. Tests pass a
1913
+ * {@link FakeStealthCrypto}.
1914
+ */
1915
+ crypto?: StealthCryptoProvider;
1916
+ }
1917
+
1918
+ /**
1919
+ * The real `StealthCryptoProvider`, backed by `@tari-project/ootle-wasm@0.32.0`.
1920
+ *
1921
+ * Marshals between the step-02 domain types (`Mask`, `Output`, statements) and the raw
1922
+ * WASM ABI (snake_case result fields, positional args, raw `Uint8Array`s/`bigint`s).
1923
+ * Async signatures wrap synchronous WASM calls — see {@link StealthCryptoProvider}.
1924
+ */
1925
+ export declare class WasmStealthCrypto implements StealthCryptoProvider {
1926
+ /**
1927
+ * The network byte fed to the WASM output-witness and DH calls. Defaults to
1928
+ * {@link Network.LocalNet}; pass the target network for non-local transfers.
1929
+ */
1930
+ private readonly network;
1931
+ constructor(network?: Network);
1932
+ generateOutputsStatement(specs: Output[], revealedOutputAmount: bigint): Promise<{
1933
+ statement: StealthOutputsStatement;
1934
+ outputMask: Mask;
1935
+ }>;
1936
+ /** Build a single output witness JSON via WASM, mapping an {@link Output} spec. */
1937
+ private outputWitness;
1938
+ buildInputsStatement(inputs: StealthInput[], revealedAmount: bigint): Promise<StealthInputsStatement>;
1939
+ generateBalanceProofSignature(inputMask: Mask, outputMask: Mask, inputsStatementJson: string, outputsStatementJson: string): Promise<BalanceProofSignature>;
1940
+ validateBalanceProofSignature(proof: BalanceProofSignature, inputsStatementJson: string, outputsStatementJson: string): Promise<boolean>;
1941
+ deriveAeadKey(privateKey: Uint8Array, publicKey: Uint8Array): Promise<Uint8Array>;
1942
+ unblindOutput(commitment: Uint8Array, encryptedData: Uint8Array, aeadKey: Uint8Array, skipMemo: boolean): Promise<DecryptedData>;
1943
+ aggregateInputMasks(masks: Mask[]): Promise<Mask>;
1944
+ stealthDhSecret(networkByte: number, ownerSecret: Uint8Array, publicNonce: Uint8Array): Promise<Uint8Array>;
1945
+ validateTransfer(statement: StealthTransferStatement): Promise<void>;
1946
+ }
1947
+
1948
+ export declare interface WatchOptions {
1949
+ /** How often to poll for the transaction result, in milliseconds. Defaults to 500ms. */
1950
+ pollIntervalMs?: number;
1951
+ /** Maximum time to wait before throwing a timeout error, in milliseconds. Defaults to 60000ms. */
1952
+ timeoutMs?: number;
1953
+ }
1954
+
1955
+ /**
1956
+ * Polls the provider until a transaction reaches a finalized state, then returns the result.
1957
+ *
1958
+ * Throws for `Reject` outcomes. `FeeIntentCommit` (fees paid, execution aborted) also
1959
+ * throws with a distinct message so callers can distinguish it from a full rejection.
1960
+ * Use `classifyOutcome` on the raw result for non-throwing outcome inspection.
1961
+ *
1962
+ * @throws {TransactionRejectedError} when consensus rejects the transaction, or commits
1963
+ * only the fee intent (execution aborted). The error's `.txId` and `.reason` carry the
1964
+ * structured fields; the message remains the human-readable summary.
1965
+ * @throws {TransactionTimeoutError} when the transaction did not finalize within
1966
+ * `timeoutMs`. The error's `.txId` identifies the polled transaction.
1967
+ */
1968
+ export declare function watchTransaction(provider: Provider, txId: string, opts?: WatchOptions): Promise<IndexerGetTransactionResultResponse>;
1969
+
1970
+ /** Claim resource held by the XTR faucet (object key `[1, 2, 3, 0, …, 0, 2]`). */
1971
+ export declare const XTR_FAUCET_CLAIM_RESOURCE_ADDRESS = "resource_0102030000000000000000000000000000000000000000000000000000000002";
1972
+
1973
+ /**
1974
+ * On-chain XTR faucet component address (object key `[1, 2, 3, 0, …, 0]`).
1975
+ * LocalNet scripts call this via `FaucetInvokeBuilder` to claim revealed TARI funds.
1976
+ */
1977
+ export declare const XTR_FAUCET_COMPONENT_ADDRESS = "component_0102030000000000000000000000000000000000000000000000000000000000";
1978
+
1979
+ /** Vault held by the XTR faucet (object key `[1, 2, 3, 0, …, 0, 1]`). */
1980
+ export declare const XTR_FAUCET_VAULT_ADDRESS = "vault_0102030000000000000000000000000000000000000000000000000000000001";
1981
+
1982
+ export { }