exchange

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

commit ce807ffddd0728dbef4c8a6538237be174c5e406
parent 2fcc6cfcda58826db33b2514d8c72c581d8788bd
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 29 Dec 2024 23:22:25 +0100

address reporting FIXME, always use full payto URI when specifying accounts

Diffstat:
Msrc/auditor/batch.conf | 6+++---
Msrc/auditor/revoke-basedb.conf | 2+-
Msrc/auditor/taler-helper-auditor-coins.c | 2+-
Msrc/auditor/taler-helper-auditor-transfer.c | 2+-
Msrc/auditor/taler-helper-auditor-wire-credit.c | 6+++---
Msrc/benchmark/benchmark-cs.conf | 2+-
Msrc/benchmark/benchmark-rsa.conf | 2+-
Msrc/exchange/test_taler_exchange_httpd.conf | 2+-
Msrc/exchange/test_taler_exchange_unix.conf | 2+-
Msrc/exchangedb/exchangedb_accounts.c | 45++++++++++++++++++++++++++-------------------
Msrc/include/taler_exchangedb_lib.h | 7+++++++
11 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/src/auditor/batch.conf b/src/auditor/batch.conf @@ -115,7 +115,7 @@ MASTER_KEY = 2XPQZ7B7EERWT7GR0MF30HPFG4TA1J0CWCQ3XBD48PA4K7GVDBK0 [merchant-account-merchant] ACTIVE_default = YES HONOR_default = YES -PAYTO_URI = payto://x-taler-bank/localhost/42 +PAYTO_URI = payto://x-taler-bank/localhost/42?receiver-name=merchant [exchange-accountcredentials-1] PASSWORD = password @@ -126,7 +126,7 @@ WIRE_GATEWAY_URL = http://localhost:8082/accounts/exchange/taler-wire-gateway/ [exchange-account-1] enable_credit = yes enable_debit = yes -PAYTO_URI = payto://x-taler-bank/localhost/exchange +PAYTO_URI = payto://x-taler-bank/localhost/exchange?receiver-name=exchange [instance-default] NAME = Merchant Inc. @@ -161,7 +161,7 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http [bank] SERVE = http ALLOW_REGISTRATIONS = YES -SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost:8082/2 +SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost:8082/2?receiver-name=exchange SUGGESTED_EXCHANGE = http://localhost:8081/ HTTP_PORT = 8082 MAX_DEBT_BANK = TESTKUDOS:100000.0 diff --git a/src/auditor/revoke-basedb.conf b/src/auditor/revoke-basedb.conf @@ -33,5 +33,5 @@ MAX_DEBT = TESTKUDOS:50.0 MAX_DEBT_BANK = TESTKUDOS:100000.0 HTTP_PORT = 8082 SUGGESTED_EXCHANGE = http://localhost:8081/ -SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost/2 +SUGGESTED_EXCHANGE_PAYTO = payto://x-taler-bank/localhost/2?receiver-name=Exchange SERVE = http diff --git a/src/auditor/taler-helper-auditor-coins.c b/src/auditor/taler-helper-auditor-coins.c @@ -452,7 +452,7 @@ check_coin_history (const struct TALER_CoinSpendPublicKeyP *coin_pub, bool have_refund; uint64_t etag_out; - /* FIXME: could use 'etag' mechanism to only fetch transactions + /* FIXME-Optimization: could use 'etag' mechanism to only fetch transactions we did not yet process, instead of going over them again and again. */ { diff --git a/src/auditor/taler-helper-auditor-transfer.c b/src/auditor/taler-helper-auditor-transfer.c @@ -487,7 +487,7 @@ run (void *cls, } if (0 == test_mode) { - // FIXME: use different event type in the future! + // FIXME-Optimization: use different event type in the future! struct GNUNET_DB_EventHeaderP es = { .size = htons (sizeof (es)), .type = htons (TALER_DBEVENT_EXCHANGE_AUDITOR_WAKE_HELPER_WIRE) diff --git a/src/auditor/taler-helper-auditor-wire-credit.c b/src/auditor/taler-helper-auditor-wire-credit.c @@ -638,7 +638,7 @@ complain_in_not_found (void *cls, .bank_row_id = rii->rowid, .diagnostic = (char *) "incoming wire transfer claimed by exchange not found", - .account.full_payto = (char *) wa->ai->section_name, + .account = wa->ai->payto_uri, .amount_exchange_expected = rii->credit_details.amount, .amount_wired = zero, .reserve_pub = rii->credit_details.details.reserve.reserve_pub, @@ -781,7 +781,7 @@ analyze_credit ( .amount_wired = zero, .reserve_pub = rii->credit_details.details.reserve.reserve_pub, .timestamp = rii->credit_details.execution_date.abs_time, - .account.full_payto = (char *) wa->ai->section_name, /* FIXME: get actual account? */ + .account = wa->ai->payto_uri, .diagnostic = (char *) "wire subject does not match" }; enum GNUNET_DB_QueryStatus qs; @@ -814,7 +814,7 @@ analyze_credit ( { struct TALER_AUDITORDB_ReserveInInconsistency riiDb = { .diagnostic = (char *) "wire amount does not match", - .account.full_payto = (char *) wa->ai->section_name, /* FIXME: get actual account! */ + .account = wa->ai->payto_uri, .bank_row_id = credit_details->serial_id, .amount_exchange_expected = rii->credit_details.amount, .amount_wired = credit_details->amount, diff --git a/src/benchmark/benchmark-cs.conf b/src/benchmark/benchmark-cs.conf @@ -4,7 +4,7 @@ [exchange-account-test] # What is the bank account (with the "Taler Bank" demo system)? Must end with "/". -PAYTO_URI = "payto://x-taler-bank/localhost/Exchange" +PAYTO_URI = "payto://x-taler-bank/localhost/Exchange?receiver-name=Exchange" # Authentication information for basic authentication ENABLE_DEBIT = YES ENABLE_CREDIT = YES diff --git a/src/benchmark/benchmark-rsa.conf b/src/benchmark/benchmark-rsa.conf @@ -4,7 +4,7 @@ [exchange-account-test] # What is the bank account (with the "Taler Bank" demo system)? Must end with "/". -PAYTO_URI = "payto://x-taler-bank/localhost/Exchange" +PAYTO_URI = "payto://x-taler-bank/localhost/Exchange?receiver-name=Exchange" # Authentication information for basic authentication ENABLE_DEBIT = YES ENABLE_CREDIT = YES diff --git a/src/exchange/test_taler_exchange_httpd.conf b/src/exchange/test_taler_exchange_httpd.conf @@ -61,7 +61,7 @@ IDLE_RESERVE_EXPIRATION_TIME = 4 weeks CONFIG = "postgres:///talercheck" [exchange-account-1] -PAYTO_URI = "payto://x-taler-bank/localhost:8082/3" +PAYTO_URI = "payto://x-taler-bank/localhost:8082/3?receiver-name=exchange" ENABLE_DEBIT = YES ENABLE_CREDIT = YES diff --git a/src/exchange/test_taler_exchange_unix.conf b/src/exchange/test_taler_exchange_unix.conf @@ -61,7 +61,7 @@ IDLE_RESERVE_EXPIRATION_TIME = 4 weeks CONFIG = "postgres:///talercheck" [exchange-account-1] -PAYTO_URI = "payto://x-taler-bank/localhost:8082/3" +PAYTO_URI = "payto://x-taler-bank/localhost:8082/3?receiver-name=exchange" ENABLE_DEBIT = YES ENABLE_CREDIT = YES diff --git a/src/exchangedb/exchangedb_accounts.c b/src/exchangedb/exchangedb_accounts.c @@ -58,6 +58,11 @@ struct WireAccount */ char *method; + /** + * Full payto://-URI of the account. + */ + struct TALER_FullPayto payto_uri; + }; @@ -172,6 +177,8 @@ add_account_cb (void *cls, char *method; bool debit; bool credit; + struct TALER_FullPayto fpt; + char *err; if (0 != strncasecmp (section, "exchange-account-", @@ -191,43 +198,42 @@ add_account_cb (void *cls, ( (credit) && (lc->credit) ) ) ) return; /* not enabled for us, skip */ - if (GNUNET_OK == + if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, section, "PAYTO_URI", &payto_uri)) { - method = TALER_payto_get_method (payto_uri); - GNUNET_free (payto_uri); - if (NULL == method) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "payto URI in config ([%s]/PAYTO_URI) malformed\n", - section); - lc->res = GNUNET_SYSERR; - return; - } - } - else if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - section, - "WIRE_METHOD", - &method)) - { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, section, - "WIRE_METHOD"); + "PAYTO_URI"); + return; + } + fpt.full_payto = payto_uri; + method = TALER_payto_get_method (payto_uri); + if ( (NULL != (err = TALER_payto_validate (fpt))) || + (NULL == method) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "payto URI in config ([%s]/PAYTO_URI) malformed: %s\n", + section, + err); + lc->res = GNUNET_SYSERR; + GNUNET_free (payto_uri); + GNUNET_free (err); return; } GNUNET_assert (NULL != method); wa = GNUNET_new (struct WireAccount); wa->section_name = GNUNET_strdup (section); + wa->payto_uri = fpt; wa->method = method; wa->ai.debit_enabled = debit; wa->ai.credit_enabled = credit; wa->ai.auth = NULL; wa->ai.section_name = wa->section_name; wa->ai.method = wa->method; + wa->ai.payto_uri = fpt; if (lc->load_auth_data) { char *csn; @@ -294,6 +300,7 @@ TALER_EXCHANGEDB_unload_accounts (void) if (NULL != wa->ai.auth) TALER_BANK_auth_free (&wa->auth); GNUNET_free (wa->section_name); + GNUNET_free (wa->payto_uri.full_payto); GNUNET_free (wa->method); GNUNET_free (wa); } diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h @@ -27,6 +27,7 @@ #include "taler_exchangedb_plugin.h" #include "taler_bank_service.h" #include "taler_kyclogic_lib.h" +#include "taler_util.h" /** @@ -75,6 +76,12 @@ struct TALER_EXCHANGEDB_AccountInfo const char *method; /** + * Full payto://-URI of the account. Do not free(), aliased + * with the underlying `struct WireAccount`. + */ + struct TALER_FullPayto payto_uri; + + /** * true if this account is enabled to be debited * by the taler-exchange-aggregator. */