X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=bin%2Fcrowdnode.js;h=8b8ce396ff0be8d4a1ec0bc843052c1bf42e75e4;hb=2e6154a9535583dba6f1589eaefc36fab70a58da;hp=2cf8cdfaf269a9dc74b4f50be7449d4ee633fa9d;hpb=f36ed50398c3eb09c6ffb5ceac7d14eb68a37bcd;p=crowdnode.js%2F.git diff --git a/bin/crowdnode.js b/bin/crowdnode.js index 2cf8cdf..8b8ce39 100755 --- a/bin/crowdnode.js +++ b/bin/crowdnode.js @@ -74,7 +74,7 @@ function showHelp() { console.info(""); console.info("Key Management & Encryption:"); - console.info(" crowdnode generate [./privkey.wif]"); + console.info(" crowdnode generate [--plain-text] [./privkey.wif]"); console.info(" crowdnode encrypt"); // TODO allow encrypting one-by-one? console.info(" crowdnode list"); console.info(" crowdnode use "); @@ -119,6 +119,7 @@ async function main() { // flags let forceConfirm = removeItem(args, "--unconfirmed"); + let plainText = removeItem(args, "--plain-text"); let noReserve = removeItem(args, "--no-reserve"); let subcommand = args.shift(); @@ -158,7 +159,7 @@ async function main() { } if ("generate" === subcommand) { - await generateKey({ defaultKey: defaultAddr }, args); + await generateKey({ defaultKey: defaultAddr, plainText }, args); return; } @@ -330,9 +331,10 @@ async function initCrowdNode(insightBaseUrl) { * @param {Number} duffs - 1/100000000 of a DASH */ function showQr(addr, duffs = 0) { + let dashAmount = toDash(duffs); let dashUri = `dash://${addr}`; if (duffs) { - dashUri += `?amount=${duffs}`; + dashUri += `?amount=${dashAmount}`; } let dashQr = Qr.ascii(dashUri, { indent: 4 }); @@ -559,9 +561,10 @@ async function mustGetDefaultWif(defaultAddr, opts) { /** * @param {Object} psuedoState * @param {String} psuedoState.defaultKey - addr name of default key + * @param {Boolean} psuedoState.plainText - don't encrypt * @param {Array} args */ -async function generateKey({ defaultKey }, args) { +async function generateKey({ defaultKey, plainText }, args) { let name = args.shift(); //@ts-ignore - TODO submit JSDoc PR for Dashcore let pk = new Dashcore.PrivateKey(); @@ -569,7 +572,10 @@ async function generateKey({ defaultKey }, args) { let addr = pk.toAddress().toString(); let plainWif = pk.toWIF(); - let wif = await maybeEncrypt(plainWif); + let wif = plainWif; + if (!plainText) { + wif = await maybeEncrypt(plainWif); + } let filename = `~/${configdir}/keys/${addr}.wif`; let filepath = Path.join(`${keysDir}/${addr}.wif`);