Compare commits

..

No commits in common. "46188ae07e97d12b73269167459707844b3c2486" and "fb5bc18c588832747dfe299f9df1beb6645cf686" have entirely different histories.

76 changed files with 1254 additions and 1592 deletions

View File

@ -74,25 +74,25 @@ handle_admin_add_incoming_finished (void *cls,
const void *response)
{
struct TALER_BANK_AdminAddIncomingHandle *aai = cls;
uint64_t row_id = UINT64_MAX;
struct GNUNET_TIME_Timestamp timestamp;
enum TALER_ErrorCode ec;
const json_t *j = response;
struct TALER_BANK_AdminAddIncomingResponse ir = {
.http_status = response_code,
.response = response
};
aai->job = NULL;
timestamp = GNUNET_TIME_UNIT_FOREVER_TS;
switch (response_code)
{
case 0:
ir.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_uint64 ("row_id",
&ir.details.ok.serial_id),
&row_id),
GNUNET_JSON_spec_timestamp ("timestamp",
&ir.details.ok.timestamp),
&timestamp),
GNUNET_JSON_spec_end ()
};
@ -102,41 +102,42 @@ handle_admin_add_incoming_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
ir.http_status = 0;
ir.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
response_code = 0;
ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
ec = TALER_EC_NONE;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the bank is buggy
(or API version conflict); just pass JSON reply to the application */
GNUNET_break_op (0);
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_FORBIDDEN:
/* Access denied */
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, bank says the password is invalid; we should
pass the JSON reply to the application */
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, maybe account really does not exist.
We should pass the JSON reply to the application */
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_CONFLICT:
/* Nothing to verify, we used the same wire subject
twice? */
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
default:
/* unexpected response code */
@ -144,11 +145,15 @@ handle_admin_add_incoming_finished (void *cls,
"Unexpected response code %u\n",
(unsigned int) response_code);
GNUNET_break (0);
ir.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
}
aai->cb (aai->cb_cls,
&ir);
response_code,
ec,
row_id,
timestamp,
j);
TALER_BANK_admin_add_incoming_cancel (aai);
}

View File

@ -1,6 +1,6 @@
/*
This file is part of TALER
Copyright (C) 2015--2023 Taler Systems SA
Copyright (C) 2015--2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@ -158,24 +158,23 @@ handle_transfer_finished (void *cls,
{
struct TALER_BANK_TransferHandle *th = cls;
const json_t *j = response;
struct TALER_BANK_TransferResponse tr = {
.http_status = response_code,
.response = j
};
uint64_t row_id = UINT64_MAX;
struct GNUNET_TIME_Timestamp timestamp = GNUNET_TIME_UNIT_FOREVER_TS;
enum TALER_ErrorCode ec;
th->job = NULL;
switch (response_code)
{
case 0:
tr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_uint64 ("row_id",
&tr.details.ok.row_id),
&row_id),
GNUNET_JSON_spec_timestamp ("timestamp",
&tr.details.ok.timestamp),
&timestamp),
GNUNET_JSON_spec_end ()
};
@ -185,38 +184,39 @@ handle_transfer_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
tr.http_status = 0;
tr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
response_code = 0;
ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
ec = TALER_EC_NONE;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the bank is buggy
(or API version conflict); just pass JSON reply to the application */
GNUNET_break_op (0);
tr.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, bank says our credentials are
invalid. We should pass the JSON reply to the application. */
tr.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, endpoint wrong -- could be user unknown */
tr.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_CONFLICT:
/* Nothing really to verify. Server says we used the same transfer request
UID before, but with different details. Should not happen if the user
properly used #TALER_BANK_prepare_transfer() and our PRNG is not
broken... */
tr.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
tr.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
default:
/* unexpected response code */
@ -224,11 +224,14 @@ handle_transfer_finished (void *cls,
"Unexpected response code %u\n",
(unsigned int) response_code);
GNUNET_break (0);
tr.ec = TALER_JSON_get_error_code (j);
ec = TALER_JSON_get_error_code (j);
break;
}
th->cb (th->cb_cls,
&tr);
response_code,
ec,
row_id,
timestamp);
TALER_BANK_transfer_cancel (th);
}

View File

@ -357,28 +357,34 @@ execute_debit_history (void)
* execution.
*
* @param cls closure
* @param tr response details
* @param response_code HTTP status code
* @param ec taler error code
* @param row_id unique ID of the wire transfer in the bank's records
* @param timestamp when did the transaction go into effect
*/
static void
confirmation_cb (void *cls,
const struct TALER_BANK_TransferResponse *tr)
unsigned int response_code,
enum TALER_ErrorCode ec,
uint64_t row_id,
struct GNUNET_TIME_Timestamp timestamp)
{
(void) cls;
eh = NULL;
if (MHD_HTTP_OK != tr->http_status)
if (MHD_HTTP_OK != response_code)
{
fprintf (stderr,
"The wire transfer didn't execute correctly (%u/%d).\n",
tr->http_status,
tr->ec);
response_code,
ec);
GNUNET_SCHEDULER_shutdown ();
return;
}
fprintf (stdout,
"Wire transfer #%llu executed successfully at %s.\n",
(unsigned long long) tr->details.ok.row_id,
GNUNET_TIME_timestamp2s (tr->details.ok.timestamp));
(unsigned long long) row_id,
GNUNET_TIME_timestamp2s (timestamp));
global_ret = 0;
GNUNET_SCHEDULER_shutdown ();
}
@ -458,29 +464,39 @@ execute_wire_transfer (void)
* Function called with the result of the operation.
*
* @param cls closure
* @param air response details
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the bank's reply is bogus (fails to follow the protocol)
* @param ec detailed error code
* @param serial_id unique ID of the wire transfer in the bank's records; UINT64_MAX on error
* @param timestamp timestamp when the transaction got settled at the bank.
* @param json detailed response from the HTTPD, or NULL if reply was not in JSON
*/
static void
res_cb (void *cls,
const struct TALER_BANK_AdminAddIncomingResponse *air)
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t serial_id,
struct GNUNET_TIME_Timestamp timestamp,
const json_t *json)
{
(void) cls;
(void) timestamp;
op = NULL;
switch (air->http_status)
switch (ec)
{
case MHD_HTTP_OK:
case TALER_EC_NONE:
global_ret = 0;
fprintf (stdout,
"%llu\n",
(unsigned long long) air->details.ok.serial_id);
(unsigned long long) serial_id);
break;
default:
fprintf (stderr,
"Operation failed with status code %u/%u\n",
(unsigned int) air->ec,
air->http_status);
if (NULL != air->response)
json_dumpf (air->response,
(unsigned int) ec,
http_status);
if (NULL != json)
json_dumpf (json,
stderr,
JSON_INDENT (2));
break;

View File

@ -15,10 +15,6 @@ bin_PROGRAMS = \
taler-bank-benchmark \
taler-exchange-benchmark
bin_SCRIPTS = \
taler-benchmark-setup.sh
taler_aggregator_benchmark_SOURCES = \
taler-aggregator-benchmark.c
taler_aggregator_benchmark_LDADD = \
@ -68,12 +64,6 @@ taler_exchange_benchmark_LDADD = \
$(XLIB)
EXTRA_DIST = \
benchmark-common.conf \
benchmark-cs.conf \
benchmark-rsa.conf \
bank-benchmark-cs.conf \
bank-benchmark-rsa.conf \
coins-cs.conf \
coins-rsa.conf \
$(bin_SCRIPTS) \
exchange_benchmark_home/.local/share/taler/exchange/offline-keys/master.priv

View File

@ -1,17 +1,128 @@
# This file is in the public domain.
@INLINE@ benchmark-common.conf
@INLINE@ coins-cs.conf
#
[paths]
# Persistent data storage for the testcase
# This value is a default for `taler_config_home'
taler_test_home = exchange_benchmark_home/
[taler]
# Currency supported by the exchange (can only be one)
currency = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
# how long is one signkey valid?
signkey_duration = 4 weeks
signkey_legal_duration = 2 years
# how long do we provide to clients denomination and signing keys
# ahead of time?
# Keep it short so the test runs fast.
lookahead_sign = 12h
# HTTP port the exchange listens to
port = 8081
# Master public key used to sign the exchange's various keys
master_public_key = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
base_url = "http://localhost:8081/"
WIREWATCH_IDLE_SLEEP_INTERVAL = 500 ms
[exchange-offline]
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
[auditor]
BASE_URL = "http://localhost:8083/"
[exchangedb-postgres]
config = "postgres:///talercheck"
[benchmark-remote-exchange]
host = localhost
# Adjust $HOME to match remote target!
dir = $HOME/repos/taler/exchange/src/benchmark
[bank]
HTTP_PORT = 8082
SERVE = http
MAX_DEBT = EUR:100000000000.0
MAX_DEBT_BANK = EUR:1000000000000000.0
[benchmark]
USER_PAYTO_URI = payto://x-taler-bank/localhost:8082/42?receiver-name=user42
[exchange-account-2]
# What is the payto://-URL of the exchange (to generate wire response)
PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange?receiver-name=Exchange"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
enable_debit = YES
enable_credit = YES
[exchange-accountcredentials-2]
# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
# Authentication information for basic authentication
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = Exchange
PASSWORD = x
username = Exchange
password = x
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS

View File

@ -1,17 +1,133 @@
# This file is in the public domain.
@INLINE@ benchmark-common.conf
@INLINE@ coins-cs.conf
#
[paths]
# Persistent data storage for the testcase
# This value is a default for `taler_config_home'
taler_test_home = exchange_benchmark_home/
[taler]
# Currency supported by the exchange (can only be one)
currency = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
# how long is one signkey valid?
signkey_duration = 4 weeks
signkey_legal_duration = 2 years
# how long do we provide to clients denomination and signing keys
# ahead of time?
# Keep it short so the test runs fast.
lookahead_sign = 12h
# HTTP port the exchange listens to
port = 8081
# Master public key used to sign the exchange's various keys
master_public_key = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
base_url = "http://localhost:8081/"
WIREWATCH_IDLE_SLEEP_INTERVAL = 1500 ms
[exchange-offline]
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
[auditor]
BASE_URL = "http://localhost:8083/"
[exchangedb-postgres]
config = "postgres://exchange:taler@192.168.42.42/exchange"
[benchmark-remote-exchange]
host = localhost
# Adjust $HOME to match remote target!
dir = $HOME/repos/taler/exchange/src/benchmark
[bank]
HTTP_PORT = 8082
SERVE = http
MAX_DEBT = EUR:100000000000.0
MAX_DEBT_BANK = EUR:1000000000000000.0
[benchmark]
USER_PAYTO_URI = payto://x-taler-bank/localhost:8082/42
[exchange-account-2]
# What is the payto://-URL of the exchange (to generate wire response)
PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange?receiver-name=Exchange"
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
PAYTO_URI = "payto://x-taler-bank/localhost:8082/Exchange"
enable_debit = YES
enable_credit = YES
[exchange-accountcredentials-2]
# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
# Authentication information for basic authentication
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = Exchange
PASSWORD = x
username = Exchange
password = x
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048

View File

@ -1,77 +0,0 @@
# This file is in the public domain.
[paths]
TALER_TEST_HOME=exchange_benchmark_home/
[taler]
CURRENCY=EUR
CURRENCY_ROUND_UNIT=EUR:0.01
[exchange]
AML_THRESHOLD=EUR:99999999
SIGNKEY_LEGAL_DURATION=2 years
PORT=8081
MASTER_PUBLIC_KEY=98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
DB=postgres
BASE_URL="http://localhost:8081/"
AGGREGATOR_SHARD_SIZE=67108864
WIREWATCH_IDLE_SLEEP_INTERVAL=5 ms
[taler-exchange-secmod-rsa]
LOOKAHEAD_SIGN="1 d"
[taler-exchange-secmod-cs]
LOOKAHEAD_SIGN="1 d"
[taler-exchange-secmod-eddsa]
DURATION="2 d"
LOOKAHEAD_SIGN="1 d"
# Trust local exchange for "EUR" currency
[merchant-exchange-benchmark]
EXCHANGE_BASE_URL = http://localhost:8081/
MASTER_KEY=98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# If currency does not match [TALER] section, the exchange
# will be ignored!
CURRENCY = EUR
[exchangedb-postgres]
CONFIG="postgres:///talercheck"
[merchantdb-postgres]
CONFIG="postgres:///talercheck"
[auditordb-postgres]
CONFIG="postgres:///talercheck"
[syncdb-postgres]
CONFIG="postgres:///talercheck"
[exchange-offline]
MASTER_PRIV_FILE=${TALER_DATA_HOME}/exchange/offline-keys/master.priv
[bank]
HTTP_PORT=8082
SERVE=http
MAX_DEBT=EUR:100000000000.0
MAX_DEBT_BANK=EUR:1000000000000000.0
DATABASE=bank-db.sqlite3
[libeufin-nexus]
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
DB_CONNECTION="jdbc:sqlite:libeufin-nexus.sqlite3"
[libeufin-sandbox]
#DB_CONNECTION="jdbc:postgresql://localhost/talercheck?socketFactory=org.newsclub.net.unix."
DB_CONNECTION="jdbc:sqlite:libeufin-sandbox.sqlite3"
[auditor]
BASE_URL="http://localhost:8083/"
[benchmark-remote-exchange]
HOST=localhost
# Adjust $HOME to match remote target!
DIR=$HOME/repos/taler/exchange/src/benchmark
[benchmark]
USER_PAYTO_URI="payto://x-taler-bank/localhost:8082/42?receiver-name=user42"

View File

@ -1,6 +1,60 @@
# This file is in the public domain.
@INLINE@ benchmark-common.conf
@INLINE@ coins-cs.conf
#
[paths]
# Persistent data storage for the testcase
# This value is a default for `taler_config_home'
TALER_TEST_HOME = exchange_benchmark_home/
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:99999999
SIGNKEY_LEGAL_DURATION = 2 years
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
AGGREGATOR_SHARD_SIZE = 67108864
#AGGREGATOR_SHARD_SIZE = 2147483648
WIREWATCH_IDLE_SLEEP_INTERVAL = 5 ms
[exchange-offline]
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
[auditor]
BASE_URL = "http://localhost:8083/"
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[benchmark-remote-exchange]
HOST = localhost
# Adjust $HOME to match remote target!
DIR = $HOME/repos/taler/exchange/src/benchmark
[bank]
HTTP_PORT = 8082
SERVE = http
MAX_DEBT = EUR:100000000000.0
MAX_DEBT_BANK = EUR:1000000000000000.0
DATABASE = bank-db.sqlite3
[benchmark]
USER_PAYTO_URI = payto://x-taler-bank/localhost:8082/42
[exchange-account-test]
# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
@ -14,3 +68,61 @@ WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = Exchange
PASSWORD = x
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS

View File

@ -1,6 +1,60 @@
# This file is in the public domain.
@INLINE@ benchmark-common.conf
@INLINE@ coins-rsa.conf
#
[paths]
# Persistent data storage for the testcase
# This value is a default for `taler_config_home'
TALER_TEST_HOME = exchange_benchmark_home/
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
AML_THRESHOLD = EUR:99999999
SIGNKEY_LEGAL_DURATION = 2 years
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
# Base URL of the exchange. Must be set to a URL where the
# exchange (or the twister) is actually listening.
BASE_URL = "http://localhost:8081/"
AGGREGATOR_SHARD_SIZE = 67108864
#AGGREGATOR_SHARD_SIZE = 2147483648
WIREWATCH_IDLE_SLEEP_INTERVAL = 5 ms
[exchange-offline]
MASTER_PRIV_FILE = ${TALER_DATA_HOME}/exchange/offline-keys/master.priv
[auditor]
BASE_URL = "http://localhost:8083/"
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[benchmark-remote-exchange]
HOST = localhost
# Adjust $HOME to match remote target!
DIR = $HOME/repos/taler/exchange/src/benchmark
[bank]
HTTP_PORT = 8082
SERVE = http
MAX_DEBT = EUR:100000000000.0
MAX_DEBT_BANK = EUR:1000000000000000.0
DATABASE = bank-db.sqlite3
[benchmark]
USER_PAYTO_URI = payto://x-taler-bank/localhost:8082/42
[exchange-account-test]
# What is the bank account (with the "Taler Bank" demo system)? Must end with "/".
@ -14,3 +68,66 @@ WIRE_GATEWAY_URL = http://localhost:8082/Exchange/
WIRE_GATEWAY_AUTH_METHOD = "basic"
USERNAME = Exchange
PASSWORD = x
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048

View File

@ -1,58 +0,0 @@
# This file is in the public domain.
#
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = CS

View File

@ -1,63 +0,0 @@
# This file is in the public domain.
#
# Sections starting with "coin_" specify which denominations
# the exchange should support (and their respective fee structure)
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_5]
value = EUR:5
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048
[coin_eur_10]
value = EUR:10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
CIPHER = RSA
rsa_keysize = 2048

View File

