commit 044fe02269259b1b723d972e22b89cd681146b98
parent 6022a26cb8de376a33d443de03cd3d26d906d555
Author: Antoine A <>
Date: Thu, 30 Jan 2025 13:15:23 +0100
magnet-bank more config work and git hash in version
Diffstat:
4 files changed, 56 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,3 +1,5 @@
+GIT_HASH=$(git rev-parse --short HEAD)
+
all: build
.PHONY: build
diff --git a/taler-magnet-bank.conf b/taler-magnet-bank.conf
@@ -1,10 +1,29 @@
[magnet-bank]
+# URL of the Magnet Bank API server
API_URL = "https://mobil.magnetbank.hu"
+
+# Your Magnet Bank API unique identifier
CONSUMER_KEY = "Consumer"
+
+# Your Magnet Bank API confidential key
CONSUMER_SECRET = "qikgjxc5y06tiil7qgrmh09l7rfi5a8e"
+
+# IBAN of the Magnet Bank account to sync
+IBAN =
+
+# Legal entity that is associated with the Magnet Bank account
+NAME =
+
+# File that holds the crypto keys and access token.
KEYS_FILE = keys.json
-# How "taler-magnet-bank-adapter serve" serves its API, this can either be tcp or unix
+# Specify the account type and therefore the indexing behavior.
+# This can either can be normal or exchange.
+# Exchange accounts bounce invalid incoming Taler transactions.
+ACCOUNT_TYPE = exchange
+
+[magnet-bank-httpd]
+# How "taler-magnet-bank serve" serves its API, this can either be tcp or unix
SERVE = tcp
# Port on which the HTTP server listens, e.g. 9967. Only used if SERVE is tcp.
@@ -19,8 +38,7 @@ BIND_TO = 0.0.0.0
# What should be the file access permissions for UNIXPATH? Only used if SERVE is unix.
# UNIXPATH_MODE = 660
-
-[magnet-bank-wire-gateway-api]
+[magnet-bank-httpd-wire-gateway-api]
# Whether to serve the Wire Gateway API
ENABLED = NO
@@ -37,7 +55,7 @@ AUTH_METHOD = bearer
TOKEN =
-[magnet-bank-revenue-api]
+[magnet-bank-httpd-revenue-api]
# Whether to serve the Revenue API
ENABLED = NO
diff --git a/taler-magnet-bank/src/config.rs b/taler-magnet-bank/src/config.rs
@@ -75,7 +75,7 @@ pub struct ServeCfg {
impl ServeCfg {
pub fn parse(cfg: &Config) -> Result<Self, ValueErr> {
- let sect = cfg.section("magnet-bank");
+ let sect = cfg.section("magnet-bank-httpd");
let serve = map_config!(sect, "serve", "SERVE",
"tcp" => {
@@ -91,8 +91,8 @@ impl ServeCfg {
)
.require()?;
- let wire_gateway = ApiCfg::parse(cfg.section("magnet-bank-wire-gateway-api"))?;
- let revenue = ApiCfg::parse(cfg.section("magnet-bank-revenue-api"))?;
+ let wire_gateway = ApiCfg::parse(cfg.section("magnet-bank-httpd-wire-gateway-api"))?;
+ let revenue = ApiCfg::parse(cfg.section("magnet-bank-httpd-revenue-api"))?;
Ok(Self {
serve,
diff --git a/taler-magnet-bank/src/main.rs b/taler-magnet-bank/src/main.rs
@@ -37,8 +37,19 @@ use taler_magnet_bank::{
MagnetPayto,
};
+pub fn long_version() -> &'static str {
+ let version = env!("CARGO_PKG_VERSION");
+ let git_hash = option_env!("GIT_HASH");
+ if let Some(hash) = git_hash {
+ format!("v{version}-git-{hash}")
+ } else {
+ format!("v{version}-git")
+ }
+ .leak()
+}
+
#[derive(clap::Parser, Debug)]
-#[command(version, about, long_about = None)]
+#[command(long_version = long_version(), about, long_about = None)]
struct Args {
#[clap(flatten)]
common: CommonArgs,
@@ -49,16 +60,25 @@ struct Args {
#[derive(clap::Subcommand, Debug)]
enum Command {
+ /// Initialize taler-magnet-bank database
+ Dbinit {
+ /// Reset database (DANGEROUS: All existing data is lost)
+ #[clap(long, short)]
+ reset: bool,
+ },
/// Setup taler-magnet-bank auth token and account settings for Wire Gateway use
Setup {
+ /// Reset connection info and overwrite keys file
#[clap(long, short)]
reset: bool,
},
- /// Initialize taler-magnet-bank database
- Dbinit {
- /// Reset database (DANGEROUS: All existing data is lost)
+ /// Run taler-magnet-bank worker
+ Worker {
+ /// Execute once and return
#[clap(long, short)]
- reset: bool,
+ transient: bool,
+ // TODO account in config
+ account: Payto,
},
/// Run taler-magnet-bank HTTP server
Serve {
@@ -67,11 +87,6 @@ enum Command {
#[clap(long)]
check: bool,
},
- /// Run taler-magnet-bank worker
- Worker {
- // TODO account in config
- account: Payto,
- },
#[command(subcommand)]
Config(ConfigCmd),
/// Hidden dev commands
@@ -111,7 +126,10 @@ async fn app(args: Args, cfg: Config) -> anyhow::Result<()> {
builder.serve(cfg.serve, None).await?;
}
}
- Command::Worker { account } => {
+ Command::Worker {
+ account,
+ transient: _,
+ } => {
let db = DbCfg::parse(&cfg)?;
let pool = PgPool::connect_with(db.cfg).await?;
let cfg = WorkerCfg::parse(&cfg)?;