xud
Version:
Exchange Union Daemon
55 lines • 2.61 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 = 'walletwithdraw <amount> <currency> <destination> [fee]';
exports.describe = 'withdraws on-chain funds from xud';
exports.builder = (argv) => argv
.positional('amount', {
description: 'the amount to withdraw, `all` withdraws everything',
type: 'string',
})
.positional('currency', {
description: 'the ticker symbol of the currency to withdraw.',
type: 'string',
})
.positional('destination', {
description: 'the address to send withdrawn funds to',
type: 'string',
})
.option('fee', {
description: 'the fee in satoshis (or equivalent) per byte',
type: 'number',
})
.example('$0 walletwithdraw 0.1 BTC 1BitcoinEaterAddressDontSendf59kuE', 'withdraws 0.1 BTC')
.example('$0 walletwithdraw 0.1 BTC 1BitcoinEaterAddressDontSendf59kuE 20', 'withdraws 0.1 BTC using 20 sats/byte')
.example('$0 walletwithdraw all BTC 1BitcoinEaterAddressDontSendf59kuE', 'withdraws all BTC');
exports.handler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
const request = new xudrpc_pb_1.WithdrawRequest();
request.setCurrency(argv.currency.toUpperCase());
if (argv.amount === 'all') {
request.setAll(true);
}
else {
if (isNaN(argv.amount)) {
console.error('amount is not a valid number');
process.exit(1);
}
request.setAmount(utils_1.coinsToSats(parseFloat(argv.amount)));
}
request.setDestination(argv.destination);
request.setFee(argv.fee);
(yield command_1.loadXudClient(argv)).walletWithdraw(request, command_1.callback(argv));
});
//# sourceMappingURL=walletwithdraw.js.map