@chironbuilder/ootle-sdk 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -17,8 +17,10 @@ export { OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH, buildOwnershipProofMessage, build
17
17
  export type { EncryptedVault } from "./vault.js";
18
18
  export { decryptVault, encryptVault, fromHex, toHex } from "./vault.js";
19
19
  export { withTimeout } from "./timeout.js";
20
- export type { CommitmentReservation, HtlcJournalEntry, HtlcJournalStatus, KeyValueStore, PendingShield, ShieldedOutputRecord } from "./storage.js";
21
- export { addPendingShield, addShieldedOutput, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
20
+ export type { CommitmentReservation, HtlcJournalEntry, HtlcJournalStatus, KeyValueStore, PendingShield, PrivatePaymentScanResume, ShieldedOutputRecord } from "./storage.js";
21
+ export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
22
+ export type { UtxosDeltaResult, UtxosPageResult, UtxoScanWatermark } from "./utxoScan.js";
23
+ export { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
22
24
  export { chromeStorageAdapter, inMemoryAdapter, localStorageAdapter } from "./adapters.js";
23
25
  export type { FeeType, HtlcClaimOptions, HtlcFundOptions, HtlcFundResult, HtlcSpendResult, PrivateBalance, TokenBalance } from "./wallet.js";
24
26
  export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAEjI,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAEhG,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEhI,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;A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CAAC;AAE3F,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7I,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,uBAAuB,EACvB,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ export { toOotleNetwork } from "./ootleNetwork.js";
11
11
  export { OWNERSHIP_PROOF_CHALLENGE_MAX_LENGTH, buildOwnershipProofMessage, buildWalletOwnershipMessage } from "./ownershipProof.js";
12
12
  export { decryptVault, encryptVault, fromHex, toHex } from "./vault.js";
13
13
  export { withTimeout } from "./timeout.js";
14
- export { addPendingShield, addShieldedOutput, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
14
+ export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
15
+ export { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
15
16
  export { chromeStorageAdapter, inMemoryAdapter, localStorageAdapter } from "./adapters.js";
16
17
  export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
package/dist/storage.d.ts CHANGED
@@ -103,6 +103,16 @@ export interface CommitmentReservation {
103
103
  * UTXO forever). */
104
104
  expiresAt: number;
105
105
  }
106
+ /** Where an unfinished private-payment catch-up left off, so the next scan continues backward from
107
+ * there instead of restarting at the newest transaction and never reaching the older part of a long gap. */
108
+ export interface PrivatePaymentScanResume {
109
+ /** Newest transaction id when the catch-up began; becomes the cursor once it completes. */
110
+ newest: string;
111
+ /** The last transaction id of the last page scanned -- the next page starts after it. */
112
+ lastId: string;
113
+ /** A not-yet-finalized transaction was seen, so the cursor must not advance when this completes. */
114
+ pending: boolean;
115
+ }
106
116
  export declare function localAccountId(index: number): string;
107
117
  /** Runs a whole read-modify-write cycle to completion before the next one starts, so two
108
118
  * concurrent callers (two tabs, a page request racing a popup request) can't interleave their
@@ -123,6 +133,9 @@ export declare function addPendingShield(pending: PendingShield): Promise<void>;
123
133
  export declare function removePendingShield(transactionId: string): Promise<void>;
124
134
  export declare function getPrivatePaymentScanCursor(accountId: string): Promise<string | null>;
125
135
  export declare function setPrivatePaymentScanCursor(accountId: string, transactionId: string): Promise<void>;
136
+ export declare function getPrivatePaymentScanResume(accountId: string): Promise<PrivatePaymentScanResume | null>;
137
+ /** Saves where a partial catch-up stopped, or clears it with `null`. */
138
+ export declare function setPrivatePaymentScanResume(accountId: string, resume: PrivatePaymentScanResume | null): Promise<void>;
126
139
  /** Substate version cache -- see `wallet.ts`'s own doc comment on `knownVersionsPromise` for why
127
140
  * this exists at all. */
128
141
  export declare function getKnownVersions(): Promise<Record<string, number>>;
@@ -151,6 +164,15 @@ export declare class CommitmentReservedError extends Error {
151
164
  readonly commitments: string[];
152
165
  constructor(commitments: string[]);
153
166
  }
167
+ /** Returns the shard watermarks last saved for `accountId` + `resourceAddress`, or `[]` if
168
+ * this resource has never been scanned (which signals the indexer to replay everything). */
169
+ export declare function getUtxoScanWatermarks(accountId: string, resourceAddress: string): Promise<Array<[number, number | string | bigint]>>;
170
+ export declare function setUtxoScanWatermarks(accountId: string, resourceAddress: string, watermarks: Array<[number, number | string | bigint]>): Promise<void>;
171
+ /** Returns the last UtxoId (commitment hex) seen during a paginated full scan, or `null` if
172
+ * no full scan is in progress for this resource. */
173
+ export declare function getUtxoScanPageCursor(accountId: string, resourceAddress: string): Promise<string | null>;
174
+ export declare function setUtxoScanPageCursor(accountId: string, resourceAddress: string, cursor: string): Promise<void>;
175
+ export declare function clearUtxoScanPageCursor(accountId: string, resourceAddress: string): Promise<void>;
154
176
  /** Clears every key this module owns -- call this from a host's own "erase wallet" flow. Does not
155
177
  * touch anything else the host's `KeyValueStore` might hold (address books, settings, ...); this
156
178
  * SDK never wrote those keys, so it isn't this function's place to remove them. */
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAID;0EAC0E;AAC1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAE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E,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrH;AAED,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvG;AAED;;mFAEmF;AACnF,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD"}
package/dist/storage.js CHANGED
@@ -27,9 +27,12 @@ const DEFAULTS = {
27
27
  shieldedOutputs: [],
28
28
  pendingShields: [],
29
29
  privatePaymentScanCursors: {},
30
+ privatePaymentScanResumes: {},
30
31
  knownVersions: {},
31
32
  htlcJournal: [],
32
33
  reservations: [],
34
+ utxoScanWatermarks: {},
35
+ utxoScanPageCursors: {},
33
36
  };
34
37
  export function localAccountId(index) {
35
38
  return `local:${index}`;
@@ -125,6 +128,17 @@ export async function setPrivatePaymentScanCursor(accountId, transactionId) {
125
128
  await write({ privatePaymentScanCursors: { ...state.privatePaymentScanCursors, [accountId]: transactionId } });
126
129
  });
127
130
  }
131
+ export async function getPrivatePaymentScanResume(accountId) {
132
+ return (await read()).privatePaymentScanResumes[accountId] ?? null;
133
+ }
134
+ /** Saves where a partial catch-up stopped, or clears it with `null`. */
135
+ export async function setPrivatePaymentScanResume(accountId, resume) {
136
+ await serialized(async () => {
137
+ const state = await read();
138
+ const { [accountId]: _dropped, ...rest } = state.privatePaymentScanResumes;
139
+ await write({ privatePaymentScanResumes: resume ? { ...rest, [accountId]: resume } : rest });
140
+ });
141
+ }
128
142
  /** Substate version cache -- see `wallet.ts`'s own doc comment on `knownVersionsPromise` for why
129
143
  * this exists at all. */
130
144
  export async function getKnownVersions() {
@@ -212,6 +226,39 @@ export class CommitmentReservedError extends Error {
212
226
  this.name = "CommitmentReservedError";
213
227
  }
214
228
  }
229
+ // ── UTXO set scan checkpoints ────────────────────────────────────────────────────────────────────
230
+ function utxoKey(accountId, resourceAddress) {
231
+ return `${accountId}:${resourceAddress}`;
232
+ }
233
+ /** Returns the shard watermarks last saved for `accountId` + `resourceAddress`, or `[]` if
234
+ * this resource has never been scanned (which signals the indexer to replay everything). */
235
+ export async function getUtxoScanWatermarks(accountId, resourceAddress) {
236
+ return (await read()).utxoScanWatermarks[utxoKey(accountId, resourceAddress)] ?? [];
237
+ }
238
+ export async function setUtxoScanWatermarks(accountId, resourceAddress, watermarks) {
239
+ await serialized(async () => {
240
+ const state = await read();
241
+ await write({ utxoScanWatermarks: { ...state.utxoScanWatermarks, [utxoKey(accountId, resourceAddress)]: watermarks } });
242
+ });
243
+ }
244
+ /** Returns the last UtxoId (commitment hex) seen during a paginated full scan, or `null` if
245
+ * no full scan is in progress for this resource. */
246
+ export async function getUtxoScanPageCursor(accountId, resourceAddress) {
247
+ return (await read()).utxoScanPageCursors[utxoKey(accountId, resourceAddress)] ?? null;
248
+ }
249
+ export async function setUtxoScanPageCursor(accountId, resourceAddress, cursor) {
250
+ await serialized(async () => {
251
+ const state = await read();
252
+ await write({ utxoScanPageCursors: { ...state.utxoScanPageCursors, [utxoKey(accountId, resourceAddress)]: cursor } });
253
+ });
254
+ }
255
+ export async function clearUtxoScanPageCursor(accountId, resourceAddress) {
256
+ await serialized(async () => {
257
+ const state = await read();
258
+ const { [utxoKey(accountId, resourceAddress)]: _dropped, ...rest } = state.utxoScanPageCursors;
259
+ await write({ utxoScanPageCursors: rest });
260
+ });
261
+ }
215
262
  /** Clears every key this module owns -- call this from a host's own "erase wallet" flow. Does not
216
263
  * touch anything else the host's `KeyValueStore` might hold (address books, settings, ...); this
217
264
  * SDK never wrote those keys, so it isn't this function's place to remove them. */
@@ -0,0 +1,68 @@
1
+ import { type StealthCryptoProvider } from "@tari-project/ootle";
2
+ import type { Shard, StateVersion } from "@tari-project/ootle-ts-bindings";
3
+ import type { ScannedStealthOutput } from "./confidential.js";
4
+ /** Checkpoint for one resource's delta scan: a `[Shard, StateVersion]` pair per shard read so far.
5
+ * Serialize as JSON; pass back verbatim as `shard_state_versions` on the next call. */
6
+ export type UtxoScanWatermark = Array<[Shard, StateVersion]>;
7
+ /** Result of a delta scan (`scanUtxosDelta`). */
8
+ export interface UtxosDeltaResult {
9
+ /** Outputs we decrypted as ours. Pass each to `addShieldedOutput`. */
10
+ owned: ScannedStealthOutput[];
11
+ /** Commitments whose outputs were spent or burnt on-chain since the last scan.
12
+ * Pass each to `markShieldedOutputSpent`. */
13
+ spentCommitments: string[];
14
+ /** Persist these with `setUtxoScanWatermarks` and pass on the next call. */
15
+ watermarks: UtxoScanWatermark;
16
+ /** True if at least one shard still has rows above the new watermark.
17
+ * Call `scanUtxosDelta` again (with the returned `watermarks`) until this is false. */
18
+ hasMore: boolean;
19
+ }
20
+ /** Result of one page of a full paginated scan (`scanUtxosPage`). */
21
+ export interface UtxosPageResult {
22
+ /** Outputs we decrypted as ours. Pass each to `addShieldedOutput`. */
23
+ owned: ScannedStealthOutput[];
24
+ /** Cursor for the next page. Save it with `setUtxoScanPageCursor` and pass as `fromId` on
25
+ * the next call. `null` means this was the last page. */
26
+ nextCursor: string | null;
27
+ }
28
+ /**
29
+ * Fetches all UTXO updates (new outputs + spends) since the given watermarks from the indexer's
30
+ * streaming endpoint, then decrypts any `Unspent` candidates with the account's view key.
31
+ *
32
+ * Pass `watermarks: []` (or the saved value from storage) on every call. The very first call
33
+ * with an empty watermarks array replays everything the indexer has retained, so it doubles as the
34
+ * initial full scan. Subsequent calls with the returned watermarks fetch only the delta.
35
+ *
36
+ * Call in a loop until `result.hasMore` is false:
37
+ * ```ts
38
+ * let wm = await getUtxoScanWatermarks(accountId, resourceAddress);
39
+ * do {
40
+ * const r = await scanUtxosDelta(indexerUrl, resourceAddress, crypto, viewSecret, wm, 200);
41
+ * for (const o of r.owned) await addShieldedOutput({ ...o, accountId, ... });
42
+ * for (const c of r.spentCommitments) await markShieldedOutputSpent(accountId, c);
43
+ * wm = r.watermarks;
44
+ * await setUtxoScanWatermarks(accountId, resourceAddress, wm);
45
+ * } while (r.hasMore);
46
+ * ```
47
+ */
48
+ export declare function scanUtxosDelta(indexerBaseUrl: string, resourceAddress: string, crypto: StealthCryptoProvider, viewSecret: Uint8Array, watermarks: UtxoScanWatermark, perShardLimit?: number): Promise<UtxosDeltaResult>;
49
+ /**
50
+ * Fetches one page of the live UTXO set for a resource and tries to decrypt each output.
51
+ *
52
+ * Use this when the watermarks are lost or a full re-scan is needed. The `fromId` cursor is the
53
+ * `UtxoId` (32-byte commitment hex) of the last output seen on the previous page.
54
+ *
55
+ * Call in a loop until `result.nextCursor` is null:
56
+ * ```ts
57
+ * let cursor = await getUtxoScanPageCursor(accountId, resourceAddress);
58
+ * do {
59
+ * const r = await scanUtxosPage(indexerUrl, resourceAddress, crypto, viewSecret, cursor);
60
+ * for (const o of r.owned) await addShieldedOutput({ ...o, accountId, ... });
61
+ * cursor = r.nextCursor;
62
+ * if (cursor) await setUtxoScanPageCursor(accountId, resourceAddress, cursor);
63
+ * } while (cursor !== null);
64
+ * await clearUtxoScanPageCursor(accountId, resourceAddress);
65
+ * ```
66
+ */
67
+ export declare function scanUtxosPage(indexerBaseUrl: string, resourceAddress: string, crypto: StealthCryptoProvider, viewSecret: Uint8Array, fromId?: string | null, pageSize?: number): Promise<UtxosPageResult>;
68
+ //# sourceMappingURL=utxoScan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utxoScan.d.ts","sourceRoot":"","sources":["../src/utxoScan.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAA2C,MAAM,iCAAiC,CAAC;AAGpH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAuC9D;uFACuF;AACvF,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;AAE7D,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B;iDAC6C;IAC7C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,4EAA4E;IAC5E,UAAU,EAAE,iBAAiB,CAAC;IAC9B;2FACuF;IACvF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B;8DAC0D;IAC1D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AA+DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,cAAc,CAClC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,qBAAqB,EAC7B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,iBAAiB,EAC7B,aAAa,SAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAiD3B;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,aAAa,CACjC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,qBAAqB,EAC7B,UAAU,EAAE,UAAU,EACtB,MAAM,GAAE,MAAM,GAAG,IAAW,EAC5B,QAAQ,SAAM,GACb,OAAO,CAAC,eAAe,CAAC,CAoB1B"}
@@ -0,0 +1,170 @@
1
+ // Scan the live UTXO set for stealth outputs owned by this account's view key.
2
+ //
3
+ // Two complementary strategies:
4
+ //
5
+ // scanUtxosDelta — incremental, checkpoint-based (POST /utxos/stream). Given the watermarks
6
+ // saved from the last call, returns only new/spent outputs since then. Pass
7
+ // empty watermarks for the first call; the indexer will replay the full set.
8
+ // Also handles `Spent` / `Burnt` updates so the caller can mark old outputs
9
+ // as spent without polling individual substates.
10
+ //
11
+ // scanUtxosPage — paginated full scan (GET /utxos). Fetches one page of the current UTXO
12
+ // set ordered by commitment id. Use the returned `nextCursor` for the next
13
+ // call. Useful for first-time imports or recovery when the watermarks are lost.
14
+ //
15
+ // The two share the same decryption helper. `ScannedStealthOutput` (defined in confidential.ts)
16
+ // is the output type passed to `addShieldedOutput` in storage.ts.
17
+ import { decryptInputData } from "@tari-project/ootle";
18
+ import { fromHex } from "./vault.js";
19
+ // ── helpers ───────────────────────────────────────────────────────────────────────────────────────
20
+ async function postJson(baseUrl, path, body) {
21
+ const url = baseUrl.replace(/\/$/, "") + "/" + path;
22
+ const resp = await fetch(url, {
23
+ method: "POST",
24
+ headers: { "Content-Type": "application/json", "Accept": "application/json" },
25
+ body: JSON.stringify(body),
26
+ });
27
+ if (!resp.ok) {
28
+ const text = await resp.text().catch(() => "");
29
+ throw new Error(`UTXO scan POST /${path} failed: ${resp.status} ${resp.statusText} — ${text}`);
30
+ }
31
+ return resp.json();
32
+ }
33
+ async function getJson(baseUrl, path, params) {
34
+ const qs = new URLSearchParams();
35
+ for (const [k, v] of Object.entries(params)) {
36
+ if (v !== undefined)
37
+ qs.set(k, String(v));
38
+ }
39
+ const url = baseUrl.replace(/\/$/, "") + "/" + path + "?" + qs.toString();
40
+ const resp = await fetch(url, { headers: { "Accept": "application/json" } });
41
+ if (!resp.ok) {
42
+ const text = await resp.text().catch(() => "");
43
+ throw new Error(`UTXO scan GET /${path} failed: ${resp.status} ${resp.statusText} — ${text}`);
44
+ }
45
+ return resp.json();
46
+ }
47
+ /** Try to decrypt a UTXO output using the account's view key.
48
+ * Returns a ScannedStealthOutput on success, null if the output doesn't belong to this key. */
49
+ async function tryDecryptUtxo(crypto, viewSecret, resourceAddress, utxoId, utxo) {
50
+ if (!utxo.output)
51
+ return null;
52
+ const body = utxo.output.output;
53
+ try {
54
+ const { value, memo } = await decryptInputData(crypto, fromHex(utxoId), fromHex(body.encrypted_data), {
55
+ senderPublicNonce: fromHex(body.public_nonce),
56
+ viewSecret,
57
+ skipMemo: false,
58
+ });
59
+ return {
60
+ resourceAddress,
61
+ commitment: utxoId,
62
+ amount: value,
63
+ transactionId: "",
64
+ memo,
65
+ };
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ }
71
+ // ── incremental delta scan ───────────────────────────────────────────────────────────────────────
72
+ /**
73
+ * Fetches all UTXO updates (new outputs + spends) since the given watermarks from the indexer's
74
+ * streaming endpoint, then decrypts any `Unspent` candidates with the account's view key.
75
+ *
76
+ * Pass `watermarks: []` (or the saved value from storage) on every call. The very first call
77
+ * with an empty watermarks array replays everything the indexer has retained, so it doubles as the
78
+ * initial full scan. Subsequent calls with the returned watermarks fetch only the delta.
79
+ *
80
+ * Call in a loop until `result.hasMore` is false:
81
+ * ```ts
82
+ * let wm = await getUtxoScanWatermarks(accountId, resourceAddress);
83
+ * do {
84
+ * const r = await scanUtxosDelta(indexerUrl, resourceAddress, crypto, viewSecret, wm, 200);
85
+ * for (const o of r.owned) await addShieldedOutput({ ...o, accountId, ... });
86
+ * for (const c of r.spentCommitments) await markShieldedOutputSpent(accountId, c);
87
+ * wm = r.watermarks;
88
+ * await setUtxoScanWatermarks(accountId, resourceAddress, wm);
89
+ * } while (r.hasMore);
90
+ * ```
91
+ */
92
+ export async function scanUtxosDelta(indexerBaseUrl, resourceAddress, crypto, viewSecret, watermarks, perShardLimit = 200) {
93
+ const req = {
94
+ resource_address: resourceAddress,
95
+ shard_state_versions: watermarks,
96
+ unspent_only: false,
97
+ per_shard_limit: perShardLimit,
98
+ };
99
+ const updateSet = await postJson(indexerBaseUrl, "utxos/stream", req);
100
+ // Collect spend updates and candidate (tag, nonce) pairs for new outputs
101
+ const spentCommitments = [];
102
+ const candidates = [];
103
+ for (const shardUpdates of Object.values(updateSet.shard_updates)) {
104
+ for (const update of shardUpdates.updates) {
105
+ if ("Spent" in update) {
106
+ spentCommitments.push(update.Spent.id);
107
+ }
108
+ else if ("Burnt" in update) {
109
+ spentCommitments.push(update.Burnt.id);
110
+ }
111
+ else if ("Unspent" in update) {
112
+ candidates.push([update.Unspent.tag, update.Unspent.public_nonce]);
113
+ }
114
+ }
115
+ }
116
+ // Batch-fetch full UTXO bodies for all candidates, then decrypt
117
+ const owned = [];
118
+ if (candidates.length > 0) {
119
+ const fetchResp = await postJson(indexerBaseUrl, "utxos/fetch", { resource_address: resourceAddress, tag_and_nonce_pairs: candidates });
120
+ for (const [utxoId, utxo] of fetchResp.utxos) {
121
+ const result = await tryDecryptUtxo(crypto, viewSecret, resourceAddress, utxoId, utxo);
122
+ if (result)
123
+ owned.push(result);
124
+ }
125
+ }
126
+ const hasMore = Object.values(updateSet.shard_updates).some((s) => s.has_more);
127
+ return {
128
+ owned,
129
+ spentCommitments,
130
+ watermarks: updateSet.per_shard_high_watermark,
131
+ hasMore,
132
+ };
133
+ }
134
+ // ── full paginated scan ───────────────────────────────────────────────────────────────────────────
135
+ /**
136
+ * Fetches one page of the live UTXO set for a resource and tries to decrypt each output.
137
+ *
138
+ * Use this when the watermarks are lost or a full re-scan is needed. The `fromId` cursor is the
139
+ * `UtxoId` (32-byte commitment hex) of the last output seen on the previous page.
140
+ *
141
+ * Call in a loop until `result.nextCursor` is null:
142
+ * ```ts
143
+ * let cursor = await getUtxoScanPageCursor(accountId, resourceAddress);
144
+ * do {
145
+ * const r = await scanUtxosPage(indexerUrl, resourceAddress, crypto, viewSecret, cursor);
146
+ * for (const o of r.owned) await addShieldedOutput({ ...o, accountId, ... });
147
+ * cursor = r.nextCursor;
148
+ * if (cursor) await setUtxoScanPageCursor(accountId, resourceAddress, cursor);
149
+ * } while (cursor !== null);
150
+ * await clearUtxoScanPageCursor(accountId, resourceAddress);
151
+ * ```
152
+ */
153
+ export async function scanUtxosPage(indexerBaseUrl, resourceAddress, crypto, viewSecret, fromId = null, pageSize = 100) {
154
+ const resp = await getJson(indexerBaseUrl, "utxos", {
155
+ resource_address: resourceAddress,
156
+ limit: pageSize,
157
+ from_id: fromId ?? undefined,
158
+ });
159
+ const owned = [];
160
+ let lastId = null;
161
+ for (const [utxoId, utxo] of resp.utxos) {
162
+ lastId = utxoId;
163
+ const result = await tryDecryptUtxo(crypto, viewSecret, resourceAddress, utxoId, utxo);
164
+ if (result)
165
+ owned.push(result);
166
+ }
167
+ // If the page was full there may be more; if it was shorter than pageSize, we're done
168
+ const nextCursor = resp.utxos.length >= pageSize ? lastId : null;
169
+ return { owned, nextCursor };
170
+ }
package/dist/wallet.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { BurnClaimProofContents } from "./burnClaim.js";
7
7
  import type { ScannedStealthOutput } from "./confidential.js";
8
8
  import { type HtlcExpectations } from "./htlcSafety.js";
9
9
  import { type NetworkName } from "./ootleNetwork.js";
10
- import type { HtlcJournalEntry, ShieldedOutputRecord } from "./storage.js";
10
+ import type { HtlcJournalEntry, PrivatePaymentScanResume, ShieldedOutputRecord } from "./storage.js";
11
11
  /** How a transaction's fee is paid. Defaults to `transparent` everywhere (unchanged behavior:
12
12
  * revealed balance, reveals the paying account on-chain). `private` instead spends a stealth
13
13
  * UTXO of `feeResourceAddress` -- see `OotleAccount.buildPrivateFeeInstructions`'s doc comment
@@ -134,6 +134,21 @@ export declare function assertValidMinimumValuePromise(promise: bigint, amount:
134
134
  * One derived Ootle account: a signer (owner + view keypair) plus the network connection needed
135
135
  * to read its state and submit transactions, entirely independent of the wallet daemon.
136
136
  */
137
+ /**
138
+ * What a private-payment scan pass should persist once it stops: the cursor only advances when the
139
+ * pass completed (reached the old cursor, or the end of history) with no not-yet-finalized
140
+ * transaction behind it; a pass that ran out of pages instead saves where to continue. `resume`
141
+ * is `null` to clear it, `undefined` to leave it alone. Exported for tests.
142
+ */
143
+ export declare function settlePrivatePaymentScan(pass: {
144
+ reachedCursor: boolean;
145
+ newestSeen: string | null;
146
+ lastId: string | null;
147
+ pendingSeen: boolean;
148
+ }): {
149
+ cursor?: string;
150
+ resume?: PrivatePaymentScanResume | null;
151
+ };
137
152
  export declare class OotleAccount implements WalletAccountApi {
138
153
  readonly index: number;
139
154
  readonly network: Network;
@@ -875,6 +890,16 @@ export declare class OotleAccount implements WalletAccountApi {
875
890
  * tells a caller whether the claim is well formed before anything is spent.
876
891
  */
877
892
  estimateClaimBurnFee(contents: BurnClaimProofContents, memo?: string): Promise<bigint>;
893
+ /** Whether `account` holds a public vault for `resourceAddress` (a private-only holding has none). */
894
+ private hasPublicVault;
895
+ /**
896
+ * `unshield()` for an existing account that has no public vault for this resource, so the usual
897
+ * dust withdrawal can't work. The stealth inputs reveal `amount` straight into a workspace bucket
898
+ * and `deposit` puts it in the account, which creates the vault. The account key is the seal
899
+ * signer (so it authorizes both the revealed output and the fee) and the fee comes from the
900
+ * account's public vault as in any other transparent transaction.
901
+ */
902
+ private unshieldWithoutVault;
878
903
  /**
879
904
  * `unshield()` for an account whose component doesn't exist on-chain yet. Everything runs in the
880
905
  * fee phase, the way Tari's own wallet unshields into a new account: the stealth inputs reveal
@@ -931,8 +956,16 @@ export declare class OotleAccount implements WalletAccountApi {
931
956
  * `buildStatus()`'s `recoverPendingShields()` call for the same pattern. Walks backward in pages
932
957
  * of `pageSize` (oldest-paging via `last_id`, per the indexer's own "recent" convention) up to
933
958
  * `maxPages`, stopping early once it reaches the transaction id it left off at last time. A very
934
- * active chain producing more than `maxPages * pageSize` new transactions between scans will
935
- * only be caught up partway; the next scan resumes from the same cursor and continues.
959
+ * active chain producing more than `maxPages * pageSize` new transactions between scans is caught
960
+ * up over several scans: a pass that runs out of pages saves where it stopped
961
+ * (`privatePaymentScanResumes`), and the next one continues backward from there instead of
962
+ * restarting at the newest transaction -- which, with the page budget the opportunistic scan
963
+ * uses, would otherwise re-scan the same newest pages forever and never reach the older gap. The
964
+ * cursor only advances once a catch-up completes.
965
+ *
966
+ * Limit: this reads transaction *bodies*, which an indexer prunes after its
967
+ * `transaction_retention_epochs` (50 by default, roughly 3-6 days on Esmeralda). A gap older than
968
+ * that is gone from the listing and cannot be recovered by this scan.
936
969
  */
937
970
  scanForPrivatePayments(maxPages?: number, pageSize?: number): Promise<{
938
971
  claimed: number;
@@ -965,6 +998,42 @@ export declare class OotleAccount implements WalletAccountApi {
965
998
  limit?: number;
966
999
  transactionIds?: string[];
967
1000
  }): Promise<ScannedStealthOutput[]>;
1001
+ /**
1002
+ * Scans the live UTXO set for outputs owned by this account, without replaying transaction
1003
+ * history. This is complementary to `scanForPrivatePayments()` (transaction-history scan) and
1004
+ * `scanForResourceUtxos()` (transaction-result walk): it queries the indexer's current UTXO set
1005
+ * directly, so it finds any output that exists on-chain right now regardless of how old it is or
1006
+ * how it was created.
1007
+ *
1008
+ * **Incremental mode (default):** Uses the indexer's delta streaming endpoint
1009
+ * (`POST /utxos/stream`). The first call with no prior state replays everything the indexer
1010
+ * has retained; subsequent calls with saved watermarks return only the delta since then. Also
1011
+ * marks known outputs as spent when the chain reports they were consumed. Call repeatedly
1012
+ * until `newOutputs` stabilises to 0.
1013
+ *
1014
+ * **Full paginated mode** (`mode: "full"`): Pages through the entire live UTXO set ordered by
1015
+ * commitment id. Use when watermarks are lost or a complete re-scan is needed. More expensive
1016
+ * than incremental for large resources; for new ones the two modes are equivalent.
1017
+ *
1018
+ * In both modes the scan saves its checkpoint automatically and resumes from there on the next
1019
+ * call, so a mid-scan crash loses at most one batch.
1020
+ *
1021
+ * @param resourceAddress - The resource whose UTXOs to scan (hex, no "resource_" prefix needed).
1022
+ * @param indexerBaseUrl - The indexer's REST base URL (the same one passed to
1023
+ * `IndexerProvider.connect({ url: ... })`).
1024
+ * @param opts.mode - `"delta"` (default) for incremental, `"full"` for a paginated sweep.
1025
+ * @param opts.perShardLimit - Max updates per shard per delta call (default 200).
1026
+ * @param opts.pageSize - Page size for full-scan mode (default 100).
1027
+ * @returns Number of newly found outputs and newly marked-spent outputs.
1028
+ */
1029
+ scanForOwnedUtxos(resourceAddress: string, indexerBaseUrl: string, opts?: {
1030
+ mode?: "delta" | "full";
1031
+ perShardLimit?: number;
1032
+ pageSize?: number;
1033
+ }): Promise<{
1034
+ newOutputs: number;
1035
+ markedSpent: number;
1036
+ }>;
968
1037
  }
969
1038
  /**
970
1039
  * Reads the commitment of the output at `outputIndex` (in the order `toStealthOutput()` was
@@ -1 +1 @@
1
- {"version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B,EAAE,EACnC,OAAO,SAAI,EACX,YAAY,SAAM,GACjB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAUhC;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQpG;AAmBD,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5E;AAOD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGvG"}
package/dist/wallet.js CHANGED
@@ -17,8 +17,9 @@ import { htlcConditions } from "./htlc.js";
17
17
  import { HtlcUnknownOutcomeError, HtlcVerificationError, decryptOwnStatementOutput, describeHtlcConditions, findScriptRoot, isDefinitiveRejection, isHtlcRefundable, newOperationId, sha256Hex, statementInputCommitment, statementOutputCommitment, subtractScalars, verifyHtlcTerms, } from "./htlcSafety.js";
18
18
  import { buildOwnershipProofMessage, buildWalletOwnershipMessage } from "./ownershipProof.js";
19
19
  import { toOotleNetwork } from "./ootleNetwork.js";
20
- import { addPendingShield, addShieldedOutput, getHtlcJournalEntry, getKnownVersions, getPrivatePaymentScanCursor, listHtlcJournal, listPendingShields, listReservedCommitments, listShieldedOutputs, localAccountId, markShieldedOutputSpent, putHtlcJournalEntry, releaseReservations, removePendingShield, reserveCommitments, setKnownVersions, setPrivatePaymentScanCursor, updateHtlcJournalEntry, CommitmentReservedError, } from "./storage.js";
20
+ import { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, getHtlcJournalEntry, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listHtlcJournal, listPendingShields, listReservedCommitments, listShieldedOutputs, localAccountId, markShieldedOutputSpent, putHtlcJournalEntry, releaseReservations, removePendingShield, reserveCommitments, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, updateHtlcJournalEntry, CommitmentReservedError, } from "./storage.js";
21
21
  import { withTimeout } from "./timeout.js";
22
+ import { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
22
23
  import { fromHex, toHex } from "./vault.js";
23
24
  /** A private fee's bookkeeping, in the journal's serializable form. */
24
25
  function journalFee(feeType, fee) {
@@ -130,6 +131,21 @@ function fromMemo(memoJson) {
130
131
  * One derived Ootle account: a signer (owner + view keypair) plus the network connection needed
131
132
  * to read its state and submit transactions, entirely independent of the wallet daemon.
132
133
  */
134
+ /**
135
+ * What a private-payment scan pass should persist once it stops: the cursor only advances when the
136
+ * pass completed (reached the old cursor, or the end of history) with no not-yet-finalized
137
+ * transaction behind it; a pass that ran out of pages instead saves where to continue. `resume`
138
+ * is `null` to clear it, `undefined` to leave it alone. Exported for tests.
139
+ */
140
+ export function settlePrivatePaymentScan(pass) {
141
+ if (pass.reachedCursor) {
142
+ return { cursor: pass.newestSeen && !pass.pendingSeen ? pass.newestSeen : undefined, resume: null };
143
+ }
144
+ if (pass.newestSeen && pass.lastId) {
145
+ return { resume: { newest: pass.newestSeen, lastId: pass.lastId, pending: pass.pendingSeen } };
146
+ }
147
+ return {};
148
+ }
133
149
  export class OotleAccount {
134
150
  index;
135
151
  network;
@@ -952,6 +968,12 @@ export class OotleAccount {
952
968
  if (!(await substateExists(provider, account))) {
953
969
  return await this.unshieldIntoNewAccount(provider, resourceAddress, revealedOutAmount, commitments, remainder, maxFee, memo);
954
970
  }
971
+ // The dust below is withdrawn from this account's public vault for the resource. An account that only
972
+ // ever received this resource privately has no such vault, and the withdraw would be rejected
973
+ // ("No vault for resource ...") after the fee was already charged.
974
+ if (!(await this.hasPublicVault(provider, account, resourceAddress))) {
975
+ return await this.unshieldWithoutVault(provider, account, resourceAddress, revealedOutAmount, commitments, remainder, maxFee, memo, feeType, accountId);
976
+ }
955
977
  // See shield()'s comment: the resource's own substate must be pinned explicitly -- prepare()
956
978
  // never adds it on its own.
957
979
  let builder = new StealthTransfer(provider, resourceAddress)
@@ -2583,6 +2605,115 @@ export class OotleAccount {
2583
2605
  const { buildClaim, value } = await this.prepareBurnClaim(contents, memo);
2584
2606
  return this.estimateClaimFee(await buildClaim(claimFeeProbe(value), true));
2585
2607
  }
2608
+ /** Whether `account` holds a public vault for `resourceAddress` (a private-only holding has none). */
2609
+ async hasPublicVault(provider, account, resourceAddress) {
2610
+ const vaultIds = await getVaultIdsForAccount(provider, account);
2611
+ if (vaultIds.length === 0)
2612
+ return false;
2613
+ const { substates } = await withTimeout(provider.fetchSubstates(vaultIds), 15_000, "checking this account's vaults");
2614
+ for (const id of vaultIds) {
2615
+ const value = substates[id]?.substate;
2616
+ if (!value || !("Vault" in value))
2617
+ continue;
2618
+ const [, data] = Object.entries(value.Vault.resource_container)[0];
2619
+ if (data.address === resourceAddress)
2620
+ return true;
2621
+ }
2622
+ return false;
2623
+ }
2624
+ /**
2625
+ * `unshield()` for an existing account that has no public vault for this resource, so the usual
2626
+ * dust withdrawal can't work. The stealth inputs reveal `amount` straight into a workspace bucket
2627
+ * and `deposit` puts it in the account, which creates the vault. The account key is the seal
2628
+ * signer (so it authorizes both the revealed output and the fee) and the fee comes from the
2629
+ * account's public vault as in any other transparent transaction.
2630
+ */
2631
+ async unshieldWithoutVault(provider, account, resourceAddress, amount, commitments, remainder, maxFee, memo, feeType, accountId) {
2632
+ if (feeType.kind === "private") {
2633
+ throw new Error("unshield: this account holds no public " +
2634
+ "vault for the resource, so the first unshield has to pay its fee publicly. Use a transparent fee.");
2635
+ }
2636
+ const crypto = new WasmStealthCrypto(this.network);
2637
+ const viewSecret = await this.signer.getViewSecret();
2638
+ const walletAddress = await this.getWalletAddress();
2639
+ const ownerPublicKey = this.accountPublicKey;
2640
+ const inputs = await Promise.all(commitments.map(async (commitmentHex) => {
2641
+ const substateId = stealthUtxoSubstateId(resourceAddress, fromHex(commitmentHex));
2642
+ const substate = await provider.getSubstate(substateId);
2643
+ const decrypted = await decryptOwnedUtxo(crypto, viewSecret, substate, substateId);
2644
+ if (!decrypted)
2645
+ throw new Error(`unshield: cannot decrypt ${substateId} -- it isn't this account's, or it is already spent.`);
2646
+ const nonce = utxoOf(substate).output.output.public_nonce;
2647
+ return { commitmentHex, substateId, mask: decrypted.mask, nonce };
2648
+ }));
2649
+ const inputMask = await crypto.aggregateInputMasks(inputs.map((i) => i.mask));
2650
+ const inputsJson = JSON.stringify({
2651
+ inputs: inputs.map((i) => ({ commitment: i.commitmentHex, witness: "KeyPath" })),
2652
+ revealed_amount: "0",
2653
+ });
2654
+ const output = createOutput({ destination: walletAddress, amount: remainder, resourceAddress, memo: toMemo(memo) });
2655
+ const { statement: outputsStatement, outputMask } = await crypto.generateOutputsStatement([output], { amount, receiver: ownerPublicKey });
2656
+ const inputsStatement = new StealthInputsStatement([], 0n, inputsJson);
2657
+ const balanceProof = await crypto.generateBalanceProofSignature(inputMask, outputMask, inputsJson, outputsStatement.statementJson);
2658
+ const statement = new StealthTransferStatement(inputsStatement, outputsStatement, balanceProof);
2659
+ await crypto.validateTransfer(statement);
2660
+ const changeCommitment = outputsStatement.parsed().outputs[0].output.commitment;
2661
+ const builder = TransactionBuilder.new(this.network, await resolveMaxEpoch(provider))
2662
+ .addInstruction({
2663
+ StealthTransfer: {
2664
+ resource_address_ref: { Address: resourceAddress },
2665
+ statement: { __ootleRawJson: statement.toCompactJson() },
2666
+ revealed_input_bucket: null,
2667
+ },
2668
+ })
2669
+ .addInstruction({ PutLastInstructionOutputOnWorkspace: { key: 0 } })
2670
+ .addInstruction({
2671
+ CallMethod: { call: { Address: account }, method: "deposit", args: [{ Workspace: { id: 0, offset: null } }] },
2672
+ });
2673
+ builder.feeTransactionPayFromComponent(account, maxFee);
2674
+ builder
2675
+ .addInput({ substate_id: resourceAddress, version: null })
2676
+ .addInput({ substate_id: account, version: null });
2677
+ for (const vaultId of await getVaultIdsForAccount(provider, account)) {
2678
+ builder.addInput({ substate_id: vaultId, version: null });
2679
+ }
2680
+ for (const input of inputs)
2681
+ builder.addInput({ substate_id: input.substateId, version: null });
2682
+ const unsignedBody = builder.buildUnsignedTransaction();
2683
+ unsignedBody.is_seal_signer_authorized = true;
2684
+ const unsignedTx = await resolveTransaction(provider, unsignedBody);
2685
+ unsignedTx.inputs = dedupeInputs(unsignedTx.inputs);
2686
+ const signers = inputs.map((input) => ({
2687
+ getAddress: async () => walletAddress,
2688
+ getPublicKey: async () => parseOotleAddress(walletAddress).owner_key,
2689
+ signTransaction: async (tx, sealPublicKey) => {
2690
+ const json = serializeUnsignedTx(tx);
2691
+ return [await this.signer.addStealthSignature(json, fromHex(input.nonce), sealPublicKey, { crypto })];
2692
+ },
2693
+ }));
2694
+ const signed = await signTransaction(signers, unsignedTx, { secret_key: this.ownerSecret, public_key: ownerPublicKey });
2695
+ const transactionId = await submitTransaction(provider, sealTransaction(signed));
2696
+ await addPendingShield({
2697
+ transactionId,
2698
+ accountId,
2699
+ resourceAddress,
2700
+ amount: remainder.toString(),
2701
+ spentCommitments: commitments,
2702
+ ownCommitment: changeCommitment,
2703
+ memo,
2704
+ });
2705
+ try {
2706
+ const response = await withTimeout(pollTransactionResult(provider, transactionId), 60_000, "submitting the unshield transaction");
2707
+ await recordKnownVersions(response);
2708
+ await recordKnownShieldedOutput(accountId, resourceAddress, changeCommitment, remainder, transactionId, memo);
2709
+ for (const commitment of commitments)
2710
+ await markShieldedOutputSpent(accountId, commitment);
2711
+ }
2712
+ finally {
2713
+ await removePendingShield(transactionId);
2714
+ }
2715
+ return { transactionId };
2716
+ }
2586
2717
  /**
2587
2718
  * `unshield()` for an account whose component doesn't exist on-chain yet. Everything runs in the
2588
2719
  * fee phase, the way Tari's own wallet unshields into a new account: the stealth inputs reveal
@@ -2851,8 +2982,16 @@ export class OotleAccount {
2851
2982
  * `buildStatus()`'s `recoverPendingShields()` call for the same pattern. Walks backward in pages
2852
2983
  * of `pageSize` (oldest-paging via `last_id`, per the indexer's own "recent" convention) up to
2853
2984
  * `maxPages`, stopping early once it reaches the transaction id it left off at last time. A very
2854
- * active chain producing more than `maxPages * pageSize` new transactions between scans will
2855
- * only be caught up partway; the next scan resumes from the same cursor and continues.
2985
+ * active chain producing more than `maxPages * pageSize` new transactions between scans is caught
2986
+ * up over several scans: a pass that runs out of pages saves where it stopped
2987
+ * (`privatePaymentScanResumes`), and the next one continues backward from there instead of
2988
+ * restarting at the newest transaction -- which, with the page budget the opportunistic scan
2989
+ * uses, would otherwise re-scan the same newest pages forever and never reach the older gap. The
2990
+ * cursor only advances once a catch-up completes.
2991
+ *
2992
+ * Limit: this reads transaction *bodies*, which an indexer prunes after its
2993
+ * `transaction_retention_epochs` (50 by default, roughly 3-6 days on Esmeralda). A gap older than
2994
+ * that is gone from the listing and cannot be recovered by this scan.
2856
2995
  */
2857
2996
  async scanForPrivatePayments(maxPages, pageSize = 50) {
2858
2997
  const accountId = localAccountId(this.index);
@@ -2862,8 +3001,11 @@ export class OotleAccount {
2862
3001
  const known = await listShieldedOutputs(accountId);
2863
3002
  const knownCommitments = new Set(known.map((r) => r.commitment));
2864
3003
  const previousCursor = await getPrivatePaymentScanCursor(accountId);
2865
- let newestSeen = null;
2866
- let lastId = null;
3004
+ // An earlier pass that ran out of pages: carry on from where it stopped, with the newest id and
3005
+ // pending flag it captured when it began (see the method doc comment).
3006
+ let resume = await getPrivatePaymentScanResume(accountId);
3007
+ let newestSeen = resume?.newest ?? null;
3008
+ let lastId = resume?.lastId ?? null;
2867
3009
  const found = [];
2868
3010
  // Whether this pass actually walked all the way back to `previousCursor` (or there was none to
2869
3011
  // reach -- the very first scan ever). Only true in that case is it safe to advance the cursor:
@@ -2880,14 +3022,30 @@ export class OotleAccount {
2880
3022
  const isFirstScan = previousCursor === null;
2881
3023
  const pageBudget = maxPages ?? (isFirstScan ? 400 : 3);
2882
3024
  let reachedCursor = false;
2883
- let pendingSeen = false;
3025
+ let pendingSeen = resume?.pending ?? false;
2884
3026
  pages: for (let page = 0; page < pageBudget; page++) {
2885
- const { transactions } = await provider.listRecentTransactions({ limit: pageSize, last_id: lastId, source: null });
3027
+ let transactions;
3028
+ try {
3029
+ ({ transactions } = await provider.listRecentTransactions({ limit: pageSize, last_id: lastId, source: null }));
3030
+ }
3031
+ catch (e) {
3032
+ // The saved resume point can name a transaction the indexer has pruned since, which it may
3033
+ // refuse as a page anchor. That part of the gap is unreachable anyway: drop the resume point
3034
+ // and start over from the newest so the scan cannot be stuck failing on it forever.
3035
+ if (page !== 0 || !resume)
3036
+ throw e;
3037
+ await setPrivatePaymentScanResume(accountId, null);
3038
+ resume = null;
3039
+ newestSeen = null;
3040
+ lastId = null;
3041
+ pendingSeen = false;
3042
+ ({ transactions } = await provider.listRecentTransactions({ limit: pageSize, last_id: null, source: null }));
3043
+ }
2886
3044
  if (transactions.length === 0) {
2887
3045
  reachedCursor = true; // the indexer's whole history fit before ever finding previousCursor
2888
3046
  break;
2889
3047
  }
2890
- if (page === 0)
3048
+ if (newestSeen === null)
2891
3049
  newestSeen = transactions[0].transaction_id;
2892
3050
  for (const entry of transactions) {
2893
3051
  if (entry.transaction_id === previousCursor) {
@@ -2924,8 +3082,11 @@ export class OotleAccount {
2924
3082
  }
2925
3083
  lastId = transactions[transactions.length - 1].transaction_id;
2926
3084
  }
2927
- if (newestSeen && reachedCursor && !pendingSeen)
2928
- await setPrivatePaymentScanCursor(accountId, newestSeen);
3085
+ const outcome = settlePrivatePaymentScan({ reachedCursor, newestSeen, lastId, pendingSeen });
3086
+ if (outcome.cursor)
3087
+ await setPrivatePaymentScanCursor(accountId, outcome.cursor);
3088
+ if (outcome.resume !== undefined)
3089
+ await setPrivatePaymentScanResume(accountId, outcome.resume);
2929
3090
  return { claimed: found.length, found };
2930
3091
  }
2931
3092
  /**
@@ -3039,6 +3200,89 @@ export class OotleAccount {
3039
3200
  }
3040
3201
  return found;
3041
3202
  }
3203
+ /**
3204
+ * Scans the live UTXO set for outputs owned by this account, without replaying transaction
3205
+ * history. This is complementary to `scanForPrivatePayments()` (transaction-history scan) and
3206
+ * `scanForResourceUtxos()` (transaction-result walk): it queries the indexer's current UTXO set
3207
+ * directly, so it finds any output that exists on-chain right now regardless of how old it is or
3208
+ * how it was created.
3209
+ *
3210
+ * **Incremental mode (default):** Uses the indexer's delta streaming endpoint
3211
+ * (`POST /utxos/stream`). The first call with no prior state replays everything the indexer
3212
+ * has retained; subsequent calls with saved watermarks return only the delta since then. Also
3213
+ * marks known outputs as spent when the chain reports they were consumed. Call repeatedly
3214
+ * until `newOutputs` stabilises to 0.
3215
+ *
3216
+ * **Full paginated mode** (`mode: "full"`): Pages through the entire live UTXO set ordered by
3217
+ * commitment id. Use when watermarks are lost or a complete re-scan is needed. More expensive
3218
+ * than incremental for large resources; for new ones the two modes are equivalent.
3219
+ *
3220
+ * In both modes the scan saves its checkpoint automatically and resumes from there on the next
3221
+ * call, so a mid-scan crash loses at most one batch.
3222
+ *
3223
+ * @param resourceAddress - The resource whose UTXOs to scan (hex, no "resource_" prefix needed).
3224
+ * @param indexerBaseUrl - The indexer's REST base URL (the same one passed to
3225
+ * `IndexerProvider.connect({ url: ... })`).
3226
+ * @param opts.mode - `"delta"` (default) for incremental, `"full"` for a paginated sweep.
3227
+ * @param opts.perShardLimit - Max updates per shard per delta call (default 200).
3228
+ * @param opts.pageSize - Page size for full-scan mode (default 100).
3229
+ * @returns Number of newly found outputs and newly marked-spent outputs.
3230
+ */
3231
+ async scanForOwnedUtxos(resourceAddress, indexerBaseUrl, opts = {}) {
3232
+ const { mode = "delta", perShardLimit = 200, pageSize = 100 } = opts;
3233
+ const accountId = localAccountId(this.index);
3234
+ const viewSecret = await this.signer.getViewSecret();
3235
+ const crypto = new WasmStealthCrypto(this.network);
3236
+ let newOutputs = 0;
3237
+ let markedSpent = 0;
3238
+ const recordOutput = async (raw) => {
3239
+ await addShieldedOutput({
3240
+ accountId,
3241
+ resourceAddress: raw.resourceAddress,
3242
+ commitment: raw.commitment,
3243
+ amount: raw.amount.toString(),
3244
+ transactionId: raw.transactionId,
3245
+ memo: raw.memo,
3246
+ createdAt: Date.now(),
3247
+ spent: false,
3248
+ });
3249
+ newOutputs++;
3250
+ };
3251
+ if (mode === "delta") {
3252
+ let watermarks = await getUtxoScanWatermarks(accountId, resourceAddress);
3253
+ let hasMore = true;
3254
+ while (hasMore) {
3255
+ const result = await scanUtxosDelta(indexerBaseUrl, resourceAddress, crypto, viewSecret, watermarks, perShardLimit);
3256
+ for (const output of result.owned)
3257
+ await recordOutput(output);
3258
+ for (const commitment of result.spentCommitments) {
3259
+ await markShieldedOutputSpent(accountId, commitment);
3260
+ markedSpent++;
3261
+ }
3262
+ watermarks = result.watermarks;
3263
+ await setUtxoScanWatermarks(accountId, resourceAddress, watermarks);
3264
+ hasMore = result.hasMore;
3265
+ }
3266
+ }
3267
+ else {
3268
+ let cursor = await getUtxoScanPageCursor(accountId, resourceAddress);
3269
+ let morePages = true;
3270
+ while (morePages) {
3271
+ const result = await scanUtxosPage(indexerBaseUrl, resourceAddress, crypto, viewSecret, cursor, pageSize);
3272
+ for (const output of result.owned)
3273
+ await recordOutput(output);
3274
+ if (result.nextCursor) {
3275
+ cursor = result.nextCursor;
3276
+ await setUtxoScanPageCursor(accountId, resourceAddress, cursor);
3277
+ }
3278
+ else {
3279
+ await clearUtxoScanPageCursor(accountId, resourceAddress);
3280
+ morePages = false;
3281
+ }
3282
+ }
3283
+ }
3284
+ return { newOutputs, markedSpent };
3285
+ }
3042
3286
  }
3043
3287
  /**
3044
3288
  * Reads the commitment of the output at `outputIndex` (in the order `toStealthOutput()` was
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chironbuilder/ootle-sdk",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Shared TypeScript client for Tari Ootle (L2): account derivation, balances, transactions, HTLCs, and stealth/confidential transfers — the account core behind Sapient and the Tari L1 web wallet's Ootle support.",
5
5
  "type": "module",
6
6
  "license": "MIT",