exchange

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

commit 1e15b2c5ad009b1b8f32dca03f346c8583887256
parent a033256e619797e5a94c9c807b8cf406e907f74b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 31 May 2026 21:38:31 +0200

remove more deprecated policy/extension logic

Diffstat:
Msrc/auditor/taler-auditor-sync.c | 3---
Msrc/exchangedb/insert_records_by_table.c | 152+------------------------------------------------------------------------------
Msrc/exchangedb/lookup_records_by_table.c | 200-------------------------------------------------------------------------------
Msrc/exchangedb/lookup_serial_by_table.c | 24------------------------
Msrc/exchangedb/test_exchangedb.c | 62--------------------------------------------------------------
Msrc/include/exchange-database/lookup_records_by_table.h | 36------------------------------------
Msrc/include/taler/taler_crypto_lib.h | 77++++++++++++++++-------------------------------------------------------------
Msrc/include/taler/taler_json_lib.h | 13-------------
Msrc/include/taler/taler_pq_lib.h | 3+++
Msrc/include/taler/taler_util.h | 12------------
Msrc/json/json.c | 10----------
Msrc/json/json_pack.c | 2+-
Msrc/pq/pq_result_helper.c | 15++++++++++++---
Msrc/pq/test_pq.c | 2++
Msrc/testing/test_exchange_api_age_restriction.c | 6++----
Msrc/util/age_restriction.c | 25-------------------------
Msrc/util/offline_signatures.c | 60------------------------------------------------------------
17 files changed, 37 insertions(+), 665 deletions(-)