@ -1,624 +0,0 @@
#!/bin/bash
#
# This file is part of TALER
# Copyright (C) 2023 Taler Systems SA
#
# TALER is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or
# (at your option) any later version.
#
# TALER is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with TALER; see the file COPYING. If not, see
# <http://www.gnu.org/licenses/>
#
# Author: Christian Grothoff
#
# This script configures and launches various GNU Taler services.
# Which ones depend on command-line options. Use "-h" to find out.
# Prints "<<READY>>" on a separate line once all requested services
# are running. Close STDIN (or input 'NEWLINE') to stop all started
# services again.
#
set -eu
# Exit, with status code "skip" (no 'real' failure)
function exit_skip() {
echo " SKIP: " "$@"
exit 77
}
# Exit, with error message (hard failure)
function exit_fail() {
echo " FAIL: " "$@"
exit 1
}
# Cleanup to run whenever we exit
function cleanup()
{
for n in $(jobs -p)
do
kill $n 2> /dev/null || true
done
wait
rm -f libeufin-nexus.pid libeufin-sandbox.pid
}
# Install cleanup handler (except for kill -9)
trap cleanup EXIT
START_AUDITOR=0
START_BACKUP=0
START_EXCHANGE=0
START_FAKEBANK=0
START_MERCHANT=0
START_NEXUS=0
START_SANDBOX=0
USE_VALGRIND=""
CONF_ORIG="~/.config/taler.conf"
LOGLEVEL="DEBUG"
DEFAULT_SLEEP="0.2"
# Parse command-line options
while getopts ':abc:efhl:mnsv' OPTION; do
case "$OPTION" in
a)
START_AUDITOR="1"
;;
b)
START_BACKUP="1"
;;
c)
CONF_ORIG="$OPTARG"
;;
e)
START_EXCHANGE="1"
;;
f)
START_FAKEBANK="1"
;;
h)
echo 'Supported options:'
echo ' -a -- start auditor'
echo ' -b -- start backup/sync'
echo ' -c $CONF -- set configuration'
echo ' -e -- start exchange'
echo ' -f -- start fakebank'
echo ' -h -- print this help'
echo ' -l $LOGLEVEL -- set log level'
echo ' -m -- start merchant'
echo ' -n -- start nexus'
echo ' -s -- start sandbox'
echo ' -v -- use valgrind'
exit 0
;;
l)
LOGLEVEL="$OPTARG"
;;
m)
START_MERCHANT="1"
;;
n)
START_NEXUS="1"
;;
s)
START_SANDBOX="1"
;;
v)
USE_VALGRIND="valgrind --leak-check=yes"
DEFAULT_SLEEP="2"
;;
?)
exit_fail "Unrecognized command line option"
;;
esac
done
echo "Starting with configuration file at: $CONF_ORIG"
CONF="$CONF_ORIG.edited"
cp "${CONF_ORIG}" "${CONF}"
echo -n "Testing for jq"
jq -h > /dev/null || exit_skip " jq required"
echo " FOUND"
if [ "1" = "$START_EXCHANGE" ]
then
echo -n "Testing for Taler exchange"
taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange-httpd required"
echo " FOUND"
fi
if [ "1" = "$START_MERCHANT" ]
then
echo -n "Testing for Taler merchant"
taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant-httpd required"
echo " FOUND"
fi
if [ "1" = "$START_BACKUP" ]
then
echo -n "Testing for sync-httpd"
sync-httpd -h > /dev/null || exit_skip " sync-httpd required"
echo " FOUND"
fi
if [ "1" = "$START_NEXUS" ]
then
echo -n "Testing for libeufin-cli"
libeufin-cli --help >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
fi
EXCHANGE_URL=$(taler-config -c "$CONF" -s "EXCHANGE" -o "BASE_URL")
CURRENCY=$(taler-config -c "$CONF" -s "TALER" -o "CURRENCY")
register_sandbox_account() {
export LIBEUFIN_SANDBOX_USERNAME="$1"
export LIBEUFIN_SANDBOX_PASSWORD="$2"
# FIXME-MS: delete should be removed after we make 'register' idempotent!
libeufin-cli sandbox \
demobank \
delete \
--bank-account "$1" &> /dev/null || true
libeufin-cli sandbox \
demobank \
register --name "$3"
unset LIBEUFIN_SANDBOX_USERNAME
unset LIBEUFIN_SANDBOX_PASSWORD
}
BANK_PORT=$(taler-config -c "$CONF" -s "BANK" -o "HTTP_PORT")
if [ "1" = "$START_NEXUS" ]
then
NEXUS_PORT="$BANK_PORT"
SANDBOX_PORT="1$BANK_PORT"
else
NEXUS_PORT="0"
SANDBOX_PORT="1$BANK_PORT"
fi
if [ "1" = "$START_SANDBOX" ]
then
export LIBEUFIN_SANDBOX_DB_CONNECTION=$(taler-config -c "$CONF" -s "libeufin-sandbox" -o "DB_CONNECTION")
# Create the default demobank.
echo -n "Configuring sandbox "
libeufin-sandbox config --currency "$CURRENCY" default &> libeufin-sandbox-config.log
echo "DONE"
echo -n "Launching sandbox "
export LIBEUFIN_SANDBOX_ADMIN_PASSWORD="secret"
libeufin-sandbox serve \
--port "$SANDBOX_PORT" \
> libeufin-sandbox-stdout.log \
2> libeufin-sandbox-stderr.log &
echo $! > libeufin-sandbox.pid
echo "DONE"
export LIBEUFIN_SANDBOX_URL="http://localhost:$SANDBOX_PORT/"
OK="0"
echo -n "Waiting for Sandbox ..."
for n in $(seq 1 100); do
echo -n "."
sleep "$DEFAULT_SLEEP"
wget --timeout=1 \
--tries=3 \
--waitretry=0 \
-o /dev/null \
-O /dev/null \
"$LIBEUFIN_SANDBOX_URL" || continue
OK="1"
break
done
if [ "1" != "$OK" ]
then
exit_skip "Failed to launch services (sandbox)"
fi
echo "OK"
echo -n "Register Sandbox users ..."
register_sandbox_account fortytwo x "Forty Two"
register_sandbox_account fortythree x "Forty Three"
register_sandbox_account exchange x "Exchange Company"
register_sandbox_account tor x "Tor Project"
register_sandbox_account gnunet x "GNUnet"
register_sandbox_account tutorial x "Tutorial"
register_sandbox_account survey x "Survey"
echo " DONE"
echo -n "Fixing up exchange's PAYTO_URI in the config ..."
export LIBEUFIN_SANDBOX_USERNAME="exchange"
export LIBEUFIN_SANDBOX_PASSWORD="x"
EXCHANGE_PAYTO=$(libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri')
taler-config -c "$CONF" -s exchange-account-1 -o "PAYTO_URI" -V "$EXCHANGE_PAYTO"
echo " OK"
echo -n "Setting this exchange as the bank's default ..."
libeufin-sandbox default-exchange "$EXCHANGE_URL" "$EXCHANGE_PAYTO"
echo " OK"
# Prepare EBICS: create Ebics host and Exchange subscriber.
# Shortly becoming admin to setup Ebics.
export LIBEUFIN_SANDBOX_USERNAME="admin"
export LIBEUFIN_SANDBOX_PASSWORD="secret"
echo -n "Create EBICS host at Sandbox.."
# FIXME-MS: || true should be removed after we make 'create' idempotent!
libeufin-cli sandbox \
--sandbox-url "$LIBEUFIN_SANDBOX_URL" \
ebicshost create --host-id talerebics &> libeufin-sandbox-ebicshost-create.log || true
echo "OK"
echo -n "Create exchange EBICS subscriber at Sandbox.."
# FIXME-MS: || true should be removed after we make 'new-ebicssubscriber' idempotent!
libeufin-cli sandbox \
demobank new-ebicssubscriber --host-id talerebics \
--user-id exchangeebics --partner-id talerpartner \
--bank-account exchange &> libeufin-sandbox-ebicsscubscriber.log || true
# that's a username _and_ a bank account name
echo "OK"
unset LIBEUFIN_SANDBOX_USERNAME
unset LIBEUFIN_SANDBOX_PASSWORD
fi
if [ "1" = "$START_NEXUS" ]
then
echo "Setting up Nexus ..."
# Prepare Nexus, which is the side actually talking
# to the exchange.
export LIBEUFIN_NEXUS_DB_CONNECTION=$(taler-config -c "$CONF" -s "libeufin-nexus" -o "DB_CONNECTION")
# For convenience, username and password are
# identical to those used at the Sandbox.
echo -n "Create exchange Nexus user ..."
libeufin-nexus superuser exchange --password x
echo "OK"
libeufin-nexus serve --port "$NEXUS_PORT" \
2> libeufin-nexus-stderr.log \
> libeufin-nexus-stdout.log &
echo $! > libeufin-nexus.pid
export LIBEUFIN_NEXUS_URL="http://localhost:$NEXUS_PORT"
echo -n "Waiting for Nexus ..."
OK="0"
for n in $(seq 1 100); do
echo -n "."
sleep "$DEFAULT_SLEEP"
wget --timeout=1 \
--tries=3 \
--waitretry=0 \
-o /dev/null \
-O /dev/null \
"$LIBEUFIN_NEXUS_URL" || continue
OK="1"
break
done
if [ "1" != "$OK" ]
then
exit_skip "Failed to launch services (bank)"
fi
echo " OK"
export LIBEUFIN_NEXUS_USERNAME=exchange
export LIBEUFIN_NEXUS_PASSWORD=x
echo -n "Creating a EBICS connection at Nexus ..."
libeufin-cli connections new-ebics-connection \
--ebics-url "http://localhost:$SANDBOX_PORT/ebicsweb" \
--host-id talerebics \
--partner-id talerpartner \
--ebics-user-id exchangeebics \
talerconn
echo "OK"
echo -n "Setup EBICS keying ..."
libeufin-cli connections connect talerconn > /dev/null
echo "OK"
echo -n "Download bank account name from Sandbox ..."
libeufin-cli connections download-bank-accounts talerconn
echo "OK"
echo -n "Importing bank account info into Nexus ..."
libeufin-cli connections import-bank-account \
--offered-account-id exchange \
--nexus-bank-account-id exchange-nexus \
talerconn
echo "OK"
echo -n "Setup payments submission task..."
# Tries every second.
libeufin-cli accounts task-schedule \
--task-type submit \
--task-name exchange-payments \
--task-cronspec "* * *" \
exchange-nexus
echo "OK"
# Tries every second. Ask C52
echo -n "Setup history fetch task..."
libeufin-cli accounts task-schedule \
--task-type fetch \
--task-name exchange-history \
--task-cronspec "* * *" \
--task-param-level report \
--task-param-range-type latest \
exchange-nexus
echo "OK"
# create Taler facade.
echo -n "Create the Taler facade at Nexus..."
libeufin-cli facades \
new-taler-wire-gateway-facade \
--currency TESTKUDOS --facade-name test-facade \
talerconn exchange-nexus
echo "OK"
# Facade schema: http://localhost:$NEXUS_PORT/facades/test-facade/taler-wire-gateway/
# FIXME: set the above URL automatically in the configuration?
fi
if [ "1" = "$START_FAKEBANK" ]
then
echo "Setting up fakebank ..."
$USE_VALGRIND taler-fakebank-run -c "$CONF" -L "$LOGLEVEL" 2> taler-fakebank-run.log &
fi
if [ "1" = "$START_EXCHANGE" ]
then
echo -n "Starting exchange ..."
EXCHANGE_PORT=$(taler-config -c "$CONF" -s EXCHANGE -o PORT)
EXCHANGE_URL="http://localhost:${EXCHANGE_PORT}/"
MASTER_PRIV_FILE=$(taler-config -f -c "${CONF}" -s "EXCHANGE-OFFLINE" -o "MASTER_PRIV_FILE")
MASTER_PRIV_DIR=$(dirname "$MASTER_PRIV_FILE")
mkdir -p "${MASTER_PRIV_DIR}"
gnunet-ecc -g1 "$MASTER_PRIV_FILE" > /dev/null 2> /dev/null
MASTER_PUB=$(gnunet-ecc -p "${MASTER_PRIV_FILE}")
MPUB=$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)
if [ "$MPUB" != "$MASTER_PUB" ]
then
echo -n " patching master_pub ($MASTER_PUB)..."
taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB"
fi
taler-exchange-dbinit -c "$CONF"
$USE_VALGRIND taler-exchange-secmod-eddsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-eddsa.log &
$USE_VALGRIND taler-exchange-secmod-rsa -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-rsa.log &
$USE_VALGRIND taler-exchange-secmod-cs -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-secmod-cs.log &
$USE_VALGRIND taler-exchange-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-exchange-httpd.log &
EXCHANGE_HTTPD_PID=$!
$USE_VALGRIND taler-exchange-wirewatch -c "$CONF" 2> taler-exchange-wirewatch.log &
WIREWATCH_PID=$!
$USE_VALGRIND taler-exchange-aggregator -c "$CONF" 2> taler-exchange-aggregator.log &
AGGREGATOR_PID=$!
$USE_VALGRIND taler-exchange-transfer -c "$CONF" 2> taler-exchange-transfer.log &
TRANSFER_PID=$!
echo " DONE"
fi
if [ "1" = "$START_MERCHANT" ]
then
echo -n "Starting merchant ..."
MEPUB=$(taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY)
MXPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
if [ "$MEPUB" != "$MXPUB" ]
then
echo -n " patching master_pub ($MXPUB)..."
taler-config -c "$CONF" -s merchant-exchange-benchmark -o MASTER_KEY -V "$MXPUB"
fi
MERCHANT_PORT=$(taler-config -c "$CONF" -s MERCHANT -o PORT)
MERCHANT_URL="http://localhost:${MERCHANT_PORT}/"
taler-merchant-dbinit -c "$CONF"
$USE_VALGRIND taler-merchant-httpd -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-httpd.log &
MERCHANT_HTTPD_PID=$!
$USE_VALGRIND taler-merchant-webhook -c "$CONF" -L "$LOGLEVEL" 2> taler-merchant-webhook.log &
MERCHANT_WEBHOOK_PID=$!
echo " DONE"
fi
if [ "1" = "$START_BACKUP" ]
then
echo -n "Starting sync ..."
SYNC_PORT=$(taler-config -c "$CONF" -s SYNC -o PORT)
SYNC_URL="http://localhost:${SYNC_PORT}/"
sync-dbinit -c "$CONF"
$USE_VALGRIND sync-httpd -c "$CONF" -L "$LOGLEVEL" 2> sync-httpd.log &
echo " DONE"
fi
if [ "1" = "$START_AUDITOR" ]
then
echo -n "Starting auditor ..."
AUDITOR_URL="http://localhost:8083/"
AUDITOR_PRIV_FILE=$(taler-config -f -c "$CONF" -s AUDITOR -o AUDITOR_PRIV_FILE)
AUDITOR_PRIV_DIR=$(dirname "$AUDITOR_PRIV_FILE")
mkdir -p "$AUDITOR_PRIV_DIR"
gnunet-ecc -g1 "$AUDITOR_PRIV_FILE" > /dev/null 2> /dev/null
AUDITOR_PUB=$(gnunet-ecc -p "${AUDITOR_PRIV_FILE}")
MAPUB=${MASTER_PUB:-$(taler-config -c "$CONF" -s exchange -o MASTER_PUBLIC_KEY)}
taler-auditor-dbinit -c "$CONF"
taler-auditor-exchange -c "$CONF" -m "$MAPUB" -u "$EXCHANGE_URL"
$USE_VALGRIND taler-auditor-httpd -L "$LOGLEVEL" -c "$CONF" 2> taler-auditor-httpd.log &
echo " DONE"
fi
if [[ "1" = "$START_NEXUS" || "1" = "$START_FAKEBANK" ]]
then
echo -n "Waiting for the bank"
# Wait for bank to be available (usually the slowest)
OK="0"
for n in $(seq 1 300)
do
echo -n "."
sleep "$DEFAULT_SLEEP"
# bank
wget --tries=1 \
--waitretry=0 \
--timeout=1 \
--user admin \
--password secret \
"http://localhost:8082/" \
-o /dev/null \
-O /dev/null >/dev/null || continue
OK="1"
break
done
if [ "1" != "$OK" ]
then
exit_skip "Failed to launch services (bank)"
fi
echo " OK"
fi
echo -n "Waiting for Taler services ..."
# Wait for all other taler services to be available
for n in $(seq 1 20)
do
echo -n "."
sleep "$DEFAULT_SLEEP"
OK="0"
if [ "1" = "$START_EXCHANGE" ]
then
wget \
--tries=1 \
--timeout=1 \
"http://localhost:8081/config" \
-o /dev/null \
-O /dev/null >/dev/null || continue
fi
if [ "1" = "$START_MERCHANT" ]
then
wget \
--tries=1 \
--timeout=1 \
"${MERCHANT_URL}config" \
-o /dev/null \
-O /dev/null >/dev/null || continue
fi
if [ "1" = "$START_BACKUP" ]
then
wget \
--tries=1 \
--timeout=1 \
"${SYNC_URL}config" \
-o /dev/null \
-O /dev/null >/dev/null || continue
fi
if [ "1" = "$START_AUDITOR" ]
then
wget \
--tries=1 \
--timeout=1 \
"${AUDITOR_URL}config" \
-o /dev/null \
-O /dev/null >/dev/null || continue
fi
OK="1"
break
done
if [ 1 != "$OK" ]
then
exit_skip "Failed to launch (some) Taler services"
fi
echo " OK"
if [ "1" = "$START_EXCHANGE" ]
then
echo -n "Wait for exchange /management/keys to be ready "
OK="0"
LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX)
for n in $(seq 1 50)
do
echo -n "."
sleep "$DEFAULT_SLEEP"
# exchange
wget \
--tries=3 \
--waitretry=0 \
--timeout=1 \
"http://localhost:8081/management/keys"\
-o /dev/null \
-O "$LAST_RESPONSE" \
>/dev/null || continue
OK="1"
break;
done
if [ "1" != "$OK" ]
then
cat "$LAST_RESPONSE"
exit_skip "Failed to setup exchange keys, check secmod logs"
fi
rm "$LAST_RESPONSE"
echo " OK"
echo -n "Setting up exchange keys ..."
taler-exchange-offline -c "$CONF" \
download \
sign \
wire-fee now iban "$CURRENCY:0.01" "$CURRENCY:0.01" \
global-fee now "$CURRENCY:0.01" "$CURRENCY:0.01" "$CURRENCY:0.01" 1h 1year 5 \
upload &> taler-exchange-offline.log
echo "OK"
for ASEC in $(taler-config -c "$CONF" -S | grep -i "exchange-account-")
do
ENABLED=$(taler-config -c "$CONF" -s "$ASEC" -o "ENABLE_CREDIT")
if [ "YES" = "$ENABLED" ]
then
echo -n "Configuring bank account $ASEC ..."
EXCHANGE_PAYTO_URI=$(taler-config -c "$CONF" -s "$ASEC" -o "PAYTO_URI")
taler-exchange-offline -c "$CONF" \
enable-account "$EXCHANGE_PAYTO_URI" \
upload &> "taler-exchange-offline-account-$ASEC.log"
echo " OK"
fi
done
if [ "1" = "$START_AUDITOR" ]
then
echo -n "Enabling auditor ..."
taler-exchange-offline -c "$CONF" \
enable-auditor $AUDITOR_PUB $AUDITOR_URL "$CURRENCY Auditor" \
upload &> taler-exchange-offline-auditor.log
echo "OK"
fi
echo -n "Checking /keys "
OK="0"
LAST_RESPONSE=$(mktemp tmp-last-response.XXXXXXXX)
for n in $(seq 1 10)
do
echo -n "."
sleep "$DEFAULT_SLEEP"
wget \
--tries=1 \
--timeout=1 \
"http://localhost:8081/keys" \
-o /dev/null \
-O "$LAST_RESPONSE" \
>/dev/null || continue
OK="1"
break
done
if [ "1" != "$OK" ]
then
cat "$LAST_RESPONSE"
exit_skip " Failed to setup keys"
fi
rm "$LAST_RESPONSE"
echo " OK"
fi
if [ "1" = "$START_AUDITOR" ]
then
echo -n "Setting up auditor signatures ..."
timeout 15 taler-auditor-offline -c "$CONF" \
download \
sign \
upload &> taler-auditor-offline.log
echo " OK"
fi
# Signal caller that we are ready.
echo "<<READY>>"
# Wait until caller stops us.
read
exit 0

