exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit fb25885342d78395295cf834a7571daf054c0b1b
parent 042f5318b30c410a2fefcc37632bf6f19a8ff506
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 12 Oct 2026 16:38:37 +0200

include total wire debit fees when summing up in auditor

Diffstat:
Mmeson.build | 2+-
Msrc/auditor/taler-helper-auditor-wire-debit.c | 14++++++++++++++
Msrc/bank-lib/bank_api_debit.c | 23+++++++++++++++++++++++
Msrc/include/taler/taler_bank_service.h | 14++++++++++++++
4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build @@ -283,7 +283,7 @@ if not get_option('only-doc') ['libtalerpq', '2:0:1'], ['libtalermhd', '8:0:1'], ['libtalertemplating', '1:1:1'], - ['libtalerbank', '6:0:0'], + ['libtalerbank', '7:0:0'], ['libtalerkyclogic', '3:0:0'], ['libtalerexchangedb', '4:0:0'], ['libtalerauditordb', '1:0:0'], diff --git a/src/auditor/taler-helper-auditor-wire-debit.c b/src/auditor/taler-helper-auditor-wire-debit.c @@ -277,6 +277,12 @@ static TALER_ARL_DEF_AB (wire_debit_duplicate_transfer_subject_total); static TALER_ARL_DEF_AB (total_wire_out); /** + * Total fees the bank charged the exchange for outgoing wire + * transfers, on top of the amounts transferred. + */ +static TALER_ARL_DEF_AB (total_wire_debit_fees); + +/** * Total amount of profits drained. */ static TALER_ARL_DEF_AB (total_drained); @@ -570,6 +576,7 @@ commit (enum GNUNET_DB_QueryStatus qs) TALER_ARL_SET_AB (total_closure_amount_lag), TALER_ARL_SET_AB (wire_debit_duplicate_transfer_subject_total), TALER_ARL_SET_AB (total_wire_out), + TALER_ARL_SET_AB (total_wire_debit_fees), NULL); if (0 > qs) goto handle_db_error; @@ -1443,6 +1450,12 @@ history_debit_cb ( TALER_amount2s (&dd->amount), TALER_B2S (&dd->wtid)); wa->wire_off_out = dd->serial_id; + /* dd->amount is what was transferred, and what the exchange's + justification (wire_out, reserve closure, profit drain) must + match; the bank's fee was debited on top of it. */ + TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_wire_debit_fees), + &TALER_ARL_USE_AB (total_wire_debit_fees), + &dd->debit_fee); slen = strlen (dd->credit_account_uri.full_payto) + 1; roi = GNUNET_malloc (sizeof (struct WireTransferOutInfo) + slen); @@ -1685,6 +1698,7 @@ begin_transaction (void) TALER_ARL_GET_AB (total_closure_amount_lag), TALER_ARL_GET_AB (wire_debit_duplicate_transfer_subject_total), TALER_ARL_GET_AB (total_wire_out), + TALER_ARL_GET_AB (total_wire_debit_fees), NULL); switch (qs) { diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c @@ -109,9 +109,14 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, for (unsigned int i = 0; i<len; i++) { struct TALER_BANK_DebitDetails *td = &dd[i]; + bool no_debit_fee; struct GNUNET_JSON_Specification hist_spec[] = { TALER_JSON_spec_amount_any ("amount", &td->amount), + GNUNET_JSON_spec_mark_optional ( + TALER_JSON_spec_amount_any ("debit_fee", + &td->debit_fee), + &no_debit_fee), GNUNET_JSON_spec_timestamp ("date", &td->execution_date), GNUNET_JSON_spec_uint64 ("row_id", @@ -122,6 +127,10 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, &td->credit_account_uri), TALER_JSON_spec_web_url ("exchange_base_url", &td->exchange_base_url), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("metadata", + &td->metadata), + NULL), GNUNET_JSON_spec_end () }; json_t *transaction = json_array_get (history_array, @@ -137,6 +146,20 @@ parse_account_history (struct TALER_BANK_DebitHistoryHandle *hh, GNUNET_free (dd); return GNUNET_SYSERR; } + if (no_debit_fee) + { + GNUNET_assert (GNUNET_OK == + TALER_amount_set_zero (td->amount.currency, + &td->debit_fee)); + } + else if (GNUNET_YES != + TALER_amount_cmp_currency (&td->amount, + &td->debit_fee)) + { + GNUNET_break_op (0); + GNUNET_free (dd); + return GNUNET_SYSERR; + } } dhr.details.ok.details_length = len; dhr.details.ok.details = dd; diff --git a/src/include/taler/taler_bank_service.h b/src/include/taler/taler_bank_service.h @@ -895,6 +895,20 @@ struct TALER_BANK_DebitDetails */ struct TALER_FullPayto credit_account_uri; + /** + * Fee the bank charged the exchange for the transfer: the + * exchange's account was debited @e amount plus @e debit_fee. + * Zero if the bank did not report a fee (optional since + * protocol v3). + */ + struct TALER_Amount debit_fee; + + /** + * Additional metadata of the transfer as reported by the bank, + * NULL if none (since protocol v5). + */ + const char *metadata; + };