UNPKG

@arkade-os/sdk

Version:

Bitcoin wallet SDK with Taproot and Ark integration

44 lines (43 loc) 2.28 kB
import { TransactionOutput } from "@scure/btc-signer/psbt.js"; import { ExtendedCoin, VirtualCoin } from "../wallet"; import { RelativeTimelock } from "../script/tapscript"; import { EncodedVtxoScript, TapLeafScript } from "../script/base"; import { CSVMultisigTapscript } from "../script/tapscript"; import { Transaction } from "./transaction"; export type ArkTxInput = { tapLeafScript: TapLeafScript; } & EncodedVtxoScript & Pick<VirtualCoin, "txid" | "vout" | "value">; export type OffchainTx = { arkTx: Transaction; checkpoints: Transaction[]; }; /** * Builds an offchain transaction with checkpoint transactions. * * Creates one checkpoint transaction per input and a virtual transaction that * combines all the checkpoints, sending to the specified outputs. This is the * core function for creating Ark transactions. * * @param inputs - Array of virtual transaction inputs * @param outputs - Array of transaction outputs * @param serverUnrollScript - Server unroll script for checkpoint transactions * @returns Object containing the virtual transaction and checkpoint transactions */ export declare function buildOffchainTx(inputs: ArkTxInput[], outputs: TransactionOutput[], serverUnrollScript: CSVMultisigTapscript.Type): OffchainTx; export declare function hasBoardingTxExpired(coin: ExtendedCoin, boardingTimelock: RelativeTimelock): boolean; /** * Verify tapscript signatures on a transaction input * @param tx Transaction to verify * @param inputIndex Index of the input to verify * @param requiredSigners List of required signer pubkeys (hex encoded) * @param excludePubkeys List of pubkeys to exclude from verification (hex encoded, e.g., server key not yet signed) * @param allowedSighashTypes List of allowed sighash types (defaults to [SigHash.DEFAULT]) * @throws Error if verification fails */ export declare function verifyTapscriptSignatures(tx: Transaction, inputIndex: number, requiredSigners: string[], excludePubkeys?: string[], allowedSighashTypes?: number[]): void; /** * Merges the signed transaction with the original transaction * @param signedTx signed transaction * @param originalTx original transaction */ export declare function combineTapscriptSigs(signedTx: Transaction, originalTx: Transaction): Transaction;