View File

@ -306,9 +306,8 @@ run (void *cls,
GNUNET_asprintf (&amount_5, "%s:5", currency);
GNUNET_asprintf (&amount_4, "%s:4", currency);
GNUNET_asprintf (&amount_1, "%s:1", currency);
GNUNET_assert (GNUNET_OK ==
TALER_amount_set_zero (currency,
&total_reserve_amount));
GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (currency,
&total_reserve_amount));
total_reserve_amount.value = 5 * howmany_coins;
GNUNET_asprintf (&withdraw_fee_str,
"%s:0.1",
@ -538,8 +537,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
struct GNUNET_OS_Process *exchange_slave = NULL;
struct GNUNET_DISK_PipeHandle *exchange_slave_pipe;
if ( (MODE_CLIENT == mode) ||
(MODE_BOTH == mode) )
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
{
if (use_fakebank)
{
@ -589,8 +587,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb,
"-c", config_file,
"-C",
NULL);
if ( (NULL == exchanged) &&
(MODE_BOTH == mode) )
if ( (NULL == exchanged) && (MODE_BOTH == mode) )
{
if (-1 != fakebank)
{
@ -981,19 +978,15 @@ main (int argc,
logfile);
if (NULL == mode_str)
mode = MODE_BOTH;
else if (0 == strcmp (mode_str,
"exchange"))
else if (0 == strcmp (mode_str, "exchange"))
mode = MODE_EXCHANGE;
else if (0 == strcmp (mode_str,
"client"))
else if (0 == strcmp (mode_str, "client"))
mode = MODE_CLIENT;
else if (0 == strcmp (mode_str,
"both"))
else if (0 == strcmp (mode_str, "both"))
mode = MODE_BOTH;
else
{
TALER_LOG_ERROR ("Unknown mode given: '%s'\n",
mode_str);
TALER_LOG_ERROR ("Unknown mode given: '%s'\n", mode_str);
GNUNET_free (cfg_filename);
return BAD_CONFIG_FILE;
}
@ -1144,9 +1137,7 @@ main (int argc,
if (GNUNET_OK == result)
{
struct rusage usage;
GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN,
&usage));
GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN, &usage));
fprintf (stdout,
"Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n",
howmany_coins,

View File

@ -388,15 +388,14 @@ load_offline_key (int do_create)
* add operation result.
*
* @param cls closure with a `struct DenominationAddRequest`
* @param adr response data
* @param hr HTTP response data
*/
static void
denomination_add_cb (
void *cls,
const struct TALER_EXCHANGE_AuditorAddDenominationResponse *adr)
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct DenominationAddRequest *dar = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &adr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@ -950,11 +949,11 @@ do_show (char *const *args)
json_t *keys;
const char *err_name;
unsigned int err_line;
const json_t *denomkeys;
json_t *denomkeys;
struct TALER_MasterPublicKeyP mpub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("denoms",
&denomkeys),
GNUNET_JSON_spec_json ("denoms",
&denomkeys),
GNUNET_JSON_spec_fixed_auto ("master_public_key",
&mpub),
GNUNET_JSON_spec_end ()
@ -998,9 +997,11 @@ do_show (char *const *args)
{
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
GNUNET_JSON_parse_free (spec);
json_decref (keys);
/* do NOT consume input if next argument is '-' */
if ( (NULL != args[0]) &&
@ -1137,10 +1138,10 @@ do_sign (char *const *args)
const char *err_name;
unsigned int err_line;
struct TALER_MasterPublicKeyP mpub;
const json_t *denomkeys;
json_t *denomkeys;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("denoms",
&denomkeys),
GNUNET_JSON_spec_json ("denoms",
&denomkeys),
GNUNET_JSON_spec_fixed_auto ("master_public_key",
&mpub),
GNUNET_JSON_spec_end ()
@ -1195,9 +1196,11 @@ do_sign (char *const *args)
{
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
GNUNET_JSON_parse_free (spec);
json_decref (keys);
next (args);
}

View File

@ -1301,15 +1301,13 @@ upload_signkey_revocation (const char *exchange_url,
* Function called with information about the post auditor add operation result.
*
* @param cls closure with a `struct AuditorAddRequest`
* @param mer response data
* @param hr HTTP response data
*/
static void
auditor_add_cb (
void *cls,
const struct TALER_EXCHANGE_ManagementAuditorEnableResponse *mer)
auditor_add_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct AuditorAddRequest *aar = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &mer->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@ -1403,15 +1401,13 @@ upload_auditor_add (const char *exchange_url,
* Function called with information about the post auditor del operation result.
*
* @param cls closure with a `struct AuditorDelRequest`
* @param mdr response data
* @param hr HTTP response data
*/
static void
auditor_del_cb (void *cls,
const struct
TALER_EXCHANGE_ManagementAuditorDisableResponse *mdr)
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct AuditorDelRequest *adr = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &mdr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@ -1543,8 +1539,8 @@ upload_wire_add (const char *exchange_url,
struct WireAddRequest *war;
const char *err_name;
const char *conversion_url = NULL;
const json_t *debit_restrictions;
const json_t *credit_restrictions;
json_t *debit_restrictions;
json_t *credit_restrictions;
unsigned int err_line;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("payto_uri",
@ -1553,10 +1549,10 @@ upload_wire_add (const char *exchange_url,
GNUNET_JSON_spec_string ("conversion_url",
&conversion_url),
NULL),
GNUNET_JSON_spec_array_const ("debit_restrictions",
&debit_restrictions),
GNUNET_JSON_spec_array_const ("credit_restrictions",
&credit_restrictions),
GNUNET_JSON_spec_json ("debit_restrictions",
&debit_restrictions),
GNUNET_JSON_spec_json ("credit_restrictions",
&credit_restrictions),
GNUNET_JSON_spec_timestamp ("validity_start",
&start_time),
GNUNET_JSON_spec_fixed_auto ("master_sig_add",
@ -1581,6 +1577,7 @@ upload_wire_add (const char *exchange_url,
stderr,
JSON_INDENT (2));
global_ret = EXIT_FAILURE;
GNUNET_JSON_parse_free (spec);
test_shutdown ();
return;
}
@ -1594,6 +1591,7 @@ upload_wire_add (const char *exchange_url,
"payto:// URI `%s' is malformed\n",
payto_uri);
global_ret = EXIT_FAILURE;
GNUNET_JSON_parse_free (spec);
test_shutdown ();
return;
}
@ -1608,6 +1606,7 @@ upload_wire_add (const char *exchange_url,
"payto URI is malformed: %s\n",
msg);
GNUNET_free (msg);
GNUNET_JSON_parse_free (spec);
test_shutdown ();
global_ret = EXIT_INVALIDARGUMENT;
return;
@ -1630,6 +1629,7 @@ upload_wire_add (const char *exchange_url,
GNUNET_CONTAINER_DLL_insert (war_head,
war_tail,
war);
GNUNET_JSON_parse_free (spec);
}
@ -1730,15 +1730,14 @@ upload_wire_del (const char *exchange_url,
* Function called with information about the post wire fee operation result.
*
* @param cls closure with a `struct WireFeeRequest`
* @param swr response data
* @param hr HTTP response data
*/
static void
wire_fee_cb (
void *cls,
const struct TALER_EXCHANGE_ManagementSetWireFeeResponse *swr)
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct WireFeeRequest *wfr = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &swr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@ -1836,15 +1835,14 @@ upload_wire_fee (const char *exchange_url,
* Function called with information about the post global fee operation result.
*
* @param cls closure with a `struct WireFeeRequest`
* @param gr response data
* @param hr HTTP response data
*/
static void
global_fee_cb (
void *cls,
const struct TALER_EXCHANGE_ManagementSetGlobalFeeResponse *gr)
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct GlobalFeeRequest *gfr = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &gr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@ -2104,13 +2102,13 @@ upload_keys (const char *exchange_url,
struct UploadKeysRequest *ukr;
const char *err_name;
unsigned int err_line;
const json_t *denom_sigs;
const json_t *signkey_sigs;
json_t *denom_sigs;
json_t *signkey_sigs;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("denom_sigs",
&denom_sigs),
GNUNET_JSON_spec_array_const ("signkey_sigs",
&signkey_sigs),
GNUNET_JSON_spec_json ("denom_sigs",
&denom_sigs),
GNUNET_JSON_spec_json ("signkey_sigs",
&signkey_sigs),
GNUNET_JSON_spec_end ()
};
bool ok = true;
@ -2226,6 +2224,7 @@ upload_keys (const char *exchange_url,
}
GNUNET_free (pkd.sign_sigs);
GNUNET_free (pkd.denom_sigs);
GNUNET_JSON_parse_free (spec);
}
@ -2273,13 +2272,13 @@ upload_extensions (const char *exchange_url,
size_t idx,
const json_t *value)
{
const json_t *extensions;
json_t *extensions;
struct TALER_MasterSignatureP sig;
const char *err_name;
unsigned int err_line;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_object_const ("extensions",
&extensions),
GNUNET_JSON_spec_json ("extensions",
&extensions),
GNUNET_JSON_spec_fixed_auto ("extensions_sig",
&sig),
GNUNET_JSON_spec_end ()
@ -2310,9 +2309,9 @@ upload_extensions (const char *exchange_url,
struct TALER_ExtensionManifestsHashP h_manifests;
if (GNUNET_OK !=
TALER_JSON_extensions_manifests_hash (extensions,
&h_manifests))
TALER_JSON_extensions_manifests_hash (extensions, &h_manifests))
{
GNUNET_JSON_parse_free (spec);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"couldn't hash extensions' manifests\n");
global_ret = EXIT_FAILURE;
@ -2329,6 +2328,7 @@ upload_extensions (const char *exchange_url,
&master_pub,
&sig))
{
GNUNET_JSON_parse_free (spec);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"invalid signature for extensions\n");
global_ret = EXIT_FAILURE;
@ -2343,9 +2343,8 @@ upload_extensions (const char *exchange_url,
.extensions = extensions,
.extensions_sig = sig,
};
struct UploadExtensionsRequest *uer
= GNUNET_new (struct UploadExtensionsRequest);
struct UploadExtensionsRequest *uer = GNUNET_new (struct
UploadExtensionsRequest);
uer->idx = idx;
uer->h = TALER_EXCHANGE_management_post_extensions (
ctx,
@ -2357,6 +2356,7 @@ upload_extensions (const char *exchange_url,
uer_tail,
uer);
}
GNUNET_JSON_parse_free (spec);
}
@ -2364,15 +2364,14 @@ upload_extensions (const char *exchange_url,
* Function called with information about the add partner operation.
*
* @param cls closure with a `struct PartnerAddRequest`
* @param apr response data
* @param hr HTTP response data
*/
static void
add_partner_cb (
void *cls,
const struct TALER_EXCHANGE_ManagementAddPartnerResponse *apr)
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct PartnerAddRequest *par = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &apr->hr;
if (MHD_HTTP_NO_CONTENT != hr->http_status)
{
@ -4483,15 +4482,15 @@ do_show (char *const *args)
json_t *keys;
const char *err_name;
unsigned int err_line;
const json_t *denomkeys;
const json_t *signkeys;
json_t *denomkeys;
json_t *signkeys;
struct TALER_MasterPublicKeyP mpub;
struct TALER_SecurityModulePublicKeySetP secmset;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("future_denoms",
&denomkeys),
GNUNET_JSON_spec_array_const ("future_signkeys",
&signkeys),
GNUNET_JSON_spec_json ("future_denoms",
&denomkeys),
GNUNET_JSON_spec_json ("future_signkeys",
&signkeys),
GNUNET_JSON_spec_fixed_auto ("master_pub",
&mpub),
GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key",
@ -4536,6 +4535,7 @@ do_show (char *const *args)
"Fatal: exchange uses different master key!\n");
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
@ -4544,6 +4544,7 @@ do_show (char *const *args)
{
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
@ -4557,10 +4558,12 @@ do_show (char *const *args)
{
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
json_decref (keys);
GNUNET_JSON_parse_free (spec);
next (args);
}
@ -4880,15 +4883,15 @@ do_sign (char *const *args)
json_t *keys;
const char *err_name;
unsigned int err_line;
const json_t *denomkeys;
const json_t *signkeys;
json_t *denomkeys;
json_t *signkeys;
struct TALER_MasterPublicKeyP mpub;
struct TALER_SecurityModulePublicKeySetP secmset;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("future_denoms",
&denomkeys),
GNUNET_JSON_spec_array_const ("future_signkeys",
&signkeys),
GNUNET_JSON_spec_json ("future_denoms",
&denomkeys),
GNUNET_JSON_spec_json ("future_signkeys",
&signkeys),
GNUNET_JSON_spec_fixed_auto ("master_pub",
&mpub),
GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key",
@ -4935,6 +4938,7 @@ do_sign (char *const *args)
"Fatal: exchange uses different master key!\n");
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
@ -4945,6 +4949,7 @@ do_sign (char *const *args)
"Fatal: security module keys changed!\n");
global_ret = EXIT_FAILURE;
test_shutdown ();
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
@ -4968,6 +4973,7 @@ do_sign (char *const *args)
test_shutdown ();
json_decref (signkey_sig_array);
json_decref (denomkey_sig_array);
GNUNET_JSON_parse_free (spec);
json_decref (keys);
return;
}
@ -4979,6 +4985,7 @@ do_sign (char *const *args)
GNUNET_JSON_pack_array_steal ("signkey_sigs",
signkey_sig_array)));
}
GNUNET_JSON_parse_free (spec);
json_decref (keys);
next (args);
}

View File

@ -984,18 +984,14 @@ TEH_handler_age_withdraw_reveal (
MHD_RESULT result = MHD_NO;
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
struct AgeRevealContext actx = {0};
const json_t *j_denoms_h;
const json_t *j_coin_evs;
const json_t *j_disclosed_coin_secrets;
json_t *j_denoms_h;
json_t *j_coin_evs;
json_t *j_disclosed_coin_secrets;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("reserve_pub",
&actx.reserve_pub),
GNUNET_JSON_spec_array_const ("denoms_h",
&j_denoms_h),
GNUNET_JSON_spec_array_const ("coin_evs",
&j_coin_evs),
GNUNET_JSON_spec_array_const ("disclosed_coin_secrets",
&j_disclosed_coin_secrets),
GNUNET_JSON_spec_fixed_auto ("reserve_pub", &actx.reserve_pub),
GNUNET_JSON_spec_json ("denoms_h", &j_denoms_h),
GNUNET_JSON_spec_json ("coin_evs", &j_coin_evs),
GNUNET_JSON_spec_json ("disclosed_coin_secrets", &j_disclosed_coin_secrets),
GNUNET_JSON_spec_end ()
};
@ -1014,8 +1010,7 @@ TEH_handler_age_withdraw_reveal (
do {
/* Extract denominations, blinded and disclosed coins */
if (GNUNET_OK !=
parse_age_withdraw_reveal_json (
if (GNUNET_OK != parse_age_withdraw_reveal_json (
rc->connection,
j_denoms_h,
j_coin_evs,
@ -1025,8 +1020,7 @@ TEH_handler_age_withdraw_reveal (
break;
/* Find original commitment */
if (GNUNET_OK !=
find_original_commitment (
if (GNUNET_OK != find_original_commitment (
rc->connection,
&actx.ach,
&actx.reserve_pub,
@ -1035,8 +1029,7 @@ TEH_handler_age_withdraw_reveal (
break;
/* Ensure validity of denoms and the sum of amounts and fees */
if (GNUNET_OK !=
are_denominations_valid (
if (GNUNET_OK != are_denominations_valid (
rc->connection,
actx.num_coins,
actx.denoms_h,
@ -1050,8 +1043,7 @@ TEH_handler_age_withdraw_reveal (
/* Verify the computed h_commitment equals the committed one and that coins
* have a maximum age group corresponding max_age (age-mask dependent) */
if (GNUNET_OK !=
verify_commitment_and_max_age (
if (GNUNET_OK != verify_commitment_and_max_age (
rc->connection,
&actx.commitment.h_commitment,
actx.commitment.max_age,
@ -1064,8 +1056,7 @@ TEH_handler_age_withdraw_reveal (
break;
/* Finally, sign and persist the coins */
if (GNUNET_OK !=
sign_and_finalize_age_withdraw (
if (GNUNET_OK != sign_and_finalize_age_withdraw (
rc->connection,
&actx.commitment.h_commitment,
actx.num_coins,
@ -1077,6 +1068,7 @@ TEH_handler_age_withdraw_reveal (
} while(0);
age_reveal_context_free (&actx);
GNUNET_JSON_parse_free (spec);
return result;
}

View File

@ -74,7 +74,7 @@ struct DecisionContext
/**
* KYC requirements imposed, NULL for none.
*/
const json_t *kyc_requirements;
json_t *kyc_requirements;
};
@ -261,8 +261,8 @@ TEH_handler_post_aml_decision (
GNUNET_JSON_spec_uint32 ("new_state",
&new_state32),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_array_const ("kyc_requirements",
&dc.kyc_requirements),
GNUNET_JSON_spec_json ("kyc_requirements",
&dc.kyc_requirements),
NULL),
GNUNET_JSON_spec_end ()
};
@ -306,6 +306,17 @@ TEH_handler_post_aml_decision (
size_t index;
json_t *elem;
if (! json_is_array (dc.kyc_requirements))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"kyc_requirements must be an array");
}
json_array_foreach (dc.kyc_requirements, index, elem)
{
const char *val;
@ -313,6 +324,7 @@ TEH_handler_post_aml_decision (
if (! json_is_string (elem))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
@ -324,6 +336,7 @@ TEH_handler_post_aml_decision (
TALER_KYCLOGIC_check_satisfiable (val))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
@ -344,9 +357,11 @@ TEH_handler_post_aml_decision (
&make_aml_decision,
&dc))
{
GNUNET_JSON_parse_free (spec);
return mhd_ret;
}
}
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_static (
connection,
MHD_HTTP_NO_CONTENT,

View File

@ -545,7 +545,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc,
{
struct MHD_Connection *connection = rc->connection;
struct BatchDepositContext dc;
const json_t *coins;
json_t *coins;
bool no_refund_deadline = true;
bool no_policy_json = true;
struct GNUNET_JSON_Specification spec[] = {
@ -557,8 +557,8 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc,
&dc.merchant_pub),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
&dc.h_contract_terms),
GNUNET_JSON_spec_array_const ("coins",
&coins),
GNUNET_JSON_spec_json ("coins",
&coins),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_json ("policy",
&dc.policy_json),

View File

@ -848,10 +848,10 @@ TEH_handler_batch_withdraw (struct TEH_RequestContext *rc,
.reserve_pub = reserve_pub,
.rc = rc
};
const json_t *planchets;
json_t *planchets;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("planchets",
&planchets),
GNUNET_JSON_spec_json ("planchets",
&planchets),
GNUNET_JSON_spec_end ()
};
@ -867,17 +867,20 @@ TEH_handler_batch_withdraw (struct TEH_RequestContext *rc,
if (GNUNET_OK != res)
return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES;
}
wc.planchets_length = json_array_size (planchets);
if (0 == wc.planchets_length)
if ( (! json_is_array (planchets)) ||
(0 == json_array_size (planchets)) )
{
GNUNET_JSON_parse_free (spec);
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"planchets");
}
wc.planchets_length = json_array_size (planchets);
if (wc.planchets_length > TALER_MAX_FRESH_COINS)
{
GNUNET_JSON_parse_free (spec);
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
@ -903,6 +906,7 @@ TEH_handler_batch_withdraw (struct TEH_RequestContext *rc,
TALER_blinded_planchet_free (&pc->blinded_planchet);
TALER_blinded_denom_sig_free (&pc->collectable.sig);
}
GNUNET_JSON_parse_free (spec);
return ret;
}
}

View File

@ -39,12 +39,12 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
{
struct TALER_RefreshMasterSecretP rms;
unsigned int csr_requests_num;
const json_t *csr_requests;
json_t *csr_requests;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("rms",
&rms),
GNUNET_JSON_spec_array_const ("nks",
&csr_requests),
GNUNET_JSON_spec_json ("nks",
&csr_requests),
GNUNET_JSON_spec_end ()
};
enum TALER_ErrorCode ec;
@ -65,7 +65,7 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
if ( (TALER_MAX_FRESH_COINS <= csr_requests_num) ||
(0 == csr_requests_num) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
rc->connection,
MHD_HTTP_BAD_REQUEST,
@ -101,12 +101,14 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc,
-1);
if (GNUNET_OK != res)
{
GNUNET_JSON_parse_free (spec);
return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
}
TALER_cs_refresh_nonce_derive (&rms,
coin_off,
&nonces[i]);
}
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i < csr_requests_num; i++)
{

View File

@ -145,7 +145,7 @@ set_extensions (void *cls,
static enum GNUNET_GenericReturnValue
verify_extensions_from_json (
const json_t *extensions,
json_t *extensions,
struct SetExtensionsContext *sec)
{
const char*name;
@ -160,7 +160,7 @@ verify_extensions_from_json (
sec->extensions = GNUNET_new_array (sec->num_extensions,
struct Extension);
json_object_foreach ((json_t *) extensions, name, manifest)
json_object_foreach (extensions, name, manifest)
{
int critical = 0;
json_t *config;
@ -200,11 +200,11 @@ TEH_handler_management_post_extensions (
const json_t *root)
{
MHD_RESULT ret;
const json_t *extensions;
json_t *extensions;
struct SetExtensionsContext sec = {0};
struct GNUNET_JSON_Specification top_spec[] = {
GNUNET_JSON_spec_object_const ("extensions",
&extensions),
GNUNET_JSON_spec_json ("extensions",
&extensions),
GNUNET_JSON_spec_fixed_auto ("extensions_sig",
&sec.extensions_sig),
GNUNET_JSON_spec_end ()
@ -223,19 +223,31 @@ TEH_handler_management_post_extensions (
return MHD_YES; /* failure */
}
/* Ensure we have an object */
if ((! json_is_object (extensions)) &&
(! json_is_null (extensions)))
{
GNUNET_JSON_parse_free (top_spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"invalid object");
}
/* Verify the signature */
{
struct TALER_ExtensionManifestsHashP h_manifests;
if (GNUNET_OK !=
TALER_JSON_extensions_manifests_hash (extensions,
&h_manifests) ||
TALER_JSON_extensions_manifests_hash (extensions, &h_manifests) ||
GNUNET_OK !=
TALER_exchange_offline_extension_manifests_hash_verify (
&h_manifests,
&TEH_master_public_key,
&sec.extensions_sig))
{
GNUNET_JSON_parse_free (top_spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
@ -251,6 +263,7 @@ TEH_handler_management_post_extensions (
if (GNUNET_OK !=
verify_extensions_from_json (extensions, &sec))
{
GNUNET_JSON_parse_free (top_spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
@ -293,6 +306,7 @@ CLEANUP:
}
}
GNUNET_free (sec.extensions);
GNUNET_JSON_parse_free (top_spec);
return ret;
}

View File

@ -340,13 +340,13 @@ TEH_handler_management_post_keys (
const json_t *root)
{
struct AddKeysContext akc;
const json_t *denom_sigs;
const json_t *signkey_sigs;
json_t *denom_sigs;
json_t *signkey_sigs;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("denom_sigs",
&denom_sigs),
GNUNET_JSON_spec_array_const ("signkey_sigs",
&signkey_sigs),
GNUNET_JSON_spec_json ("denom_sigs",
&denom_sigs),
GNUNET_JSON_spec_json ("signkey_sigs",
&signkey_sigs),
GNUNET_JSON_spec_end ()
};
bool ok;
@ -363,12 +363,24 @@ TEH_handler_management_post_keys (
if (GNUNET_NO == res)
return MHD_YES; /* failure */
}
if (! (json_is_array (denom_sigs) &&
json_is_array (signkey_sigs)) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"array expected for denom_sigs and signkey_sigs");
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received /management/keys\n");
akc.ksh = TEH_keys_get_state_for_management_only (); /* may start its own transaction, thus must be done here, before we run ours! */
if (NULL == akc.ksh)
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (
connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
@ -411,6 +423,7 @@ TEH_handler_management_post_keys (
if (! ok)
{
GNUNET_free (akc.d_sigs);
GNUNET_JSON_parse_free (spec);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failure to handle /management/keys\n");
return ret;
@ -453,6 +466,7 @@ TEH_handler_management_post_keys (
"Failure to handle /management/keys\n");
GNUNET_free (akc.d_sigs);
GNUNET_free (akc.s_sigs);
GNUNET_JSON_parse_free (spec);
return ret;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@ -470,6 +484,7 @@ TEH_handler_management_post_keys (
&akc);
GNUNET_free (akc.d_sigs);
GNUNET_free (akc.s_sigs);
GNUNET_JSON_parse_free (spec);
if (GNUNET_SYSERR == res)
return ret;
}

View File

@ -62,12 +62,12 @@ struct AddWireContext
/**
* Restrictions imposed when crediting this account.
*/
const json_t *credit_restrictions;
json_t *credit_restrictions;
/**
* Restrictions imposed when debiting this account.
*/
const json_t *debit_restrictions;
json_t *debit_restrictions;
/**
* Timestamp for checking against replay attacks.
@ -176,10 +176,10 @@ TEH_handler_management_post_wire (
GNUNET_JSON_spec_string ("conversion_url",
&awc.conversion_url),
NULL),
GNUNET_JSON_spec_array_const ("credit_restrictions",
&awc.credit_restrictions),
GNUNET_JSON_spec_array_const ("debit_restrictions",
&awc.debit_restrictions),
GNUNET_JSON_spec_json ("credit_restrictions",
&awc.credit_restrictions),
GNUNET_JSON_spec_json ("debit_restrictions",
&awc.debit_restrictions),
GNUNET_JSON_spec_timestamp ("validity_start",
&awc.validity_start),
GNUNET_JSON_spec_end ()

View File

@ -430,7 +430,7 @@ TEH_handler_purses_create (
.pd.purse_pub = *purse_pub,
.exchange_timestamp = GNUNET_TIME_timestamp_get ()
};
const json_t *deposits;
json_t *deposits;
json_t *deposit;
unsigned int idx;
struct GNUNET_JSON_Specification spec[] = {
@ -449,8 +449,8 @@ TEH_handler_purses_create (
&pcc.purse_sig),
GNUNET_JSON_spec_fixed_auto ("h_contract_terms",
&pcc.pd.h_contract_terms),
GNUNET_JSON_spec_array_const ("deposits",
&deposits),
GNUNET_JSON_spec_json ("deposits",
&deposits),
GNUNET_JSON_spec_timestamp ("purse_expiration",
&pcc.pd.purse_expiration),
GNUNET_JSON_spec_end ()
@ -482,6 +482,7 @@ TEH_handler_purses_create (
pcc.exchange_timestamp))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_EXCHANGE_PURSE_CREATE_EXPIRATION_BEFORE_NOW,
@ -490,6 +491,7 @@ TEH_handler_purses_create (
if (GNUNET_TIME_absolute_is_never (pcc.pd.purse_expiration.abs_time))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_EXCHANGE_PURSE_CREATE_EXPIRATION_IS_NEVER,
@ -500,6 +502,7 @@ TEH_handler_purses_create (
(pcc.num_coins > TALER_MAX_FRESH_COINS) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
@ -512,6 +515,7 @@ TEH_handler_purses_create (
if (NULL == keys)
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_EXCHANGE_GENERIC_KEYS_MISSING,
@ -543,6 +547,7 @@ TEH_handler_purses_create (
deposit);
if (GNUNET_OK != res)
{
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<idx; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -554,6 +559,7 @@ TEH_handler_purses_create (
&pcc.deposit_total))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
GNUNET_free (pcc.coins);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
@ -573,6 +579,7 @@ TEH_handler_purses_create (
&pcc.purse_sig))
{
TALER_LOG_WARNING ("Invalid signature on /purses/$PID/create request\n");
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -590,6 +597,7 @@ TEH_handler_purses_create (
&pcc.econtract.econtract_sig)) )
{
TALER_LOG_WARNING ("Invalid signature on /purses/$PID/create request\n");
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -604,6 +612,7 @@ TEH_handler_purses_create (
TEH_plugin->preflight (TEH_plugin->cls))
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -625,6 +634,7 @@ TEH_handler_purses_create (
&create_transaction,
&pcc))
{
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -643,6 +653,7 @@ TEH_handler_purses_create (
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
GNUNET_JSON_parse_free (spec);
return res;
}
}

View File

@ -329,12 +329,12 @@ TEH_handler_purses_deposit (
.purse_pub = purse_pub,
.exchange_timestamp = GNUNET_TIME_timestamp_get ()
};
const json_t *deposits;
json_t *deposits;
json_t *deposit;
unsigned int idx;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("deposits",
&deposits),
GNUNET_JSON_spec_json ("deposits",
&deposits),
GNUNET_JSON_spec_end ()
};
@ -363,6 +363,7 @@ TEH_handler_purses_deposit (
(pcc.num_coins > TALER_MAX_FRESH_COINS) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
@ -434,6 +435,7 @@ TEH_handler_purses_deposit (
deposit);
if (GNUNET_OK != res)
{
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<idx; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -445,6 +447,7 @@ TEH_handler_purses_deposit (
TEH_plugin->preflight (TEH_plugin->cls))
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -466,6 +469,7 @@ TEH_handler_purses_deposit (
&deposit_transaction,
&pcc))
{
GNUNET_JSON_parse_free (spec);
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
@ -497,6 +501,7 @@ TEH_handler_purses_deposit (
for (unsigned int i = 0; i<pcc.num_coins; i++)
TEH_common_purse_deposit_free_coin (&pcc.coins[i]);
GNUNET_free (pcc.coins);
GNUNET_JSON_parse_free (spec);
return res;
}
}

View File

@ -983,26 +983,26 @@ TEH_handler_reveal (struct TEH_RequestContext *rc,
const json_t *root,
const char *const args[2])
{
const json_t *coin_evs;
const json_t *transfer_privs;
const json_t *link_sigs;
const json_t *new_denoms_h;
const json_t *old_age_commitment;
json_t *coin_evs;
json_t *transfer_privs;
json_t *link_sigs;
json_t *new_denoms_h;
json_t *old_age_commitment;
struct RevealContext rctx;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("transfer_pub",
&rctx.gamma_tp),
GNUNET_JSON_spec_array_const ("transfer_privs",
&transfer_privs),
GNUNET_JSON_spec_array_const ("link_sigs",
&link_sigs),
GNUNET_JSON_spec_array_const ("coin_evs",
&coin_evs),
GNUNET_JSON_spec_array_const ("new_denoms_h",
&new_denoms_h),
GNUNET_JSON_spec_json ("transfer_privs",
&transfer_privs),
GNUNET_JSON_spec_json ("link_sigs",
&link_sigs),
GNUNET_JSON_spec_json ("coin_evs",
&coin_evs),
GNUNET_JSON_spec_json ("new_denoms_h",
&new_denoms_h),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_array_const ("old_age_commitment",
&old_age_commitment),
GNUNET_JSON_spec_json ("old_age_commitment",
&old_age_commitment),
NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto ("rms",
@ -1053,6 +1053,7 @@ TEH_handler_reveal (struct TEH_RequestContext *rc,
/* Note we do +1 as 1 row (cut-and-choose!) is missing! */
if (TALER_CNC_KAPPA != json_array_size (transfer_privs) + 1)
{
GNUNET_JSON_parse_free (spec);
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST,
@ -1060,13 +1061,19 @@ TEH_handler_reveal (struct TEH_RequestContext *rc,
NULL);
}
return handle_refreshes_reveal_json (rc->connection,
&rctx,
transfer_privs,
link_sigs,
new_denoms_h,
old_age_commitment,
coin_evs);
{
MHD_RESULT res;
res = handle_refreshes_reveal_json (rc->connection,
&rctx,
transfer_privs,
link_sigs,
new_denoms_h,
old_age_commitment,
coin_evs);
GNUNET_JSON_parse_free (spec);
return res;
}
}

View File

@ -68,7 +68,7 @@ struct ReserveAttestContext
/**
* List of requested details.
*/
const json_t *details;
json_t *details;
/**
* Client signature approving the request.
@ -287,8 +287,8 @@ TEH_handler_reserves_attest (struct TEH_RequestContext *rc,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp ("request_timestamp",
&rsc.timestamp),
GNUNET_JSON_spec_array_const ("details",
&rsc.details),
GNUNET_JSON_spec_json ("details",
&rsc.details),
GNUNET_JSON_spec_fixed_auto ("reserve_sig",
&rsc.reserve_sig),
GNUNET_JSON_spec_end ()

View File

@ -303,7 +303,7 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc,
const json_t *root)
{
struct ReserveOpenContext rsc;
const json_t *payments;
json_t *payments;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp ("request_timestamp",
&rsc.timestamp),
@ -313,8 +313,8 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc,
&rsc.reserve_sig),
GNUNET_JSON_spec_uint32 ("purse_limit",
&rsc.purse_limit),
GNUNET_JSON_spec_array_const ("payments",
&payments),
GNUNET_JSON_spec_json ("payments",
&payments),
TALER_JSON_spec_amount ("reserve_payment",
TEH_currency,
&rsc.reserve_payment),
@ -403,6 +403,7 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc,
if (NULL == keys)
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
cleanup_rsc (&rsc);
return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,

View File

@ -406,17 +406,25 @@ batch_done (void)
* except for irrecoverable errors.
*
* @param cls `struct WirePrepareData` we are working on
* @param tr transfer response
* @param http_status_code #MHD_HTTP_OK on success
* @param ec taler error code
* @param row_id unique ID of the wire transfer in the bank's records
* @param wire_timestamp when did the transfer happen
*/
static void
wire_confirm_cb (void *cls,
const struct TALER_BANK_TransferResponse *tr)
unsigned int http_status_code,
enum TALER_ErrorCode ec,
uint64_t row_id,
struct GNUNET_TIME_Timestamp wire_timestamp)
{
struct WirePrepareData *wpd = cls;
enum GNUNET_DB_QueryStatus qs;
(void) row_id;
(void) wire_timestamp;
wpd->eh = NULL;
switch (tr->http_status)
switch (http_status_code)
{
case MHD_HTTP_OK:
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@ -430,8 +438,8 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transaction %llu failed: %u/%d\n",
(unsigned long long) wpd->row_id,
tr->http_status,
tr->ec);
http_status_code,
ec);
qs = db_plugin->wire_prepare_data_mark_failed (db_plugin->cls,
wpd->row_id);
/* continued below */
@ -448,7 +456,7 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Wire transfer %llu failed (%u), trying again\n",
(unsigned long long) wpd->row_id,
tr->http_status);
http_status_code);
wpd->eh = TALER_BANK_transfer (ctx,
wpd->wa->auth,
&wpd[1],
@ -460,8 +468,8 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transaction %llu failed: %u/%d\n",
(unsigned long long) wpd->row_id,
tr->http_status,
tr->ec);
http_status_code,
ec);
cleanup_wpd ();
db_plugin->rollback (db_plugin->cls);
global_ret = EXIT_FAILURE;
@ -471,8 +479,8 @@ wire_confirm_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Wire transfer %llu failed: %u/%d\n",
(unsigned long long) wpd->row_id,
tr->http_status,
tr->ec);
http_status_code,
ec);
db_plugin->rollback (db_plugin->cls);
cleanup_wpd ();
global_ret = EXIT_FAILURE;

View File

@ -65,9 +65,6 @@ exchange-0004.sql: exchange-0004.sql.in 0004-*.sql
gcc -E -P -undef - < exchange-0004.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
chmod ugo-w $@
check_SCRIPTS = \
test_idempotency.sh
EXTRA_DIST = \
exchangedb.conf \
exchangedb-postgres.conf \
@ -75,7 +72,6 @@ EXTRA_DIST = \
test-exchange-db-postgres.conf \
$(sqlinputs) \
$(sql_DATA) \
$(check_SCRIPTS) \
pg_template.h pg_template.c \
pg_template.sh
@ -315,7 +311,6 @@ noinst_PROGRAMS = \
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;
TESTS = \
$(check_SCRIPTS) \
$(check_PROGRAMS)
test_exchangedb_postgres_SOURCES = \

View File

@ -30,8 +30,8 @@ enum GNUNET_DB_QueryStatus
TEH_PG_insert_wire (void *cls,
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
json_t *debit_restrictions,
json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp start_date,
const struct TALER_MasterSignatureP *master_sig)
{

View File

@ -42,8 +42,8 @@ enum GNUNET_DB_QueryStatus
TEH_PG_insert_wire (void *cls,
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
json_t *debit_restrictions,
json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp start_date,
const struct TALER_MasterSignatureP *master_sig);

View File

@ -30,8 +30,8 @@ enum GNUNET_DB_QueryStatus
TEH_PG_update_wire (void *cls,
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
json_t *debit_restrictions,
json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp change_date,
bool enabled)
{

View File

@ -43,8 +43,8 @@ enum GNUNET_DB_QueryStatus
TEH_PG_update_wire (void *cls,
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
json_t *debit_restrictions,
json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp change_date,
bool enabled);

View File

@ -1,11 +0,0 @@
#!/bin/sh
# This file is in the public domain.
set -eu
echo "Initializing DB"
taler-exchange-dbinit -r test-exchange-db-postgres.conf
echo "Re-initializing DB"
taler-exchange-dbinit test-exchange-db-postgres.conf
echo "Re-loading procedures"
psql talercheck < procedures.sql
echo "Test PASSED"
exit 0

View File

@ -138,7 +138,7 @@ TALER_extensions_get_by_name (
enum GNUNET_GenericReturnValue
TALER_extensions_verify_manifests_signature (
const json_t *manifests,
json_t *manifests,
struct TALER_MasterSignatureP *extensions_sig,
struct TALER_MasterPublicKeyP *master_pub)
{
@ -274,76 +274,72 @@ TALER_extensions_parse_manifest (
json_t **config)
{
enum GNUNET_GenericReturnValue ret;
json_t *cfg;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_boolean ("critical",
critical),
GNUNET_JSON_spec_string ("version",
version),
GNUNET_JSON_spec_json ("config",
config),
&cfg),
GNUNET_JSON_spec_end ()
};
*config = NULL;
if (GNUNET_OK !=
(ret = GNUNET_JSON_parse (obj,
spec,
NULL,
NULL)))
return ret;
*config = json_copy (cfg);
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}
enum GNUNET_GenericReturnValue
TALER_extensions_load_manifests (
const json_t *extensions)
json_t *extensions)
{
const char *name;
const char*name;
json_t *manifest;
GNUNET_assert (NULL != extensions);
GNUNET_assert (json_is_object (extensions));
json_object_foreach ((json_t *) extensions, name, manifest)
json_object_foreach (extensions, name, manifest)
{
int critical;
const char *version;
json_t *config;
struct TALER_Extension *extension
= (struct TALER_Extension *)
TALER_extensions_get_by_name (name);
struct TALER_Extension *extension = (struct
TALER_Extension *)
TALER_extensions_get_by_name (name);
if (NULL == extension)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"no such extension: %s\n",
name);
"no such extension: %s\n", name);
return GNUNET_SYSERR;
}
/* load and verify criticality, version, etc. */
if (GNUNET_OK !=
TALER_extensions_parse_manifest (
manifest,
&critical,
&version,
&config))
manifest, &critical, &version, &config))
return GNUNET_SYSERR;
if (critical != extension->critical
|| 0 != strcmp (version,
extension->version) // TODO: libtool compare?
|| 0 != strcmp (version, extension->version) // TODO: libtool compare?
|| NULL == config
|| (GNUNET_OK !=
extension->load_config (config,
NULL)) )
|| GNUNET_OK != extension->load_config (config, NULL))
return GNUNET_SYSERR;
/* This _should_ work now */
if (GNUNET_OK !=
extension->load_config (config,
extension))
extension->load_config (config, extension))
return GNUNET_SYSERR;
extension->enabled = true;

View File

@ -99,65 +99,27 @@ struct TALER_BANK_AuthenticationData
struct TALER_BANK_AdminAddIncomingHandle;
/**
* Response details for a history request.
*/
struct TALER_BANK_AdminAddIncomingResponse
{
/**
* HTTP status.
*/
unsigned int http_status;
/**
* Taler error code, #TALER_EC_NONE on success.
*/
enum TALER_ErrorCode ec;
/**
* Full response, NULL if body was not in JSON format.
*/
const json_t *response;
/**
* Details returned depending on the @e http_status.
*/
union
{
/**
* Details if status was #MHD_HTTP_OK
*/
struct
{
/**
* unique ID of the wire transfer in the bank's records
*/
uint64_t serial_id;
/**
* time when the transaction was made.
*/
struct GNUNET_TIME_Timestamp timestamp;
} ok;
} details;
};
/**
* Callbacks of this type are used to return the result of submitting
* a request to transfer funds to the exchange.
*
* @param cls closure
* @param air response details
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful status request
* 0 if the bank's reply is bogus (fails to follow the protocol)
* @param ec detailed error code
* @param serial_id unique ID of the wire transfer in the bank's records; UINT64_MAX on error
* @param timestamp time when the transaction was made.
* @param json detailed response from the HTTPD, or NULL if reply was not in JSON
*/
// FIXME: bad API
typedef void
(*TALER_BANK_AdminAddIncomingCallback) (
void *cls,
const struct TALER_BANK_AdminAddIncomingResponse *air);
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t serial_id,
struct GNUNET_TIME_Timestamp timestamp,
const json_t *json);
/**
@ -229,65 +191,23 @@ TALER_BANK_prepare_transfer (
struct TALER_BANK_TransferHandle;
/**
* Response details for a history request.
*/
struct TALER_BANK_TransferResponse
{
/**
* HTTP status.
*/
unsigned int http_status;
/**
* Taler error code, #TALER_EC_NONE on success.
*/
enum TALER_ErrorCode ec;
/**
* Full response, NULL if body was not in JSON format.
*/
const json_t *response;
/**
* Details returned depending on the @e http_status.
*/
union
{
/**
* Details if status was #MHD_HTTP_OK
*/
struct
{
/**
* unique ID of the wire transfer in the bank's records
*/
uint64_t row_id;
/**
* when did the transaction go into effect
*/
struct GNUNET_TIME_Timestamp timestamp;
} ok;
} details;
};
/**
* Function called with the result from the execute step.
*
* @param cls closure
* @param tr response details
* @param response_code HTTP status code
* @param ec taler error code
* @param row_id unique ID of the wire transfer in the bank's records
* @param timestamp when did the transaction go into effect
*/
// FIXME: bad API
typedef void
(*TALER_BANK_TransferCallback)(
void *cls,
const struct TALER_BANK_TransferResponse *tr);
unsigned int response_code,
enum TALER_ErrorCode ec,
uint64_t row_id,
struct GNUNET_TIME_Timestamp timestamp);
/**

View File

@ -3592,7 +3592,7 @@ enum GNUNET_GenericReturnValue
TALER_EXCHANGE_verify_coin_history (
const struct TALER_EXCHANGE_DenomPublicKey *dk,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const json_t *history,
json_t *history,
struct TALER_Amount *total);
@ -4498,7 +4498,7 @@ TALER_EXCHANGE_post_management_keys_cancel (
*/
struct TALER_EXCHANGE_ManagementPostExtensionsData
{
const json_t *extensions;
json_t *extensions;
struct TALER_MasterSignatureP extensions_sig;
};
@ -4548,7 +4548,7 @@ struct TALER_EXCHANGE_ManagementPostExtensionsHandle *
TALER_EXCHANGE_management_post_extensions (
struct GNUNET_CURL_Context *ctx,
const char *url,
const struct TALER_EXCHANGE_ManagementPostExtensionsData *ped,
struct TALER_EXCHANGE_ManagementPostExtensionsData *ped,
TALER_EXCHANGE_ManagementPostExtensionsCallback cb,
void *cb_cls);
@ -5091,7 +5091,7 @@ TALER_EXCHANGE_lookup_aml_decision (
/**
* Cancel #TALER_EXCHANGE_lookup_aml_decision() operation.
* Cancel #TALER_EXCHANGE_add_aml_decision() operation.
*
* @param rh handle of the operation to cancel
*/
@ -5105,30 +5105,18 @@ TALER_EXCHANGE_lookup_aml_decision_cancel (
*/
struct TALER_EXCHANGE_AddAmlDecision;
/**
* Response when making an AML decision.
*/
struct TALER_EXCHANGE_AddAmlDecisionResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about storing an
* an AML decision.
*
* @param cls closure
* @param adr response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_AddAmlDecisionCallback) (
void *cls,
const struct TALER_EXCHANGE_AddAmlDecisionResponse *adr);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**
* Inform the exchange that an AML decision has been taken.
@ -5173,28 +5161,18 @@ TALER_EXCHANGE_add_aml_decision_cancel (
struct TALER_EXCHANGE_AddAmlDecision *rh);
/**
* Response when adding a partner exchange.
*/
struct TALER_EXCHANGE_ManagementAddPartnerResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about the change to
* an AML officer status.
*
* @param cls closure
* @param apr response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_ManagementAddPartnerCallback) (
void *cls,
const struct TALER_EXCHANGE_ManagementAddPartnerResponse *apr);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**
@ -5245,27 +5223,17 @@ TALER_EXCHANGE_management_add_partner_cancel (
struct TALER_EXCHANGE_ManagementAddPartner *rh);
/**
* Response when enabling an auditor.
*/
struct TALER_EXCHANGE_ManagementAuditorEnableResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about the auditor setup operation result.
*
* @param cls closure
* @param aer response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_ManagementAuditorEnableCallback) (
void *cls,
const struct TALER_EXCHANGE_ManagementAuditorEnableResponse *aer);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**
@ -5310,27 +5278,18 @@ void
TALER_EXCHANGE_management_enable_auditor_cancel (
struct TALER_EXCHANGE_ManagementAuditorEnableHandle *ah);
/**
* Response when disabling an auditor.
*/
struct TALER_EXCHANGE_ManagementAuditorDisableResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about the auditor disable operation result.
*
* @param cls closure
* @param adr HTTP response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_ManagementAuditorDisableCallback) (
void *cls,
const struct TALER_EXCHANGE_ManagementAuditorDisableResponse *adr);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**
@ -5508,27 +5467,17 @@ TALER_EXCHANGE_management_disable_wire_cancel (
struct TALER_EXCHANGE_ManagementWireDisableHandle *wh);
/**
* Response when setting wire fees.
*/
struct TALER_EXCHANGE_ManagementSetWireFeeResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about the wire enable operation result.
*
* @param cls closure
* @param wfr response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_ManagementSetWireFeeCallback) (
void *cls,
const struct TALER_EXCHANGE_ManagementSetWireFeeResponse *wfr);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**
@ -5575,28 +5524,17 @@ TALER_EXCHANGE_management_set_wire_fees_cancel (
struct TALER_EXCHANGE_ManagementSetWireFeeHandle *swfh);
/**
* Response when setting global fees.
*/
struct TALER_EXCHANGE_ManagementSetGlobalFeeResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about the global fee setting operation result.
*
* @param cls closure
* @param gfr HTTP response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_ManagementSetGlobalFeeCallback) (
void *cls,
const struct TALER_EXCHANGE_ManagementSetGlobalFeeResponse *gfr);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**
@ -5647,29 +5585,18 @@ TALER_EXCHANGE_management_set_global_fees_cancel (
struct TALER_EXCHANGE_ManagementSetGlobalFeeHandle *sgfh);
/**
* Response when adding denomination signature by auditor.
*/
struct TALER_EXCHANGE_AuditorAddDenominationResponse
{
/**
* HTTP response data.
*/
struct TALER_EXCHANGE_HttpResponse hr;
};
/**
* Function called with information about the POST
* /auditor/$AUDITOR_PUB/$H_DENOM_PUB operation result.
*
* @param cls closure
* @param adr HTTP response data
* @param hr HTTP response data
*/
// FIXME: bad API
typedef void
(*TALER_EXCHANGE_AuditorAddDenominationCallback) (
void *cls,
const struct TALER_EXCHANGE_AuditorAddDenominationResponse *adr);
const struct TALER_EXCHANGE_HttpResponse *hr);
/**

View File

@ -5577,8 +5577,8 @@ struct TALER_EXCHANGEDB_Plugin
(*insert_wire)(void *cls,
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
json_t *debit_restrictions,
json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp start_date,
const struct TALER_MasterSignatureP *master_sig);
@ -5600,8 +5600,8 @@ struct TALER_EXCHANGEDB_Plugin
(*update_wire)(void *cls,
const char *payto_uri,
const char *conversion_url,
const json_t *debit_restrictions,
const json_t *credit_restrictions,
json_t *debit_restrictions,
json_t *credit_restrictions,
struct GNUNET_TIME_Timestamp change_date,
bool enabled);

View File

@ -259,13 +259,13 @@ TALER_extensions_parse_manifest (
*/
enum GNUNET_GenericReturnValue
TALER_extensions_load_manifests (
const json_t *manifests);
json_t *manifests);
/*
* @brief Returns the head of the linked list of extensions.
*/
const struct TALER_Extensions *
TALER_extensions_get_head (void);
TALER_extensions_get_head ();
/**
* @brief Finds and returns a supported extension by a given type.
@ -323,7 +323,7 @@ TALER_extensions_is_enabled (
*/
enum GNUNET_GenericReturnValue
TALER_extensions_verify_manifests_signature (
const json_t *manifests,
json_t *manifests,
struct TALER_MasterSignatureP *extensions_sig,
struct TALER_MasterPublicKeyP *master_pub);
@ -363,7 +363,7 @@ struct TALER_AgeRestrictionConfig
* @return age restriction configuration if present, otherwise NULL.
*/
const struct TALER_AgeRestrictionConfig *
TALER_extensions_get_age_restriction_config (void);
TALER_extensions_get_age_restriction_config ();
/**
* @brief Check if age restriction is enabled
@ -371,7 +371,7 @@ TALER_extensions_get_age_restriction_config (void);
* @return true, if age restriction is loaded, configured and enabled; otherwise false.
*/
bool
TALER_extensions_is_age_restriction_enabled (void);
TALER_extensions_is_age_restriction_enabled ();
/**
* @brief Return the age mask for age restriction
@ -379,6 +379,6 @@ TALER_extensions_is_age_restriction_enabled (void);
* @return configured age mask, if age restriction is loaded, configured and enabled; otherwise zero mask.
*/
struct TALER_AgeMask
TALER_extensions_get_age_restriction_mask (void);
TALER_extensions_get_age_restriction_mask ();
#endif

View File

@ -1237,6 +1237,11 @@ parse_i18n_string (void *cls,
const char *str;
str = json_string_value (val);
if (NULL == str)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
*(const char **) spec->ptr = str;
}
return GNUNET_OK;

View File

@ -758,12 +758,11 @@ kycaid_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
* @param verifications JSON object with failure details
*/
static void
log_failure (const json_t *verifications)
log_failure (json_t *verifications)
{
const json_t *member;
json_t *member;
const char *name;
json_object_foreach ((json_t *) verifications, name, member)
json_object_foreach (verifications, name, member)
{
bool iverified;
const char *comment;
@ -1177,7 +1176,7 @@ kycaid_webhook (void *cls,
const char *status = NULL;
bool verified = false;
bool no_verified = true;
const json_t *verifications = NULL;
json_t *verifications = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("request_id",
&request_id),
@ -1196,8 +1195,8 @@ kycaid_webhook (void *cls,
&verified),
&no_verified),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_object_const ("verifications",
&verifications),
GNUNET_JSON_spec_json ("verifications",
&verifications),
NULL),
GNUNET_JSON_spec_end ()
};
@ -1254,6 +1253,7 @@ kycaid_webhook (void *cls,
wh->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
GNUNET_JSON_parse_free (spec);
return wh;
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
@ -1267,6 +1267,7 @@ kycaid_webhook (void *cls,
wh->response_code = MHD_HTTP_NOT_FOUND;
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
GNUNET_JSON_parse_free (spec);
return wh;
}
wh->verification_id = GNUNET_strdup (verification_id);
@ -1285,6 +1286,7 @@ kycaid_webhook (void *cls,
MHD_RESPMEM_PERSISTENT);
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
GNUNET_JSON_parse_free (spec);
return wh;
}
@ -1298,6 +1300,7 @@ kycaid_webhook (void *cls,
wh->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
wh->task = GNUNET_SCHEDULER_add_now (&async_webhook_reply,
wh);
GNUNET_JSON_parse_free (spec);
return wh;
}
@ -1321,6 +1324,7 @@ kycaid_webhook (void *cls,
pd->slist,
&handle_webhook_finished,
wh);
GNUNET_JSON_parse_free (spec);
return wh;
}

View File

@ -951,12 +951,12 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
const json_t *j)
{
const char *state;
const json_t *data;
json_t *data;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("status",
&state),
GNUNET_JSON_spec_object_const ("data",
&data),
GNUNET_JSON_spec_json ("data",
&data),
GNUNET_JSON_spec_end ()
};
enum GNUNET_GenericReturnValue res;
@ -988,6 +988,7 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
GNUNET_break_op (0);
handle_proof_error (ph,
j);
GNUNET_JSON_parse_free (spec);
return;
}
{
@ -1015,6 +1016,7 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
"Unexpected response from KYC gateway: data must contain id");
ph->http_status
= MHD_HTTP_BAD_GATEWAY;
GNUNET_JSON_parse_free (spec);
return;
}
ph->status = TALER_KYCLOGIC_STATUS_SUCCESS;
@ -1032,6 +1034,7 @@ parse_proof_success_reply (struct TALER_KYCLOGIC_ProofHandle *ph,
}
ph->attributes = data2attributes (ph->pd,
data);
GNUNET_JSON_parse_free (spec);
}

View File

@ -1113,17 +1113,17 @@ handle_proof_finished (void *cls,
const char *inquiry_id;
const char *account_id;
const char *type = NULL;
const json_t *attributes;
const json_t *relationships;
json_t *attributes;
json_t *relationships;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("type",
&type),
GNUNET_JSON_spec_string ("id",
&inquiry_id),
GNUNET_JSON_spec_object_const ("attributes",
&attributes),
GNUNET_JSON_spec_object_const ("relationships",
&relationships),
GNUNET_JSON_spec_json ("attributes",
&attributes),
GNUNET_JSON_spec_json ("relationships",
&relationships),
GNUNET_JSON_spec_end ()
};
@ -1141,6 +1141,7 @@ handle_proof_finished (void *cls,
inquiry_id,
"data",
data);
GNUNET_JSON_parse_free (spec);
break;
}
@ -1171,6 +1172,8 @@ handle_proof_finished (void *cls,
inquiry_id,
"data-attributes",
data);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
{
@ -1189,6 +1192,8 @@ handle_proof_finished (void *cls,
inquiry_id,
"data-attributes-reference_id",
data);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
}
@ -1202,6 +1207,8 @@ handle_proof_finished (void *cls,
inquiry_id,
"data-id",
data);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
@ -1233,6 +1240,8 @@ handle_proof_finished (void *cls,
GNUNET_JSON_pack_object_incref ("data",
(json_t *)
data))));
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
@ -1251,7 +1260,9 @@ handle_proof_finished (void *cls,
j,
&proof_post_conversion_cb,
ph);
GNUNET_JSON_parse_free (ispec);
}
GNUNET_JSON_parse_free (spec);
return; /* continued in proof_post_conversion_cb */
}
case MHD_HTTP_BAD_REQUEST:
@ -1638,17 +1649,17 @@ handle_webhook_finished (void *cls,
const char *inquiry_id;
const char *account_id;
const char *type = NULL;
const json_t *attributes;
const json_t *relationships;
json_t *attributes;
json_t *relationships;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("type",
&type),
GNUNET_JSON_spec_string ("id",
&inquiry_id),
GNUNET_JSON_spec_object_const ("attributes",
&attributes),
GNUNET_JSON_spec_object_const ("relationships",
&relationships),
GNUNET_JSON_spec_json ("attributes",
&attributes),
GNUNET_JSON_spec_json ("relationships",
&relationships),
GNUNET_JSON_spec_end ()
};
@ -1698,6 +1709,8 @@ handle_webhook_finished (void *cls,
webhook_reply_error (wh,
inquiry_id,
MHD_HTTP_BAD_GATEWAY);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
{
@ -1714,6 +1727,8 @@ handle_webhook_finished (void *cls,
webhook_reply_error (wh,
inquiry_id,
MHD_HTTP_BAD_GATEWAY);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
}
@ -1725,6 +1740,8 @@ handle_webhook_finished (void *cls,
webhook_reply_error (wh,
inquiry_id,
MHD_HTTP_BAD_GATEWAY);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
@ -1746,6 +1763,8 @@ handle_webhook_finished (void *cls,
inquiry_id,
NULL,
MHD_HTTP_OK);
GNUNET_JSON_parse_free (ispec);
GNUNET_JSON_parse_free (spec);
break;
}
@ -1765,7 +1784,9 @@ handle_webhook_finished (void *cls,
j,
&webhook_post_conversion_cb,
wh);
GNUNET_JSON_parse_free (ispec);
}
GNUNET_JSON_parse_free (spec);
return; /* continued in webhook_post_conversion_cb */
}
case MHD_HTTP_BAD_REQUEST:

0
src/kyclogic/taler-exchange-kyc-kycaid-converter.sh Executable file → Normal file
View File

View File

@ -79,9 +79,9 @@ handle_add_aml_decision_finished (void *cls,
{
struct TALER_EXCHANGE_AddAmlDecision *wh = cls;
const json_t *json = response;
struct TALER_EXCHANGE_AddAmlDecisionResponse adr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
wh->job = NULL;
@ -89,34 +89,34 @@ handle_add_aml_decision_finished (void *cls,
{
case 0:
/* no reply */
adr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
adr.hr.hint = "server offline?";
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
hr.hint = "server offline?";
break;
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_CONFLICT:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for exchange AML decision\n",
(unsigned int) response_code,
(int) adr.hr.ec);
(int) hr.ec);
break;
}
if (NULL != wh->cb)
{
wh->cb (wh->cb_cls,
&adr);
&hr);
wh->cb = NULL;
}
TALER_EXCHANGE_add_aml_decision_cancel (wh);

View File

@ -79,9 +79,9 @@ handle_auditor_add_denomination_finished (void *cls,
{
struct TALER_EXCHANGE_AuditorAddDenominationHandle *ah = cls;
const json_t *json = response;
struct TALER_EXCHANGE_AuditorAddDenominationResponse adr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
ah->job = NULL;
@ -90,37 +90,37 @@ handle_auditor_add_denomination_finished (void *cls,
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_NOT_FOUND:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_GONE:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_PRECONDITION_FAILED:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
if (NULL != json)
{
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for exchange auditor-add-denomination at URL `%s'\n",
(unsigned int) response_code,
(int) adr.hr.ec,
(int) hr.ec,
ah->url);
}
else
{
adr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
adr.hr.hint = NULL;
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
hr.hint = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected HTTP response code %u (no JSON returned) at URL `%s'\n",
(unsigned int) response_code,
@ -131,7 +131,7 @@ handle_auditor_add_denomination_finished (void *cls,
if (NULL != ah->cb)
{
ah->cb (ah->cb_cls,
&adr);
&hr);
ah->cb = NULL;
}
TALER_EXCHANGE_add_auditor_denomination_cancel (ah);

View File

@ -237,12 +237,12 @@ handle_deposit_finished (void *cls,
case MHD_HTTP_OK:
{
const struct TALER_EXCHANGE_Keys *key_state;
const json_t *sigs;
json_t *sigs;
json_t *sig;
unsigned int idx;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("exchange_sigs",
&sigs),
GNUNET_JSON_spec_json ("exchange_sigs",
&sigs),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
&dh->exchange_pub),
GNUNET_JSON_spec_mark_optional (
@ -269,6 +269,7 @@ handle_deposit_finished (void *cls,
GNUNET_break_op (0);
dr.hr.http_status = 0;
dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
GNUNET_JSON_parse_free (spec);
break;
}
dh->exchange_sigs = GNUNET_new_array (dh->num_cdds,
@ -281,6 +282,7 @@ handle_deposit_finished (void *cls,
GNUNET_break_op (0);
dr.hr.http_status = 0;
dr.hr.ec = TALER_EC_EXCHANGE_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE;
GNUNET_JSON_parse_free (spec);
break;
}
json_array_foreach (sigs, idx, sig)
@ -301,6 +303,7 @@ handle_deposit_finished (void *cls,
GNUNET_break_op (0);
dr.hr.http_status = 0;
dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
GNUNET_JSON_parse_free (spec);
break;
}
dki = TALER_EXCHANGE_get_denomination_key_by_hash (key_state,
@ -329,12 +332,14 @@ handle_deposit_finished (void *cls,
GNUNET_break_op (0);
dr.hr.http_status = 0;
dr.hr.ec = TALER_EC_EXCHANGE_DEPOSIT_INVALID_SIGNATURE_BY_EXCHANGE;
GNUNET_JSON_parse_free (spec);
break;
}
}
TEAH_get_auditors_for_dc (dh->exchange,
&auditor_cb,
dh);
GNUNET_JSON_parse_free (spec);
}
dr.details.ok.exchange_sigs = dh->exchange_sigs;
dr.details.ok.exchange_pub = &dh->exchange_pub;

View File

@ -1465,7 +1465,7 @@ enum GNUNET_GenericReturnValue
TALER_EXCHANGE_verify_coin_history (
const struct TALER_EXCHANGE_DenomPublicKey *dk,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const json_t *history,
json_t *history,
struct TALER_Amount *total)
{
const char *currency = dk->value.currency;
@ -1865,7 +1865,7 @@ TALER_EXCHANGE_check_coin_amount_conflict_ (
struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_Amount *remaining)
{
const json_t *history;
json_t *history;
struct TALER_Amount total;
struct TALER_DenominationHashP h_denom_pub;
const struct TALER_EXCHANGE_DenomPublicKey *dki;
@ -1874,8 +1874,8 @@ TALER_EXCHANGE_check_coin_amount_conflict_ (
coin_pub),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
&h_denom_pub),
GNUNET_JSON_spec_array_const ("history",
&history),
GNUNET_JSON_spec_json ("history",
&history),
GNUNET_JSON_spec_end ()
};
@ -1902,8 +1902,10 @@ TALER_EXCHANGE_check_coin_amount_conflict_ (
&total))
{
GNUNET_break_op (0);
json_decref (history);
return GNUNET_SYSERR;
}
json_decref (history);
if (0 >
TALER_amount_subtract (remaining,
&dki->value,
@ -2296,8 +2298,8 @@ TALER_EXCHANGE_parse_accounts (const struct TALER_MasterPublicKeyP *master_pub,
i++)
{
struct TALER_EXCHANGE_WireAccount *wa = &was[i];
const json_t *credit_restrictions;
const json_t *debit_restrictions;
json_t *credit_restrictions;
json_t *debit_restrictions;
struct GNUNET_JSON_Specification spec_account[] = {
GNUNET_JSON_spec_string ("payto_uri",
&wa->payto_uri),
@ -2305,10 +2307,10 @@ TALER_EXCHANGE_parse_accounts (const struct TALER_MasterPublicKeyP *master_pub,
GNUNET_JSON_spec_string ("conversion_url",
&wa->conversion_url),
NULL),
GNUNET_JSON_spec_array_const ("credit_restrictions",
&credit_restrictions),
GNUNET_JSON_spec_array_const ("debit_restrictions",
&debit_restrictions),
GNUNET_JSON_spec_json ("credit_restrictions",
&credit_restrictions),
GNUNET_JSON_spec_json ("debit_restrictions",
&debit_restrictions),
GNUNET_JSON_spec_fixed_auto ("master_sig",
&wa->master_sig),
GNUNET_JSON_spec_end ()
@ -2364,6 +2366,7 @@ TALER_EXCHANGE_parse_accounts (const struct TALER_MasterPublicKeyP *master_pub,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
GNUNET_JSON_parse_free (spec_account);
} /* end 'for all accounts */
return GNUNET_OK;
}

View File

@ -400,7 +400,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
json_t *auditor_obj,
const struct TALER_EXCHANGE_Keys *key_data)
{
const json_t *keys;
json_t *keys;
json_t *key;
unsigned int len;
unsigned int off;
@ -411,8 +411,8 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
&auditor->auditor_pub),
GNUNET_JSON_spec_string ("auditor_url",
&auditor_url),
GNUNET_JSON_spec_array_const ("denomination_keys",
&keys),
GNUNET_JSON_spec_json ("denomination_keys",
&keys),
GNUNET_JSON_spec_end ()
};
@ -492,6 +492,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
&auditor_sig))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@ -500,6 +501,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
off++;
}
auditor->num_denom_keys = off;
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}
@ -732,7 +734,7 @@ decode_keys_json (const json_t *resp_obj,
const char *currency;
const char *asset_type;
bool tipping_allowed = true;
const json_t *wblwk = NULL;
json_t *wblwk = NULL;
struct GNUNET_JSON_Specification mspec[] = {
GNUNET_JSON_spec_fixed_auto ("denominations_sig",
&denominations_sig),
@ -753,8 +755,8 @@ decode_keys_json (const json_t *resp_obj,
&tipping_allowed),
NULL),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_array_const ("wallet_balance_limit_without_kyc",
&wblwk),
GNUNET_JSON_spec_json ("wallet_balance_limit_without_kyc",
&wblwk),
NULL),
GNUNET_JSON_spec_end ()
};
@ -906,14 +908,14 @@ decode_keys_json (const json_t *resp_obj,
/* TODO: maybe lift all this into a FP in TALER_Extension ? */
{
struct TALER_MasterSignatureP extensions_sig = {0};
const json_t *manifests = NULL;
json_t *manifests = NULL;
bool no_extensions = false;
bool no_signature = false;
struct GNUNET_JSON_Specification ext_spec[] = {
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_object_const ("extensions",
&manifests),
GNUNET_JSON_spec_json ("extensions",
&manifests),
&no_extensions),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_fixed_auto (
@ -1705,15 +1707,15 @@ static void
deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
const json_t *data)
{
const json_t *keys;
json_t *keys;
const char *url;
uint32_t version;
struct GNUNET_TIME_Timestamp expire;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_uint32 ("version",
&version),
GNUNET_JSON_spec_array_const ("keys",
&keys),
GNUNET_JSON_spec_json ("keys",
&keys),
GNUNET_JSON_spec_string ("exchange_url",
&url),
GNUNET_JSON_spec_timestamp ("expire",
@ -1740,12 +1742,14 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
}
if (0 != version)
{
GNUNET_JSON_parse_free (spec);
return; /* unsupported version */
}
if (0 != strcmp (url,
exchange->url))
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
return;
}
memset (&key_data,
@ -1758,6 +1762,7 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
&kresp.details.ok.compat))
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
return;
}
/* decode successful, initialize with the result */
@ -1772,6 +1777,7 @@ deserialize_data (struct TALER_EXCHANGE_Handle *exchange,
/* notify application about the key information */
exchange->cert_cb (exchange->cert_cb_cls,
&kresp);
GNUNET_JSON_parse_free (spec);
}

View File

@ -96,7 +96,7 @@ handle_kyc_check_finished (void *cls,
break;
case MHD_HTTP_OK:
{
const json_t *kyc_details;
json_t *kyc_details;
uint32_t status;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("exchange_sig",
@ -105,8 +105,8 @@ handle_kyc_check_finished (void *cls,
&ks.details.ok.exchange_pub),
GNUNET_JSON_spec_timestamp ("now",
&ks.details.ok.timestamp),
GNUNET_JSON_spec_object_const ("kyc_details",
&kyc_details),
GNUNET_JSON_spec_json ("kyc_details",
&kyc_details),
GNUNET_JSON_spec_uint32 ("aml_status",
&status),
GNUNET_JSON_spec_end ()

View File

@ -270,10 +270,9 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
whilst 'i' and 'session' track the 2d array. *///
for (session = 0; session<json_array_size (json); session++)
{
const json_t *jsona;
json_t *jsona;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("new_coins",
&jsona),
GNUNET_JSON_spec_json ("new_coins", &jsona),
GNUNET_JSON_spec_end ()
};
@ -286,8 +285,16 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (! json_is_array (jsona))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
/* count all coins over all sessions */
num_coins += json_array_size (jsona);
GNUNET_JSON_parse_free (spec);
}
/* Now that we know how big the 1d array is, allocate
and fill it. */
@ -300,11 +307,11 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
off_coin = 0;
for (session = 0; session<json_array_size (json); session++)
{
const json_t *jsona;
json_t *jsona;
struct TALER_TransferPublicKeyP trans_pub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("new_coins",
&jsona),
GNUNET_JSON_spec_json ("new_coins",
&jsona),
GNUNET_JSON_spec_fixed_auto ("transfer_pub",
&trans_pub),
GNUNET_JSON_spec_end ()
@ -319,6 +326,12 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (! json_is_array (jsona))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
/* decode all coins */
for (i = 0; i<json_array_size (jsona); i++)
@ -344,8 +357,10 @@ parse_link_ok (struct TALER_EXCHANGE_LinkHandle *lh,
{
GNUNET_break_op (0);
ret = GNUNET_SYSERR;
GNUNET_JSON_parse_free (spec);
break;
}
GNUNET_JSON_parse_free (spec);
} /* end of for (session) */
if (off_coin == num_coins)

View File

@ -127,12 +127,13 @@ parse_kyc_attributes (const json_t *kyc_attributes,
json_array_foreach (kyc_attributes, idx, obj)
{
struct TALER_EXCHANGE_KycHistoryDetail *kyc = &kyc_attributes_ar[idx];
json_t *attributes = NULL;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp ("collection_time",
&kyc->collection_time),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_object_const ("attributes",
&kyc->attributes),
GNUNET_JSON_spec_json ("attributes",
&attributes),
NULL),
GNUNET_JSON_spec_string ("provider_section",
&kyc->provider_section),
@ -148,6 +149,8 @@ parse_kyc_attributes (const json_t *kyc_attributes,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
kyc->attributes = attributes;
json_decref (attributes); /* this is OK, RC preserved via 'kyc_attributes' as long as needed! */
}
return GNUNET_OK;
}
@ -168,13 +171,13 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh,
.hr.reply = json,
.hr.http_status = MHD_HTTP_OK
};
const json_t *aml_history;
const json_t *kyc_attributes;
json_t *aml_history;
json_t *kyc_attributes;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("aml_history",
&aml_history),
GNUNET_JSON_spec_array_const ("kyc_attributes",
&kyc_attributes),
GNUNET_JSON_spec_json ("aml_history",
&aml_history),
GNUNET_JSON_spec_json ("kyc_attributes",
&kyc_attributes),
GNUNET_JSON_spec_end ()
};
@ -196,12 +199,6 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh,
GNUNET_NZL (lr.details.ok.kyc_attributes_length)];
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
memset (aml_history_ar,
0,
sizeof (aml_history_ar));
memset (kyc_attributes_ar,
0,
sizeof (kyc_attributes_ar));
lr.details.ok.aml_history = aml_history_ar;
lr.details.ok.kyc_attributes = kyc_attributes_ar;
ret = parse_aml_history (aml_history,

View File

@ -123,10 +123,10 @@ parse_decisions_ok (struct TALER_EXCHANGE_LookupAmlDecisions *lh,
.hr.reply = json,
.hr.http_status = MHD_HTTP_OK
};
const json_t *records;
json_t *records;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("records",
&records),
GNUNET_JSON_spec_json ("records",
&records),
GNUNET_JSON_spec_end ()
};

View File

@ -79,9 +79,9 @@ handle_add_partner_finished (void *cls,
{
struct TALER_EXCHANGE_ManagementAddPartner *wh = cls;
const json_t *json = response;
struct TALER_EXCHANGE_ManagementAddPartnerResponse apr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
wh->job = NULL;
@ -89,34 +89,34 @@ handle_add_partner_finished (void *cls,
{
case 0:
/* no reply */
apr.hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
apr.hr.hint = "server offline?";
hr.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
hr.hint = "server offline?";
break;
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
apr.hr.ec = TALER_JSON_get_error_code (json);
apr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_CONFLICT:
apr.hr.ec = TALER_JSON_get_error_code (json);
apr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
apr.hr.ec = TALER_JSON_get_error_code (json);
apr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for adding exchange partner\n",
(unsigned int) response_code,
(int) apr.hr.ec);
(int) hr.ec);
break;
}
if (NULL != wh->cb)
{
wh->cb (wh->cb_cls,
&apr);
&hr);
wh->cb = NULL;
}
TALER_EXCHANGE_management_add_partner_cancel (wh);

View File

@ -81,9 +81,9 @@ handle_auditor_disable_finished (void *cls,
{
struct TALER_EXCHANGE_ManagementAuditorDisableHandle *ah = cls;
const json_t *json = response;
struct TALER_EXCHANGE_ManagementAuditorDisableResponse adr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
ah->job = NULL;
@ -92,32 +92,32 @@ handle_auditor_disable_finished (void *cls,
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_NOT_FOUND:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_CONFLICT:
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
adr.hr.ec = TALER_JSON_get_error_code (json);
adr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for exchange management auditor disable\n",
(unsigned int) response_code,
(int) adr.hr.ec);
(int) hr.ec);
break;
}
if (NULL != ah->cb)
{
ah->cb (ah->cb_cls,
&adr);
&hr);
ah->cb = NULL;
}
TALER_EXCHANGE_management_disable_auditor_cancel (ah);

View File

@ -82,9 +82,9 @@ handle_auditor_enable_finished (void *cls,
{
struct TALER_EXCHANGE_ManagementAuditorEnableHandle *ah = cls;
const json_t *json = response;
struct TALER_EXCHANGE_ManagementAuditorEnableResponse aer = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
ah->job = NULL;
@ -93,28 +93,28 @@ handle_auditor_enable_finished (void *cls,
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
aer.hr.ec = TALER_JSON_get_error_code (json);
aer.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_CONFLICT:
aer.hr.ec = TALER_JSON_get_error_code (json);
aer.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
aer.hr.ec = TALER_JSON_get_error_code (json);
aer.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for exchange management auditor enable\n",
(unsigned int) response_code,
(int) aer.hr.ec);
(int) hr.ec);
break;
}
if (NULL != ah->cb)
{
ah->cb (ah->cb_cls,
&aer);
&hr);
ah->cb = NULL;
}
TALER_EXCHANGE_management_enable_auditor_cancel (ah);

View File

@ -85,14 +85,14 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,
};
struct TALER_EXCHANGE_FutureKeys *fk
= &gkr.details.ok.keys;
const json_t *sk;
const json_t *dk;
json_t *sk;
json_t *dk;
bool ok;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("future_denoms",
&dk),
GNUNET_JSON_spec_array_const ("future_signkeys",
&sk),
GNUNET_JSON_spec_json ("future_denoms",
&dk),
GNUNET_JSON_spec_json ("future_signkeys",
&sk),
GNUNET_JSON_spec_fixed_auto ("master_pub",
&fk->master_pub),
GNUNET_JSON_spec_fixed_auto ("denom_secmod_public_key",
@ -127,7 +127,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,
i);
struct TALER_EXCHANGE_FutureSigningPublicKey *sign_key
= &fk->sign_keys[i];
struct GNUNET_JSON_Specification ispec[] = {
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("key",
&sign_key->key),
GNUNET_JSON_spec_fixed_auto ("signkey_secmod_sig",
@ -143,7 +143,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,
if (GNUNET_OK !=
GNUNET_JSON_parse (j,
ispec,
spec,
NULL, NULL))
{
GNUNET_break_op (0);
@ -276,6 +276,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,
break;
}
}
GNUNET_JSON_parse_free (spec);
if (! ok)
break;
}
@ -288,6 +289,7 @@ handle_ok (struct TALER_EXCHANGE_ManagementGetKeysHandle *gh,
TALER_denom_pub_free (&fk->denom_keys[i].key);
GNUNET_free (fk->sign_keys);
GNUNET_free (fk->denom_keys);
GNUNET_JSON_parse_free (spec);
return (ok) ? GNUNET_OK : GNUNET_SYSERR;
}

View File

@ -126,7 +126,7 @@ struct TALER_EXCHANGE_ManagementPostExtensionsHandle *
TALER_EXCHANGE_management_post_extensions (
struct GNUNET_CURL_Context *ctx,
const char *url,
const struct TALER_EXCHANGE_ManagementPostExtensionsData *ped,
struct TALER_EXCHANGE_ManagementPostExtensionsData *ped,
TALER_EXCHANGE_ManagementPostExtensionsCallback cb,
void *cb_cls)
{
@ -151,7 +151,7 @@ TALER_EXCHANGE_management_post_extensions (
body = GNUNET_JSON_PACK (
GNUNET_JSON_pack_object_steal ("extensions",
(json_t *) ped->extensions),
ped->extensions),
GNUNET_JSON_pack_data_auto ("extensions_sig",
&ped->extensions_sig));

View File

@ -79,9 +79,9 @@ handle_set_global_fee_finished (void *cls,
{
struct TALER_EXCHANGE_ManagementSetGlobalFeeHandle *sgfh = cls;
const json_t *json = response;
struct TALER_EXCHANGE_ManagementSetGlobalFeeResponse sfr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
sgfh->job = NULL;
@ -90,32 +90,32 @@ handle_set_global_fee_finished (void *cls,
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
sfr.hr.ec = TALER_JSON_get_error_code (json);
sfr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_CONFLICT:
sfr.hr.ec = TALER_JSON_get_error_code (json);
sfr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_PRECONDITION_FAILED:
sfr.hr.ec = TALER_JSON_get_error_code (json);
sfr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
sfr.hr.ec = TALER_JSON_get_error_code (json);
sfr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for exchange management set global fee\n",
(unsigned int) response_code,
(int) sfr.hr.ec);
(int) hr.ec);
break;
}
if (NULL != sgfh->cb)
{
sgfh->cb (sgfh->cb_cls,
&sfr);
&hr);
sgfh->cb = NULL;
}
TALER_EXCHANGE_management_set_global_fees_cancel (sgfh);

View File

@ -79,9 +79,9 @@ handle_set_wire_fee_finished (void *cls,
{
struct TALER_EXCHANGE_ManagementSetWireFeeHandle *swfh = cls;
const json_t *json = response;
struct TALER_EXCHANGE_ManagementSetWireFeeResponse swr = {
.hr.http_status = (unsigned int) response_code,
.hr.reply = json
struct TALER_EXCHANGE_HttpResponse hr = {
.http_status = (unsigned int) response_code,
.reply = json
};
swfh->job = NULL;
@ -90,32 +90,32 @@ handle_set_wire_fee_finished (void *cls,
case MHD_HTTP_NO_CONTENT:
break;
case MHD_HTTP_FORBIDDEN:
swr.hr.ec = TALER_JSON_get_error_code (json);
swr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_CONFLICT:
swr.hr.ec = TALER_JSON_get_error_code (json);
swr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
case MHD_HTTP_PRECONDITION_FAILED:
swr.hr.ec = TALER_JSON_get_error_code (json);
swr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
break;
default:
/* unexpected response code */
GNUNET_break_op (0);
swr.hr.ec = TALER_JSON_get_error_code (json);
swr.hr.hint = TALER_JSON_get_error_hint (json);
hr.ec = TALER_JSON_get_error_code (json);
hr.hint = TALER_JSON_get_error_hint (json);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u/%d for exchange management set wire fee\n",
(unsigned int) response_code,
(int) swr.hr.ec);
(int) hr.ec);
break;
}
if (NULL != swfh->cb)
{
swfh->cb (swfh->cb_cls,
&swr);
&hr);
swfh->cb = NULL;
}
TALER_EXCHANGE_management_set_wire_fees_cancel (swfh);

View File

@ -107,10 +107,10 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,
const json_t *json,
struct TALER_EXCHANGE_RevealedCoinInfo *rcis)
{
const json_t *jsona;
json_t *jsona;
struct GNUNET_JSON_Specification outer_spec[] = {
GNUNET_JSON_spec_array_const ("ev_sigs",
&jsona),
GNUNET_JSON_spec_json ("ev_sigs",
&jsona),
GNUNET_JSON_spec_end ()
};
@ -122,10 +122,18 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (! json_is_array (jsona))
{
/* We expected an array of coins */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR;
}
if (rrh->md.num_fresh_coins != json_array_size (jsona))
{
/* Number of coins generated does not match our expectation */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR;
}
for (unsigned int i = 0; i<rrh->md.num_fresh_coins; i++)
@ -172,6 +180,7 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,
NULL, NULL))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR;
}
@ -200,11 +209,13 @@ refresh_reveal_ok (struct TALER_EXCHANGE_RefreshesRevealHandle *rrh,
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_SYSERR;
}
GNUNET_JSON_parse_free (spec);
rci->sig = coin.sig;
}
GNUNET_JSON_parse_free (outer_spec);
return GNUNET_OK;
}

