import { Ecc } from './ecc.js'; import { Script } from './script.js'; import { type SigHashType } from './sigHashType.js'; import { SignData, Tx } from './tx.js'; /** * BIP 174 **magic bytes** for PSBT version 0: ASCII `psbt` + `0xff`. * Defined in BIP 174 “Specification > Version 0” (must be first bytes of a `.psbt`). * - https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#specification * - https://bips.dev/174/#specification */ export declare const PSBT_MAGIC: Uint8Array; /** * Bitcoin ABC `PSBT_IN_UTXO` (BIP 174 input type `0x00`): value is either the full * previous transaction (BIP “non-witness UTXO”) or a serialized `CTxOut` (amount + * scriptPubKey). This is the **only** key we use for spent-output data; BIP type * `0x01` is not handled like the node (see module TSDoc). Resolved in * {@link resolveWitnessFromKey00}. */ export declare const PSBT_IN_UTXO = 0; /** Strip input scripts for PSBT global unsigned transaction (BIP 174). */ export declare function txToUnsigned(tx: Tx): Tx; export interface PsbtInputMaps { witnessUtxo: { sats: bigint; scriptPubKey: Uint8Array; }; redeemScript?: Script; partialSigs: Map; } /** One PSBT key-value pair (BIP 174). */ export type PsbtKeyValue = { key: Uint8Array; value: Uint8Array; }; /** * BIP 174 PSBT for eCash multisig and ABC-aligned decode/encode. * See https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#serialization * * Typical flow: {@link Psbt.fromTx} from a partially signed {@link Tx} plus * {@link SignData} per input → {@link Psbt.toBytes} → share → {@link Psbt.fromBytes}. * Unknown key-value pairs are preserved (BIP 174). */ export declare class Psbt { /** Unsigned transaction (empty scriptSigs). */ readonly unsignedTx: Tx; /** Per-input signing data (amount, scripts, partial sig maps). */ readonly signDataPerInput: SignData[]; /** Per-input partial signatures: hex(pubkey) → signature incl. sighash byte. */ readonly inputPartialSigs: Map[]; /** * Unknown global key-value pairs (BIP 174: implementations must preserve * unknown keys on round-trip). */ readonly unknownGlobalPairs: PsbtKeyValue[]; /** Unknown per-input pairs (excluding consumed `PSBT_IN_UTXO` / `0x00` entries). */ readonly unknownInputPairs: PsbtKeyValue[][]; /** Unknown per-output pairs. */ readonly unknownOutputPairs: PsbtKeyValue[][]; /** * When true, this input had no `PSBT_IN_UTXO` (`0x00`) field in the PSBT (e.g. * creator-only PSBT or finalized script fields only). {@link toBytes} will * not emit that entry for the input. */ readonly inputWitnessIncomplete: boolean[]; constructor(params: { unsignedTx: Tx; signDataPerInput: SignData[]; inputPartialSigs: Map[]; unknownGlobalPairs?: PsbtKeyValue[]; unknownInputPairs?: PsbtKeyValue[][]; unknownOutputPairs?: PsbtKeyValue[][]; inputWitnessIncomplete?: boolean[]; }); /** * Build a PSBT from a transaction that may already include partial scriptSigs. * Populates `PSBT_IN_UTXO` (`0x00`) + redeem script + partial signatures. */ static fromTx(tx: Tx, signDataPerInput: SignData[], ecc: Ecc): Psbt; /** Deserialize PSBT bytes (BIP 174). */ static fromBytes(data: Uint8Array): Psbt; /** Serialize to BIP 174 bytes. */ toBytes(): Uint8Array; /** * Current transaction with scriptSigs built from partial signatures. * Attach each input's `signData` for signing and validation helpers. */ toTx(): Tx; /** * Add or merge a multisig signature on an input (same semantics as * {@link Tx.addMultisigSignature}). */ addMultisigSignature(params: { inputIdx: number; signature: Uint8Array; signData: SignData; ecc?: Ecc; }): Psbt; /** * Like {@link addMultisigSignature}, but signs with a secret key (see * {@link Tx.addMultisigSignatureFromKey}). */ addMultisigSignatureFromKey(params: { inputIdx: number; sk: Uint8Array; signData: SignData; sigHashType?: SigHashType; ecc?: Ecc; }): Psbt; /** * Same as {@link Tx.isFullySignedMultisig} on {@link toTx} (including * vacuous `true` when there are no multisig inputs). */ isFullySignedMultisig(): boolean; } //# sourceMappingURL=psbt.d.ts.map