UNPKG

@zebec-network/exchange-card-sdk

Version:
57 lines (56 loc) 1.81 kB
import * as bitcoin from "bitcoinjs-lib"; import { APIConfig } from "../helpers/apiHelpers"; import { Quote } from "../types"; interface BitcoinWallet { address: string; signTransaction: (psbt: bitcoin.Psbt) => Promise<bitcoin.Psbt>; broadcastTransaction: (tx: string) => Promise<string>; } export declare class BitcoinService { readonly wallet: BitcoinWallet; private apiService; private network; private apiEndpoint; constructor(wallet: BitcoinWallet, apiConfig: APIConfig, sdkOptions?: { sandbox?: boolean; apiKey?: string; }); /** * Fetches a quote for Bitcoin transfer. * * @returns {Promise<Quote>} A promise that resolves to a Quote object. */ fetchQuote(): Promise<Quote>; /** * Fetches the Bitcoin vault address. * * @returns {Promise<{ address: string }>} A promise that resolves to the vault address. */ fetchVault(): Promise<{ address: string; tag?: string; }>; getUTXOs(): Promise<Array<{ txid: string; vout: number; value: number; rawTx: Buffer; }>>; private getBalance; /** * Transfers Bitcoin to the vault address. * * @param {string} amount - The amount of BTC to transfer in BTC units * @param {number} feeRate - Fee rate in satoshis per byte * @returns {Promise<string>} - A promise that resolves to the transaction hash * @throws {Error} If there is not enough balance or if the transaction fails. */ transferBTC(amount: string, feeRate?: number): Promise<string>; /** * Gets the balance of the Bitcoin wallet. * * @returns {Promise<string>} - A promise that resolves to the wallet balance in BTC */ getWalletBalance(): Promise<string>; } export {};