Cashu-TS - v4.6.0
    Preparing search index...

    DocumentsWallet EventsProof State Streams

    Proof state streams

    import { CheckStateEnum } from '@cashu/cashu-ts';
    const ac = new AbortController();
    (async () => {
    for await (const u of wallet.on.proofStatesStream(proofs, { signal: ac.signal })) {
    if (u.state === CheckStateEnum.SPENT) {
    console.log('Spent proof', u.proof.id);
    }
    }
    })();

    // later
    ac.abort();

    Note: the subscription is sent to the mint on the first iteration, not when proofStatesStream is called. Per NUT-17 the mint replays the current state on subscribe, so the latest state is never lost — only intermediate transitions before the first iteration are collapsed into that snapshot.