@xlink-network/xlink-sdk
Version:
31 lines (28 loc) • 1.53 kB
TypeScript
import { EstimationInput } from '@c4/btc-utils';
interface UTXOBasic {
txId: string;
index: number;
amount: bigint;
}
interface UTXOConfirmed extends UTXOBasic {
blockHeight: bigint;
}
type UTXOSpendable = EstimationInput & UTXOBasic & {
scriptPubKey: Uint8Array;
};
interface BitcoinNetwork {
bech32: string;
pubKeyHash: number;
scriptHash: number;
wif: number;
}
declare function sumUTXO(utxos: Array<UTXOBasic>): bigint;
declare function isSameUTXO(utxo1: UTXOBasic, utxo2: UTXOBasic): boolean;
declare function addressToScriptPubKey(network: BitcoinNetwork, address: string): Uint8Array;
declare function scriptPubKeyToAddress(network: BitcoinNetwork, output: Uint8Array): string;
declare function bitcoinToSatoshi(bitcoinAmount: string): bigint;
declare function satoshiToBitcoin(satoshiAmount: bigint): string;
declare function getP2TRInternalPublicKey_from_P2TR_publicKey(network: BitcoinNetwork, publicKey: Uint8Array): Uint8Array;
declare function getTapInternalKey_from_P2TR_publicKey(network: BitcoinNetwork, publicKey: Uint8Array): Uint8Array;
declare function getRedeemScript_from_P2SH_P2WPKH_publicKey(network: BitcoinNetwork, publicKey: Uint8Array): Uint8Array;
export { type BitcoinNetwork, type UTXOBasic, type UTXOConfirmed, type UTXOSpendable, addressToScriptPubKey, bitcoinToSatoshi, getP2TRInternalPublicKey_from_P2TR_publicKey, getRedeemScript_from_P2SH_P2WPKH_publicKey, getTapInternalKey_from_P2TR_publicKey, isSameUTXO, satoshiToBitcoin, scriptPubKeyToAddress, sumUTXO };