diff --git a/src/auditor/taler-auditor-sync.c b/src/auditor/taler-auditor-sync.c @@ -315,9 +315,6 @@ static struct Table tables[] = { { .rt = TALER_EXCHANGEDB_RT_GLOBAL_FEE}, { .rt = TALER_EXCHANGEDB_RT_RECOUP}, { .rt = TALER_EXCHANGEDB_RT_RECOUP_REFRESH }, - { .rt = TALER_EXCHANGEDB_RT_EXTENSIONS}, - { .rt = TALER_EXCHANGEDB_RT_POLICY_DETAILS }, - { .rt = TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS }, { .rt = TALER_EXCHANGEDB_RT_PURSE_REQUESTS}, { .rt = TALER_EXCHANGEDB_RT_PURSE_DECISION}, { .rt = TALER_EXCHANGEDB_RT_PURSE_MERGES}, diff --git a/src/exchangedb/insert_records_by_table.c b/src/exchangedb/insert_records_by_table.c @@ -930,11 +930,6 @@ irbt_cb_table_batch_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg, &td->details.batch_deposits.wire_salt), GNUNET_PQ_query_param_auto_from_type ( &td->details.batch_deposits.wire_target_h_payto), - td->details.batch_deposits.no_policy_details - ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_uint64 ( - &td->details.batch_deposits.policy_details_serial_id), - GNUNET_PQ_query_param_bool (td->details.batch_deposits.policy_blocked), TALER_PQ_query_param_amount ( pg->conn, &td->details.batch_deposits.total_amount), @@ -961,15 +956,13 @@ irbt_cb_table_batch_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg, ",wallet_data_hash" ",wire_salt" ",wire_target_h_payto" - ",policy_details_serial_id" - ",policy_blocked" ",total_amount" ",total_without_fee" ",merchant_sig" ",done" ") VALUES " "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10," - " $11, $12, $13, $14, $15, $16, $17);"); + " $11, $12, $13, $14, $15);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_into_table_batch_deposits", params); @@ -1324,140 +1317,6 @@ irbt_cb_table_recoup_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg, /** - * Function called with extensions records to insert into table. - * - * @param pg plugin context - * @param td record to insert - */ -static enum GNUNET_DB_QueryStatus -irbt_cb_table_extensions (struct TALER_EXCHANGEDB_PostgresContext *pg, - const struct TALER_EXCHANGEDB_TableData *td) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&td->serial), - GNUNET_PQ_query_param_string (td->details.extensions.name), - NULL == td->details.extensions.manifest ? - GNUNET_PQ_query_param_null () : - GNUNET_PQ_query_param_string (td->details.extensions.manifest), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "insert_into_table_extensions", - "INSERT INTO extensions" - "(extension_id" - ",name" - ",manifest" - ") VALUES " - "($1, $2, $3);"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "insert_into_table_extensions", - params); -} - - -/** - * Function called with policy_details records to insert into table. - * - * @param pg plugin context - * @param td record to insert - */ -static enum GNUNET_DB_QueryStatus -irbt_cb_table_policy_details (struct TALER_EXCHANGEDB_PostgresContext *pg, - const struct TALER_EXCHANGEDB_TableData *td) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&td->serial), - GNUNET_PQ_query_param_auto_from_type ( - &td->details.policy_details.hash_code), - (td->details.policy_details.no_policy_json) - ? GNUNET_PQ_query_param_null () - : TALER_PQ_query_param_json (td->details.policy_details.policy_json), - TALER_PQ_query_param_amount ( - pg->conn, - &td->details.policy_details.commitment), - TALER_PQ_query_param_amount ( - pg->conn, - &td->details.policy_details.accumulated_total), - TALER_PQ_query_param_amount ( - pg->conn, - &td->details.policy_details.fee), - TALER_PQ_query_param_amount (pg->conn, - &td->details.policy_details.transferable), - GNUNET_PQ_query_param_timestamp (&td->details.policy_details.deadline), - GNUNET_PQ_query_param_uint16 ( - &td->details.policy_details.fulfillment_state), - (td->details.policy_details.no_fulfillment_id) - ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_uint64 ( - &td->details.policy_details.fulfillment_id), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "insert_into_table_policy_details", - "INSERT INTO policy_details" - "(policy_details_serial_id" - ",policy_hash_code" - ",policy_json" - ",deadline" - ",commitment" - ",accumulated_total" - ",fee" - ",transferable" - ",fulfillment_state" - ",fulfillment_id" - ") VALUES " - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "insert_into_table_policy_details", - params); -} - - -/** - * Function called with policy_fulfillment records to insert into table. - * - * @param pg plugin context - * @param td record to insert - */ -static enum GNUNET_DB_QueryStatus -irbt_cb_table_policy_fulfillments (struct TALER_EXCHANGEDB_PostgresContext *pg, - const struct TALER_EXCHANGEDB_TableData *td) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_uint64 (&td->serial), - GNUNET_PQ_query_param_timestamp ( - &td->details.policy_fulfillments.fulfillment_timestamp), - (NULL == td->details.policy_fulfillments.fulfillment_proof) - ? GNUNET_PQ_query_param_null () - : GNUNET_PQ_query_param_string ( - td->details.policy_fulfillments.fulfillment_proof), - GNUNET_PQ_query_param_auto_from_type ( - &td->details.policy_fulfillments.h_fulfillment_proof), - GNUNET_PQ_query_param_fixed_size ( - td->details.policy_fulfillments.policy_hash_codes, - td->details.policy_fulfillments.policy_hash_codes_count), - GNUNET_PQ_query_param_end - }; - - PREPARE (pg, - "insert_into_table_policy_fulfillments", - "INSERT INTO policy_fulfillments " - "(fulfillment_id" - ",fulfillment_timestamp" - ",fulfillment_proof" - ",h_fulfillment_proof" - ",policy_hash_codes" - ") VALUES " - "($1, $2, $3::TEXT::JSONB, $4, $5);"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, - "insert_into_table_policy_fulfillments", - params); -} - - -/** * Function called with purse_requests records to insert into table. * * @param pg plugin context @@ -2372,15 +2231,6 @@ TALER_EXCHANGEDB_insert_records_by_table (struct case TALER_EXCHANGEDB_RT_RECOUP_REFRESH: rh = &irbt_cb_table_recoup_refresh; break; - case TALER_EXCHANGEDB_RT_EXTENSIONS: - rh = &irbt_cb_table_extensions; - break; - case TALER_EXCHANGEDB_RT_POLICY_DETAILS: - rh = &irbt_cb_table_policy_details; - break; - case TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS: - rh = &irbt_cb_table_policy_fulfillments; - break; case TALER_EXCHANGEDB_RT_PURSE_REQUESTS: rh = &irbt_cb_table_purse_requests; break; diff --git a/src/exchangedb/lookup_records_by_table.c b/src/exchangedb/lookup_records_by_table.c @@ -1049,14 +1049,6 @@ lrbt_cb_table_batch_deposits (void *cls, GNUNET_PQ_result_spec_auto_from_type ( "wire_target_h_payto", &td.details.batch_deposits.wire_target_h_payto), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_uint64 ( - "policy_details_serial_id", - &td.details.batch_deposits.policy_details_serial_id), - &td.details.batch_deposits.no_policy_details), - GNUNET_PQ_result_spec_bool ( - "policy_blocked", - &td.details.batch_deposits.policy_blocked), TALER_PQ_RESULT_SPEC_AMOUNT ( "total_amount", &td.details.batch_deposits.total_amount), @@ -1072,7 +1064,6 @@ lrbt_cb_table_batch_deposits (void *cls, GNUNET_PQ_result_spec_end }; - td.details.batch_deposits.policy_details_serial_id = 0; if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, @@ -1551,180 +1542,6 @@ lrbt_cb_table_recoup_refresh (void *cls, /** - * Function called with extensions table entries. - * - * @param cls closure - * @param result the postgres result - * @param num_results the number of results in @a result - */ -static void -lrbt_cb_table_extensions (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct LookupRecordsByTableContext *ctx = cls; - struct TALER_EXCHANGEDB_TableData td = { - .table = TALER_EXCHANGEDB_RT_EXTENSIONS - }; - bool no_manifest = false; - - for (unsigned int i = 0; i<num_results; i++) - { - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("extension_id", - &td.serial), - GNUNET_PQ_result_spec_string ("name", - &td.details.extensions.name), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("manifest", - &td.details.extensions.manifest), - &no_manifest), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - ctx->error = true; - return; - } - ctx->cb (ctx->cb_cls, - &td); - GNUNET_PQ_cleanup_result (rs); - } -} - - -/** - * Function called with policy_details table entries. - * - * @param cls closure - * @param result the postgres result - * @param num_results the number of results in @a result - */ -static void -lrbt_cb_table_policy_details (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct LookupRecordsByTableContext *ctx = cls; - struct TALER_EXCHANGEDB_PostgresContext *pg = ctx->pg; - struct TALER_EXCHANGEDB_TableData td = { - .table = TALER_EXCHANGEDB_RT_POLICY_DETAILS - }; - - for (unsigned int i = 0; i<num_results; i++) - { - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("policy_details_serial_id", - &td.serial), - GNUNET_PQ_result_spec_auto_from_type ("hash_code", - &td.details.policy_details. - hash_code), - GNUNET_PQ_result_spec_allow_null ( - TALER_PQ_result_spec_json ("policy_json", - &td.details.policy_details. - policy_json), - &td.details.policy_details.no_policy_json), - GNUNET_PQ_result_spec_timestamp ("deadline", - &td.details.policy_details. - deadline), - TALER_PQ_RESULT_SPEC_AMOUNT ("commitment", - &td.details.policy_details. - commitment), - TALER_PQ_RESULT_SPEC_AMOUNT ("accumulated_total", - &td.details.policy_details. - accumulated_total), - TALER_PQ_RESULT_SPEC_AMOUNT ("fee", - &td.details.policy_details. - fee), - TALER_PQ_RESULT_SPEC_AMOUNT ("transferable", - &td.details.policy_details. - transferable), - GNUNET_PQ_result_spec_uint16 ("fulfillment_state", - &td.details.policy_details. - fulfillment_state), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_uint64 ("fulfillment_id", - &td.details.policy_details. - fulfillment_id), - &td.details.policy_details.no_fulfillment_id), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - ctx->error = true; - return; - } - ctx->cb (ctx->cb_cls, - &td); - GNUNET_PQ_cleanup_result (rs); - } -} - - -/** - * Function called with policy_fulfillments table entries. - * - * @param cls closure - * @param result the postgres result - * @param num_results the number of results in @a result - */ -static void -lrbt_cb_table_policy_fulfillments (void *cls, - PGresult *result, - unsigned int num_results) -{ - struct LookupRecordsByTableContext *ctx = cls; - struct TALER_EXCHANGEDB_TableData td = { - .table = TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS - }; - - for (unsigned int i = 0; i<num_results; i++) - { - bool no_proof = false; - bool no_timestamp = false; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_uint64 ("fulfillment_id", - &td.serial), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_timestamp ("fulfillment_timestamp", - &td.details.policy_fulfillments. - fulfillment_timestamp), - &no_timestamp), - GNUNET_PQ_result_spec_allow_null ( - GNUNET_PQ_result_spec_string ("fulfillment_proof", - &td.details.policy_fulfillments. - fulfillment_proof), - &no_proof), - GNUNET_PQ_result_spec_end - }; - - if (GNUNET_OK != - GNUNET_PQ_extract_result (result, - rs, - i)) - { - GNUNET_break (0); - ctx->error = true; - return; - } - ctx->cb (ctx->cb_cls, - &td); - GNUNET_PQ_cleanup_result (rs); - } -} - - -/** * Function called with purse_requests table entries. * * @param cls closure @@ -3320,8 +3137,6 @@ TALER_EXCHANGEDB_lookup_records_by_table ( ",wallet_data_hash" ",wire_salt" ",wire_target_h_payto" - ",policy_details_serial_id" - ",policy_blocked" ",total_amount" ",total_without_fee" ",merchant_sig" @@ -3447,21 +3262,6 @@ TALER_EXCHANGEDB_lookup_records_by_table ( " ORDER BY recoup_refresh_uuid ASC;"); rh = &lrbt_cb_table_recoup_refresh; break; - case TALER_EXCHANGEDB_RT_EXTENSIONS: - // FIXME[oec]: this seems broken! -- where is the SQL!? - statement = "select_above_serial_by_table_extensions"; - rh = &lrbt_cb_table_extensions; - break; - case TALER_EXCHANGEDB_RT_POLICY_DETAILS: - // FIXME[oec]: this seems broken! -- where is the SQL!? - statement = "select_above_serial_by_table_policy_details"; - rh = &lrbt_cb_table_policy_details; - break; - case TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS: - // FIXME[oec]: this seems broken! -- where is the SQL!? - statement = "select_above_serial_by_table_policy_fulfillments"; - rh = &lrbt_cb_table_policy_fulfillments; - break; case TALER_EXCHANGEDB_RT_PURSE_REQUESTS: XPREPARE ("select_above_serial_by_table_purse_requests", "SELECT" diff --git a/src/exchangedb/lookup_serial_by_table.c b/src/exchangedb/lookup_serial_by_table.c @@ -251,30 +251,6 @@ TALER_EXCHANGEDB_lookup_serial_by_table (struct " ORDER BY recoup_refresh_uuid DESC" " LIMIT 1;"); break; - case TALER_EXCHANGEDB_RT_EXTENSIONS: - XPREPARE ("select_serial_by_table_extensions", - "SELECT" - " extension_id AS serial" - " FROM extensions" - " ORDER BY extension_id DESC" - " LIMIT 1;"); - break; - case TALER_EXCHANGEDB_RT_POLICY_DETAILS: - XPREPARE ("select_serial_by_table_policy_details", - "SELECT" - " policy_details_serial_id AS serial" - " FROM policy_details" - " ORDER BY policy_details_serial_id DESC" - " LIMIT 1;"); - break; - case TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS: - XPREPARE ("select_serial_by_table_policy_fulfillments", - "SELECT" - " fulfillment_id AS serial" - " FROM policy_fulfillments" - " ORDER BY fulfillment_id DESC" - " LIMIT 1;"); - break; case TALER_EXCHANGEDB_RT_PURSE_REQUESTS: XPREPARE ("select_serial_by_table_purse_requests", "SELECT" diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c @@ -170,64 +170,6 @@ mark_prepare_cb (void *cls, /** - * Simple check that config retrieval and setting for extensions work - */ -static enum GNUNET_GenericReturnValue -test_extension_manifest (void) -{ - char *manifest; - - FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->set_extension_manifest (plugin->cls, - "fnord", - "bar")); - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (0 != strcmp ("bar", manifest)); - GNUNET_free (manifest); - - /* let's do this again! */ - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->set_extension_manifest (plugin->cls, - "fnord", - "buzz")); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (0 != strcmp ("buzz", manifest)); - GNUNET_free (manifest); - - /* let's do this again, with NULL */ - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->set_extension_manifest (plugin->cls, - "fnord", - NULL)); - - FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != - plugin->get_extension_manifest (plugin->cls, - "fnord", - &manifest)); - - FAILIF (NULL != manifest); - - return GNUNET_OK; -drop: - return GNUNET_SYSERR; -} - - -/** * Test API relating to persisting the wire plugins preparation data. * * @return #GNUNET_OK on success @@ -1411,10 +1353,6 @@ run (struct TALER_EXCHANGEDB_PostgresContext *pg) &recoup_cb, NULL)); - /* simple extension check */ - FAILIF (GNUNET_OK != - test_extension_manifest ()); - RND_BLK (&reserve_pub); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":1.000000", diff --git a/src/include/exchange-database/lookup_records_by_table.h b/src/include/exchange-database/lookup_records_by_table.h @@ -57,9 +57,6 @@ enum TALER_EXCHANGEDB_ReplicatedTable TALER_EXCHANGEDB_RT_GLOBAL_FEE, TALER_EXCHANGEDB_RT_RECOUP, TALER_EXCHANGEDB_RT_RECOUP_REFRESH, - TALER_EXCHANGEDB_RT_EXTENSIONS, - TALER_EXCHANGEDB_RT_POLICY_DETAILS, - TALER_EXCHANGEDB_RT_POLICY_FULFILLMENTS, TALER_EXCHANGEDB_RT_PURSE_REQUESTS, TALER_EXCHANGEDB_RT_PURSE_DECISION, TALER_EXCHANGEDB_RT_PURSE_MERGES, @@ -337,9 +334,6 @@ struct TALER_EXCHANGEDB_TableData struct GNUNET_HashCode wallet_data_hash; struct TALER_WireSaltP wire_salt; struct TALER_FullPaytoHashP wire_target_h_payto; - bool no_policy_details; - uint64_t policy_details_serial_id; - bool policy_blocked; struct TALER_Amount total_amount; struct TALER_Amount total_without_fee; struct TALER_MerchantSignatureP merchant_sig; @@ -421,36 +415,6 @@ struct TALER_EXCHANGEDB_TableData struct { - char *name; - char *manifest; - } extensions; - - struct - { - struct GNUNET_HashCode hash_code; - json_t *policy_json; - bool no_policy_json; - struct GNUNET_TIME_Timestamp deadline; - struct TALER_Amount commitment; - struct TALER_Amount accumulated_total; - struct TALER_Amount fee; - struct TALER_Amount transferable; - uint16_t fulfillment_state; /* will also be recomputed */ - uint64_t fulfillment_id; - bool no_fulfillment_id; - } policy_details; - - struct - { - struct GNUNET_TIME_Timestamp fulfillment_timestamp; - char *fulfillment_proof; - struct GNUNET_HashCode h_fulfillment_proof; - struct GNUNET_HashCode *policy_hash_codes; - size_t policy_hash_codes_count; - } policy_fulfillments; - - struct - { struct TALER_PurseContractPublicKeyP purse_pub; struct TALER_PurseMergePublicKeyP merge_pub; struct GNUNET_TIME_Timestamp purse_creation; diff --git a/src/include/taler/taler_crypto_lib.h b/src/include/taler/taler_crypto_lib.h @@ -959,18 +959,6 @@ struct TALER_PrivateContractHashP /** - * Hash used to represent the policy extension to a deposit - */ -struct TALER_ExtensionPolicyHashP -{ - /** - * Actual hash value. - */ - struct GNUNET_HashCode hash; -}; - - -/** * Hash used to represent the salted hash of a * merchant's bank account. */ @@ -1086,19 +1074,6 @@ struct TALER_PickupIdentifierP /** - * @brief Salted hash over the JSON object representing the manifests of - * extensions. - */ -struct TALER_ExtensionManifestsHashP -{ - /** - * Actual hash value. - */ - struct GNUNET_HashCode hash; -}; - - -/** * Set of the fees applying to a denomination. */ struct TALER_DenomFeeSetNBOP @@ -1545,8 +1520,8 @@ struct TALER_BlindedDenominationSignature * | | | | | * oooooooo oo1oo1o1 o1o1o1o1 ooooooo1 * - * A value of 0 means that the exchange does not support the extension for - * age-restriction. + * A value of 0 means that the exchange does not support + * age-restrictions. * * For a non-0 age mask, the 0th bit always must be set, otherwise the age * mask is considered invalid. @@ -4413,6 +4388,19 @@ TALER_wallet_reserve_attest_request_verify ( /** + * Hash used to represent an extension to a deposit. + * Not used in the current code, but kept for compatibility. + */ +struct TALER_ExtensionPolicyHashP +{ + /** + * Actual hash value. + */ + struct GNUNET_HashCode hash; +}; + + +/** * Sign a deposit permission. Function for wallets. * * @param amount the amount to be deposited @@ -4421,7 +4409,7 @@ TALER_wallet_reserve_attest_request_verify ( * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) * @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL) * @param h_age_commitment hash over the age commitment, if applicable to the denomination (maybe NULL) - * @param h_policy hash over the policy extension + * @param h_policy hash over the policy extension, use NULL for now * @param h_denom_pub hash of the coin denomination's public key * @param coin_priv coin’s private key * @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future @@ -6876,39 +6864,6 @@ TALER_merchant_contract_verify ( struct TALER_MerchantSignatureP *merchant_sig); -/* **************** /management/extensions offline signing **************** */ - -/** - * Create a signature for the hash of the manifests of extensions - * - * @param h_manifests hash of the JSON object representing the manifests - * @param master_priv private key to sign with - * @param[out] master_sig where to write the signature - */ -void -TALER_exchange_offline_extension_manifests_hash_sign ( - const struct TALER_ExtensionManifestsHashP *h_manifests, - const struct TALER_MasterPrivateKeyP *master_priv, - struct TALER_MasterSignatureP *master_sig); - - -/** - * Verify the signature in @a master_sig of the given hash, taken over the JSON - * blob representing the manifests of extensions - * - * @param h_manifest hash of the JSON blob of manifests of extensions - * @param master_pub master public key of the exchange - * @param master_sig signature of the exchange - * @return #GNUNET_OK if signature is valid - */ -enum GNUNET_GenericReturnValue -TALER_exchange_offline_extension_manifests_hash_verify ( - const struct TALER_ExtensionManifestsHashP *h_manifest, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_MasterSignatureP *master_sig - ); - - /** * @brief Representation of an age commitment: one public key per age group. * diff --git a/src/include/taler/taler_json_lib.h b/src/include/taler/taler_json_lib.h @@ -1141,19 +1141,6 @@ TALER_deposit_policy_hash ( /** - * Hash the @a manifests of extensions, given as JSON - * - * @param manifests Manifests of the extensions - * @param[out] eh where to write the hash - * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure - */ -enum GNUNET_GenericReturnValue -TALER_JSON_extensions_manifests_hash ( - const json_t *manifests, - struct TALER_ExtensionManifestsHashP *eh); - - -/** * Canonicalize a JSON input to a string according to RFC 8785. */ char * diff --git a/src/include/taler/taler_pq_lib.h b/src/include/taler/taler_pq_lib.h @@ -457,6 +457,8 @@ TALER_PQ_result_spec_array_amount ( * Array of amounts including currency * * @param db context of the database connection + * @param schema DB schema in which the "taler_amount_currency" type is + * expected to be defined * @param name name of the field in the table * @param[out] num number of elements in @e amounts * @param[out] amounts where to store the result @@ -465,6 +467,7 @@ TALER_PQ_result_spec_array_amount ( struct GNUNET_PQ_ResultSpec TALER_PQ_result_spec_array_amount_with_currency ( struct GNUNET_PQ_Context *db, + const char *schema, const char *name, size_t *num, struct TALER_Amount **amounts); diff --git a/src/include/taler/taler_util.h b/src/include/taler/taler_util.h @@ -961,18 +961,6 @@ TALER_get_age_group ( /** - * @brief Parses a JSON object { "age_groups": "a:b:...y:z" }. - * - * @param root is the json object - * @param[out] mask on success, will contain the age mask - * @return #GNUNET_OK on success and #GNUNET_SYSERR on failure. - */ -enum GNUNET_GenericReturnValue -TALER_JSON_parse_age_groups (const json_t *root, - struct TALER_AgeMask *mask); - - -/** * @brief Return the lowest age in the corresponding group for a given age * according the given age mask. * diff --git a/src/json/json.c b/src/json/json.c @@ -884,16 +884,6 @@ TALER_JSON_canonicalize (const json_t *input) } -enum GNUNET_GenericReturnValue -TALER_JSON_extensions_manifests_hash (const json_t *manifests, - struct TALER_ExtensionManifestsHashP *ech) -{ - return dump_and_hash (manifests, - "taler-extensions-manifests", - &ech->hash); -} - - json_t * TALER_JSON_currency_specs_to_json ( const struct TALER_CurrencySpecification *cspec) diff --git a/src/json/json_pack.c b/src/json/json_pack.c @@ -543,7 +543,7 @@ TALER_JSON_pack_array_of_data ( }; json_t *j_array = json_array (); - GNUNET_assert (NULL!=j_array); + GNUNET_assert (NULL != j_array); if (0 == num) { ps.object = j_array; diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c @@ -1656,20 +1656,29 @@ TALER_PQ_result_spec_array_amount ( struct GNUNET_PQ_ResultSpec TALER_PQ_result_spec_array_amount_with_currency ( struct GNUNET_PQ_Context *db, + const char *schema, const char *name, size_t *num, struct TALER_Amount **amounts) { struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); - + char *tn; + + if (NULL != schema) + GNUNET_asprintf (&tn, + "%s.taler_amount_currency", + schema); + else + GNUNET_asprintf (&tn, + "taler_amount_currency"); info->num = num; info->typ = TALER_PQ_array_of_amount_currency; info->db = db; GNUNET_assert (GNUNET_OK == GNUNET_PQ_get_oid_by_name (db, - "merchant.taler_amount_currency", + tn, &info->oid)); - + GNUNET_free (tn); { struct GNUNET_PQ_ResultSpec res = { .conv = extract_array_generic, diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c @@ -206,6 +206,7 @@ run_queries (struct GNUNET_PQ_Context *conn) &npamount, &pamount), TALER_PQ_result_spec_array_amount_with_currency (conn, + NULL, "aamountc", &npamountc, &pamountc), @@ -215,6 +216,7 @@ run_queries (struct GNUNET_PQ_Context *conn) &npamountn, &pamountn), TALER_PQ_result_spec_array_amount_with_currency (conn, + NULL, "aamountnc", &npamountnc, &pamountnc), diff --git a/src/testing/test_exchange_api_age_restriction.c b/src/testing/test_exchange_api_age_restriction.c @@ -97,12 +97,10 @@ run (void *cls, /** * Test withdrawal with age restriction. Success is expected (because the * amount is below the kyc threshold ), so it MUST be - * called _after_ TALER_TESTING_cmd_exec_offline_sign_extensions is called, - * i. e. age restriction is activated in the exchange! + * called age restriction is activated in the exchange! * * FIXME: create a test that tries to withdraw coins with age restriction but - * (expectedly) fails because the exchange doesn't support age restriction - * yet. + * (expectedly) fails because the exchange doesn't support age restrictions. */ struct TALER_TESTING_Command withdraw_age[] = { /** diff --git a/src/util/age_restriction.c b/src/util/age_restriction.c @@ -659,31 +659,6 @@ TALER_age_commitment_deep_copy ( enum GNUNET_GenericReturnValue -TALER_JSON_parse_age_groups (const json_t *root, - struct TALER_AgeMask *mask) -{ - enum GNUNET_GenericReturnValue ret; - const char *str; - struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_string ("age_groups", - &str), - GNUNET_JSON_spec_end () - }; - - ret = GNUNET_JSON_parse (root, - spec, - NULL, - NULL); - if (GNUNET_OK == ret) - TALER_parse_age_group_string (str, mask); - - GNUNET_JSON_parse_free (spec); - - return ret; -} - - -enum GNUNET_GenericReturnValue TALER_parse_age_group_string ( const char *groups, struct TALER_AgeMask *mask) diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c @@ -1168,66 +1168,6 @@ TALER_exchange_offline_global_fee_verify ( GNUNET_NETWORK_STRUCT_BEGIN /** - * @brief Signature made by the exchange offline key over the manifest of - * an extension. - */ -struct TALER_MasterExtensionManifestPS -{ - /** - * Purpose is #TALER_SIGNATURE_MASTER_EXTENSION. Signed - * by a `struct TALER_MasterPublicKeyP` using EdDSA. - */ - struct GNUNET_CRYPTO_SignaturePurpose purpose; - - /** - * Hash of the JSON object that represents the manifests of extensions. - */ - struct TALER_ExtensionManifestsHashP h_manifest GNUNET_PACKED; -}; - -GNUNET_NETWORK_STRUCT_END - - -void -TALER_exchange_offline_extension_manifests_hash_sign ( - const struct TALER_ExtensionManifestsHashP *h_manifest, - const struct TALER_MasterPrivateKeyP *master_priv, - struct TALER_MasterSignatureP *master_sig) -{ - struct TALER_MasterExtensionManifestPS ec = { - .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), - .purpose.size = htonl (sizeof(ec)), - .h_manifest = *h_manifest - }; - GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, - &ec, - &master_sig->eddsa_signature); -} - - -enum GNUNET_GenericReturnValue -TALER_exchange_offline_extension_manifests_hash_verify ( - const struct TALER_ExtensionManifestsHashP *h_manifest, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_MasterSignatureP *master_sig - ) -{ - struct TALER_MasterExtensionManifestPS ec = { - .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), - .purpose.size = htonl (sizeof(ec)), - .h_manifest = *h_manifest - }; - - return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_EXTENSION, - &ec, - &master_sig->eddsa_signature, - &master_pub->eddsa_pub); -} - - -GNUNET_NETWORK_STRUCT_BEGIN - -/** * @brief Information signed by the exchange's master * key affirming the IBAN details for the exchange. */