import { RailgunWallet } from '../wallet/railgun-wallet'; import { Prover } from '../prover/prover'; import { Transaction } from './transaction'; import { SpendingSolutionGroup, UnshieldData } from '../models/txo-types'; import { AdaptID, TokenData } from '../models/formatted-types'; import { TransactionStructV2, TransactionStructV3 } from '../models/transaction-types'; import { SigningEnvelope } from '../solutions/nullifiers'; import { Chain } from '../models/engine-types'; import { TransactNote } from '../note/transact-note'; import { PreTransactionPOIsPerTxidLeafPerList, TXIDVersion, TreeBalance } from '../models'; export declare const GAS_ESTIMATE_VARIANCE_DUMMY_TO_ACTUAL_TRANSACTION = 9000; export declare class TransactionBatch { private adaptID; private chain; private outputs; private unshieldDataMap; private overallBatchMinGasPrice; /** * Create TransactionBatch Object * @param chain - chain type/id of network */ constructor(chain: Chain, overallBatchMinGasPrice?: bigint); addOutput(output: TransactNote): void; resetOutputs(): void; addUnshieldData(unshieldData: UnshieldData): void; resetUnshieldData(): void; private unshieldTotal; setAdaptID(adaptID: AdaptID): void; private getOutputTokenDatas; generateValidSpendingSolutionGroupsAllOutputs(wallet: RailgunWallet, txidVersion: TXIDVersion, originShieldTxidForSpendabilityOverride?: string, envelopeOverride?: SigningEnvelope): Promise; /** * Generates spending solution groups for outputs * @param wallet - wallet to spend from */ private generateValidSpendingSolutionGroups; private createSimpleSpendingSolutionGroupsIfPossible; /** * Finds exact group of UTXOs above required amount. */ private static createSimpleSatisfyingUTXOGroup; /** * Finds array of UTXOs groups that satisfies the required amount, excluding an already-used array of UTXO IDs. */ createComplexSatisfyingSpendingSolutionGroups(tokenData: TokenData, tokenOutputs: TransactNote[], treeSortedBalances: TreeBalance[], signingEnvelope?: SigningEnvelope): SpendingSolutionGroup[]; /** Outputs of the transaction built from a group: its notes, change if any, an unshield. */ private static outputCount; static getChangeOutput(wallet: RailgunWallet, spendingSolutionGroup: SpendingSolutionGroup): Optional; /** * Generate proofs and return serialized transactions * @param prover - prover to use * @param wallet - wallet to spend from * @param encryptionKey - encryption key for wallet * @returns serialized transaction */ /** * Can this batch be clear-signed at all, independently of UTXO shape? * * Shape is the envelope's job. These are the properties that no choice of UTXOs can fix, * so they must disqualify clear-signing *before* solution generation runs — otherwise * `prefer` would select under the narrow envelope, succeed, and then throw at sign time * instead of falling back, which is precisely the downgrade the mode exists to make * automatic. */ private clearSignDisqualification; /** * Pick the signing mode for this batch and produce the solution groups that go with it. * * Clear-signing is shape-limited; blind signing covers effectively every circuit. A * device that can do the former can always do the latter, so this walks the wallet's * attempts in preference order and keeps the first whose envelope can actually satisfy * the request. The chosen mode and the groups are returned together because they are one * decision: signing groups selected under a different envelope than the mode assumes is * the failure the envelope exists to prevent. * * All-or-nothing per batch, deliberately. A batch spanning several tokens could in * principle clear-sign one transaction and blind-sign another, but batch approval is a * single device interaction whose payload would then have to describe both kinds — a * device contract that cannot be validated without firmware. Mixed-mode batches are a * follow-up, not an accident to fall into here. */ private resolveSigningAttempt; generateTransactions(prover: Prover, wallet: RailgunWallet, txidVersion: TXIDVersion, encryptionKey: string, progressCallback: (progress: number, status: string) => void, shouldGeneratePreTransactionPOIs: boolean, originShieldTxidForSpendabilityOverride?: string, mnemonicPassword?: string): Promise<{ provedTransactions: (TransactionStructV2 | TransactionStructV3)[]; preTransactionPOIsPerTxidLeafPerList: PreTransactionPOIsPerTxidLeafPerList; }>; /** * One-line summary of what the user is approving. * * Under clear-sign the accompanying `publicInputs` are provisional — the device replaces * the output randomness — so this description, built from the plaintext notes, is the * part that is actually meaningful to a human at approval time. */ private static describeForApproval; private static logDummySpendingSolutionGroupsSummary; /** * Generate dummy proofs and return serialized transactions * @param wallet - wallet to spend from * @param encryptionKey - encryption key for wallet * @returns serialized transaction */ generateDummyTransactions(prover: Prover, wallet: RailgunWallet, txidVersion: TXIDVersion, encryptionKey: string, originShieldTxidForSpendabilityOverride?: string, mnemonicPassword?: string): Promise<(TransactionStructV2 | TransactionStructV3)[]>; generateTransactionForSpendingSolutionGroup(spendingSolutionGroup: SpendingSolutionGroup, changeOutput: Optional): Transaction; }