@nawab_kibria/bitcoin-lib
Version:
A comprehensive Bitcoin HD wallet library with BIP84, BIP44, BIP49 support, mnemonic generation and restoration
122 lines (121 loc) • 2.75 kB
TypeScript
import * as bitcoin from "bitcoinjs-lib";
export interface WalletKeys {
mnemonic: string;
xpub: string;
xpriv: string;
firstAddress: string;
zpub?: string;
zprv?: string;
taprootXpub?: string;
taprootXprv?: string;
}
export interface AddressDetails {
address: string;
publicKey: string;
privateKey: string;
derivationPath: string;
}
export interface WalletOptions {
mnemonic?: string;
network?: bitcoin.Network;
addressCount?: number;
}
export type AddressType = 'legacy' | 'segwit' | 'native-segwit';
export type ExtendedKeyFormat = 'xpub' | 'xprv' | 'ypub' | 'yprv' | 'zpub' | 'zprv' | 'tpub' | 'tprv' | 'upub' | 'uprv' | 'vpub' | 'vprv';
export interface ElectrumConfig {
host: string;
port: number;
ssl?: boolean;
timeout?: number;
}
export interface ElectrumBalance {
confirmed: number;
unconfirmed: number;
}
export interface ElectrumUTXO {
tx_hash: string;
tx_pos: number;
value: number;
height: number;
}
export interface ElectrumHistoryItem {
tx_hash: string;
height: number;
fee?: number;
}
export interface ElectrumResponse {
id: number;
result?: any;
error?: {
code: number;
message: string;
};
}
export interface ElectrumRequest {
id: number;
method: string;
params: any[];
}
export interface TransactionInput {
txHash: string;
outputIndex: number;
value: number;
address: string;
addressType: AddressType;
privateKey: string;
publicKey: string;
derivationPath?: string;
}
export interface TransactionOutput {
address: string;
value: number;
}
export interface FeeEstimate {
fastestFee: number;
halfHourFee: number;
hourFee: number;
economyFee: number;
minimumFee: number;
}
export interface TransactionOptions {
feeRate?: number;
changeAddress?: string;
subtractFeeFromOutputs?: number[];
rbf?: boolean;
minConfirmations?: number;
}
export interface PreparedTransaction {
hex: string;
txid: string;
fee: number;
size: number;
vsize: number;
inputs: TransactionInput[];
outputs: TransactionOutput[];
changeOutput?: TransactionOutput;
}
export interface BroadcastResult {
txid: string;
success: boolean;
error?: string;
}
export interface PSBTInput {
hash: string;
index: number;
witnessUtxo?: {
script: Buffer;
value: number;
};
nonWitnessUtxo?: Buffer;
bip32Derivation?: Array<{
masterFingerprint: Buffer;
path: string;
pubkey: Buffer;
}>;
}
export interface PSBTOptions {
network: bitcoin.Network;
inputs: PSBTInput[];
outputs: TransactionOutput[];
feeRate?: number;
}