RAILGUN Reloaded
    Preparing search index...

    Type Alias WalletStorage

    Wallet-specific storage operations.

    type WalletStorage = {
        createWallet(wallet: any): Promise<boolean>;
        getWallet(walletId: string): Promise<any>;
        listWallets(): Promise<any[]>;
        deleteWallet(walletId: string): Promise<number>;
        insertNote(note: any): Promise<void>;
        insertNotesBatch(noteList: any[]): Promise<number>;
        getUnspentNotes(walletId: string, deployment: Deployment): Promise<any[]>;
        getUnspentNotesByToken(
            walletId: string,
            deployment: Deployment,
            token: string,
        ): Promise<any[]>;
        getNoteByCommitment(identity: NoteIdentity): Promise<any>;
        getNoteByNullifier(identity: NoteNullifierIdentity): Promise<any>;
        markNoteSpent(
            identity: NoteIdentity,
            spentTxid: Uint8Array,
            spentBlockNumber: bigint,
            spentTimestamp: Date | null,
        ): Promise<number>;
        markNotesSpentBatch(
            identities: NoteIdentity[],
            spentTxid: Uint8Array,
            spentBlockNumber: bigint,
            spentTimestamp: Date | null,
        ): Promise<number>;
        getAllNotes(walletId: string, deployment: Deployment): Promise<any[]>;
        getNotesNeedingPoiRefresh(
            walletId: string,
            deployment: Deployment,
            requiredListKeys: readonly string[],
        ): Promise<any[]>;
        updateNotePoiStatus(
            identity: NoteIdentity,
            blindedCommitment: Uint8Array,
            poisPerList: Record<string, string | null> | null,
        ): Promise<number>;
        updateNotePoiStatusBatch(updates: NotePoiStatusUpdate[]): Promise<number>;
        insertSentCommitmentsBatch(commitmentList: any[]): Promise<number>;
        getSentCommitments(
            walletId: string,
            deployment: Deployment,
        ): Promise<any[]>;
        getOutputPoiStatuses(
            walletId: string,
            deployment: Deployment,
        ): Promise<any[]>;
        upsertOutputPoiStatuses(updates: any[]): Promise<number>;
        getScanState(walletId: string, deployment: Deployment): Promise<any>;
        updateScanState(
            walletId: string,
            deployment: Deployment,
            lastScannedBlock: bigint,
        ): Promise<void>;
        rollbackWallets(deployment: Deployment, toHeight: bigint): Promise<void>;
        allocateEphemeralIndex(
            walletId: string,
            chainId: number,
        ): Promise<number | undefined>;
        getNextEphemeralIndex(walletId: string, chainId: number): Promise<number>;
        raiseNextEphemeralIndex(
            walletId: string,
            chainId: number,
            nextIndex: number,
        ): Promise<void>;
        insertTxHistory(tx: any): Promise<void>;
        insertTxHistoryBatch(txs: any[]): Promise<number>;
        getTxHistory(
            walletId: string,
            deployment: Deployment,
            limit?: number,
        ): Promise<any[]>;
        getTxById(txId: string): Promise<any>;
        getWalletDBStats(walletId: string): Promise<WalletDBStats>;
    }
    Index
    • Insert a new wallet record, leaving any existing row for the same id untouched.

      Parameters

      • wallet: any

        Data for the new wallet.

      Returns Promise<boolean>

      True when a row was inserted, false when the id already existed.

    • Retrieve a wallet by its ID.

      Parameters

      • walletId: string

        Identifier of the wallet to fetch.

      Returns Promise<any>

      The wallet record, or undefined when absent.

    • Delete a wallet by ID, cascading to its dependent rows.

      Parameters

      • walletId: string

        Identifier of the wallet to delete.

      Returns Promise<number>

      Normalized count of deleted wallet rows (0 or 1).

    • Insert a note, normalizing its token and ignoring conflicts on an existing note identity.

      Parameters

      • note: any

        Note data to insert.

      Returns Promise<void>

    • Batch-insert notes, normalizing tokens and enriching existing rows with previously-null optional fields on conflict. An empty batch is a no-op and returns 0.

      Parameters

      • noteList: any[]

        Array of notes to insert.

      Returns Promise<number>

      Normalized count of affected rows.

    • Retrieve all unspent notes for a wallet/chain pair.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      Returns Promise<any[]>

      Unspent notes for the wallet on the chain.

    • Retrieve unspent notes filtered by normalized token for a wallet/chain pair.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      • token: string

        Token identifier to filter by, in any case.

      Returns Promise<any[]>

      Unspent notes for the wallet/chain/token.

    • Mark a note as spent and record its spending transaction provenance.

      Parameters

      • identity: NoteIdentity

        Wallet, chain, and commitment of the note to update.

      • spentTxid: Uint8Array

        Transaction ID that spent the note.

      • spentBlockNumber: bigint

        Block containing the spending transaction.

      • spentTimestamp: Date | null

        Timestamp of the spending block, or null when the data source does not carry one for this transaction.

      Returns Promise<number>

      Normalized count of updated rows.

    • Mark multiple notes as spent atomically. An empty list is a no-op and returns 0.

      Parameters

      • identities: NoteIdentity[]

        Note identities to update.

      • spentTxid: Uint8Array

        Transaction ID that spent the notes.

      • spentBlockNumber: bigint

        Block containing the spending transaction.

      • spentTimestamp: Date | null

        Timestamp of the spending block, or null when the data source does not carry one for this transaction.

      Returns Promise<number>

      Normalized count of updated rows.

    • Return all notes belonging to a wallet on a given chain.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      Returns Promise<any[]>

      Note records for the wallet on the chain.

    • Return received notes whose PPOI status needs refreshing: notes with no persisted status, or with at least one required list whose status is not Valid.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      • requiredListKeys: readonly string[]

        PPOI list keys that must all be Valid.

      Returns Promise<any[]>

      Notes with no PPOI status or a non-Valid required-list status.

    • Atomically merge a note's PPOI tags and persist its blinded commitment.

      Parameters

      • identity: NoteIdentity

        Wallet, chain, and commitment of the note to update.

      • blindedCommitment: Uint8Array

        Derived PPOI lookup key.

      • poisPerList: Record<string, string | null> | null

        Tags to merge. Omitted keys stay unchanged. A per-key null removes that tag; whole-map null clears all tags to pending.

      Returns Promise<number>

      Normalized count of updated rows.

    • Batch-insert sender-side commitments, normalizing tokens and ignoring an existing row for the same identity. An empty batch is a no-op and returns 0.

      Parameters

      • commitmentList: any[]

        Sent commitments to insert.

      Returns Promise<number>

      Normalized count of inserted rows.

    • Return every sender-side commitment a wallet created on a chain. These are the outputs the wallet itself produced, including the ones another wallet owns, so a caller can report what a transaction sent.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      Returns Promise<any[]>

      Sent commitment rows for the wallet on the chain.

    • Read persisted per-list PPOI results for sent outputs and unshields.

      Parameters

      • walletId: string

        Wallet whose output results to read.

      • deployment: Deployment

        Chain and RAILGUN version to read.

      Returns Promise<any[]>

      Stored results; an absent output or list has no known status.

    • Atomically insert or replace per-list output PPOI results. Omitted lists stay unchanged. Storage does not classify statuses or validate node responses.

      Parameters

      • updates: any[]

        Results scoped to wallet, deployment, output type, key, and list.

      Returns Promise<number>

      Number of written rows, or zero for an empty batch.

      When a wallet is absent, a key is not 32 bytes, or a write fails.

    • Retrieve the scan state for a wallet on a particular chain.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      Returns Promise<any>

      The scan state, or undefined when absent.

    • Insert or update the scan state for a wallet/chain pair.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      • lastScannedBlock: bigint

        Latest block height scanned.

      Returns Promise<void>

    • Remove what every wallet of a deployment learned above a block, in one transaction. Deletes notes and sent commitments above toHeight, clears the spend fields of notes spent above it, and lowers every scan cursor above it to toHeight. Creates no scan state row. PPOI statuses, transaction history and ephemeral indexes stay unchanged. Stop decryption for the deployment first: updateScanState writes a cursor as given.

      Parameters

      • deployment: Deployment

        Deployment (chain and RAILGUN version) to roll back.

      • toHeight: bigint

        Highest block to keep.

      Returns Promise<void>

      When toHeight is outside 0 to 2^256 - 1.

    • Allocate the next ephemeral index for a wallet/chain pair and advance the stored counter by one, atomically. Concurrent callers on the same database can never receive the same index.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • chainId: number

        Chain identifier.

      Returns Promise<number | undefined>

      The allocated index, or undefined when the counter is exhausted: the stored next index has reached 2147483647, is left unchanged, and the largest index ever returned is 2147483646.

    • Read the next ephemeral index available to allocate for a wallet/chain pair, writing nothing.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • chainId: number

        Chain identifier.

      Returns Promise<number>

      The stored next available index, or 0 when no counter row exists.

    • Raise the stored next ephemeral index for a wallet/chain pair to the given value. The counter never moves down.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • chainId: number

        Chain identifier.

      • nextIndex: number

        New next available index. Must be an integer in [0, 2147483647].

      Returns Promise<void>

    • Add a transaction history entry, ignoring duplicates.

      Parameters

      • tx: any

        Transaction history record to insert.

      Returns Promise<void>

    • Batch-insert transaction history entries, ignoring duplicates. An empty batch is a no-op and returns 0.

      Parameters

      • txs: any[]

        Transaction history records.

      Returns Promise<number>

      Normalized count of inserted rows.

    • Retrieve recent transaction history for a wallet on a chain, ordered descending by block number.

      Parameters

      • walletId: string

        Identifier of the wallet.

      • deployment: Deployment

        Deployment (chain and RAILGUN version).

      • Optionallimit: number

        Maximum number of rows to return. Omit for all of them.

      Returns Promise<any[]>

      Transaction history rows ordered by block descending.

    • Fetch a transaction history entry by its ID.

      Parameters

      • txId: string

        Transaction ID to look up.

      Returns Promise<any>

      The history record, or undefined.