xud
Version:
Exchange Union Daemon
60 lines • 3.11 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handler = exports.builder = exports.describe = exports.command = void 0;
const xudrpc_pb_1 = require("../../proto/xudrpc_pb");
const command_1 = require("../command");
const utils_1 = require("../utils");
exports.command = 'openchannel <currency> <amount> [node_identifier] [push_amount] [fee]';
exports.describe = 'open a payment channel with a peer';
exports.builder = (argv) => argv
.positional('currency', {
description: 'the ticker symbol for the currency',
type: 'string',
})
.positional('amount', {
type: 'number',
description: 'the amount to be deposited into the channel',
})
.option('node_identifier', {
description: 'the node key or alias of the connected peer to open the channel with',
type: 'string',
})
.option('push_amount', {
type: 'number',
description: 'the amount to be pushed to the remote side of the channel',
default: 0,
})
.option('fee', {
type: 'number',
description: 'the manual fee rate set in sat/byte that should be used when crafting the funding transaction in the channel',
default: 0,
})
.example('$0 openchannel BTC 0.1 028599d05b18c0c3f8028915a17d603416f7276c822b6b2d20e71a3502bd0f9e0b', 'open an 0.1 BTC channel by node key')
.example('$0 openchannel BTC 0.1 CheeseMonkey', 'open an 0.1 BTC channel by alias')
.example('$0 openchannel BTC 0.1 CheeseMonkey 0.05', 'open an 0.1 BTC channel by alias and push 0.05 to remote side')
.example('$0 openchannel BTC 0.1 CheeseMonkey 0.05 1', 'open an 0.1 BTC channel by alias, push 0.05 to remote side with 1 sat per byte')
.example('$0 openchannel ETH 0.5', 'deposit 0.5 into an ETH Connext channel without specifying a remote node');
exports.handler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
if (isNaN(argv.amount)) {
throw 'amount must be a number';
}
const request = new xudrpc_pb_1.OpenChannelRequest();
if (argv.node_identifier) {
request.setNodeIdentifier(argv.node_identifier);
}
request.setCurrency(argv.currency.toUpperCase());
request.setAmount(utils_1.coinsToSats(argv.amount));
request.setPushAmount(utils_1.coinsToSats(argv.push_amount));
request.setFee(argv.fee);
(yield command_1.loadXudClient(argv)).openChannel(request, command_1.callback(argv));
});
//# sourceMappingURL=openchannel.js.map