bitmask-core
Version:
Core functionality for the BitMask wallet
151 lines • 5.45 kB
TypeScript
export declare const hashPassword: (password: string) => string;
export declare const decryptWallet: (hash: string, encryptedDescriptors: string, seedPassword?: string) => Promise<Vault>;
export declare const upgradeWallet: (hash: string, encryptedDescriptors: string, seedPassword?: string) => Promise<string>;
export declare const syncWallets: () => Promise<void>;
export declare const newWallet: (hash: string, seedPassword: string) => Promise<string>;
export declare const encryptWallet: (mnemonic: string, hash: string, seedPassword: string) => Promise<string>;
export declare const getWalletData: (descriptor: string, changeDescriptor?: string) => Promise<WalletData>;
export declare const getNewAddress: (descriptor: string, changeDescriptor?: string) => Promise<string>;
export declare const sendSats: (descriptor: string, changeDescriptor: string, address: string, amount: bigint, broadcast: boolean, feeRate: number) => Promise<TransactionData>;
export declare const fundVault: (descriptor: string, changeDescriptor: string, rgbAddress: string, broadcast: boolean, feeRate?: number) => Promise<FundVaultDetails>;
export declare const getAssetsVault: (rgbDescriptorXpub: string) => Promise<FundVaultDetails>;
export declare const drainWallet: (destination: string, descriptor: string, changeDescriptor?: string, feeRate?: number) => Promise<TransactionData>;
export declare const bumpFee: (txid: string, feeRate: number, broadcast: boolean, descriptor: string, changeDescriptor?: string) => Promise<TransactionData>;
export interface PrivateWalletData {
xprvkh: string;
btcDescriptorXprv: string;
btcChangeDescriptorXprv: string;
rgbDescriptorXprv: string;
nostrPrv: string;
nostrNsec: string;
}
export interface PublicWalletData {
xpubkh: string;
btcDescriptorXpub: string;
btcChangeDescriptorXpub: string;
rgbDescriptorXpub: string;
nostrPub: string;
nostrNpub: string;
}
export interface Vault {
mnemonic: string;
private: PrivateWalletData;
public: PublicWalletData;
}
export interface Transaction extends WalletTransaction {
amount: number;
asset?: string;
assetType: string;
fee: number;
message?: string;
note?: string;
}
export interface Activity extends Transaction {
id: string;
date: number;
action: string;
status: string;
lightning?: boolean;
sender?: {
name: string;
address: string;
};
recipient?: {
name: string;
address: string;
invoice: string;
};
}
export interface TransactionDetails extends Transaction {
sender: {
name: string;
address: string;
};
recipient: {
name: string;
address: string;
invoice: string;
};
}
export interface TransactionData {
details: TransactionDataDetails;
vsize: number;
feeRate: number;
}
export interface TransactionDataDetails {
transaction?: Transaction;
txid: string;
received: number;
sent: number;
fee: number;
confirmationTime?: ConfirmationTime;
confirmed?: boolean;
}
export interface ConfirmationTime {
height: number;
timestamp: number;
}
export interface WalletTransaction {
txid: string;
received: number;
sent: number;
fee: number;
confirmed: boolean;
confirmationTime: ConfirmationTime;
vsize: number;
feeRate: number;
}
export interface WalletBalance {
immature: number;
trustedPending: number;
untrustedPending: number;
confirmed: number;
}
export interface WalletData {
wallet?: string;
name: string;
address: string;
balance: WalletBalance;
transactions: WalletTransaction[];
utxos: string[];
}
export interface FundVaultDetails {
rgbOutput?: string;
isFunded: boolean;
fundTxid?: string;
fundFee?: number;
}
/**
* Fetch current fee estimates (sat/vB) from the configured Esplora endpoint.
* Esplora returns a JSON object keyed by confirmation target (e.g., "1","2","3","6",...)
* with floating-point sat/vB values.
* Example:
* { "1": 9.2, "2": 7.8, "3": 6.5, "6": 3.1, "144": 1.01 }
*/
export type FeeEstimates = Record<string, number>;
export declare function fetchFeeEstimates(): Promise<FeeEstimates>;
/**
* Compute absolute fee in sats from a sat/vB rate and an estimated vsize.
* Always ceil so we don't underpay policy minimums.
*/
export declare function feeFromRate(vbytes: number, satPerVb: number): number;
/**
* Rough vbytes guesser for swap/bid PSBTs when you don't yet know exact inputs/outputs.
* Prefer passing a conservative bound to avoid underpaying relays:
* - Default assumes ~2 inputs, ~3 outputs, taproot heavy mix, returns ~400 vB.
* - Scale linearly for more inputs/outputs.
*
* If you know inputs/outputs counts beforehand, pass them to tighten the estimate.
*/
export declare function guessSwapVbytes(inputs?: number, outputs?: number, taprootHeavy?: boolean): number;
/**
* Convenience: get a safe absolute fee quote for a swap given a target confirmation bucket.
* - bucket can be "1","2","3","6","144", etc., matching Esplora keys.
* - vbytesEstimate can be computed via guessSwapVbytes() or a tighter UI estimate.
* - Adds a small 10% safety margin on the feerate to reduce min-relay rejections.
*/
export declare function quoteSwapFeeSats(bucket: string, vbytesEstimate: number): Promise<{
rate: number;
fee: number;
}>;
//# sourceMappingURL=bitcoin.d.ts.map