View File

@ -172,11 +172,11 @@ static enum GNUNET_GenericReturnValue
verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
const json_t *json)
{
const json_t *history;
json_t *history;
struct TALER_DenominationHashP h_denom_pub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("history",
&history),
GNUNET_JSON_spec_json ("history",
&history),
GNUNET_JSON_spec_fixed_auto ("h_denom_pub",
&h_denom_pub),
GNUNET_JSON_spec_end ()
@ -199,6 +199,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
if (0 == len)
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
have_deposit = false;
@ -224,6 +225,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
NULL, NULL))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (0 == strcasecmp (type,
@ -272,6 +274,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
NULL, NULL))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -289,6 +292,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&sig))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if ( (0 != GNUNET_memcmp (&rh->h_contract_terms,
@ -298,6 +302,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
{
/* deposit information is about a different merchant/contract */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (have_deposit)
@ -308,6 +313,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&dtotal))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
GNUNET_break (0 <=
@ -350,6 +356,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
NULL, NULL))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (0 >
@ -358,6 +365,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&amount))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -369,6 +377,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&sig))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if ( (0 != GNUNET_memcmp (&rh->h_contract_terms,
@ -378,6 +387,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
{
/* refund is about a different merchant/contract */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (rtransaction_id == rh->rtransaction_id)
@ -385,6 +395,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
/* Eh, this shows either a dependency failure or idempotency,
but must not happen in a conflict reply. Fail! */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
@ -395,6 +406,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&rtotal))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
GNUNET_break (0 <=
@ -415,6 +427,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
"Unexpected type `%s' in response for exchange refund\n",
type);
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@ -427,6 +440,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&rh->refund_amount))
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@ -438,6 +452,7 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
if (! have_deposit)
{
GNUNET_break (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (-1 != TALER_amount_cmp (&dtotal,
@ -445,9 +460,11 @@ verify_conflict_history_ok (struct TALER_EXCHANGE_RefundHandle *rh,
{
/* rtotal <= dtotal is fine, no conflict! */
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
/* dtotal < rtotal: that's a conflict! */
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}
@ -465,11 +482,11 @@ static enum GNUNET_GenericReturnValue
verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,
const json_t *json)
{
const json_t *h;
json_t *h;
json_t *e;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("history",
&h),
GNUNET_JSON_spec_json ("history",
&h),
GNUNET_JSON_spec_end ()
};
@ -481,9 +498,11 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
if (1 != json_array_size (h))
if ( (! json_is_array (h)) ||
(1 != json_array_size (h) ) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
e = json_array_get (h, 0);
@ -519,6 +538,7 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,
NULL, NULL))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -530,6 +550,7 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&sig))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if ( (rtransaction_id != rh->rtransaction_id) ||
@ -541,9 +562,11 @@ verify_failed_dependency_ok (struct TALER_EXCHANGE_RefundHandle *rh,
&amount)) )
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}

