getSpendWitnesses
Produce inclusion proofs for a spend from the synced notes tree. All returned proofs share the same authenticated root.
Under the sharded engine, cold notes (no witness tracked — e.g. restored wallet) are recovered transparently: one shard fetch from the dumb leaf feed, verified against the already-chain-anchored shard root, then persisted. The global engine holds every leaf, so it never needs recovery.
Import
import { getSpendWitnesses } from "@0xcurvy/curvy-sdk/actions";Usage
const supplied = await getSpendWitnesses({
networkSlug,
noteIds,
config,
});Signature
function getSpendWitnesses(parameters: GetSpendWitnessesParameters): Promise<SuppliedInclusionProofs>Returns
Promise<SuppliedInclusionProofs>
The action resolves or returns the value shown in the signature.
Parameters
networkSlug
- Type:
string - Required: yes
The network whose notes tree should supply the spend witnesses.
const result = await getSpendWitnesses({
networkSlug,
noteIds,
});noteIds
- Type:
Array<bigint | string> - Required: yes
Note ids to witness, in spend order (decimal strings or bigints).
const result = await getSpendWitnesses({
networkSlug,
noteIds,
});leafIndices
- Type:
Array<number | undefined> - Required: no
Supplied leaf positions corresponding to noteIds. This lets a bearer-note flow (for example a gift link) recover a sharded witness without first writing the note into an unrelated account's balance storage. Positions come from the chain-scoped indexer status route and are still verified against the locally assembled, RPC-anchored tree root.
const result = await getSpendWitnesses({
networkSlug,
noteIds,
leafIndices,
});persistRecoveredWitnesses
- Type:
boolean - Required: no
Persist witnesses recovered by this call. Disable for bearer notes that do not belong to the active account: their witness is needed only long enough to build this proof and must not enter the finalized wallet snapshot. Defaults to true for ordinary account-owned cold-note recovery.
const result = await getSpendWitnesses({
networkSlug,
noteIds,
persistRecoveredWitnesses,
});accountId
- Type:
string - Required: no
Account whose balance entries supply leaf indices for cold notes; defaults to active.
const result = await getSpendWitnesses({
networkSlug,
noteIds,
accountId,
});config
- Type:
CurvyConfig - Required: no
Curvy config to use. Defaults to the ambient config.
const result = await getSpendWitnesses({
networkSlug,
noteIds,
config,
});Errors
Errors from config resolution and the underlying SDK operation are propagated to the caller.
Related
- Querying balances guide
syncNotes— Run one notes-tree sync pass per network: pull the indexer delta, discover owned notes, reconcile spends, verify the assembled root against a DIRECT chain read, persist, and apply the account-facing effects (balance entries + tx history).resolveNoteWitness— Resolve a note by scanning forward from a public lower-bound hint.refreshBalances— Re-sync and persist an account's shielded balances.
Source
packages/@0xcurvy/sdk/src/actions/notes/getSpendWitnesses.ts