cash2ecash

cash2ecash: cash acceptor that issues digital cash (experimental)
Log | Files | Refs | README | LICENSE

commit e9f963afc6563066f6f4567e3785d54b20dc00f1
parent 2d71353b4e9a7276755b217c1e7e17462bcb78cb
Author: Tellenbach Reto <tellr1@bfh.ch>
Date:   Thu,  4 Jun 2026 16:16:10 +0200

[new] State-logic: Init state implemented

Diffstat:
Msrc/taler-digitizer.c | 73++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Mtaler-digitizer.conf | 2+-
2 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/src/taler-digitizer.c b/src/taler-digitizer.c @@ -220,22 +220,28 @@ struct DIGITIZER_StateContext enum TALLER_BANK_CurrencyCompatibility currency_compa; /** - * digitizer defined min transaction amount, + * digitizer defined max amount for one insertion action, * sum from bill- and coin-acceptor */ struct TALER_Amount max_insertion_amount; /** - * digitizer defined min transaction amount, + * digitizer defined min amount for one insertion action, * min from bill-/coin-acceptor */ struct TALER_Amount min_insertion_amount; /** - * balance updated in each Idle state, - * at the befor of each withdrawal + * max_wire_transfer_amount of bank config */ - struct TALER_Amount bank_balance_befor_withdrawal; + struct TALER_Amount bank_max_wire_transfer_amount; + + /** + * amount avaliable for current withdrawal process + * is updated according to bank balance and bank withdrawal-limits + * in init state of each withdrawal process + */ + struct TALER_Amount withdrawal_balance; }; static enum DIGITIZER_states state; @@ -294,6 +300,30 @@ on_get_config_done (void *cls, GNUNET_SCHEDULER_add_now(state_controller_task,NULL); return; } + if(-1 == TALER_amount_cmp(&(vr->details.ok.configi.max_wire_transfer_amount), + &(state_ctx->max_insertion_amount))) + { + GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR, + "taler-digitizer", + "BANK_BASE_URL or MAX_DENOMINATION", + "max denominations not compatible with bank max_wire_transfer_amount"); + state = DIGITIZER_STATE_TERMINAL_ERROR; + GNUNET_SCHEDULER_add_now(state_controller_task,NULL); + return; + } + state_ctx->bank_max_wire_transfer_amount = vr->details.ok.configi.max_wire_transfer_amount; + if(-1 == TALER_amount_cmp(&(vr->details.ok.configi.min_wire_transfer_amount), + &(state_ctx->min_insertion_amount))) + { + GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR, + "taler-digitizer", + "BANK_BASE_URL or MAX_DENOMINATION", + "min denominations not compatible with bank min_wire_transfer_amount"); + state = DIGITIZER_STATE_TERMINAL_ERROR; + GNUNET_SCHEDULER_add_now(state_controller_task,NULL); + return; + } + state = DIGITIZER_STATE_SCAN_QR; GNUNET_SCHEDULER_add_now(state_controller_task,NULL); @@ -342,12 +372,12 @@ static void Init_state_task(void *cls) if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "taler-digitizer", - "BACKEND_BASE_URL", + "BANK_BASE_URL", &cfg_bank_base_url)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "taler-digitizer", - "BACKEND_BASE_URL"); + "BANK_BASE_URL"); global_ret = EXIT_FAILURE; return; } @@ -474,6 +504,12 @@ static void Init_state_task(void *cls) if(GNUNET_OK != cfg_ba_enable) { cfg_ba_enable = GNUNET_NO; + join_strings_to_amount(cfg_currency, + "0", + &cfg_ba_max_denomination); + join_strings_to_amount(cfg_currency, + "0", + &cfg_ba_min_denomination); if(GNUNET_OK != cfg_ca_enable) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, @@ -556,6 +592,12 @@ static void Init_state_task(void *cls) if(GNUNET_OK != cfg_ca_enable) { cfg_ca_enable = GNUNET_NO; + join_strings_to_amount(cfg_currency, + "0", + &cfg_ca_max_denomination); + join_strings_to_amount(cfg_currency, + "0", + &cfg_ca_min_denomination); } else { @@ -651,6 +693,23 @@ static void Init_state_task(void *cls) } } + state_ctx->min_insertion_amount = + ((1 == TALER_amount_cmp(&cfg_ba_min_denomination, + &cfg_ca_min_denomination))? + cfg_ca_min_denomination : cfg_ba_min_denomination); + + if(TALER_AAR_INVALID_NEGATIVE_RESULT == TALER_amount_add(&state_ctx->max_insertion_amount, + &cfg_ba_min_denomination, + &cfg_ca_min_denomination)) + { + GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR, + "coin-acceptor", + "XXX_DENOMINATION", + "could not determine min insertion amount"); + global_ret = EXIT_FAILURE; + return; + } + //Screen INIT //Touch INIT diff --git a/taler-digitizer.conf b/taler-digitizer.conf @@ -1,5 +1,5 @@ [taler-digitizer] -BACKEND_BASE_URL = https://bank.demo.taler.net/ +BANK_BASE_URL = https://bank.demo.taler.net/ CURRENCY = KUDOS BANK_ACCOUNT = bank_acc_tellr