mirror of
https://github.com/alexbosworth/balanceofsatoshis.git
synced 2026-08-13 12:33:37 +02:00
add support for lnd 0.17.0
This commit is contained in:
parent
24e10eeb6d
commit
b2f624f666
7 changed files with 518 additions and 637 deletions
|
|
@ -1,5 +1,12 @@
|
|||
# Versions
|
||||
|
||||
## 17.0.0
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- Remove `gateway` command
|
||||
- Remove support for node.js 16 and require 18+
|
||||
|
||||
## 16.0.2
|
||||
|
||||
- `trade-secret`: Fix advertising when node is behind TorV3
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ Commands for working with LND balances.
|
|||
|
||||
Supported LND versions:
|
||||
|
||||
- v0.17.0-beta
|
||||
- v0.16.0-beta to v0.16.4-beta
|
||||
- v0.15.2-beta to v0.15.5-beta
|
||||
|
||||
## Install
|
||||
|
||||
- Requires an [installation of Node v16+][nodejs-install-guide]
|
||||
- Requires an [installation of Node v18+][nodejs-install-guide]
|
||||
|
||||
```shell
|
||||
npm install -g balanceofsatoshis
|
||||
|
|
|
|||
30
bos
30
bos
|
|
@ -802,36 +802,6 @@ prog
|
|||
});
|
||||
})
|
||||
|
||||
// Gateway service
|
||||
.command('gateway', 'Request gateway for https://ln-operator.github.io/')
|
||||
.visible(false)
|
||||
.help('Start LND gateway server listening for Web UI access')
|
||||
.help('Using the --remote option generates credentials for a remote gateway')
|
||||
.option('--minutes <minutes>', 'Minutes credentials valid for', INT, 10)
|
||||
.option('--node <node_name>', 'Node for gateway')
|
||||
.option('--nospend', 'Credentials do not include spending privileges')
|
||||
.option('--port <port>', 'Port for gateway', INT, 4805)
|
||||
.option('--remote <url>', 'Output credentials for a remote gateway')
|
||||
.action((args, options, logger) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
return lnd.gateway({
|
||||
logger,
|
||||
credentials: await lnd.lndCredentials({
|
||||
is_nospend: options.nospend,
|
||||
node: options.node,
|
||||
}),
|
||||
minutes: options.minutes,
|
||||
is_nospend: options.nospend || undefined,
|
||||
port: options.port,
|
||||
remote: options.remote,
|
||||
});
|
||||
} catch (err) {
|
||||
return logger.error({err}) && reject();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// Give a peer some tokens
|
||||
.command('gift', 'Give a direct peer some free funds off-chain')
|
||||
.visible(false)
|
||||
|
|
|
|||
101
lnd/gateway.js
101
lnd/gateway.js
|
|
@ -1,101 +0,0 @@
|
|||
const {encode} = require('cbor');
|
||||
const {grpcProxyServer} = require('ln-service/routers');
|
||||
const moment = require('moment');
|
||||
const {restrictMacaroon} = require('ln-service');
|
||||
|
||||
const base64AsBuf = base64 => Buffer.from(base64, 'base64');
|
||||
const bufferAsHex = buffer => buffer.toString('hex');
|
||||
const expiryMs = n => 1000 * 60 * n;
|
||||
const maxTimeLimitMinutes = 60;
|
||||
const {now} = Date;
|
||||
const path = '/v0/grpc/';
|
||||
|
||||
/** Start an LND gateway server
|
||||
|
||||
{
|
||||
credentials: {
|
||||
cert: <LND Base64 Encoded String>
|
||||
socket: <LND Socket String>
|
||||
}
|
||||
[is_nospend]: <Restrict Credentials To Non-Spending Permissions Bool>
|
||||
logger: <Winston Logger Object>
|
||||
minutes: <Expire Access in Minutes Number>
|
||||
port: <Listen Port Number>
|
||||
remote: <Remote Gateway URL String>
|
||||
}
|
||||
|
||||
@returns
|
||||
{}
|
||||
*/
|
||||
module.exports = args => {
|
||||
if (!args.credentials) {
|
||||
throw new Error('ExpectedCredentialsForLndGateway');
|
||||
}
|
||||
|
||||
if (!args.credentials.cert) {
|
||||
throw new Error('ExpectedCertToStartLndGateway');
|
||||
}
|
||||
|
||||
if (!args.logger) {
|
||||
throw new Error('ExpectedLoggerToStartLndGateway');
|
||||
}
|
||||
|
||||
if (!args.minutes) {
|
||||
throw new Error('ExpectedMinutesToStartLndGateway');
|
||||
}
|
||||
|
||||
if (args.minutes > maxTimeLimitMinutes) {
|
||||
throw new Error('ExpectedMinutesToBeLessThanOrEqualToOneHour');
|
||||
}
|
||||
|
||||
if (!args.port) {
|
||||
throw new Error('ExpectedPortToStartLndGateway');
|
||||
}
|
||||
|
||||
if (!args.credentials.socket) {
|
||||
throw new Error('ExpectedLndRpcSocketToStartLndGateway');
|
||||
}
|
||||
|
||||
const expiry = new Date(now() + expiryMs(args.minutes));
|
||||
|
||||
const {macaroon} = restrictMacaroon({
|
||||
expires_at: expiry.toISOString(),
|
||||
macaroon: args.credentials.macaroon,
|
||||
});
|
||||
|
||||
const code = encode({
|
||||
macaroon: base64AsBuf(macaroon),
|
||||
port: !args.remote ? args.port : undefined,
|
||||
url: args.remote || undefined,
|
||||
});
|
||||
|
||||
args.logger.info({
|
||||
connection_code: bufferAsHex(code),
|
||||
expires_at: moment(expiry).calendar(),
|
||||
});
|
||||
|
||||
if (!!args.remote) {
|
||||
return;
|
||||
}
|
||||
|
||||
const log = (err, line) => {
|
||||
if (!!err) {
|
||||
return args.logger.error({gateway: err});
|
||||
}
|
||||
|
||||
return args.logger.info({
|
||||
gateway: line,
|
||||
is_nospend: !!args.is_nospend,
|
||||
})
|
||||
};
|
||||
|
||||
const {app, server, wss} = grpcProxyServer({
|
||||
log,
|
||||
path,
|
||||
cert: args.credentials.cert,
|
||||
port: args.port,
|
||||
socket: args.credentials.socket,
|
||||
});
|
||||
|
||||
return {};
|
||||
};
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
const authenticatedLnd = require('./authenticated_lnd');
|
||||
const findRecord = require('./find_record');
|
||||
const gateway = require('./gateway');
|
||||
const getCertValidityDays = require('./get_cert_validity_days');
|
||||
const getCredentials = require('./get_credentials');
|
||||
const getLnds = require('./get_lnds');
|
||||
|
|
@ -9,7 +8,6 @@ const lndCredentials = require('./lnd_credentials');
|
|||
module.exports = {
|
||||
authenticatedLnd,
|
||||
findRecord,
|
||||
gateway,
|
||||
getCertValidityDays,
|
||||
getCredentials,
|
||||
getLnds,
|
||||
|
|
|
|||
1004
package-lock.json
generated
1004
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -37,7 +37,7 @@
|
|||
"ini": "4.1.1",
|
||||
"inquirer": "9.2.11",
|
||||
"ln-accounting": "7.0.2",
|
||||
"ln-service": "56.14.0",
|
||||
"ln-service": "57.0.0",
|
||||
"ln-sync": "5.2.3",
|
||||
"ln-telegram": "5.0.0",
|
||||
"moment": "2.29.4",
|
||||
|
|
@ -54,11 +54,11 @@
|
|||
"description": "Lightning balance CLI",
|
||||
"devDependencies": {
|
||||
"invoices": "3.0.0",
|
||||
"ln-docker-daemons": "5.1.3",
|
||||
"ln-docker-daemons": "6.0.1",
|
||||
"mock-lnd": "1.4.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": ">=18"
|
||||
},
|
||||
"keywords": [
|
||||
"cli",
|
||||
|
|
@ -82,5 +82,5 @@
|
|||
"postpublish": "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t alexbosworth/balanceofsatoshis -t alexbosworth/balanceofsatoshis:$npm_package_version --push .",
|
||||
"test": "npx nyc@15.1.0 node --experimental-test-coverage --test test/arrays/*.js test/balances/*.js test/chain/*.js test/display/*.js test/encryption/*.js test/lnd/*.js test/network/*.js test/nodes/*.js test/peers/*.js test/responses/*.js test/routing/*.js test/services/*.js test/swaps/*.js test/tags/*.js test/telegram/*.js test/wallets/*.js"
|
||||
},
|
||||
"version": "16.0.2"
|
||||
"version": "17.0.0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue