@imikailoby/sats
Version:
Tiny non-custodial Bitcoin SDK (TS) — keys, addresses, PSBT, provider chain
33 lines (32 loc) • 1.08 kB
TypeScript
import * as bitcoin from "bitcoinjs-lib";
import type { Utxo } from "../types";
/** Sum input values in satoshis. */
export declare function sumInputs(utxos: Utxo[]): number;
/** Sum output values plus a fixed fee. */
export declare function sumOutputs(outputs: {
address: string;
value: number;
}[], fee: number): number;
/** Calculate non-negative change amount. */
export declare function calcChange(totalIn: number, totalOut: number): number;
/**
* Build a PSBT for P2WPKH-like inputs.
* @throws PsbtBuildError | InsufficientFundsError
*/
export declare function buildPsbt(params: {
utxos: Utxo[];
outputs: {
address: string;
value: number;
}[];
changeAddress: string;
fee: number;
testnet?: boolean;
}): bitcoin.Psbt;
/** Sign PSBT with WIF or raw private key. */
export declare function signPsbt(psbt: bitcoin.Psbt, priv: Buffer | string, testnet?: boolean): bitcoin.Psbt;
/** Finalize all inputs and return hex and txid. */
export declare function finalizePsbt(psbt: bitcoin.Psbt): {
hex: string;
txid: string;
};