import { RailgunWallet } from '../wallet/railgun-wallet'; import { Prover, ProverProgressCallback } from '../prover/prover'; import { AdaptID, TokenData } from '../models/formatted-types'; import { UnshieldNote } from '../note/unshield-note'; import { TXO, UnshieldData } from '../models/txo-types'; import { Chain } from '../models/engine-types'; import { TransactNote } from '../note/transact-note'; import { UnprovedTransactionInputs, RailgunTransactionRequest } from '../models/prover-types'; import { BoundParamsStruct, CommitmentCiphertextStruct as CommitmentCiphertextStructV2 } from '../abi/typechain/RailgunSmartWallet'; import { TXIDVersion } from '../models/poi-types'; import { PoseidonMerkleVerifier } from '../abi/typechain'; import { TransactionStructV2, TransactionStructV3 } from '../models/transaction-types'; import { OrderedClearSignOutputs } from './clear-sign-request'; import { ClearSignTransactRequest } from '../wallet/clear-sign'; /** Output of {@link Transaction.deriveTransactionInputs} — nothing here depends on * output randomness, so it survives an external signer choosing its own. */ export type DerivedTransactionInputs = { readonly merkleRoot: string; readonly spendingKey: Awaited>; readonly nullifyingKey: bigint; readonly senderViewingKeys: ReturnType; readonly nullifiers: bigint[]; readonly pathElements: bigint[][]; readonly pathIndices: bigint[]; readonly allOutputs: (TransactNote | UnshieldNote)[]; readonly onlyInternalOutputs: TransactNote[]; readonly hasUnshield: boolean; }; declare class Transaction { private readonly adaptID; private readonly chain; private readonly tokenOutputs; private unshieldNote; private unshieldFlag; private readonly tokenData; private readonly tokenHash; private readonly spendingTree; private readonly utxos; /** * Create ERC20Transaction Object * @param tokenAddress - token address, unformatted * @param tokenType - enum of token type * @param chain - chain type/id of network * @param spendingTree - tree index to spend from * @param utxos - UTXOs to spend from */ constructor(chain: Chain, tokenData: TokenData, spendingTree: number, utxos: TXO[], tokenOutputs: TransactNote[], adaptID: AdaptID); addUnshieldData(unshieldData: UnshieldData, unshieldValue: bigint): void; /** The unshield note, for clear-sign verification. Undefined when not unshielding. */ get unshieldNoteForClearSign(): Optional; get unshieldValue(): bigint; /** * Everything about a transact that does NOT depend on output randomness: the merkle * root, the nullifiers, and the output notes themselves. * * Split out from `generateTransactionRequest` so it runs exactly once. Under Ledger * clear-signing the device is shown these values and signs over them, then the host * finalizes from the device's response — if the root were re-derived in between, a * commitment landing in that window would change it, and the proof would assert a root * the device never signed. * * @param wallet - wallet to spend from * @param encryptionKey - encryption key of wallet */ deriveTransactionInputs(wallet: RailgunWallet, txidVersion: TXIDVersion, encryptionKey: string, mnemonicPassword?: string, canonicalOutputOrder?: boolean): Promise; /** * Turn derived inputs into the request the prover consumes: output ciphertext, * boundParams, and the public/private inputs bound to them. * * `overrideInternalOutputs` replaces the internal output notes with ones carrying the * randomness an external signer chose (Ledger clear-sign), so `npkOut` and * `commitmentsOut` bind to what the device actually signed rather than to host-generated * randomness. `overrideCommitmentCiphertext` supplies the matching device ciphertext, * already verified against the approved notes. Both are omitted on the blind path, which * behaves exactly as before. */ finalizeTransactionRequest(derived: DerivedTransactionInputs, wallet: RailgunWallet, txidVersion: TXIDVersion, globalBoundParams: PoseidonMerkleVerifier.GlobalBoundParamsStruct, overrides?: { readonly internalOutputs: readonly TransactNote[]; readonly commitmentCiphertext: readonly CommitmentCiphertextStructV2[]; }): Promise; /** * Build the plaintext transact the device reviews, from already-derived inputs. * * Returns the canonical-ordered request alongside `sourceIndices`, which maps each * device response slot back to the note that produced it. The caller must carry that * permutation: responses arrive in the device's order, not the engine's. */ buildClearSignRequest(derived: DerivedTransactionInputs, globalBoundParams: PoseidonMerkleVerifier.GlobalBoundParamsStruct): { request: ClearSignTransactRequest; sourceIndices: OrderedClearSignOutputs['sourceIndices']; }; /** * Derive then finalize in one step — the blind-signing path, unchanged. * * @param wallet - wallet to spend from * @param encryptionKey - encryption key of wallet */ generateTransactionRequest(wallet: RailgunWallet, txidVersion: TXIDVersion, encryptionKey: string, globalBoundParams: PoseidonMerkleVerifier.GlobalBoundParamsStruct, mnemonicPassword?: string): Promise; /** * Generate proof and return serialized transaction * @param prover - prover to use * @param wallet - wallet to spend from * @param encryptionKey - encryption key for wallet * @returns serialized transaction */ generateProvedTransaction(txidVersion: TXIDVersion, prover: Prover, unprovedTransactionInputs: UnprovedTransactionInputs, progressCallback: ProverProgressCallback): Promise; /** * Return serialized transaction with zero'd proof for gas estimates. * @param wallet - wallet to spend from * @param encryptionKey - encryption key for wallet * @returns serialized transaction */ generateDummyProvedTransaction(prover: Prover, transactionRequest: RailgunTransactionRequest): Promise; private static assertCanProve; private static createTransactionStructV2; private static createTransactionStructV3; static getLocalBoundParams(transaction: TransactionStructV2 | TransactionStructV3): PoseidonMerkleVerifier.TransactionBoundParamsStruct | BoundParamsStruct; } export { Transaction };