update auditordb and test logic to work with new key separation logic (#6175)

This commit is contained in:
Christian Grothoff 2020-12-17 13:04:37 +01:00
parent ff27037d42
commit b74612fc33
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
18 changed files with 2217 additions and 1725 deletions

View File

@ -1 +1 @@
1608145201
1608204318

View File

@ -1 +1 @@
RQEJK57B1MJF72CCA0G25A2QZNFRQ1GG9GAAX3BQS5Q8QF8FMYQG
RF053Y0TERE9WRNC4T4V5454F0SYA8HSBA63P58EAXBFY9BP7E90

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,10 @@ DB = postgres
# Where do we store the auditor's private key?
AUDITOR_PRIV_FILE = ${TALER_DATA_HOME}/auditor/offline-keys/auditor.priv
# What is the public key of this auditor? Used for processes that
# verify auditor's signatures but have no access to the private key.
# PUBLIC_KEY = VALUE
# What is the Web site of the auditor (i.e. to file complaints about
# a misbehaving exchange)?
# AUDITOR_URL = https://auditor.taler.net/

View File

@ -120,7 +120,7 @@ $TLIBEXEC/taler-helper-crypto-rsa -c $CONF 2> taler-helper-crypto-rsa.log &
taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
taler-auditor-httpd -L INFO -c $CONF 2> taler-auditor-httpd.log &
# Wait for all bank to be available (usually the slowest)
for n in `seq 1 50`

View File

@ -95,6 +95,7 @@ taler-exchange-dbinit -c $CONF
# setup auditor
echo "Setting up auditor"
taler-auditor-dbinit -c $CONF
taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
# Launch services
echo "Launching services"

View File

@ -61,6 +61,11 @@ struct TALER_AUDITORDB_Session *TALER_ARL_asession;
*/
struct TALER_MasterPublicKeyP TALER_ARL_master_pub;
/**
* Public key of the auditor.
*/
static struct TALER_AuditorPublicKeyP TALER_ARL_auditor_pub;
/**
* At what time did the auditor process start?
*/
@ -150,21 +155,84 @@ TALER_ARL_report (json_t *array,
/**
* Function called with the results of select_denomination_info()
* Function called with the results of iterate_denomination_info(),
* or directly (!). Used to check and add the respective denomination
* to our hash table.
*
* @param cls closure, NULL
* @param denom_pub public key, sometimes NULL (!)
* @param issue issuing information with value, fees and other info about the denomination.
* @return #GNUNET_OK (to continue)
*/
static int
static void
add_denomination (void *cls,
const struct TALER_DenominationKeyValidityPS *issue)
const struct TALER_DenominationPublicKey *denom_pub,
const struct
TALER_EXCHANGEDB_DenominationKeyInformationP *validity)
{
const struct TALER_DenominationKeyValidityPS *issue = &validity->properties;
(void) cls;
(void) denom_pub;
if (NULL !=
GNUNET_CONTAINER_multihashmap_get (denominations,
&issue->denom_hash))
return GNUNET_OK; /* value already known */
return; /* value already known */
#if FIXME_IMPLEMENT
qs = TALER_ARL_edb->select_auditor_denom_sig (TALER_ARL_edb->cls,
TALER_ARL_esession,
&issue->denom_hash,
&TALER_ARL_auditor_pub,
&auditor_sig);
if (0 >= qs)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Encountered denomination `%s' that this auditor is not auditing!\n",
GNUNET_h2s (&issue->denom_hash));
return; /* skip! */
}
{
// TODO: one of the auditor passes should really just do this
// add problems to JSON report (even if the implications are unclear),
// instead of doing it here!
struct TALER_Amount coin_value;
struct TALER_Amount fee_withdraw;
struct TALER_Amount fee_deposit;
struct TALER_Amount fee_refresh;
struct TALER_Amount fee_refund;
TALER_amount_hton (&coin_value,
&issue->value);
TALER_amount_hton (&fee_withdraw,
&issue->fee_withdraw);
TALER_amount_hton (&fee_deposit,
&issue->fee_deposit);
TALER_amount_hton (&fee_refresh,
&issue->fee_refresh);
TALER_amount_hton (&fee_refund,
&issue->fee_refund);
if (GNUNET_OK !=
TALER_auditor_denom_validity_verify (
TALER_ARL_auditor_url,
&issue->denom_hash,
&TALER_ARL_master_pub,
GNUNET_TIME_absolute_ntoh (issue->start),
GNUNET_TIME_absolute_ntoh (issue->expire_withdraw),
GNUNET_TIME_absolute_ntoh (issue->expire_deposit),
GNUNET_TIME_absolute_ntoh (issue->expire_legal),
&coin_value,
&fee_withdraw,
&fee_deposit,
&fee_refresh,
&fee_refund,
&TALER_ARL_auditor_pub,
&auditor_sig))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Exchange has invalid signature from this auditor for denomination `%s' in its database!\n",
GNUNET_h2s (&issue->denom_hash));
}
}
#endif
#if GNUNET_EXTRA_LOGGING >= 1
{
struct TALER_Amount value;
@ -201,7 +269,6 @@ add_denomination (void *cls,
i,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
return GNUNET_OK;
}
@ -214,9 +281,9 @@ add_denomination (void *cls,
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
TALER_ARL_get_denomination_info_by_hash (const struct GNUNET_HashCode *dh,
const struct
TALER_DenominationKeyValidityPS **issue)
TALER_ARL_get_denomination_info_by_hash (
const struct GNUNET_HashCode *dh,
const struct TALER_DenominationKeyValidityPS **issue)
{
enum GNUNET_DB_QueryStatus qs;
@ -224,11 +291,10 @@ TALER_ARL_get_denomination_info_by_hash (const struct GNUNET_HashCode *dh,
{
denominations = GNUNET_CONTAINER_multihashmap_create (256,
GNUNET_NO);
qs = TALER_ARL_adb->select_denomination_info (TALER_ARL_adb->cls,
TALER_ARL_asession,
&TALER_ARL_master_pub,
&add_denomination,
NULL);
qs = TALER_ARL_edb->iterate_denomination_info (TALER_ARL_edb->cls,
// FIXME: change API to pass session!?
&add_denomination,
NULL);
if (0 > qs)
{
*issue = NULL;
@ -248,18 +314,24 @@ TALER_ARL_get_denomination_info_by_hash (const struct GNUNET_HashCode *dh,
}
}
/* maybe database changed since we last iterated, give it one more shot */
qs = TALER_ARL_adb->select_denomination_info (TALER_ARL_adb->cls,
TALER_ARL_asession,
&TALER_ARL_master_pub,
&add_denomination,
NULL);
if (qs <= 0)
{
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Denomination %s not found\n",
TALER_B2S (dh));
return qs;
struct TALER_EXCHANGEDB_DenominationKeyInformationP issue;
qs = TALER_ARL_edb->get_denomination_info (TALER_ARL_edb->cls,
TALER_ARL_esession,
dh,
&issue);
if (qs <= 0)
{
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Denomination %s not found\n",
TALER_B2S (dh));
return qs;
}
add_denomination (NULL,
NULL,
&issue);
}
{
const struct TALER_DenominationKeyValidityPS *i;
@ -659,13 +731,13 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c)
if (GNUNET_YES == GNUNET_is_zero (&TALER_ARL_master_pub))
{
/* -m option not given, try configuration */
char *TALER_ARL_master_public_key_str;
char *master_public_key_str;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (TALER_ARL_cfg,
"exchange",
"MASTER_PUBLIC_KEY",
&TALER_ARL_master_public_key_str))
&master_public_key_str))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Pass option -m or set MASTER_PUBLIC_KEY in the configuration!\n");
@ -676,24 +748,81 @@ TALER_ARL_init (const struct GNUNET_CONFIGURATION_Handle *c)
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_public_key_from_string (
TALER_ARL_master_public_key_str,
strlen (
TALER_ARL_master_public_key_str),
&TALER_ARL_master_pub.
eddsa_pub))
master_public_key_str,
strlen (master_public_key_str),
&TALER_ARL_master_pub.eddsa_pub))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed master public key given in configuration file.");
GNUNET_free (TALER_ARL_master_public_key_str);
GNUNET_log_config_malformed (GNUNET_ERROR_TYPE_ERROR,
"exchange",
"MASTER_PUBLIC_KEY",
"invalid key");
GNUNET_free (master_public_key_str);
return GNUNET_SYSERR;
}
GNUNET_free (TALER_ARL_master_public_key_str);
GNUNET_free (master_public_key_str);
} /* end of -m not given */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Taler auditor running for exchange master public key %s\n",
TALER_B2S (&TALER_ARL_master_pub));
if (GNUNET_YES == GNUNET_is_zero (&TALER_ARL_auditor_pub))
{
/* try loading private key and deriving public key */
char *fn;
if (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_filename (kcfg,
"auditor",
"AUDITOR_PRIV_FILE",
&fn))
{
struct TALER_AuditorPrivateKeyP auditor_priv;
if (GNUNET_OK ==
GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_NO, /* do NOT create it! */
&auditor_priv.eddsa_priv))
{
GNUNET_CRYPTO_eddsa_key_get_public (&auditor_priv.eddsa_priv,
&auditor_pub.eddsa_pub);
}
GNUNET_free (fn);
}
}
if (GNUNET_YES == GNUNET_is_zero (&TALER_ARL_auditor_pub))
{
/* private key not available, try configuration for public key */
char *auditor_public_key_str;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (TALER_ARL_cfg,
"auditor",
"PUBLIC_KEY",
&auditor_public_key_str))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"PUBLIC_KEY");
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_public_key_from_string (
auditor_public_key_str,
strlen (auditor_master_public_key_str),
&TALER_ARL_auditor_pub.eddsa_pub))
{
GNUNET_log_config_malformed (GNUNET_ERROR_TYPE_ERROR,
"auditor",
"PUBLIC_KEY",
"invalid key");
GNUNET_free (auditor_public_key_str);
return GNUNET_SYSERR;
}
GNUNET_free (auditor_public_key_str);
}
if (GNUNET_OK !=
TALER_config_get_currency (TALER_ARL_cfg,
&TALER_ARL_currency))

