@synonymdev/blocktank-lsp-http-client
Advanced tools
Comparing version 2.0.0 to 2.2.0
@@ -6,2 +6,3 @@ import { IBtInfo, IBtOrder, ICJitEntry } from './shared'; | ||
import { ICreateCjitOptions } from './ICreateCjitOptions'; | ||
import { IBtEstimateFeeResponse2 } from './shared/IBtEstimateFeeResponse2'; | ||
export declare class BlocktankClientError extends Error { | ||
@@ -34,2 +35,11 @@ data: any; | ||
/** | ||
* Estimates the fee to create a channel order without actually creating an order. | ||
* Includes network and service fee. | ||
* @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. | ||
* @param channelExpiryWeeks Number of weeks the channel will be leased for before the LSP may close the channel. | ||
* @param options Optional parameters. | ||
* @returns | ||
*/ | ||
estimateOrderFeeFull(lspBalanceSat: number, channelExpiryWeeks: number, options?: Partial<ICreateOrderOptions>): Promise<IBtEstimateFeeResponse2>; | ||
/** | ||
* Create a new channel order. | ||
@@ -36,0 +46,0 @@ * @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. |
@@ -30,3 +30,3 @@ "use strict"; | ||
class BlocktankClient { | ||
constructor(_baseUrl = 'https://blocktank.synonym.to/api/v2') { | ||
constructor(_baseUrl = 'https://api1.blocktank.to/api') { | ||
this._baseUrl = _baseUrl; | ||
@@ -84,2 +84,19 @@ } | ||
/** | ||
* Estimates the fee to create a channel order without actually creating an order. | ||
* Includes network and service fee. | ||
* @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. | ||
* @param channelExpiryWeeks Number of weeks the channel will be leased for before the LSP may close the channel. | ||
* @param options Optional parameters. | ||
* @returns | ||
*/ | ||
estimateOrderFeeFull(lspBalanceSat, channelExpiryWeeks, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const opts = Object.assign({}, ICreateOrderOptions_1.defaultCreateOrderOptions, options); | ||
return yield this.wrapErrorHandler(`Failed to estimate channel order fee.`, () => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield axios_1.default.post(this.baseUrl + '/channels/estimate-fee-full', Object.assign(Object.assign({}, opts), { lspBalanceSat: lspBalanceSat, channelExpiryWeeks: channelExpiryWeeks })); | ||
return response.data; | ||
})); | ||
}); | ||
} | ||
/** | ||
* Create a new channel order. | ||
@@ -86,0 +103,0 @@ * @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. |
@@ -42,3 +42,3 @@ import { BitcoinNetworkEnum } from './BitcoinNetwork.enum'; | ||
/** | ||
* Maximum clientBalanceSat in general. | ||
* @deprecated Same as maxChannelSizeSat. | ||
*/ | ||
@@ -45,0 +45,0 @@ maxClientBalanceSat: number; |
@@ -22,4 +22,10 @@ import { IBtChannel } from "./IBtChannel"; | ||
/** | ||
* Requested funds on the LSP side. | ||
* Onchain transaction fees for the channel open. | ||
* This is variable depending on the network fee conditions. | ||
*/ | ||
networkFeeSat: number; | ||
/** | ||
* Service fees to pay for us to fulfill the channel open. Includes liquidity fees. | ||
*/ | ||
serviceFeeSat: number; | ||
lspBalanceSat: number; | ||
@@ -26,0 +32,0 @@ /** |
@@ -20,2 +20,11 @@ import { ILspNode } from './ILspNode'; | ||
/** | ||
* Onchain transaction fees for the channel open. | ||
* This is variable depending on the network fee conditions. | ||
*/ | ||
networkFeeSat: number; | ||
/** | ||
* Service fees to pay for us to fulfill the channel open. Includes liquidity fees. | ||
*/ | ||
serviceFeeSat: number; | ||
/** | ||
* Requested channel size in satoshi | ||
@@ -22,0 +31,0 @@ */ |
{ | ||
"name": "@synonymdev/blocktank-lsp-http-client", | ||
"version": "2.0.0", | ||
"version": "2.2.0", | ||
"description": "Blocktank Http Api Client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -36,2 +36,18 @@ import {BlocktankClient} from './BlocktankClient' | ||
test('estimate fee2', async () => { | ||
const client = new BlocktankClient(serviceUrl) | ||
const info = await client.getInfo() | ||
const firstNodeId = info.nodes[0].pubkey; | ||
const estimate = await client.estimateOrderFeeFull(100*1000, 10, { | ||
clientBalanceSat: 20*1000, | ||
couponCode: 'test', | ||
lspNodeId: firstNodeId, | ||
turboChannel: true, | ||
}) | ||
expect(estimate.feeSat).toBeGreaterThan(0) | ||
expect(estimate.networkFeeSat).toBeDefined() | ||
expect(estimate.serviceFeeSat).toBeDefined() | ||
expect(estimate.min0ConfTxFee.satPerVByte).toBeGreaterThan(0) | ||
}) | ||
test('createOrder regular', async () => { | ||
@@ -130,4 +146,3 @@ const client = new BlocktankClient(serviceUrl) | ||
order.id, | ||
'03775370500b8c8642617bced873e7914eaec4f6a79c9ca99043224a1b28677082@172.19.0.7:9735', | ||
true | ||
'03775370500b8c8642617bced873e7914eaec4f6a79c9ca99043224a1b28677082@172.19.0.7:9735' | ||
) | ||
@@ -148,4 +163,3 @@ console.log('order', openOrder) | ||
orderId, | ||
'03a384c1182026376425293e5e5df8516f2130d0c621364cda1e6ca922ce3ade62@172.20.0.4:9735', | ||
true | ||
'03a384c1182026376425293e5e5df8516f2130d0c621364cda1e6ca922ce3ade62@172.20.0.4:9735' | ||
) | ||
@@ -152,0 +166,0 @@ console.log('success', openOrder.channel) |
@@ -7,2 +7,3 @@ import axios from 'axios'; | ||
import { ICreateCjitOptions } from './ICreateCjitOptions'; | ||
import { IBtEstimateFeeResponse2 } from './shared/IBtEstimateFeeResponse2'; | ||
@@ -22,3 +23,3 @@ | ||
export class BlocktankClient { | ||
constructor(private _baseUrl: string = 'https://blocktank.synonym.to/api/v2') { } | ||
constructor(private _baseUrl: string = 'https://api1.blocktank.to/api') { } | ||
@@ -77,2 +78,23 @@ get baseUrl(): string { | ||
/** | ||
* Estimates the fee to create a channel order without actually creating an order. | ||
* Includes network and service fee. | ||
* @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. | ||
* @param channelExpiryWeeks Number of weeks the channel will be leased for before the LSP may close the channel. | ||
* @param options Optional parameters. | ||
* @returns | ||
*/ | ||
async estimateOrderFeeFull(lspBalanceSat: number, channelExpiryWeeks: number, options: Partial<ICreateOrderOptions> = {}): Promise<IBtEstimateFeeResponse2> { | ||
const opts: any = Object.assign({}, defaultCreateOrderOptions, options) | ||
return await this.wrapErrorHandler(`Failed to estimate channel order fee.`, async () => { | ||
const response = await axios.post(this.baseUrl + '/channels/estimate-fee-full', { | ||
...opts, | ||
lspBalanceSat: lspBalanceSat, | ||
channelExpiryWeeks: channelExpiryWeeks | ||
}) | ||
return response.data; | ||
}) | ||
} | ||
/** | ||
* Create a new channel order. | ||
@@ -79,0 +101,0 @@ * @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84716
1826
101