View File

@ -93,7 +93,7 @@ handle_reserves_attest_ok (struct TALER_EXCHANGE_ReservesAttestHandle *rsh,
.hr.reply = j,
.hr.http_status = MHD_HTTP_OK
};
const json_t *attributes;
json_t *attributes;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp ("exchange_timestamp",
&rs.details.ok.exchange_time),
@ -103,8 +103,8 @@ handle_reserves_attest_ok (struct TALER_EXCHANGE_ReservesAttestHandle *rsh,
&rs.details.ok.exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
&rs.details.ok.exchange_pub),
GNUNET_JSON_spec_object_const ("attributes",
&attributes),
GNUNET_JSON_spec_json ("attributes",
&attributes),
GNUNET_JSON_spec_end ()
};

View File

@ -88,10 +88,10 @@ handle_reserves_get_attestable_ok (
.hr.reply = j,
.hr.http_status = MHD_HTTP_OK
};
const json_t *details;
json_t *details;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_array_const ("details",
&details),
GNUNET_JSON_spec_json ("details",
&details),
GNUNET_JSON_spec_end ()
};
@ -116,6 +116,7 @@ handle_reserves_get_attestable_ok (
if (NULL == attributes[i])
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
}
@ -125,6 +126,7 @@ handle_reserves_get_attestable_ok (
&rs);
rgah->cb = NULL;
}
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}

