UNPKG

@bigmi/core

Version:

TypeScript library for Bitcoin apps.

29 lines 939 B
import { RpcErrorCode } from '../../errors/rpc.js'; import { urlWithParams } from '../../utils/url.js'; export const getTransactionFee = async (client, { baseUrl, apiKey }, { txId }) => { const apiUrl = urlWithParams(`${baseUrl}/dashboards/transaction/${txId}`, { key: apiKey, }); const response = (await client.request({ url: apiUrl, fetchOptions: { method: 'GET', }, })); if (!response.data[txId] || response.context.error || response.context?.code !== 200) { return { error: { code: response.context.code === 429 ? RpcErrorCode.ACCESS_DENIED : RpcErrorCode.MISC_ERROR, message: response.context?.error, }, }; } return { result: BigInt(response.data[txId].transaction.fee), }; }; //# sourceMappingURL=getTransactionFee.js.map