import type { Program, Idl } from "@coral-xyz/anchor"; import { Keypair, PublicKey } from "@solana/web3.js"; import type { TransactionProofBuilder } from "../proofs/types.js"; import type { InputUTXO, SerializedUTXO } from "../notes/model.js"; import { MerkleTree } from "../merkle.js"; import { type NoteCiphers } from "../compactNote.js"; export type WithdrawResult = { /** Change UTXO (remaining balance) */ changeUTXO: SerializedUTXO; /** Leaf index of the change UTXO */ leafIndex: number; /** New Merkle root after insertion */ root: Uint8Array; }; /** * Withdraw funds from the privacy pool. * * For withdrawals, we spend input UTXOs and create change output UTXOs. * The publicAmount is negative (funds flowing out). * * @param withdrawAmount - Amount to withdraw in lamports/token units * @param inputUTXOs - The UTXOs being spent * @param changePubkey - UTXO public key for the change output * @param inputTreeId - The tree ID where input UTXOs are located * @param outputTreeId - The tree ID where change outputs will be inserted */ export declare function withdraw(params: { program: Program; relayer: Keypair; recipient: PublicKey; mintAddress: PublicKey; inputUTXOs: [InputUTXO, InputUTXO]; changePubkey: bigint; withdrawAmount: bigint; fee: bigint; refund: bigint; root: Uint8Array; inputTreeId: number; outputTreeId: number; tree: MerkleTree; proofBuilder: TransactionProofBuilder; /** When true, the fee is debited in addition to withdrawAmount. */ feeOnTop?: boolean; deadline?: bigint; /** Solana wallet key used to encrypt the change note for chain recovery. */ changeNoteRecipientWallet?: PublicKey | Uint8Array; /** Verified X25519 view-v2 target; overrides changeNoteRecipientWallet. */ changeNoteRecipientViewKey?: Uint8Array; /** Prebuilt recovery payload. Takes precedence over changeNoteRecipientWallet. */ noteCiphers?: NoteCiphers | null; }): Promise; /** * Result of a private transfer operation. */