View File

@ -99,7 +99,7 @@ static enum GNUNET_GenericReturnValue
handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,
const json_t *j)
{
const json_t *history;
json_t *history;
unsigned int len;
struct TALER_EXCHANGE_ReserveHistory rs = {
.hr.reply = j,
@ -110,8 +110,8 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any ("balance",
&rs.details.ok.balance),
GNUNET_JSON_spec_array_const ("history",
&history),
GNUNET_JSON_spec_json ("history",
&history),
GNUNET_JSON_spec_end ()
};
@ -143,6 +143,7 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,
GNUNET_break_op (0);
TALER_EXCHANGE_free_reserve_history (rhistory,
len);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (NULL != rsh->cb)
@ -156,6 +157,7 @@ handle_reserves_history_ok (struct TALER_EXCHANGE_ReservesHistoryHandle *rsh,
TALER_EXCHANGE_free_reserve_history (rhistory,
len);
}
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}

View File

@ -89,7 +89,7 @@ static enum GNUNET_GenericReturnValue
handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,
const json_t *j)
{
const json_t *history;
json_t *history;
unsigned int len;
struct TALER_EXCHANGE_ReserveStatus rs = {
.hr.reply = j,
@ -98,8 +98,8 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount_any ("balance",
&rs.details.ok.balance),
GNUNET_JSON_spec_array_const ("history",
&history),
GNUNET_JSON_spec_json ("history",
&history),
GNUNET_JSON_spec_end ()
};
@ -145,6 +145,7 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,
TALER_EXCHANGE_free_reserve_history (rhistory,
len);
}
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}

