import type { BitcoinCoinConfig } from "../config"; import { DerivationModes } from "./selectUtxos"; /** * The arguments of hw-app-btc's `createPaymentTransaction`, the derivation paths excepted: the * signer knows them. hw-app-btc sends the inputs and outputs to the Ledger app, which checks them, * shows the payment and returns one signature per input; hw-app-btc then serializes the signed * transaction and returns it (`createTransaction.ts`; for app-bitcoin-new, `BtcNew.ts` turns them * into a PSBT the app signs). Amounts are decimal strings. */ export type PaymentTransactionParameters = { currencyId: string; inputs: { /** Id of the transaction that created the spent output. */ txid: string; vout: number; value: string; /** That transaction, serialized (hex): the Ledger app verifies the spent amount from it. */ prevTxHex: string; sequence: number; }[]; /** The outputs, serialized in the currency's format (`createPaymentTransaction`'s `outputScriptHex`). */ outputScriptHex: string; /** Index of the change output, sent back to the account's address, if any. */ changeOutputIndex?: number; lockTime?: number; /** Expiry height, hex (4 bytes), for the formats that carry one. */ expiryHeight?: string; sigHashType: number; segwit: boolean; /** hw-app-btc's format flags (`additionals`). */ additionals: string[]; /** Whether previous transactions carry extra data (hw-app-btc `splitTransaction`). */ hasExtraData: boolean; }; /** * The transaction `craftTransaction` returns for the formats bitcoinjs-lib cannot serialize (Komodo, * Decred): the `createPaymentTransaction` arguments plus the outputs, serialized as JSON. hw-app-btc * serializes those formats itself. */ export type SigningRequest = { type: "bitcoin-signing-request"; version: 1; outputs: { script: string; value: string; }[]; } & PaymentTransactionParameters; export declare const SIGNING_REQUEST_TYPE: SigningRequest["type"]; /** * The outputs as hw-app-btc serializes them: count, then for each output its 8-byte value, then * its script. Decred inserts a 2-byte script version (0) before the script, as the bridge writes it * (`buildAndSign.ts`). */ export declare function serializeOutputs(outputs: { script: Buffer; value: bigint; }[], additionals: string[]): string; /** * The `createPaymentTransaction` format parameters of a currency, as the bridge derives them (`signOperation.ts`): * the currency id and the format flags of its config, the address format, the expiry height, the * extra-data flag, the sighash type and, for Komodo, the interest locktime. */ export declare function formatParameters(config: BitcoinCoinConfig, currencyId: string, derivationMode: DerivationModes, recipient: string, now: Date): Pick; /** The outputs of a signing request as hw-app-btc serializes them, from its `outputs`. */ export declare function requestOutputScript(request: SigningRequest): Buffer; /** * The signing request a crafted transaction carries, or `undefined` for a PSBT. A request that is * malformed, or whose `outputScriptHex` does not serialize its `outputs`, is refused. */ export declare function parseSigningRequest(tx: string): SigningRequest | undefined; /** * The arguments of hw-app-btc's `createPaymentTransaction` (the derivation paths excepted) for the * transaction `craftTransaction` returned, whatever its form: a PSBT for Bitcoin serialization, a * signing request for the formats bitcoinjs-lib cannot serialize. `createPaymentTransaction` serves * every Ledger bitcoin-family app; it is the only way for all of them but app-bitcoin-new, which can * also sign the PSBT itself. * * `options.recipient` is the recipient as the user entered it: some format flags depend on its * format (Bitcoin Cash's `cashaddr`, which makes the Ledger app show a cashaddr address). Without it, * the format Ledger Wallet shows is assumed. `config` is the currency's coin config, as for every * other method. */ export declare function paymentTransactionParameters(config: BitcoinCoinConfig, currencyId: string, tx: string, options?: { recipient?: string; now?: Date; }): PaymentTransactionParameters; //# sourceMappingURL=signingRequest.d.ts.map