diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-06-21 18:20:39 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-06-21 18:20:39 +0530 |
commit | 06d9aab47c066fe162752a2dce7b3d2ea32ae470 (patch) | |
tree | 79ae6e1d33cf8e989d1db24f8b74214a480c9d25 /src/headless/taler-wallet-cli.ts | |
parent | 76fffdedd7274b1ea8653d1631e72646f86d94c9 (diff) | |
download | wallet-core-06d9aab47c066fe162752a2dce7b3d2ea32ae470.tar.xz |
prettier
Diffstat (limited to 'src/headless/taler-wallet-cli.ts')
-rw-r--r-- | src/headless/taler-wallet-cli.ts | 95 |
1 files changed, 49 insertions, 46 deletions
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts index 839ee9992..99d7b5a0a 100644 --- a/src/headless/taler-wallet-cli.ts +++ b/src/headless/taler-wallet-cli.ts @@ -25,7 +25,11 @@ import * as clk from "./clk"; import { BridgeIDBFactory } from "idb-bridge"; import { Logger } from "../util/logging"; import { Amounts } from "../util/amounts"; -import { decodeCrock, setupRefreshPlanchet, encodeCrock } from "../crypto/talerCrypto"; +import { + decodeCrock, + setupRefreshPlanchet, + encodeCrock, +} from "../crypto/talerCrypto"; import { OperationFailedAndReportedError } from "../operations/errors"; import { Bank } from "./bank"; import { classifyTalerUri, TalerUriType } from "../util/taleruri"; @@ -368,41 +372,42 @@ advancedCli fs.writeFileSync(1, decodeCrock(enc.trim())); }); - advancedCli -.subcommand("withdrawManually", "withdraw-manually", { - help: "Withdraw manually from an exchange.", -}) -.requiredOption("exchange", ["--exchange"], clk.STRING, { - help: "Base URL of the exchange.", -}) -.requiredOption("amount", ["--amount"], clk.STRING, { - help: "Amount to withdraw", -}) -.action(async (args) => { - await withWallet(args, async (wallet) => { - const exchange = await wallet.updateExchangeFromUrl(args.withdrawManually.exchange); - const acct = exchange.wireInfo?.accounts[0]; - if (!acct) { - console.log("exchange has no accounts"); - return; - } - const reserve = await wallet.createReserve({ - amount: Amounts.parseOrThrow(args.withdrawManually.amount), - exchangeWire: acct.payto_uri, - exchange: exchange.baseUrl, - }); - await wallet.confirmReserve({ - reservePub: reserve.reservePub, - }); - const completePaytoUri = addPaytoQueryParams(acct.payto_uri, { - amount: args.withdrawManually.amount, - message: `Taler top-up ${reserve.reservePub}`, + .subcommand("withdrawManually", "withdraw-manually", { + help: "Withdraw manually from an exchange.", + }) + .requiredOption("exchange", ["--exchange"], clk.STRING, { + help: "Base URL of the exchange.", + }) + .requiredOption("amount", ["--amount"], clk.STRING, { + help: "Amount to withdraw", + }) + .action(async (args) => { + await withWallet(args, async (wallet) => { + const exchange = await wallet.updateExchangeFromUrl( + args.withdrawManually.exchange, + ); + const acct = exchange.wireInfo?.accounts[0]; + if (!acct) { + console.log("exchange has no accounts"); + return; + } + const reserve = await wallet.createReserve({ + amount: Amounts.parseOrThrow(args.withdrawManually.amount), + exchangeWire: acct.payto_uri, + exchange: exchange.baseUrl, + }); + await wallet.confirmReserve({ + reservePub: reserve.reservePub, + }); + const completePaytoUri = addPaytoQueryParams(acct.payto_uri, { + amount: args.withdrawManually.amount, + message: `Taler top-up ${reserve.reservePub}`, + }); + console.log("Created reserve", reserve.reservePub); + console.log("Payto URI", completePaytoUri); }); - console.log("Created reserve", reserve.reservePub); - console.log("Payto URI", completePaytoUri); }); -}); const reservesCli = advancedCli.subcommand("reserves", "reserves", { help: "Manage reserves.", @@ -572,19 +577,17 @@ const testCli = walletCli.subcommand("testingArgs", "testing", { help: "Subcommands for testing GNU Taler deployments.", }); -testCli - .subcommand("vectors", "vectors") - .action(async (args) => { - const secretSeed = nacl.randomBytes(64); - const coinIndex = Math.ceil(Math.random() * 100) - const p = setupRefreshPlanchet(secretSeed, coinIndex); - console.log("setupRefreshPlanchet") - console.log(` (in) secret seed: ${encodeCrock(secretSeed)}`); - console.log(` (in) coin index: ${coinIndex}`); - console.log(` (out) blinding secret: ${encodeCrock(p.bks)}`); - console.log(` (out) coin priv: ${encodeCrock(p.coinPriv)}`); - console.log(` (out) coin pub: ${encodeCrock(p.coinPub)}`); - }); +testCli.subcommand("vectors", "vectors").action(async (args) => { + const secretSeed = nacl.randomBytes(64); + const coinIndex = Math.ceil(Math.random() * 100); + const p = setupRefreshPlanchet(secretSeed, coinIndex); + console.log("setupRefreshPlanchet"); + console.log(` (in) secret seed: ${encodeCrock(secretSeed)}`); + console.log(` (in) coin index: ${coinIndex}`); + console.log(` (out) blinding secret: ${encodeCrock(p.bks)}`); + console.log(` (out) coin priv: ${encodeCrock(p.coinPriv)}`); + console.log(` (out) coin pub: ${encodeCrock(p.coinPub)}`); +}); testCli .subcommand("integrationtestBasic", "integrationtest-basic") |