UNPKG

@bigmi/core

Version:

TypeScript library for Bitcoin apps.

23 lines 686 B
import { urlWithParams } from '../../utils/url.js'; import { getRpcErrorCode } from './utils.js'; export const getBalance = async (client, { baseUrl, apiKey }, { address }) => { const apiUrl = urlWithParams(`${baseUrl}/addrs/${address}`, { token: apiKey, }); const response = (await client.request({ url: apiUrl, fetchOptions: { method: 'GET' }, })); if (response.error) { return { error: { code: getRpcErrorCode(response.error), message: response.error, }, }; } return { result: BigInt(response.balance), }; }; //# sourceMappingURL=getBalance.js.map