diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-11-27 17:59:51 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-11-27 17:59:57 +0100 |
commit | c3ca556affe2f514aeb7fd052fe6d626d9319e99 (patch) | |
tree | ffd85c479b3201c6372d380bb0a2819af503539c /src/headless | |
parent | d42b9e3df8d1bf0e2d0805a04663a79b22a2545d (diff) |
JS-only crypto (only primitives so far)
Diffstat (limited to 'src/headless')
-rw-r--r-- | src/headless/clk.ts | 24 | ||||
-rw-r--r-- | src/headless/integrationtest.ts | 5 | ||||
-rw-r--r-- | src/headless/taler-wallet-cli.ts | 12 |
3 files changed, 32 insertions, 9 deletions
diff --git a/src/headless/clk.ts b/src/headless/clk.ts index 51ee119c9..4a568dc18 100644 --- a/src/headless/clk.ts +++ b/src/headless/clk.ts @@ -329,6 +329,7 @@ export class CommandGroup<GN extends keyof any, TG> { let foundSubcommand: CommandGroup<any, any> | undefined = undefined; const myArgs: any = (parsedArgs[this.argKey] = {}); const foundOptions: { [name: string]: boolean } = {}; + const currentName = this.name ?? progname; for (i = 0; i < unparsedArgs.length; i++) { const argVal = unparsedArgs[i]; if (argsTerminated == false) { @@ -341,8 +342,7 @@ export class CommandGroup<GN extends keyof any, TG> { const r = splitOpt(opt); const d = this.longOptions[r.key]; if (!d) { - const n = this.name ?? progname; - console.error(`error: unknown option '--${r.key}' for ${n}`); + console.error(`error: unknown option '--${r.key}' for ${currentName}`); process.exit(-1); throw Error("not reached"); } @@ -412,8 +412,7 @@ export class CommandGroup<GN extends keyof any, TG> { } else { const d = this.arguments[posArgIndex]; if (!d) { - const n = this.name ?? progname; - console.error(`error: too many arguments for ${n}`); + console.error(`error: too many arguments for ${currentName}`); process.exit(-1); throw Error("not reached"); } @@ -424,12 +423,11 @@ export class CommandGroup<GN extends keyof any, TG> { for (let i = posArgIndex; i < this.arguments.length; i++) { const d = this.arguments[i]; - const n = this.name ?? progname; if (d.required) { if (d.args.default !== undefined) { myArgs[d.name] = d.args.default; } else { - console.error(`error: missing positional argument '${d.name}' for ${n}`); + console.error(`error: missing positional argument '${d.name}' for ${currentName}`); process.exit(-1); throw Error("not reached"); } @@ -465,7 +463,19 @@ export class CommandGroup<GN extends keyof any, TG> { parsedArgs, ); } else if (this.myAction) { - this.myAction(parsedArgs); + let r; + try { + r = this.myAction(parsedArgs); + } catch (e) { + console.error(`An error occured while running ${currentName}`); + console.error(e); + process.exit(1); + } + Promise.resolve(r).catch((e) => { + console.error(`An error occured while running ${currentName}`); + console.error(e); + process.exit(1); + }); } else { this.printHelp(progname, parents); process.exit(-1); diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts index 6f2139c9d..91adfaa6d 100644 --- a/src/headless/integrationtest.ts +++ b/src/headless/integrationtest.ts @@ -82,8 +82,9 @@ export async function runIntegrationTest(args: { throw Error("payment did not succeed"); } - const refreshRes = await myWallet.refreshDirtyCoins(); - console.log(`waited to refresh ${refreshRes.numRefreshed} coins`); + await myWallet.runPending(); + //const refreshRes = await myWallet.refreshDirtyCoins(); + //console.log(`waited to refresh ${refreshRes.numRefreshed} coins`); myWallet.stop(); } diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts index 0a6780808..bec098aca 100644 --- a/src/headless/taler-wallet-cli.ts +++ b/src/headless/taler-wallet-cli.ts @@ -15,6 +15,7 @@ */ import os = require("os"); +import fs = require("fs"); import { getDefaultNodeWallet, withdrawTestBalance } from "./helpers"; import { MerchantBackendConnection } from "./merchant"; import { runIntegrationTest } from "./integrationtest"; @@ -24,6 +25,7 @@ import * as clk from "./clk"; import { BridgeIDBFactory, MemoryBackend } from "idb-bridge"; import { Logger } from "../logging"; import * as Amounts from "../amounts"; +import { decodeCrock } from "../crypto/talerCrypto"; const logger = new Logger("taler-wallet-cli.ts"); @@ -255,6 +257,16 @@ const advancedCli = walletCli.subcommand("advancedArgs", "advanced", { }); advancedCli + .subcommand("decode", "decode", { + help: "Decode base32-crockford", + }) + .action(args => { + const enc = fs.readFileSync(0, 'utf8'); + fs.writeFileSync(1, decodeCrock(enc.trim())) + }); + + +advancedCli .subcommand("refresh", "force-refresh", { help: "Force a refresh on a coin.", }) |