taler-rust

GNU Taler code in Rust. Largely core banking integrations.
Log | Files | Refs | Submodules | README | LICENSE

commit cfdf098fea5f565e2a0d2cffb10f20af07946054
parent 19baefe91213c8298726dff96662554f53165a8d
Author: Antoine A <>
Date:   Wed, 18 Feb 2026 23:44:54 +0100

cyclos: more setup fixes

Diffstat:
Mtaler-cyclos/src/setup.rs | 120+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Mtaler-magnet-bank/src/main.rs | 2+-
2 files changed, 63 insertions(+), 59 deletions(-)

diff --git a/taler-cyclos/src/setup.rs b/taler-cyclos/src/setup.rs @@ -87,36 +87,38 @@ pub async fn setup(cfg: &Config, _reset: bool, client: &http_client::Client) -> } // Check account type - let accounts = client.accounts().await?; - let accounts_fmt = { - let mut s = String::new(); - if accounts.is_empty() { - s.write_str(" none").unwrap(); - } - for a in &accounts { - write!( - &mut s, - "\n{} '{}' in {}", - a.ty.id, a.ty.name, a.currency.ty.name, - ) - .unwrap(); - } - s - }; - let currency = if let Some(id) = cfg.account_type_id { - if let Some(p) = accounts.iter().find(|it| it.ty.id == id) { - debug!(target: "setup", "ACCOUNT_TYPE_ID {id} in config is one of:{accounts_fmt}"); - Some(&p.currency) + let accmunts = client.accounts().await?; + if accounts.is_empty() { + debug!(target: "setup", "No accounts found, there is some issues in the Cyclos configuration"); + ready = false; + } else { + let accounts_fmt = { + let mut s = String::new(); + for a in &accounts { + write!( + &mut s, + "\n{} '{}' in {}", + a.ty.id, a.ty.name, a.currency.ty.name, + ) + .unwrap(); + } + s + }; + let currency = if let Some(id) = cfg.account_type_id { + if let Some(p) = accounts.iter().find(|it| it.ty.id == id) { + debug!(target: "setup", "ACCOUNT_TYPE_ID {id} in config is one of:{accounts_fmt}"); + Some(&p.currency) + } else { + error!(target: "setup", "Unknown ACCOUNT_TYPE_ID {id} in config, must be one of:{accounts_fmt}"); + ready = false; + None + } } else { - error!(target: "setup", "Unknown ACCOUNT_TYPE_ID {id} in config, must be one of:{accounts_fmt}"); + error!(target: "setup", "Missing ACCOUNT_TYPE_ID in config, must be one of:{accounts_fmt}"); ready = false; None - } - } else { - error!(target: "setup", "Missing ACCOUNT_TYPE_ID in config, must be one of:{accounts_fmt}"); - ready = false; - None - }; + }; + } if let Some(currency) = currency { // Check currency @@ -130,44 +132,46 @@ pub async fn setup(cfg: &Config, _reset: bool, client: &http_client::Client) -> // Check payment type let data = client.payment_data().await?; - let payment_fmt = { - let mut s = String::new(); - if data.payment_types.is_empty() { - s.write_str(" none").unwrap(); - } - for p in &data.payment_types { - if let Some(currency) = currency { - if p.currency.ty.id == currency.ty.id { - write!(&mut s, "\n{} '{}'", p.ty.id, p.ty.name).unwrap(); + if data.payment_types.is_empty() { + debug!(target: "setup", "No payment ids found, there is some issues in the Cyclos configuration"); + ready = false; + } else { + let payment_fmt = { + let mut s = String::new(); + for p in &data.payment_types { + if let Some(currency) = currency { + if p.currency.ty.id == currency.ty.id { + write!(&mut s, "\n{} '{}'", p.ty.id, p.ty.name).unwrap(); + } + } else { + write!( + &mut s, + "\n{} '{}' in {}", + p.ty.id, p.ty.name, p.currency.ty.name + ) + .unwrap(); } - } else { - write!( - &mut s, - "\n{} '{}' in {}", - p.ty.id, p.ty.name, p.currency.ty.name - ) - .unwrap(); } - } - s - }; - if let Some(id) = cfg.payment_type_id { - if let Some(p) = data.payment_types.iter().find(|it| it.ty.id == id) { - if let Some(currency) = currency - && p.currency.ty.id != currency.ty.id - { - error!(target: "setup", "PAYMENT_TYPE_ID {} in config use currency {} expected {}, must be one of:{payment_fmt}", p.ty.id, p.currency.ty.name, currency.ty.name); - ready = false + s + }; + if let Some(id) = cfg.payment_type_id { + if let Some(p) = data.payment_types.iter().find(|it| it.ty.id == id) { + if let Some(currency) = currency + && p.currency.ty.id != currency.ty.id + { + error!(target: "setup", "PAYMENT_TYPE_ID {} in config use currency {} expected {}, must be one of:{payment_fmt}", p.ty.id, p.currency.ty.name, currency.ty.name); + ready = false + } else { + debug!(target: "setup", "PAYMENT_TYPE_ID {id} config is one of:{payment_fmt}"); + } } else { - debug!(target: "setup", "PAYMENT_TYPE_ID {id} config is one of:{payment_fmt}"); + error!(target: "setup", "Unknown PAYMENT_TYPE_ID {id} in config, must be one of:{payment_fmt}"); + ready = false; } } else { - error!(target: "setup", "Unknown PAYMENT_TYPE_ID {id} in config, must be one of:{payment_fmt}"); + error!(target: "setup", "Missing PAYMENT_TYPE_ID in config, must be one of:{payment_fmt}"); ready = false; } - } else { - error!(target: "setup", "Missing PAYMENT_TYPE_ID in config, must be one of:{payment_fmt}"); - ready = false; } if ready { diff --git a/taler-magnet-bank/src/main.rs b/taler-magnet-bank/src/main.rs @@ -130,7 +130,7 @@ async fn run(cmd: Command, cfg: &Config) -> anyhow::Result<()> { } AuthCfg::Bearer(token) => { println!("WIRE_GATEWAY_AUTH_METHOD = bearer"); - println!("AUTH_TOKEN = {token}"); + println!("TOKEN = {token}"); } AuthCfg::None => { println!("WIRE_GATEWAY_AUTH_METHOD = none");