View File

@ -84,7 +84,7 @@ check_transfers_get_response_ok (
struct TALER_EXCHANGE_TransfersGetHandle *wdh,
const json_t *json)
{
const json_t *details_j;
json_t *details_j;
struct TALER_Amount total_expected;
struct TALER_MerchantPublicKeyP merchant_pub;
struct TALER_EXCHANGE_TransfersGetResponse tgr = {
@ -104,8 +104,8 @@ check_transfers_get_response_ok (
&td->h_payto),
GNUNET_JSON_spec_timestamp ("execution_time",
&td->execution_time),
GNUNET_JSON_spec_array_const ("deposits",
&details_j),
GNUNET_JSON_spec_json ("deposits",
&details_j),
GNUNET_JSON_spec_fixed_auto ("exchange_sig",
&td->exchange_sig),
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
@ -126,6 +126,7 @@ check_transfers_get_response_ok (
&total_expected))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
@ -134,6 +135,7 @@ check_transfers_get_response_ok (
&td->exchange_pub))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
return GNUNET_SYSERR;
}
td->details_length = json_array_size (details_j);
@ -179,6 +181,7 @@ check_transfers_get_response_ok (
{
GNUNET_break_op (0);
GNUNET_CRYPTO_hash_context_abort (hash_context);
GNUNET_JSON_parse_free (spec);
GNUNET_free (details);
return GNUNET_SYSERR;
}
@ -208,6 +211,7 @@ check_transfers_get_response_ok (
&td->exchange_sig))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
GNUNET_free (details);
return GNUNET_SYSERR;
}
@ -219,6 +223,7 @@ check_transfers_get_response_ok (
&td->wire_fee))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
GNUNET_free (details);
return GNUNET_SYSERR;
}
@ -227,6 +232,7 @@ check_transfers_get_response_ok (
&td->total_amount))
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
GNUNET_free (details);
return GNUNET_SYSERR;
}
@ -234,6 +240,7 @@ check_transfers_get_response_ok (
&tgr);
GNUNET_free (details);
}
GNUNET_JSON_parse_free (spec);
return GNUNET_OK;
}

