UNPKG

@bitgo/utxo-lib

Version:

Client-side Bitcoin JavaScript library

88 lines 4.5 kB
import { Payment } from 'bitcoinjs-lib'; import { PsbtOutput, PsbtOutputUpdate } from 'bip174/src/lib/interfaces'; import { UtxoPsbt } from '../UtxoPsbt'; import { RootWalletKeys, DerivedWalletKeys } from './WalletKeys'; import { ChainCode } from './chains'; import { ScriptId } from './ScriptId'; /** * Get the BIP32 derivation data for a PSBT output. * * @param rootWalletKeys root wallet keys used for master fingerprints * @param walletKeys derived wallet keys for the specific chain and index * @param scriptType the script type to determine whether to use regular or taproot derivation * @param payment optional payment object for taproot scripts to calculate leaf hashes * @returns Object containing BIP32 derivation data */ export declare function getPsbtBip32DerivationOutputUpdate(rootWalletKeys: RootWalletKeys, walletKeys: DerivedWalletKeys, scriptType: string, payment?: Payment): PsbtOutputUpdate; /** * Get the PSBT output update object from a PSBT output and output script. * * @param output the PSBT output to get update for * @param outputScript the output script * @param rootWalletKeys keys that will be able to spend the output * @param chain chain code to use for deriving scripts (and to determine script type) * @param index derivation index for the change address * @returns PsbtOutputUpdate object with the required information */ export declare function getPsbtOutputUpdateFromPsbtOutput(output: PsbtOutput, outputScript: Buffer, rootWalletKeys: RootWalletKeys, chain: ChainCode, index: number): PsbtOutputUpdate; /** * Get the PSBT output update object with the required information. * * @param psbt the PSBT to get output update for * @param rootWalletKeys keys that will be able to spend the output * @param outputIndex output index where to update the output * @param chain chain code to use for deriving scripts (and to determine script * type) chain is an API parameter in the BitGo API, and may be * any valid ChainCode * @param index derivation index for the change address * @returns PsbtOutputUpdate object with the required information */ export declare function getPsbtOutputUpdate(psbt: UtxoPsbt, rootWalletKeys: RootWalletKeys, outputIndex: number, chain: ChainCode, index: number): PsbtOutputUpdate; /** * Update the wallet output with the required information when necessary. If the * information is there already, it will skip over it. * * This function assumes that the output script and value have already been set. * * @param psbt the PSBT to update change output at * @param rootWalletKeys keys that will be able to spend the output * @param outputIndex output index where to update the output * @param chain chain code to use for deriving scripts (and to determine script * type) chain is an API parameter in the BitGo API, and may be * any valid ChainCode * @param index derivation index for the change address */ export declare function updateWalletOutputForPsbt(psbt: UtxoPsbt, rootWalletKeys: RootWalletKeys, outputIndex: number, chain: ChainCode, index: number): void; /** * Add a verifiable wallet output to the PSBT. The output and all data * needed to verify it from public keys only are added to the PSBT. * Typically these are change outputs. * * @param psbt the PSBT to add change output to * @param rootWalletKeys keys that will be able to spend the output * @param chain chain code to use for deriving scripts (and to determine script * type) chain is an API parameter in the BitGo API, and may be * any valid ChainCode * @param index derivation index for the change address * @param value value of the change output */ export declare function addWalletOutputToPsbt(psbt: UtxoPsbt, rootWalletKeys: RootWalletKeys, chain: ChainCode, index: number, value: bigint, { addDerivationInfo }?: { addDerivationInfo?: boolean; }): void; /** * Get the script id from the output. * The output can have either bip32Derivation or tapBip32Derivation, but not both. * @param output * @throws Error if neither or both bip32Derivation and tapBip32Derivation are present * @throws Error if the output is empty * @throws Error if we cannot fold the script ids into a single script id */ export declare function getScriptIdFromOutput(output: { bip32Derivation?: { path: string; }[]; tapBip32Derivation?: { path: string; }[]; }): ScriptId; //# sourceMappingURL=WalletOutput.d.ts.map