/* tslint:disable */ /* eslint-disable */ /** * barkd REST API * A simple REST API for barkd, a wallet daemon for integrating bitcoin payments into your app over HTTP. Supports self-custodial Lightning, Ark, and on-chain out of the box. barkd is a long-running daemon best suited for always-on or high-connectivity environments like nodes, servers, desktops, and point-of-sale terminals. All endpoints return JSON. Amounts are denominated in satoshis. * * The version of the OpenAPI document: 0.6.1 * Contact: hello@second.tech * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { BadRequestError, FeeEstimateResponse, InternalServerError, NotFoundError, OffboardFeeEstimateRequest, OnchainFeeRatesResponse, } from '../models/index'; import { BadRequestErrorFromJSON, BadRequestErrorToJSON, FeeEstimateResponseFromJSON, FeeEstimateResponseToJSON, InternalServerErrorFromJSON, InternalServerErrorToJSON, NotFoundErrorFromJSON, NotFoundErrorToJSON, OffboardFeeEstimateRequestFromJSON, OffboardFeeEstimateRequestToJSON, OnchainFeeRatesResponseFromJSON, OnchainFeeRatesResponseToJSON, } from '../models/index'; export interface BoardFeeRequest { amountSat: number; } export interface LightningReceiveFeeRequest { amountSat: number; } export interface LightningSendFeeRequest { amountSat: number; } export interface OffboardAllFeeRequest { address: string; } export interface OffboardFeeRequest { offboardFeeEstimateRequest: OffboardFeeEstimateRequest; } export interface SendOnchainFeeRequest { amountSat: number; address: string; } /** * */ export class FeesApi extends runtime.BaseAPI { /** * Creates request options for boardFee without sending the request */ async boardFeeRequestOpts(requestParameters: BoardFeeRequest): Promise { if (requestParameters['amountSat'] == null) { throw new runtime.RequiredError( 'amountSat', 'Required parameter "amountSat" was null or undefined when calling boardFee().' ); } const queryParameters: any = {}; if (requestParameters['amountSat'] != null) { queryParameters['amount_sat'] = requestParameters['amountSat']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/board`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Estimates the Ark protocol fee for boarding the specified amount of on-chain bitcoin. The net amount is what the user receives as a VTXO. Does not include the on-chain transaction fee for the board anchor transaction. * Estimate board fee */ async boardFeeRaw(requestParameters: BoardFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.boardFeeRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FeeEstimateResponseFromJSON(jsonValue)); } /** * Estimates the Ark protocol fee for boarding the specified amount of on-chain bitcoin. The net amount is what the user receives as a VTXO. Does not include the on-chain transaction fee for the board anchor transaction. * Estimate board fee */ async boardFee(requestParameters: BoardFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.boardFeeRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for lightningReceiveFee without sending the request */ async lightningReceiveFeeRequestOpts(requestParameters: LightningReceiveFeeRequest): Promise { if (requestParameters['amountSat'] == null) { throw new runtime.RequiredError( 'amountSat', 'Required parameter "amountSat" was null or undefined when calling lightningReceiveFee().' ); } const queryParameters: any = {}; if (requestParameters['amountSat'] != null) { queryParameters['amount_sat'] = requestParameters['amountSat']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/lightning/receive`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Estimates the fee for receiving the specified amount over Lightning. The gross amount is the Lightning payment amount, and the net amount is what the user receives as a VTXO after the Ark server deducts its fee. * Estimate Lightning receive fee */ async lightningReceiveFeeRaw(requestParameters: LightningReceiveFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.lightningReceiveFeeRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FeeEstimateResponseFromJSON(jsonValue)); } /** * Estimates the fee for receiving the specified amount over Lightning. The gross amount is the Lightning payment amount, and the net amount is what the user receives as a VTXO after the Ark server deducts its fee. * Estimate Lightning receive fee */ async lightningReceiveFee(requestParameters: LightningReceiveFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.lightningReceiveFeeRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for lightningSendFee without sending the request */ async lightningSendFeeRequestOpts(requestParameters: LightningSendFeeRequest): Promise { if (requestParameters['amountSat'] == null) { throw new runtime.RequiredError( 'amountSat', 'Required parameter "amountSat" was null or undefined when calling lightningSendFee().' ); } const queryParameters: any = {}; if (requestParameters['amountSat'] != null) { queryParameters['amount_sat'] = requestParameters['amountSat']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/lightning/pay`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Estimates the fee for sending the specified amount over Lightning. The net amount is what the recipient receives. The fee depends on the VTXOs selected and their expiry. If the wallet has insufficient funds, returns a worst-case fee estimate assuming the user acquires enough funds to cover the payment. * Estimate Lightning send fee */ async lightningSendFeeRaw(requestParameters: LightningSendFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.lightningSendFeeRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FeeEstimateResponseFromJSON(jsonValue)); } /** * Estimates the fee for sending the specified amount over Lightning. The net amount is what the recipient receives. The fee depends on the VTXOs selected and their expiry. If the wallet has insufficient funds, returns a worst-case fee estimate assuming the user acquires enough funds to cover the payment. * Estimate Lightning send fee */ async lightningSendFee(requestParameters: LightningSendFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.lightningSendFeeRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for offboardAllFee without sending the request */ async offboardAllFeeRequestOpts(requestParameters: OffboardAllFeeRequest): Promise { if (requestParameters['address'] == null) { throw new runtime.RequiredError( 'address', 'Required parameter "address" was null or undefined when calling offboardAllFee().' ); } const queryParameters: any = {}; if (requestParameters['address'] != null) { queryParameters['address'] = requestParameters['address']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/offboard-all`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Estimates the fee for offboarding the entire Ark balance to the given on-chain address. The gross amount is the total spendable balance, and the net amount is what the user receives on-chain after fees. The fee depends on the destination address type, current fee rates, and VTXO expiry. * Estimate offboard-all fee */ async offboardAllFeeRaw(requestParameters: OffboardAllFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.offboardAllFeeRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FeeEstimateResponseFromJSON(jsonValue)); } /** * Estimates the fee for offboarding the entire Ark balance to the given on-chain address. The gross amount is the total spendable balance, and the net amount is what the user receives on-chain after fees. The fee depends on the destination address type, current fee rates, and VTXO expiry. * Estimate offboard-all fee */ async offboardAllFee(requestParameters: OffboardAllFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.offboardAllFeeRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for offboardFee without sending the request */ async offboardFeeRequestOpts(requestParameters: OffboardFeeRequest): Promise { if (requestParameters['offboardFeeEstimateRequest'] == null) { throw new runtime.RequiredError( 'offboardFeeEstimateRequest', 'Required parameter "offboardFeeEstimateRequest" was null or undefined when calling offboardFee().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/offboard`; return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: OffboardFeeEstimateRequestToJSON(requestParameters['offboardFeeEstimateRequest']), }; } /** * Estimates the fee for offboarding a specific set of VTXOs to the given on-chain address. Each VTXO is offboarded in full. The gross amount is the total value of the selected VTXOs, and the net amount is what the user receives on-chain after fees. The fee depends on the destination address type, current fee rates, and VTXO expiry. * Estimate offboard fee */ async offboardFeeRaw(requestParameters: OffboardFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.offboardFeeRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FeeEstimateResponseFromJSON(jsonValue)); } /** * Estimates the fee for offboarding a specific set of VTXOs to the given on-chain address. Each VTXO is offboarded in full. The gross amount is the total value of the selected VTXOs, and the net amount is what the user receives on-chain after fees. The fee depends on the destination address type, current fee rates, and VTXO expiry. * Estimate offboard fee */ async offboardFee(requestParameters: OffboardFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.offboardFeeRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for onchainFeeRates without sending the request */ async onchainFeeRatesRequestOpts(): Promise { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/onchain`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Returns the current mempool fee rates from the chain source at three confirmation targets: fast (~1 block), regular (~3 blocks), and slow (~6 blocks). Rates are in sat/vB, rounded up. * Get on-chain fee rates */ async onchainFeeRatesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.onchainFeeRatesRequestOpts(); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OnchainFeeRatesResponseFromJSON(jsonValue)); } /** * Returns the current mempool fee rates from the chain source at three confirmation targets: fast (~1 block), regular (~3 blocks), and slow (~6 blocks). Rates are in sat/vB, rounded up. * Get on-chain fee rates */ async onchainFeeRates(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.onchainFeeRatesRaw(initOverrides); return await response.value(); } /** * Creates request options for sendOnchainFee without sending the request */ async sendOnchainFeeRequestOpts(requestParameters: SendOnchainFeeRequest): Promise { if (requestParameters['amountSat'] == null) { throw new runtime.RequiredError( 'amountSat', 'Required parameter "amountSat" was null or undefined when calling sendOnchainFee().' ); } if (requestParameters['address'] == null) { throw new runtime.RequiredError( 'address', 'Required parameter "address" was null or undefined when calling sendOnchainFee().' ); } const queryParameters: any = {}; if (requestParameters['amountSat'] != null) { queryParameters['amount_sat'] = requestParameters['amountSat']; } if (requestParameters['address'] != null) { queryParameters['address'] = requestParameters['address']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/fees/send-onchain`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Estimates the total fee for sending bitcoin from the Ark wallet to an on-chain address. The fee depends on the destination address type and current fee rates. The gross amount is what the user pays (including VTXOs spent), and the net amount is what the recipient receives on-chain. * Estimate send-onchain fee */ async sendOnchainFeeRaw(requestParameters: SendOnchainFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.sendOnchainFeeRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FeeEstimateResponseFromJSON(jsonValue)); } /** * Estimates the total fee for sending bitcoin from the Ark wallet to an on-chain address. The fee depends on the destination address type and current fee rates. The gross amount is what the user pays (including VTXOs spent), and the net amount is what the recipient receives on-chain. * Estimate send-onchain fee */ async sendOnchainFee(requestParameters: SendOnchainFeeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.sendOnchainFeeRaw(requestParameters, initOverrides); return await response.value(); } }