View File

@ -62,15 +62,13 @@ struct AuditorAddState
* if the response code is acceptable.
*
* @param cls closure.
* @param aer response details
* @param hr HTTP response details
*/
static void
auditor_add_cb (
void *cls,
const struct TALER_EXCHANGE_ManagementAuditorEnableResponse *aer)
auditor_add_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct AuditorAddState *ds = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &aer->hr;
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)

View File

@ -67,15 +67,13 @@ struct AuditorAddDenomSigState
* if the response code is acceptable.
*
* @param cls closure.
* @param adr response details
* @param hr HTTP response details
*/
static void
denom_sig_add_cb (
void *cls,
const struct TALER_EXCHANGE_AuditorAddDenominationResponse *adr)
denom_sig_add_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct AuditorAddDenomSigState *ds = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &adr->hr;
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)

View File

@ -62,16 +62,13 @@ struct AuditorDelState
* if the response code is acceptable.
*
* @param cls closure.
* @param adr response details
* @param hr HTTP response details
*/
static void
auditor_del_cb (
void *cls,
const struct TALER_EXCHANGE_ManagementAuditorDisableResponse *adr)
auditor_del_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct AuditorDelState *ds = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &adr->hr;
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)

View File

@ -194,15 +194,28 @@ do_retry (void *cls)
* acceptable.
*
* @param cls closure with the interpreter state
* @param air response details
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for
* successful status request; 0 if the exchange's reply is
* bogus (fails to follow the protocol)
* @param ec taler-specific error code, #TALER_EC_NONE on success
* @param serial_id unique ID of the wire transfer
* @param timestamp time stamp of the transaction made.
* @param json raw response
*/
static void
confirmation_cb (void *cls,
const struct TALER_BANK_AdminAddIncomingResponse *air)
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t serial_id,
struct GNUNET_TIME_Timestamp timestamp,
const json_t *json)
{
struct AdminAddIncomingState *fts = cls;
struct TALER_TESTING_Interpreter *is = fts->is;
(void) json;
fts->reserve_history.details.in_details.timestamp = timestamp;
fts->reserve_history.details.in_details.wire_reference = serial_id;
fts->aih = NULL;
/**
* Test case not caring about the HTTP status code.
@ -224,23 +237,17 @@ confirmation_cb (void *cls,
TALER_TESTING_interpreter_next (is);
return;
}
if (air->http_status != fts->expected_http_status)
if (http_status != fts->expected_http_status)
{
GNUNET_break (0);
TALER_TESTING_interpreter_fail (is);
return;
}
switch (air->http_status)
switch (http_status)
{
case MHD_HTTP_OK:
fts->reserve_history.details.in_details.timestamp
= air->details.ok.timestamp;
fts->reserve_history.details.in_details.wire_reference
= air->details.ok.serial_id;
fts->serial_id
= air->details.ok.serial_id;
fts->timestamp
= air->details.ok.timestamp;
fts->serial_id = serial_id;
fts->timestamp = timestamp;
TALER_TESTING_interpreter_next (is);
return;
case MHD_HTTP_UNAUTHORIZED:
@ -264,17 +271,17 @@ confirmation_cb (void *cls,
if (0 != fts->do_retry)
{
fts->do_retry--;
if ( (0 == air->http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == air->ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == air->http_status) )
if ( (0 == http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
{
GNUNET_log (
GNUNET_ERROR_TYPE_INFO,
"Retrying fakebank transfer failed with %u/%d\n",
air->http_status,
(int) air->ec);
http_status,
(int) ec);
/* on DB conflicts, do not use backoff */
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == air->ec)
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == ec)
fts->backoff = GNUNET_TIME_UNIT_ZERO;
else
fts->backoff = GNUNET_TIME_randomized_backoff (fts->backoff,
@ -292,8 +299,8 @@ confirmation_cb (void *cls,
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Fakebank returned HTTP status %u/%d\n",
air->http_status,
(int) air->ec);
http_status,
(int) ec);
TALER_TESTING_interpreter_fail (is);
}

View File

@ -163,31 +163,39 @@ do_retry (void *cls)
* acceptable.
*
* @param cls closure with the interpreter state
* @param tr response details
* @param http_status HTTP response code, #MHD_HTTP_OK (200) for
* successful status request; 0 if the exchange's reply is
* bogus (fails to follow the protocol)
* @param ec taler-specific error code, #TALER_EC_NONE on success
* @param serial_id unique ID of the wire transfer
* @param timestamp time stamp of the transaction made.
*/
static void
confirmation_cb (void *cls,
const struct TALER_BANK_TransferResponse *tr)
unsigned int http_status,
enum TALER_ErrorCode ec,
uint64_t serial_id,
struct GNUNET_TIME_Timestamp timestamp)
{
struct TransferState *fts = cls;
struct TALER_TESTING_Interpreter *is = fts->is;
fts->weh = NULL;
if (MHD_HTTP_OK != tr->http_status)
if (MHD_HTTP_OK != http_status)
{
if (0 != fts->do_retry)
{
fts->do_retry--;
if ( (0 == tr->http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == tr->ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == tr->http_status) )
if ( (0 == http_status) ||
(TALER_EC_GENERIC_DB_SOFT_FAILURE == ec) ||
(MHD_HTTP_INTERNAL_SERVER_ERROR == http_status) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Retrying transfer failed with %u/%d\n",
tr->http_status,
(int) tr->ec);
http_status,
(int) ec);
/* on DB conflicts, do not use backoff */
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == tr->ec)
if (TALER_EC_GENERIC_DB_SOFT_FAILURE == ec)
fts->backoff = GNUNET_TIME_UNIT_ZERO;
else
fts->backoff = EXCHANGE_LIB_BACKOFF (fts->backoff);
@ -202,14 +210,14 @@ confirmation_cb (void *cls,
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Bank returned HTTP status %u/%d\n",
tr->http_status,
(int) tr->ec);
http_status,
(int) ec);
TALER_TESTING_interpreter_fail (is);
return;
}
fts->serial_id = tr->details.ok.row_id;
fts->timestamp = tr->details.ok.timestamp;
fts->serial_id = serial_id;
fts->timestamp = timestamp;
TALER_TESTING_interpreter_next (is);
}

View File

@ -77,14 +77,13 @@ struct WireFeeState
* if the response code is acceptable.
*
* @param cls closure.
* @param sfr response details
* @param hr HTTP response details
*/
static void
wire_add_cb (void *cls,
const struct TALER_EXCHANGE_ManagementSetWireFeeResponse *sfr)
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct WireFeeState *ds = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &sfr->hr;
ds->dh = NULL;
if (ds->expected_response_code != hr->http_status)

View File

@ -90,19 +90,17 @@ struct AmlDecisionState
/**
* Callback to analyze the /aml-decision/$OFFICER_PUB response, just used to check
* Callback to analyze the /management/XXX response, just used to check
* if the response code is acceptable.
*
* @param cls closure.
* @param adr response details
* @param hr HTTP response details
*/
static void
take_aml_decision_cb (
void *cls,
const struct TALER_EXCHANGE_AddAmlDecisionResponse *adr)
take_aml_decision_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr)
{
struct AmlDecisionState *ds = cls;
const struct TALER_EXCHANGE_HttpResponse *hr = &adr->hr;
ds->dh = NULL;
if (ds->expected_response != hr->http_status)

View File

@ -17,13 +17,13 @@ TALER_HOME = ${TALER_TEST_HOME:-${HOME:-${USERPROFILE}}}
# for how these should be used.
# Persistent data storage
TALER_DATA_HOME = ${TALER_TEST_HOME:-${XDG_DATA_HOME:-${TALER_HOME}/.local/share/}/.local/share/}taler/
TALER_DATA_HOME = ${XDG_DATA_HOME:-$TALER_HOME/.local/share}/taler/
# Configuration files
TALER_CONFIG_HOME = ${TALER_TEST_HOME:-${XDG_CONFIG_HOME:-${TALER_HOME}/.config/}/.config/}taler/
TALER_CONFIG_HOME = ${XDG_CONFIG_HOME:-$TALER_HOME/.config}/taler/
# Cached data, no big deal if lost
TALER_CACHE_HOME = ${TALER_TEST_HOME:-${XDG_CACHE_HOME:-${TALER_HOME}/.cache/}/.cache/}taler/
TALER_CACHE_HOME = ${XDG_CACHE_HOME:-$TALER_HOME/.cache}/taler/
# Runtime data (always lost on system boot)
TALER_RUNTIME_DIR = ${TMPDIR:-${TMP:-/tmp}}/taler-system-runtime/