Optimizes wallet leaf structure by consolidating or splitting leaves. This is an async generator that yields progress updates.
Method Signature
async *optimizeLeaves(
multiplicity?: number
): AsyncGenerator<{
step: number;
total: number;
controller: AbortController;
}>
Parameters
Optimization multiplicity (0-5, default from config)
Yields
Progress object containing:
step: Current step number
total: Total number of steps
controller: AbortController to cancel optimization
Example
for await (const progress of wallet.optimizeLeaves()) {
console.log(`Step ${progress.step} of ${progress.total}`);
// Cancel if needed
if (shouldCancel) {
progress.controller.abort();
break;
}
}
console.log("Optimization complete");