improved denomination generator

This commit is contained in:
Florian Dold 2021-08-04 23:26:47 +02:00
parent 9769f69601
commit 0439096a53
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 22 additions and 6 deletions
debian
packages/taler-wallet-cli/src

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
taler-wallet-cli (0.0.1-2) unstable; urgency=low
* Improved denomination generator.
-- Florian Dold <dold@taler.net> Wed, 04 Aug 2021 23:26:17 +0200
taler-wallet-cli (0.0.1-1) unstable; urgency=low taler-wallet-cli (0.0.1-1) unstable; urgency=low
* Added exchange deployment linting tool. * Added exchange deployment linting tool.

View File

@ -40,6 +40,7 @@ import {
codecForString, codecForString,
Logger, Logger,
Configuration, Configuration,
getTimestampNow,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { import {
NodeHttpLib, NodeHttpLib,
@ -891,15 +892,24 @@ deploymentCli
.subcommand("coincfg", "gen-coin-config", { .subcommand("coincfg", "gen-coin-config", {
help: "Generate a coin/denomination configuration for the exchange.", help: "Generate a coin/denomination configuration for the exchange.",
}) })
.requiredOption("currency", ["--currency"], clk.STRING, { .requiredOption("minAmount", ["--min-amount"], clk.STRING, {
help: "Currency to use", help: "Smallest denomination",
})
.requiredOption("maxAmount", ["--max-amount"], clk.STRING, {
help: "Largest denomination",
}) })
.action(async (args) => { .action(async (args) => {
let out = ""; let out = "";
const currency = args.coincfg.currency;
const min = Amounts.parseOrThrow(`${currency}:0.01`); const stamp = Math.floor((new Date()).getTime() / 1000);
const max = Amounts.parseOrThrow(`${currency}:100`);
const min = Amounts.parseOrThrow(args.coincfg.minAmount);
const max = Amounts.parseOrThrow(args.coincfg.maxAmount);
if (min.currency != max.currency) {
console.error("currency mismatch")
process.exit(1);
}
const currency = min.currency;
let x = min; let x = min;
let n = 1; let n = 1;
@ -908,7 +918,7 @@ deploymentCli
out += "\n"; out += "\n";
while (Amounts.cmp(x, max) < 0) { while (Amounts.cmp(x, max) < 0) {
out += `[COIN-${currency}_${n}]\n`; out += `[COIN-${currency}-n${n}-t${stamp}]\n`;
out += `VALUE = ${Amounts.stringify(x)}\n`; out += `VALUE = ${Amounts.stringify(x)}\n`;
out += `DURATION_WITHDRAW = 7 days\n`; out += `DURATION_WITHDRAW = 7 days\n`;
out += `DURATION_SPEND = 2 years\n`; out += `DURATION_SPEND = 2 years\n`;