@synonymdev/blocktank-client
Advanced tools
Comparing version 0.0.46 to 0.0.47
@@ -58,3 +58,3 @@ "use strict"; | ||
this.additionalHeaders = {}; | ||
this.setNetwork('testnet'); | ||
this.setNetwork('regtest'); | ||
} | ||
@@ -93,7 +93,7 @@ Client.getStateMessage = function (code) { | ||
case 'testnet': { | ||
this.host = 'http://35.233.47.252:443/blocktank/'; | ||
throw new Error('Network not yet supported'); | ||
break; | ||
} | ||
case 'regtest': { | ||
throw new Error('Network not yet supported'); | ||
this.host = 'http://35.233.47.252:443/blocktank/'; | ||
break; | ||
@@ -100,0 +100,0 @@ } |
{ | ||
"name": "@synonymdev/blocktank-client", | ||
"version": "0.0.46", | ||
"version": "0.0.47", | ||
"description": "LSP client library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
# Blocktank Client library | ||
### Description | ||
Client side library for interacting with the Blocktank LSP server | ||
Client side wrapper library for interacting with the Blocktank LSP server. For REST API docs see [synonym.readme.io](https://synonym.readme.io/) | ||
[Blocktank](https://blocktank.synonym.to/) is an LSP that allows businesses, apps, or online platforms to integrate, automate, and monetize services from your Lightning node. This includes channel configuration, channel purchases, channel info and more. | ||
For widget and complete code samples see [blocktank-ui](https://github.com/synonymdev/blocktank-ui) | ||
### Rest API docs | ||
https://synonym.readme.io/ | ||
## Getting started | ||
@@ -11,3 +18,3 @@ | ||
#or | ||
npm i -s @synonymdev/blocktank-client | ||
npm i -S @synonymdev/blocktank-client | ||
```` | ||
@@ -21,3 +28,6 @@ | ||
```javascript | ||
//Get all node info and available services | ||
// Choose network | ||
bt.setNetwork('mainnet'); // Options are 'mainnet' and 'regtest' | ||
// Get all node info and available services | ||
const info = await bt.getInfo(); | ||
@@ -27,4 +37,4 @@ | ||
//Place order | ||
const buy = await bt.buyChannel({ | ||
// 1. Place order | ||
const buyRes = await bt.buyChannel({ | ||
product_id: service.product_id, | ||
@@ -36,6 +46,54 @@ channel_expiry: 4, | ||
//Then pay for the order onchain using btc_address or via lightning with lnurl | ||
// 2. Make payment using one of below methods | ||
const {btc_address, ln_invoice} = buyRes; | ||
//Check order status and details | ||
// 3. Get order details for current state | ||
const order = await bt.getOrder(buy.order_id); | ||
// 4. Make an onchain transaction using the below min fee with RBF disabled to instantly be able to claim your channel | ||
const {zero_conf_satvbyte, zero_conf_satvbyte_expiry} = order; | ||
// Once order state === 100 a channel can be claimed | ||
const {state, stateMessage} = order; | ||
// For all order states see: https://github.com/synonymdev/blocktank-client/blob/f8a20c35a4953435cecf8f718ee555e311e1db9b/src/services/client.ts#L15 | ||
// 5. Claim lnurl-channel | ||
const {lnurl_string} = order; | ||
// Or claim manually with an additional method | ||
try { | ||
await bt.finalizeChannel({ | ||
order_id: order._id, | ||
node_uri: '0296b2db342fcf87ea94d981757fdf4d3e545bd5cef4919f58b5d38dfdd73bf5c9@34.79.58.84:9735', | ||
private: true // For mobile nodes that won't be routing transactions | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
``` | ||
## Development | ||
### `yarn build` | ||
Builds library ready for production use. | ||
### `yarn test` | ||
Integration tests. | ||
### `yarn format` | ||
Code formatting. | ||
### `yarn lint` | ||
Code linting. | ||
### `yarn prepublish` | ||
Prepares code for publishing bu building and bumping package version. |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
33313
96
1