View File

@ -1 +1 @@
1608145250
1608206482

View File

@ -1 +1 @@
FKRQX2MX42PV4QR92HFNTPQD5BPCAX1RPQDKY3Y0Z691EMFNBKYG
XJQWG3K7M83H35H9QX0NNRJGQT9GBV8Q2EAN2CRG26VNPKD068K0

File diff suppressed because it is too large Load Diff

View File

@ -1305,12 +1305,12 @@ echo "===========22: denomination key expired ================="
H_DENOM=`echo 'SELECT denom_pub_hash FROM reserves_out LIMIT 1;' | psql $DB -Aqt`
OLD_START=`echo "SELECT valid_from FROM auditor_denominations WHERE denom_pub_hash='${H_DENOM}';" | psql $DB -Aqt`
OLD_WEXP=`echo "SELECT expire_withdraw FROM auditor_denominations WHERE denom_pub_hash='${H_DENOM}';" | psql $DB -Aqt`
OLD_START=`echo "SELECT valid_from FROM denominations WHERE denom_pub_hash='${H_DENOM}';" | psql $DB -Aqt`
OLD_WEXP=`echo "SELECT expire_withdraw FROM denominations WHERE denom_pub_hash='${H_DENOM}';" | psql $DB -Aqt`
# Basically expires 'immediately', so that the withdraw must have been 'invalid'
NEW_WEXP=`expr $OLD_START + 1 || true`
echo "UPDATE auditor_denominations SET expire_withdraw=${NEW_WEXP} WHERE denom_pub_hash='${H_DENOM}';" | psql -Aqt $DB
echo "UPDATE denominations SET expire_withdraw=${NEW_WEXP} WHERE denom_pub_hash='${H_DENOM}';" | psql -Aqt $DB
run_audit
@ -1321,7 +1321,7 @@ jq -e .denomination_key_validity_withdraw_inconsistencies[0] < test-audit-reserv
echo PASS
# Undo modification
echo "UPDATE auditor_denominations SET expire_withdraw=${OLD_WEXP} WHERE denom_pub_hash='${H_DENOM}';" | psql -Aqt $DB
echo "UPDATE denominations SET expire_withdraw=${OLD_WEXP} WHERE denom_pub_hash='${H_DENOM}';" | psql -Aqt $DB
}
@ -1650,7 +1650,7 @@ fi
function test_29() {
echo "===========29: withdraw fee inconsistency ================="
echo "UPDATE auditor_denominations SET fee_withdraw_frac=5000000 WHERE coin_val=1;" | psql -Aqt $DB
echo "UPDATE denominations SET fee_withdraw_frac=5000000 WHERE coin_val=1;" | psql -Aqt $DB
run_audit
@ -1668,7 +1668,7 @@ then
fi
echo "OK"
# Undo
echo "UPDATE auditor_denominations SET fee_withdraw_frac=2000000 WHERE coin_val=1;" | psql -Aqt $DB
echo "UPDATE denominations SET fee_withdraw_frac=2000000 WHERE coin_val=1;" | psql -Aqt $DB
}
@ -1678,7 +1678,7 @@ echo "UPDATE auditor_denominations SET fee_withdraw_frac=2000000 WHERE coin_val=
function test_30() {
echo "===========30: melt fee inconsistency ================="
echo "UPDATE auditor_denominations SET fee_refresh_frac=5000000 WHERE coin_val=10;" | psql -Aqt $DB
echo "UPDATE denominations SET fee_refresh_frac=5000000 WHERE coin_val=10;" | psql -Aqt $DB
run_audit
echo -n "Testing inconsistency detection... "
@ -1697,7 +1697,7 @@ fi
jq -e .emergencies[0] < test-audit-coins.json > /dev/null && exit_fail "Unexpected emergency detected in ordinary run"
echo "OK"
# Undo
echo "UPDATE auditor_denominations SET fee_refresh_frac=3000000 WHERE coin_val=1;" | psql -Aqt $DB
echo "UPDATE denominations SET fee_refresh_frac=3000000 WHERE coin_val=1;" | psql -Aqt $DB
}
@ -1715,7 +1715,7 @@ then
echo "===========31: deposit fee inconsistency ================="
echo "UPDATE auditor_denominations SET fee_deposit_frac=5000000 WHERE coin_val=8;" | psql -Aqt $DB
echo "UPDATE denominations SET fee_deposit_frac=5000000 WHERE coin_val=8;" | psql -Aqt $DB
run_audit aggregator
echo -n "Testing inconsistency detection... "
@ -1733,7 +1733,7 @@ then
echo "OK"
# Undo
echo "UPDATE auditor_denominations SET fee_deposit_frac=2000000 WHERE coin_val=8;" | psql -Aqt $DB
echo "UPDATE denominations SET fee_deposit_frac=2000000 WHERE coin_val=8;" | psql -Aqt $DB
else
echo "Test skipped (database too new)"
@ -1821,7 +1821,6 @@ check_with_database()
done
echo "Cleanup (disabled, leaving database $DB behind)"
# dropdb $DB
rm -r $WIRE_FEE_DIR
}

