@synonymdev/blocktank-lsp-http-client
Advanced tools
Comparing version 0.7.0 to 0.9.0
@@ -46,3 +46,3 @@ import { IBtInfo, IBtOrder, ICJitEntry } from './shared'; | ||
/** | ||
* Create a new channel order. | ||
* Estimates the fee to create a channel order without actually creating an order. | ||
* @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. | ||
@@ -53,2 +53,12 @@ * @param channelExpiryWeeks Number of weeks the channel will be leased for before the LSP may close the channel. | ||
*/ | ||
estimateOrderFee(lspBalanceSat: number, channelExpiryWeeks: number, options?: Partial<ICreateOrderOptions>): Promise<{ | ||
feeSat: number; | ||
}>; | ||
/** | ||
* Create a new channel order. | ||
* @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 | ||
*/ | ||
createOrder(lspBalanceSat: number, channelExpiryWeeks: number, options?: Partial<ICreateOrderOptions>): Promise<IBtOrder>; | ||
@@ -55,0 +65,0 @@ /** |
@@ -73,3 +73,3 @@ "use strict"; | ||
/** | ||
* Create a new channel order. | ||
* Estimates the fee to create a channel order without actually creating an order. | ||
* @param lspBalanceSat Number of satoshi that the LSP will provide on their channel side initially. | ||
@@ -80,2 +80,20 @@ * @param channelExpiryWeeks Number of weeks the channel will be leased for before the LSP may close the channel. | ||
*/ | ||
estimateOrderFee(lspBalanceSat, channelExpiryWeeks, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const opts = Object.assign({}, exports.defaultCreateOrderOptions, options); | ||
opts.zeroConf = opts.turboChannel; | ||
delete opts.turboChannel; | ||
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', Object.assign(Object.assign({}, opts), { lspBalanceSat: lspBalanceSat, channelExpiryWeeks: channelExpiryWeeks })); | ||
return response.data; | ||
})); | ||
}); | ||
} | ||
/** | ||
* Create a new channel order. | ||
* @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 | ||
*/ | ||
createOrder(lspBalanceSat, channelExpiryWeeks, options = {}) { | ||
@@ -82,0 +100,0 @@ return __awaiter(this, void 0, void 0, function* () { |
import { ILspNode } from './ILspNode'; | ||
export interface IBtInfo { | ||
/** | ||
* Current Blocktank version | ||
* @deprecated Use the `versions` object instead. | ||
*/ | ||
@@ -45,2 +45,19 @@ version: number; | ||
}; | ||
/** | ||
* SemVer versions of the micro services. | ||
*/ | ||
versions: { | ||
/** | ||
* SemVer versions of the http micro services. | ||
*/ | ||
http: string; | ||
/** | ||
* SemVer versions of the btc micro services. | ||
*/ | ||
btc: string; | ||
/** | ||
* SemVer versions of the ln2 micro services. | ||
*/ | ||
ln2: string; | ||
}; | ||
} |
@@ -9,2 +9,3 @@ export interface IBtOnchainTransaction { | ||
confirmed: boolean; | ||
suspicious0ConfReason: string; | ||
} |
{ | ||
"name": "@synonymdev/blocktank-lsp-http-client", | ||
"version": "0.7.0", | ||
"version": "0.9.0", | ||
"description": "Blocktank Http Api Client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -12,4 +12,18 @@ import {BlocktankClient} from './BlocktankClient' | ||
expect(info.version).toEqual(2) | ||
expect(info.versions.ln2).toBeDefined() | ||
}) | ||
test('estimate fee', async () => { | ||
const client = new BlocktankClient(serviceUrl) | ||
const info = await client.getInfo() | ||
const firstNodeId = info.nodes[0].pubkey; | ||
const {feeSat} = await client.estimateOrderFee(100*1000, 10, { | ||
clientBalanceSat: 20*1000, | ||
couponCode: 'test', | ||
lspNodeId: firstNodeId, | ||
turboChannel: true, | ||
}) | ||
expect(feeSat).toBeGreaterThan(0) | ||
}) | ||
test('createOrder regular', async () => { | ||
@@ -16,0 +30,0 @@ const client = new BlocktankClient(serviceUrl) |
@@ -82,2 +82,23 @@ import axios from 'axios'; | ||
/** | ||
* Estimates the fee to create a channel order without actually creating an order. | ||
* @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 estimateOrderFee(lspBalanceSat: number, channelExpiryWeeks: number, options: Partial<ICreateOrderOptions> = {}): Promise<{feeSat: number}> { | ||
const opts: any = Object.assign({}, defaultCreateOrderOptions, options) | ||
opts.zeroConf = opts.turboChannel | ||
delete opts.turboChannel | ||
return await this.wrapErrorHandler(`Failed to estimate channel order fee.`, async () => { | ||
const response = await axios.post(this.baseUrl + '/channels/estimate-fee', { | ||
...opts, | ||
lspBalanceSat: lspBalanceSat, | ||
channelExpiryWeeks: channelExpiryWeeks | ||
}) | ||
return response.data; | ||
}) | ||
} | ||
/** | ||
* Create a new channel order. | ||
@@ -84,0 +105,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
57519
1107
65