View File

@ -495,7 +495,6 @@ check_with_database()
done
# echo "Cleanup (disabled, leaving database $DB behind)"
dropdb $DB
rm -r $WIRE_FEE_DIR
rm -f test-audit.log test-wire-audit.log
}

View File

@ -41,28 +41,6 @@ COMMENT ON TABLE auditor_exchange_signkeys
IS 'list of the online signing keys of exchanges we are auditing';
CREATE TABLE IF NOT EXISTS auditor_denominations
(denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
,master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,valid_from INT8 NOT NULL
,expire_withdraw INT8 NOT NULL
,expire_deposit INT8 NOT NULL
,expire_legal INT8 NOT NULL
,coin_val INT8 NOT NULL
,coin_frac INT4 NOT NULL
,fee_withdraw_val INT8 NOT NULL
,fee_withdraw_frac INT4 NOT NULL
,fee_deposit_val INT8 NOT NULL
,fee_deposit_frac INT4 NOT NULL
,fee_refresh_val INT8 NOT NULL
,fee_refresh_frac INT4 NOT NULL
,fee_refund_val INT8 NOT NULL
,fee_refund_frac INT4 NOT NULL
);
COMMENT ON TABLE auditor_denominations
IS 'denomination keys the auditor is aware of';
CREATE TABLE IF NOT EXISTS auditor_progress_reserve
(master_pub BYTEA CONSTRAINT master_pub_ref REFERENCES auditor_exchanges(master_pub) ON DELETE CASCADE
,last_reserve_in_serial_id INT8 NOT NULL DEFAULT 0
@ -173,7 +151,7 @@ COMMENT ON TABLE auditor_wire_fee_balance
CREATE TABLE IF NOT EXISTS auditor_denomination_pending
(denom_pub_hash BYTEA PRIMARY KEY REFERENCES auditor_denominations (denom_pub_hash) ON DELETE CASCADE
(denom_pub_hash BYTEA PRIMARY KEY CHECK (LENGTH(denom_pub_hash)=64)
,denom_balance_val INT8 NOT NULL
,denom_balance_frac INT4 NOT NULL
,denom_loss_val INT8 NOT NULL

View File

@ -221,48 +221,6 @@ postgres_get_session (void *cls)
",master_sig"
") VALUES ($1,$2,$3,$4,$5,$6);",
6),
/* Used in #postgres_insert_denomination_info() */
GNUNET_PQ_make_prepare ("auditor_denominations_insert",
"INSERT INTO auditor_denominations "
"(denom_pub_hash"
",master_pub"
",valid_from"
",expire_withdraw"
",expire_deposit"
",expire_legal"
",coin_val"
",coin_frac"
",fee_withdraw_val"
",fee_withdraw_frac"
",fee_deposit_val"
",fee_deposit_frac"
",fee_refresh_val"
",fee_refresh_frac"
",fee_refund_val"
",fee_refund_frac"
") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16);",
16),
/* Used in #postgres_insert_denomination_info() */
GNUNET_PQ_make_prepare ("auditor_denominations_select",
"SELECT"
" denom_pub_hash"
",valid_from"
",expire_withdraw"
",expire_deposit"
",expire_legal"
",coin_val"
",coin_frac"
",fee_withdraw_val"
",fee_withdraw_frac"
",fee_deposit_val"
",fee_deposit_frac"
",fee_refresh_val"
",fee_refresh_frac"
",fee_refund_val"
",fee_refund_frac"
" FROM auditor_denominations"
" WHERE master_pub=$1;",
1),
/* Used in #postgres_insert_deposit_confirmation() */
GNUNET_PQ_make_prepare ("auditor_deposit_confirmation_insert",
"INSERT INTO deposit_confirmations "
@ -1291,192 +1249,6 @@ postgres_get_deposit_confirmations (
}
/**
* Insert information about a denomination key and in particular
* the properties (value, fees, expiration times) the coins signed
* with this key have.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to use
* @param issue issuing information with value, fees and other info about the denomination
* @return operation status result
*/
static enum GNUNET_DB_QueryStatus
postgres_insert_denomination_info (
void *cls,
struct TALER_AUDITORDB_Session *session,
const struct TALER_DenominationKeyValidityPS *issue)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (&issue->denom_hash),
GNUNET_PQ_query_param_auto_from_type (&issue->master),
TALER_PQ_query_param_absolute_time_nbo (&issue->start),
TALER_PQ_query_param_absolute_time_nbo (&issue->expire_withdraw),
TALER_PQ_query_param_absolute_time_nbo (&issue->expire_deposit),
TALER_PQ_query_param_absolute_time_nbo (&issue->expire_legal),
TALER_PQ_query_param_amount_nbo (&issue->value),
TALER_PQ_query_param_amount_nbo (&issue->fee_withdraw),
TALER_PQ_query_param_amount_nbo (&issue->fee_deposit),
TALER_PQ_query_param_amount_nbo (&issue->fee_refresh),
TALER_PQ_query_param_amount_nbo (&issue->fee_refund),
GNUNET_PQ_query_param_end
};
(void) cls;
/* check fees match coin currency */
GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->value,
&issue->fee_withdraw));
GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->value,
&issue->fee_deposit));
GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->value,
&issue->fee_refresh));
GNUNET_assert (GNUNET_YES ==
TALER_amount_cmp_currency_nbo (&issue->value,
&issue->fee_refund));
return GNUNET_PQ_eval_prepared_non_select (session->conn,
"auditor_denominations_insert",
params);
}
/**
* Closure for #denomination_info_cb().
*/
struct DenominationInfoContext
{
/**
* Master public key that is being used.
*/
const struct TALER_MasterPublicKeyP *master_pub;
/**
* Function to call for each denomination.
*/
TALER_AUDITORDB_DenominationInfoDataCallback cb;
/**
* Closure for @e cb
*/
void *cb_cls;
/**
* Plugin context.
*/
struct PostgresClosure *pg;
/**
* Query status to return.
*/
enum GNUNET_DB_QueryStatus qs;
};
/**
* Helper function for #postgres_select_denomination_info().
* To be called with the results of a SELECT statement
* that has returned @a num_results results.
*
* @param cls closure of type `struct DenominationInfoContext *`
* @param result the postgres result
* @param num_results the number of results in @a result
*/
static void
denomination_info_cb (void *cls,
PGresult *result,
unsigned int num_results)
{
struct DenominationInfoContext *dic = cls;
struct PostgresClosure *pg = dic->pg;
for (unsigned int i = 0; i < num_results; i++)
{
struct TALER_DenominationKeyValidityPS issue = {
.master = *dic->master_pub
};
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("denom_pub_hash",
&issue.denom_hash),
TALER_PQ_result_spec_absolute_time_nbo ("valid_from", &issue.start),
TALER_PQ_result_spec_absolute_time_nbo ("expire_withdraw",
&issue.expire_withdraw),
TALER_PQ_result_spec_absolute_time_nbo ("expire_deposit",
&issue.expire_deposit),
TALER_PQ_result_spec_absolute_time_nbo ("expire_legal",
&issue.expire_legal),
TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("coin", &issue.value),
TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_withdraw", &issue.fee_withdraw),
TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_deposit", &issue.fee_deposit),
TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refresh", &issue.fee_refresh),
TALER_PQ_RESULT_SPEC_AMOUNT_NBO ("fee_refund", &issue.fee_refund),
GNUNET_PQ_result_spec_end
};
if (GNUNET_OK !=
GNUNET_PQ_extract_result (result,
rs,
i))
{
GNUNET_break (0);
dic->qs = GNUNET_DB_STATUS_HARD_ERROR;
return;
}
dic->qs = i + 1;
if (GNUNET_OK !=
dic->cb (dic->cb_cls,
&issue))
return;
}
}
/**
* Get information about denomination keys of a particular exchange.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to use
* @param master_pub master public key of the exchange
* @param cb function to call with the results
* @param cb_cls closure for @a cb
* @return transaction status code
*/
static enum GNUNET_DB_QueryStatus
postgres_select_denomination_info (
void *cls,
struct TALER_AUDITORDB_Session *session,
const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_DenominationInfoDataCallback cb,
void *cb_cls)
{
struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (master_pub),
GNUNET_PQ_query_param_end
};
struct DenominationInfoContext dic = {
.master_pub = master_pub,
.cb = cb,
.cb_cls = cb_cls,
.pg = pg
};
enum GNUNET_DB_QueryStatus qs;
(void) cls;
qs = GNUNET_PQ_eval_prepared_multi_select (session->conn,
"auditor_denominations_select",
params,
&denomination_info_cb,
&dic);
if (qs > 0)
return dic.qs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR != qs);
return qs;
}
/**
* Insert information about the auditor's progress with an exchange's
* data.
@ -3221,9 +2993,6 @@ libtaler_plugin_auditordb_postgres_init (void *cls)
plugin->insert_deposit_confirmation = &postgres_insert_deposit_confirmation;
plugin->get_deposit_confirmations = &postgres_get_deposit_confirmations;
plugin->select_denomination_info = &postgres_select_denomination_info;
plugin->insert_denomination_info = &postgres_insert_denomination_info;
plugin->get_auditor_progress_reserve = &postgres_get_auditor_progress_reserve;
plugin->update_auditor_progress_reserve =
&postgres_update_auditor_progress_reserve;

View File

@ -64,25 +64,6 @@ static int result = -1;
static struct TALER_AUDITORDB_Plugin *plugin;
static int
select_denomination_info_result (void *cls,
const struct
TALER_DenominationKeyValidityPS *issue2)
{
const struct TALER_DenominationKeyValidityPS *issue1 = cls;
if (0 != GNUNET_memcmp (issue1,
issue2))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"select_denomination_info_result: issue does not match\n");
GNUNET_break (0);
return GNUNET_SYSERR;
}
return GNUNET_OK;
}
/**
* Main function that will be run by the scheduler.
*
@ -188,48 +169,6 @@ run (void *cls)
"https://exchange/"));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: insert_denomination_info\n");
struct TALER_DenominationKeyValidityPS issue = { 0 };
issue.master = master_pub;
issue.denom_hash = denom_pub_hash;
issue.start = GNUNET_TIME_absolute_hton (now);
issue.expire_withdraw = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add (now,
GNUNET_TIME_UNIT_HOURS));
issue.expire_deposit = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add
(now,
GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_HOURS, 2)));
issue.expire_legal = GNUNET_TIME_absolute_hton
(GNUNET_TIME_absolute_add
(now,
GNUNET_TIME_relative_multiply (
GNUNET_TIME_UNIT_HOURS, 3)));
TALER_amount_hton (&issue.value, &value);
TALER_amount_hton (&issue.fee_withdraw, &fee_withdraw);
TALER_amount_hton (&issue.fee_deposit, &fee_deposit);
TALER_amount_hton (&issue.fee_refresh, &fee_refresh);
TALER_amount_hton (&issue.fee_refund, &fee_refund);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->insert_denomination_info (plugin->cls,
session,
&issue));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: select_denomination_info\n");
FAILIF (0 >=
plugin->select_denomination_info (plugin->cls,
session,
&master_pub,
&select_denomination_info_result,
&issue));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Test: insert_auditor_progress\n");

View File

@ -376,6 +376,7 @@ denomination_add_cb (
hr->http_status,
TALER_ErrorCode_get_hint (hr->ec),
hr->hint);
global_ret = 42;
}
GNUNET_CONTAINER_DLL_remove (dar_head,
dar_tail,

View File

@ -8683,8 +8683,8 @@ postgres_insert_auditor_denom_sig (
const struct TALER_AuditorSignatureP *auditor_sig)
{
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
GNUNET_PQ_query_param_auto_from_type (auditor_pub),
GNUNET_PQ_query_param_auto_from_type (h_denom_pub),
GNUNET_PQ_query_param_auto_from_type (auditor_sig),
GNUNET_PQ_query_param_end
};

View File

@ -44,23 +44,6 @@ typedef void
const char *exchange_url);
/**
* Function called with the results of select_denomination_info()
*
* @param cls closure
* @param issue issuing information with value, fees and other info about the denomination.
*
* @return sets the return value of select_denomination_info(),
* #GNUNET_OK to continue,
* #GNUNET_NO to stop processing further rows
* #GNUNET_SYSERR or other values on error.
*/
typedef int
(*TALER_AUDITORDB_DenominationInfoDataCallback)(
void *cls,
const struct TALER_DenominationKeyValidityPS *issue);
/**
* Function called with the results of select_historic_denom_revenue()
*
@ -583,41 +566,6 @@ struct TALER_AUDITORDB_Plugin
void *cb_cls);
/**
* Insert information about a denomination key and in particular
* the properties (value, fees, expiration times) the coins signed
* with this key have.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to use
* @param issue issuing information with value, fees and other info about the denomination
* @return status of database operation
*/
enum GNUNET_DB_QueryStatus
(*insert_denomination_info)(
void *cls,
struct TALER_AUDITORDB_Session *session,
const struct TALER_DenominationKeyValidityPS *issue);
/**
* Get information about denomination keys of a particular exchange.
*
* @param cls the @e cls of this struct with the plugin-specific state
* @param session connection to use
* @param master_pub master public key of the exchange
* @param cb function to call with the results
* @param cb_cls closure for @a cb
* @return transaction status code
*/
enum GNUNET_DB_QueryStatus
(*select_denomination_info)(void *cls,
struct TALER_AUDITORDB_Session *session,
const struct TALER_MasterPublicKeyP *master_pub,
TALER_AUDITORDB_DenominationInfoDataCallback cb,
void *cb_cls);
/**
* Insert information about the auditor's progress with an exchange's
* data.