commit ffe0a1499466134eedadbce02bc09dd65b680f85 parent 8b43033a83a05c62ffcb2ac2d90fff49ee99e33c Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch> Date: Tue, 28 Nov 2023 01:26:02 +0100 solve merge conflicts Diffstat:
147 files changed, 4185 insertions(+), 6845 deletions(-)
diff --git a/doc/Makefile.am b/doc/Makefile.am @@ -26,7 +26,7 @@ man_MANS = \ prebuilt/man/taler-donau-dbinit.1 \ #prebuilt/man/taler-donau-drain.1 \ #prebuilt/man/taler-donau-expire.1 \ - prebuilt/man/taler-donau-httpd.1 \ + prebuilt/man/donau-httpd.1 \ #prebuilt/man/taler-donau-kyc-aml-pep-trigger.1 \ #prebuilt/man/taler-donau-kyc-tester.1 \ prebuilt/man/taler-donau-offline.1 \ diff --git a/src/donau-tools/Makefile.am b/src/donau-tools/Makefile.am @@ -23,7 +23,7 @@ taler_donau_offline_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/lib/libtalerdonau.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/extensions/libtalerextensions.la \ -lgnunetjson \ -lgnunetcurl \ @@ -37,7 +37,7 @@ taler_auditor_offline_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/lib/libtalerdonau.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/extensions/libtalerextensions.la \ -lgnunetjson \ -lgnunetcurl \ @@ -49,7 +49,7 @@ taler_donau_dbinit_SOURCES = \ taler-donau-dbinit.c taler_donau_dbinit_LDADD = \ $(LIBGCRYPT_LIBS) \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/pq/libtalerpq.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -lgnunetutil \ diff --git a/src/donau-tools/taler-donau-dbinit.c b/src/donau-tools/taler-donau-dbinit.c @@ -19,7 +19,7 @@ * @author Florian Dold * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include "taler_donaudb_lib.h" @@ -68,14 +68,14 @@ run (void *cls, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - struct TALER_DONAUDB_Plugin *plugin; + struct DONAUDB_Plugin *plugin; (void) cls; (void) args; (void) cfgfile; if (NULL == - (plugin = TALER_DONAUDB_plugin_load (cfg))) + (plugin = DONAUDB_plugin_load (cfg))) { fprintf (stderr, "Failed to initialize database plugin.\n"); @@ -98,7 +98,7 @@ run (void *cls, { fprintf (stderr, "Failed to initialize database.\n"); - TALER_DONAUDB_plugin_unload (plugin); + DONAUDB_plugin_unload (plugin); plugin = NULL; global_ret = EXIT_NOPERMISSION; return; @@ -110,7 +110,7 @@ run (void *cls, { fprintf (stderr, "Failed to prepare database.\n"); - TALER_DONAUDB_plugin_unload (plugin); + DONAUDB_plugin_unload (plugin); plugin = NULL; global_ret = EXIT_NOPERMISSION; return; @@ -133,7 +133,7 @@ run (void *cls, } } } - TALER_DONAUDB_plugin_unload (plugin); + DONAUDB_plugin_unload (plugin); plugin = NULL; } diff --git a/src/donau-tools/taler-donau-offline.c b/src/donau-tools/taler-donau-offline.c @@ -21,9 +21,9 @@ #include <platform.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_util_lib.h> -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_donau_service.h" -#include "taler_extensions.h" +#include "taler/taler_extensions.h" #include <regex.h> @@ -224,7 +224,7 @@ struct DenomRevocationRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementRevokeDenominationKeyHandle *h; + struct DONAU_ManagementRevokeDenominationKeyHandle *h; /** * Array index of the associated command. @@ -252,7 +252,7 @@ struct SignkeyRevocationRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementRevokeSigningKeyHandle *h; + struct DONAU_ManagementRevokeSigningKeyHandle *h; /** * Array index of the associated command. @@ -280,7 +280,7 @@ struct AuditorAddRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementAuditorEnableHandle *h; + struct DONAU_ManagementAuditorEnableHandle *h; /** * Array index of the associated command. @@ -308,7 +308,7 @@ struct AuditorDelRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementAuditorDisableHandle *h; + struct DONAU_ManagementAuditorDisableHandle *h; /** * Array index of the associated command. @@ -336,7 +336,7 @@ struct WireAddRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementWireEnableHandle *h; + struct DONAU_ManagementWireEnableHandle *h; /** * Array index of the associated command. @@ -364,7 +364,7 @@ struct WireDelRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementWireDisableHandle *h; + struct DONAU_ManagementWireDisableHandle *h; /** * Array index of the associated command. @@ -392,7 +392,7 @@ struct WireFeeRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementSetWireFeeHandle *h; + struct DONAU_ManagementSetWireFeeHandle *h; /** * Array index of the associated command. @@ -420,7 +420,7 @@ struct DrainProfitsRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementDrainProfitsHandle *h; + struct DONAU_ManagementDrainProfitsHandle *h; /** * Array index of the associated command. @@ -448,7 +448,7 @@ struct GlobalFeeRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementSetGlobalFeeHandle *h; + struct DONAU_ManagementSetGlobalFeeHandle *h; /** * Array index of the associated command. @@ -475,7 +475,7 @@ struct UploadKeysRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementPostKeysHandle *h; + struct DONAU_ManagementPostKeysHandle *h; /** * Operation index. @@ -501,7 +501,7 @@ struct UploadExtensionsRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementPostExtensionsHandle *h; + struct DONAU_ManagementPostExtensionsHandle *h; /** * Operation index. @@ -529,7 +529,7 @@ struct AmlStaffRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementUpdateAmlOfficer *h; + struct DONAU_ManagementUpdateAmlOfficer *h; /** * Array index of the associated command. @@ -557,7 +557,7 @@ struct PartnerAddRequest /** * Operation handle. */ - struct TALER_DONAU_ManagementAddPartner *h; + struct DONAU_ManagementAddPartner *h; /** * Array index of the associated command. @@ -574,7 +574,7 @@ static struct GNUNET_SCHEDULER_Task *nxt; /** * Handle for #do_download. */ -static struct TALER_DONAU_ManagementGetKeysHandle *mgkh; +static struct DONAU_ManagementGetKeysHandle *mgkh; /** @@ -726,7 +726,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete AML staff update #%u\n", (unsigned int) asr->idx); - TALER_DONAU_management_update_aml_officer_cancel (asr->h); + DONAU_management_update_aml_officer_cancel (asr->h); GNUNET_CONTAINER_DLL_remove (asr_head, asr_tail, asr); @@ -741,7 +741,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete partner add request #%u\n", (unsigned int) par->idx); - TALER_DONAU_management_add_partner_cancel (par->h); + DONAU_management_add_partner_cancel (par->h); GNUNET_CONTAINER_DLL_remove (par_head, par_tail, par); @@ -756,7 +756,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete denomination revocation #%u\n", (unsigned int) drr->idx); - TALER_DONAU_management_revoke_denomination_key_cancel (drr->h); + DONAU_management_revoke_denomination_key_cancel (drr->h); GNUNET_CONTAINER_DLL_remove (drr_head, drr_tail, drr); @@ -771,7 +771,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete signkey revocation #%u\n", (unsigned int) srr->idx); - TALER_DONAU_management_revoke_signing_key_cancel (srr->h); + DONAU_management_revoke_signing_key_cancel (srr->h); GNUNET_CONTAINER_DLL_remove (srr_head, srr_tail, srr); @@ -787,7 +787,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete auditor add #%u\n", (unsigned int) aar->idx); - TALER_DONAU_management_enable_auditor_cancel (aar->h); + DONAU_management_enable_auditor_cancel (aar->h); GNUNET_CONTAINER_DLL_remove (aar_head, aar_tail, aar); @@ -802,7 +802,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete auditor del #%u\n", (unsigned int) adr->idx); - TALER_DONAU_management_disable_auditor_cancel (adr->h); + DONAU_management_disable_auditor_cancel (adr->h); GNUNET_CONTAINER_DLL_remove (adr_head, adr_tail, adr); @@ -817,7 +817,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete wire add #%u\n", (unsigned int) war->idx); - TALER_DONAU_management_enable_wire_cancel (war->h); + DONAU_management_enable_wire_cancel (war->h); GNUNET_CONTAINER_DLL_remove (war_head, war_tail, war); @@ -832,7 +832,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete wire del #%u\n", (unsigned int) wdr->idx); - TALER_DONAU_management_disable_wire_cancel (wdr->h); + DONAU_management_disable_wire_cancel (wdr->h); GNUNET_CONTAINER_DLL_remove (wdr_head, wdr_tail, wdr); @@ -847,7 +847,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete wire fee #%u\n", (unsigned int) wfr->idx); - TALER_DONAU_management_set_wire_fees_cancel (wfr->h); + DONAU_management_set_wire_fees_cancel (wfr->h); GNUNET_CONTAINER_DLL_remove (wfr_head, wfr_tail, wfr); @@ -862,7 +862,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete global fee #%u\n", (unsigned int) gfr->idx); - TALER_DONAU_management_set_global_fees_cancel (gfr->h); + DONAU_management_set_global_fees_cancel (gfr->h); GNUNET_CONTAINER_DLL_remove (gfr_head, gfr_tail, gfr); @@ -877,7 +877,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete key signature upload #%u\n", (unsigned int) ukr->idx); - TALER_DONAU_post_management_keys_cancel (ukr->h); + DONAU_post_management_keys_cancel (ukr->h); GNUNET_CONTAINER_DLL_remove (ukr_head, ukr_tail, ukr); @@ -892,7 +892,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete extensions signature upload #%u\n", (unsigned int) uer->idx); - TALER_DONAU_management_post_extensions_cancel (uer->h); + DONAU_management_post_extensions_cancel (uer->h); GNUNET_CONTAINER_DLL_remove (uer_head, uer_tail, uer); @@ -908,7 +908,7 @@ do_shutdown (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting incomplete drain profits request #%u\n", (unsigned int) dpr->idx); - TALER_DONAU_management_drain_profits_cancel (dpr->h); + DONAU_management_drain_profits_cancel (dpr->h); GNUNET_CONTAINER_DLL_remove (dpr_head, dpr_tail, dpr); @@ -938,7 +938,7 @@ do_shutdown (void *cls) } if (NULL != mgkh) { - TALER_DONAU_get_management_keys_cancel (mgkh); + DONAU_get_management_keys_cancel (mgkh); mgkh = NULL; } if (NULL != ctx) @@ -1126,10 +1126,10 @@ load_offline_key (int do_create) static void denom_revocation_cb ( void *cls, - const struct TALER_DONAU_ManagementRevokeDenominationResponse *dr) + const struct DONAU_ManagementRevokeDenominationResponse *dr) { struct DenomRevocationRequest *drr = cls; - const struct TALER_DONAU_HttpResponse *hr = &dr->hr; + const struct DONAU_HttpResponse *hr = &dr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1195,12 +1195,12 @@ upload_denom_revocation (const char *donau_url, drr = GNUNET_new (struct DenomRevocationRequest); drr->idx = idx; drr->h = - TALER_DONAU_management_revoke_denomination_key (ctx, - donau_url, - &h_denom_pub, - &master_sig, - &denom_revocation_cb, - drr); + DONAU_management_revoke_denomination_key (ctx, + donau_url, + &h_denom_pub, + &master_sig, + &denom_revocation_cb, + drr); GNUNET_CONTAINER_DLL_insert (drr_head, drr_tail, drr); @@ -1216,10 +1216,10 @@ upload_denom_revocation (const char *donau_url, static void signkey_revocation_cb ( void *cls, - const struct TALER_DONAU_ManagementRevokeSigningKeyResponse *sr) + const struct DONAU_ManagementRevokeSigningKeyResponse *sr) { struct SignkeyRevocationRequest *srr = cls; - const struct TALER_DONAU_HttpResponse *hr = &sr->hr; + const struct DONAU_HttpResponse *hr = &sr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1252,7 +1252,7 @@ upload_signkey_revocation (const char *donau_url, const json_t *value) { struct TALER_MasterSignatureP master_sig; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct SignkeyRevocationRequest *srr; const char *err_name; unsigned int err_line; @@ -1285,12 +1285,12 @@ upload_signkey_revocation (const char *donau_url, srr = GNUNET_new (struct SignkeyRevocationRequest); srr->idx = idx; srr->h = - TALER_DONAU_management_revoke_signing_key (ctx, - donau_url, - &donau_pub, - &master_sig, - &signkey_revocation_cb, - srr); + DONAU_management_revoke_signing_key (ctx, + donau_url, + &donau_pub, + &master_sig, + &signkey_revocation_cb, + srr); GNUNET_CONTAINER_DLL_insert (srr_head, srr_tail, srr); @@ -1306,10 +1306,10 @@ upload_signkey_revocation (const char *donau_url, static void auditor_add_cb ( void *cls, - const struct TALER_DONAU_ManagementAuditorEnableResponse *mer) + const struct DONAU_ManagementAuditorEnableResponse *mer) { struct AuditorAddRequest *aar = cls; - const struct TALER_DONAU_HttpResponse *hr = &mer->hr; + const struct DONAU_HttpResponse *hr = &mer->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1384,15 +1384,15 @@ upload_auditor_add (const char *donau_url, aar = GNUNET_new (struct AuditorAddRequest); aar->idx = idx; aar->h = - TALER_DONAU_management_enable_auditor (ctx, - donau_url, - &auditor_pub, - auditor_url, - auditor_name, - start_time, - &master_sig, - &auditor_add_cb, - aar); + DONAU_management_enable_auditor (ctx, + donau_url, + &auditor_pub, + auditor_url, + auditor_name, + start_time, + &master_sig, + &auditor_add_cb, + aar); GNUNET_CONTAINER_DLL_insert (aar_head, aar_tail, aar); @@ -1408,10 +1408,10 @@ upload_auditor_add (const char *donau_url, static void auditor_del_cb (void *cls, const struct - TALER_DONAU_ManagementAuditorDisableResponse *mdr) + DONAU_ManagementAuditorDisableResponse *mdr) { struct AuditorDelRequest *adr = cls; - const struct TALER_DONAU_HttpResponse *hr = &mdr->hr; + const struct DONAU_HttpResponse *hr = &mdr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1480,13 +1480,13 @@ upload_auditor_del (const char *donau_url, adr = GNUNET_new (struct AuditorDelRequest); adr->idx = idx; adr->h = - TALER_DONAU_management_disable_auditor (ctx, - donau_url, - &auditor_pub, - end_time, - &master_sig, - &auditor_del_cb, - adr); + DONAU_management_disable_auditor (ctx, + donau_url, + &auditor_pub, + end_time, + &master_sig, + &auditor_del_cb, + adr); GNUNET_CONTAINER_DLL_insert (adr_head, adr_tail, adr); @@ -1501,10 +1501,10 @@ upload_auditor_del (const char *donau_url, */ static void wire_add_cb (void *cls, - const struct TALER_DONAU_ManagementWireEnableResponse *wer) + const struct DONAU_ManagementWireEnableResponse *wer) { struct WireAddRequest *war = cls; - const struct TALER_DONAU_HttpResponse *hr = &wer->hr; + const struct DONAU_HttpResponse *hr = &wer->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1616,17 +1616,17 @@ upload_wire_add (const char *donau_url, war = GNUNET_new (struct WireAddRequest); war->idx = idx; war->h = - TALER_DONAU_management_enable_wire (ctx, - donau_url, - payto_uri, - conversion_url, - debit_restrictions, - credit_restrictions, - start_time, - &master_sig_add, - &master_sig_wire, - &wire_add_cb, - war); + DONAU_management_enable_wire (ctx, + donau_url, + payto_uri, + conversion_url, + debit_restrictions, + credit_restrictions, + start_time, + &master_sig_add, + &master_sig_wire, + &wire_add_cb, + war); GNUNET_CONTAINER_DLL_insert (war_head, war_tail, war); @@ -1641,10 +1641,10 @@ upload_wire_add (const char *donau_url, */ static void wire_del_cb (void *cls, - const struct TALER_DONAU_ManagementWireDisableResponse *wdres) + const struct DONAU_ManagementWireDisableResponse *wdres) { struct WireDelRequest *wdr = cls; - const struct TALER_DONAU_HttpResponse *hr = &wdres->hr; + const struct DONAU_HttpResponse *hr = &wdres->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1713,13 +1713,13 @@ upload_wire_del (const char *donau_url, wdr = GNUNET_new (struct WireDelRequest); wdr->idx = idx; wdr->h = - TALER_DONAU_management_disable_wire (ctx, - donau_url, - payto_uri, - end_time, - &master_sig, - &wire_del_cb, - wdr); + DONAU_management_disable_wire (ctx, + donau_url, + payto_uri, + end_time, + &master_sig, + &wire_del_cb, + wdr); GNUNET_CONTAINER_DLL_insert (wdr_head, wdr_tail, wdr); @@ -1735,10 +1735,10 @@ upload_wire_del (const char *donau_url, static void wire_fee_cb ( void *cls, - const struct TALER_DONAU_ManagementSetWireFeeResponse *swr) + const struct DONAU_ManagementSetWireFeeResponse *swr) { struct WireFeeRequest *wfr = cls; - const struct TALER_DONAU_HttpResponse *hr = &swr->hr; + const struct DONAU_HttpResponse *hr = &swr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1817,15 +1817,15 @@ upload_wire_fee (const char *donau_url, wfr = GNUNET_new (struct WireFeeRequest); wfr->idx = idx; wfr->h = - TALER_DONAU_management_set_wire_fees (ctx, - donau_url, - wire_method, - start_time, - end_time, - &fees, - &master_sig, - &wire_fee_cb, - wfr); + DONAU_management_set_wire_fees (ctx, + donau_url, + wire_method, + start_time, + end_time, + &fees, + &master_sig, + &wire_fee_cb, + wfr); GNUNET_CONTAINER_DLL_insert (wfr_head, wfr_tail, wfr); @@ -1841,10 +1841,10 @@ upload_wire_fee (const char *donau_url, static void global_fee_cb ( void *cls, - const struct TALER_DONAU_ManagementSetGlobalFeeResponse *gr) + const struct DONAU_ManagementSetGlobalFeeResponse *gr) { struct GlobalFeeRequest *gfr = cls; - const struct TALER_DONAU_HttpResponse *hr = &gr->hr; + const struct DONAU_HttpResponse *hr = &gr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -1932,17 +1932,17 @@ upload_global_fee (const char *donau_url, gfr = GNUNET_new (struct GlobalFeeRequest); gfr->idx = idx; gfr->h = - TALER_DONAU_management_set_global_fees (ctx, - donau_url, - start_time, - end_time, - &fees, - purse_timeout, - history_expiration, - purse_account_limit, - &master_sig, - &global_fee_cb, - gfr); + DONAU_management_set_global_fees (ctx, + donau_url, + start_time, + end_time, + &fees, + purse_timeout, + history_expiration, + purse_account_limit, + &master_sig, + &global_fee_cb, + gfr); GNUNET_CONTAINER_DLL_insert (gfr_head, gfr_tail, gfr); @@ -1958,10 +1958,10 @@ upload_global_fee (const char *donau_url, static void drain_profits_cb ( void *cls, - const struct TALER_DONAU_ManagementDrainResponse *mdr) + const struct DONAU_ManagementDrainResponse *mdr) { struct DrainProfitsRequest *dpr = cls; - const struct TALER_DONAU_HttpResponse *hr = &mdr->hr; + const struct DONAU_HttpResponse *hr = &mdr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -2040,16 +2040,16 @@ upload_drain (const char *donau_url, dpr = GNUNET_new (struct DrainProfitsRequest); dpr->idx = idx; dpr->h = - TALER_DONAU_management_drain_profits (ctx, - donau_url, - &wtid, - &amount, - date, - account_section, - payto_uri, - &master_sig, - &drain_profits_cb, - dpr); + DONAU_management_drain_profits (ctx, + donau_url, + &wtid, + &amount, + date, + account_section, + payto_uri, + &master_sig, + &drain_profits_cb, + dpr); GNUNET_CONTAINER_DLL_insert (dpr_head, dpr_tail, dpr); @@ -2065,10 +2065,10 @@ upload_drain (const char *donau_url, static void keys_cb ( void *cls, - const struct TALER_DONAU_ManagementPostKeysResponse *mr) + const struct DONAU_ManagementPostKeysResponse *mr) { struct UploadKeysRequest *ukr = cls; - const struct TALER_DONAU_HttpResponse *hr = &mr->hr; + const struct DONAU_HttpResponse *hr = &mr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -2100,7 +2100,7 @@ upload_keys (const char *donau_url, size_t idx, const json_t *value) { - struct TALER_DONAU_ManagementPostKeysData pkd; + struct DONAU_ManagementPostKeysData pkd; struct UploadKeysRequest *ukr; const char *err_name; unsigned int err_line; @@ -2140,13 +2140,13 @@ upload_keys (const char *donau_url, pkd.num_sign_sigs); pkd.sign_sigs = GNUNET_new_array ( pkd.num_sign_sigs, - struct TALER_DONAU_SigningKeySignature); + struct DONAU_SigningKeySignature); pkd.denom_sigs = GNUNET_new_array ( pkd.num_denom_sigs, - struct TALER_DONAU_DenominationKeySignature); + struct DONAU_DenominationKeySignature); for (unsigned int i = 0; i<pkd.num_sign_sigs; i++) { - struct TALER_DONAU_SigningKeySignature *ss = &pkd.sign_sigs[i]; + struct DONAU_SigningKeySignature *ss = &pkd.sign_sigs[i]; json_t *val = json_array_get (signkey_sigs, i); struct GNUNET_JSON_Specification spec[] = { @@ -2176,7 +2176,7 @@ upload_keys (const char *donau_url, } for (unsigned int i = 0; i<pkd.num_denom_sigs; i++) { - struct TALER_DONAU_DenominationKeySignature *ds = &pkd.denom_sigs[i]; + struct DONAU_DenominationKeySignature *ds = &pkd.denom_sigs[i]; json_t *val = json_array_get (denom_sigs, i); struct GNUNET_JSON_Specification spec[] = { @@ -2210,11 +2210,11 @@ upload_keys (const char *donau_url, ukr = GNUNET_new (struct UploadKeysRequest); ukr->idx = idx; ukr->h = - TALER_DONAU_post_management_keys (ctx, - donau_url, - &pkd, - &keys_cb, - ukr); + DONAU_post_management_keys (ctx, + donau_url, + &pkd, + &keys_cb, + ukr); GNUNET_CONTAINER_DLL_insert (ukr_head, ukr_tail, ukr); @@ -2238,10 +2238,10 @@ upload_keys (const char *donau_url, static void extensions_cb ( void *cls, - const struct TALER_DONAU_ManagementPostExtensionsResponse *er) + const struct DONAU_ManagementPostExtensionsResponse *er) { struct UploadExtensionsRequest *uer = cls; - const struct TALER_DONAU_HttpResponse *hr = &er->hr; + const struct DONAU_HttpResponse *hr = &er->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -2339,7 +2339,7 @@ upload_extensions (const char *donau_url, /* 3. Upload the extensions */ { - struct TALER_DONAU_ManagementPostExtensionsData ped = { + struct DONAU_ManagementPostExtensionsData ped = { .extensions = extensions, .extensions_sig = sig, }; @@ -2347,7 +2347,7 @@ upload_extensions (const char *donau_url, = GNUNET_new (struct UploadExtensionsRequest); uer->idx = idx; - uer->h = TALER_DONAU_management_post_extensions ( + uer->h = DONAU_management_post_extensions ( ctx, donau_url, &ped, @@ -2369,10 +2369,10 @@ upload_extensions (const char *donau_url, static void add_partner_cb ( void *cls, - const struct TALER_DONAU_ManagementAddPartnerResponse *apr) + const struct DONAU_ManagementAddPartnerResponse *apr) { struct PartnerAddRequest *par = cls; - const struct TALER_DONAU_HttpResponse *hr = &apr->hr; + const struct DONAU_HttpResponse *hr = &apr->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -2454,17 +2454,17 @@ add_partner (const char *donau_url, par = GNUNET_new (struct PartnerAddRequest); par->idx = idx; par->h = - TALER_DONAU_management_add_partner (ctx, - donau_url, - &partner_pub, - start_date, - end_date, - wad_frequency, - &wad_fee, - partner_base_url, - &master_sig, - &add_partner_cb, - par); + DONAU_management_add_partner (ctx, + donau_url, + &partner_pub, + start_date, + end_date, + wad_frequency, + &wad_fee, + partner_base_url, + &master_sig, + &add_partner_cb, + par); GNUNET_CONTAINER_DLL_insert (par_head, par_tail, par); @@ -2480,10 +2480,10 @@ add_partner (const char *donau_url, static void update_aml_officer_cb ( void *cls, - const struct TALER_DONAU_ManagementUpdateAmlOfficerResponse *ar) + const struct DONAU_ManagementUpdateAmlOfficerResponse *ar) { struct AmlStaffRequest *asr = cls; - const struct TALER_DONAU_HttpResponse *hr = &ar->hr; + const struct DONAU_HttpResponse *hr = &ar->hr; if (MHD_HTTP_NO_CONTENT != hr->http_status) { @@ -2561,16 +2561,16 @@ update_aml_staff (const char *donau_url, asr = GNUNET_new (struct AmlStaffRequest); asr->idx = idx; asr->h = - TALER_DONAU_management_update_aml_officer (ctx, - donau_url, - &officer_pub, - officer_name, - change_date, - is_active, - read_only, - &master_sig, - &update_aml_officer_cb, - asr); + DONAU_management_update_aml_officer (ctx, + donau_url, + &officer_pub, + officer_name, + change_date, + is_active, + read_only, + &master_sig, + &update_aml_officer_cb, + asr); GNUNET_CONTAINER_DLL_insert (asr_head, asr_tail, asr); @@ -2790,8 +2790,8 @@ do_revoke_denomination_key (char *const *args) load_offline_key (GNUNET_NO)) return; TALER_donau_offline_denomination_revoke_sign (&h_denom_pub, - &master_priv, - &master_sig); + &master_priv, + &master_sig); output_operation (OP_REVOKE_DENOMINATION, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("h_denom_pub", @@ -2811,7 +2811,7 @@ do_revoke_denomination_key (char *const *args) static void do_revoke_signkey (char *const *args) { - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_MasterSignatureP master_sig; if (NULL != in) @@ -2839,8 +2839,8 @@ do_revoke_signkey (char *const *args) load_offline_key (GNUNET_NO)) return; TALER_donau_offline_signkey_revoke_sign (&donau_pub, - &master_priv, - &master_sig); + &master_priv, + &master_sig); output_operation (OP_REVOKE_SIGNKEY, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("donau_pub", @@ -2904,10 +2904,10 @@ do_add_auditor (char *const *args) return; now = GNUNET_TIME_timestamp_get (); TALER_donau_offline_auditor_add_sign (&auditor_pub, - args[1], - now, - &master_priv, - &master_sig); + args[1], + now, + &master_priv, + &master_sig); output_operation (OP_ENABLE_AUDITOR, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("auditor_url", @@ -2963,9 +2963,9 @@ do_del_auditor (char *const *args) return; now = GNUNET_TIME_timestamp_get (); TALER_donau_offline_auditor_del_sign (&auditor_pub, - now, - &master_priv, - &master_sig); + now, + &master_priv, + &master_sig); output_operation (OP_DISABLE_AUDITOR, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("auditor_pub", @@ -3199,18 +3199,18 @@ do_add_wire (char *const *args) break; } TALER_donau_offline_wire_add_sign (args[0], - conversion_url, - debit_restrictions, - credit_restrictions, - now, - &master_priv, - &master_sig_add); + conversion_url, + debit_restrictions, + credit_restrictions, + now, + &master_priv, + &master_sig_add); TALER_donau_wire_signature_make (args[0], - conversion_url, - debit_restrictions, - credit_restrictions, - &master_priv, - &master_sig_wire); + conversion_url, + debit_restrictions, + credit_restrictions, + &master_priv, + &master_sig_wire); output_operation (OP_ENABLE_WIRE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("payto_uri", @@ -3265,9 +3265,9 @@ do_del_wire (char *const *args) return; now = GNUNET_TIME_timestamp_get (); TALER_donau_offline_wire_del_sign (args[0], - now, - &master_priv, - &master_sig); + now, + &master_priv, + &master_sig); output_operation (OP_DISABLE_WIRE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("payto_uri", @@ -3340,11 +3340,11 @@ do_set_wire_fee (char *const *args) GNUNET_TIME_year_to_time (year + 1)); TALER_donau_offline_wire_fee_sign (args[1], - start_time, - end_time, - &fees, - &master_priv, - &master_sig); + start_time, + end_time, + &fees, + &master_priv, + &master_sig); output_operation (OP_SET_WIRE_FEE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("wire_method", @@ -3471,13 +3471,13 @@ do_set_global_fee (char *const *args) GNUNET_TIME_year_to_time (year + 1)); TALER_donau_offline_global_fee_sign (start_time, - end_time, - &fees, - purse_timeout, - history_expiration, - (uint32_t) purse_account_limit, - &master_priv, - &master_sig); + end_time, + &fees, + purse_timeout, + history_expiration, + (uint32_t) purse_account_limit, + &master_priv, + &master_sig); output_operation (OP_SET_GLOBAL_FEE, GNUNET_JSON_PACK ( GNUNET_JSON_pack_timestamp ("start_time", @@ -3586,12 +3586,12 @@ do_drain (char *const *args) sizeof (wtid)); date = GNUNET_TIME_timestamp_get (); TALER_donau_offline_profit_drain_sign (&wtid, - date, - &amount, - account_section, - payto_uri, - &master_priv, - &master_sig); + date, + &amount, + account_section, + payto_uri, + &master_priv, + &master_sig); output_operation (OP_DRAIN_PROFITS, GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("wtid", @@ -3715,13 +3715,13 @@ do_add_partner (char *const *args) load_offline_key (GNUNET_NO)) return; TALER_donau_offline_partner_details_sign (&partner_pub, - start_date, - end_date, - wad_frequency, - &wad_fee, - partner_base_url, - &master_priv, - &master_sig); + start_date, + end_date, + wad_frequency, + &wad_fee, + partner_base_url, + &master_priv, + &master_sig); output_operation (OP_ADD_PARTNER, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("partner_base_url", @@ -3813,12 +3813,12 @@ do_set_aml_staff (bool is_active, load_offline_key (GNUNET_NO)) return; TALER_donau_offline_aml_officer_status_sign (&officer_pub, - officer_name, - now, - is_active, - read_only, - &master_priv, - &master_sig); + officer_name, + now, + is_active, + read_only, + &master_priv, + &master_sig); output_operation (OP_UPDATE_AML_STAFF, GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("officer_name", @@ -3875,10 +3875,10 @@ enable_aml_staff (char *const *args) */ static void download_cb (void *cls, - const struct TALER_DONAU_ManagementGetKeysResponse *mgr) + const struct DONAU_ManagementGetKeysResponse *mgr) { char *const *args = cls; - const struct TALER_DONAU_HttpResponse *hr = &mgr->hr; + const struct DONAU_HttpResponse *hr = &mgr->hr; mgkh = NULL; switch (hr->http_status) @@ -3940,10 +3940,10 @@ do_download (char *const *args) global_ret = EXIT_NOTCONFIGURED; return; } - mgkh = TALER_DONAU_get_management_keys (ctx, - CFG_donau_url, - &download_cb, - (void *) args); + mgkh = DONAU_get_management_keys (ctx, + CFG_donau_url, + &download_cb, + (void *) args); } @@ -4154,7 +4154,7 @@ show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub, json_array_foreach (signkeys, index, value) { const char *err_name; unsigned int err_line; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_SecurityModuleSignatureP secm_sig; struct GNUNET_TIME_Timestamp start_time; struct GNUNET_TIME_Timestamp sign_end; @@ -4196,10 +4196,10 @@ show_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub, sign_end.abs_time); if (GNUNET_OK != TALER_donau_secmod_eddsa_verify (&donau_pub, - start_time, - duration, - secm_pub, - &secm_sig)) + start_time, + duration, + secm_pub, + &secm_sig)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid security module signature for signing key %s (aborting)\n", @@ -4314,11 +4314,11 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa, TALER_rsa_pub_hash (denom_pub.details.rsa_public_key, &h_rsa); ok = TALER_donau_secmod_rsa_verify (&h_rsa, - section_name, - stamp_start, - duration, - secm_pub_rsa, - &secm_sig); + section_name, + stamp_start, + duration, + secm_pub_rsa, + &secm_sig); } break; case TALER_DENOMINATION_CS: @@ -4328,11 +4328,11 @@ show_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa, TALER_cs_pub_hash (&denom_pub.details.cs_public_key, &h_cs); ok = TALER_donau_secmod_cs_verify (&h_cs, - section_name, - stamp_start, - duration, - secm_pub_cs, - &secm_sig); + section_name, + stamp_start, + duration, + secm_pub_cs, + &secm_sig); } break; default: @@ -4584,7 +4584,7 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub, json_array_foreach (signkeys, index, value) { const char *err_name; unsigned int err_line; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_SecurityModuleSignatureP secm_sig; struct GNUNET_TIME_Timestamp start_time; struct GNUNET_TIME_Timestamp sign_end; @@ -4627,10 +4627,10 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub, sign_end.abs_time); if (GNUNET_OK != TALER_donau_secmod_eddsa_verify (&donau_pub, - start_time, - duration, - secm_pub, - &secm_sig)) + start_time, + duration, + secm_pub, + &secm_sig)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid security module signature for signing key %s (aborting)\n", @@ -4644,11 +4644,11 @@ sign_signkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub, struct TALER_MasterSignatureP master_sig; TALER_donau_offline_signkey_validity_sign (&donau_pub, - start_time, - sign_end, - legal_end, - &master_priv, - &master_sig); + start_time, + sign_end, + legal_end, + &master_priv, + &master_sig); GNUNET_assert (0 == json_array_append_new ( result, @@ -4795,11 +4795,11 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa, &h_rsa); if (GNUNET_OK != TALER_donau_secmod_rsa_verify (&h_rsa, - section_name, - stamp_start, - duration, - secm_pub_rsa, - &secm_sig)) + section_name, + stamp_start, + duration, + secm_pub_rsa, + &secm_sig)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid security module signature for denomination key %s (aborting)\n", @@ -4819,11 +4819,11 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa, &h_cs); if (GNUNET_OK != TALER_donau_secmod_cs_verify (&h_cs, - section_name, - stamp_start, - duration, - secm_pub_cs, - &secm_sig)) + section_name, + stamp_start, + duration, + secm_pub_cs, + &secm_sig)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid security module signature for denomination key %s (aborting)\n", @@ -4846,14 +4846,14 @@ sign_denomkeys (const struct TALER_SecurityModulePublicKeyP *secm_pub_rsa, struct TALER_MasterSignatureP master_sig; TALER_donau_offline_denom_validity_sign (&h_denom_pub, - stamp_start, - stamp_expire_withdraw, - stamp_expire_deposit, - stamp_expire_legal, - &coin_value, - &fees, - &master_priv, - &master_sig); + stamp_start, + stamp_expire_withdraw, + stamp_expire_deposit, + stamp_expire_legal, + &coin_value, + &fees, + &master_priv, + &master_sig); GNUNET_assert (0 == json_array_append_new ( result, @@ -5113,8 +5113,8 @@ do_extensions_sign (char *const *args) } TALER_donau_offline_extension_manifests_hash_sign (&h_manifests, - &master_priv, - &sig); + &master_priv, + &sig); obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_object_steal ("extensions", extensions), diff --git a/src/donau/Makefile.am b/src/donau/Makefile.am @@ -19,7 +19,7 @@ bin_SCRIPTS = \ taler-donau-kyc-aml-pep-trigger.sh bin_PROGRAMS = \ - taler-donau-httpd + donau-httpd # taler_donau_aggregator_SOURCES = \ taler-donau-aggregator.c @@ -27,8 +27,7 @@ bin_PROGRAMS = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/kyclogic/libtalerkyclogic.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -41,8 +40,7 @@ bin_PROGRAMS = \ # taler_donau_closer_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -54,8 +52,7 @@ bin_PROGRAMS = \ # taler_donau_drain_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -67,8 +64,7 @@ bin_PROGRAMS = \ # taler_donau_expire_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -80,8 +76,7 @@ bin_PROGRAMS = \ # taler_donau_router_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -93,8 +88,7 @@ bin_PROGRAMS = \ # taler_donau_transfer_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -106,8 +100,7 @@ bin_PROGRAMS = \ # taler_donau_wirewatch_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ -ljansson \ -lgnunetcurl \ @@ -115,65 +108,10 @@ bin_PROGRAMS = \ $(XLIB) -taler_donau_httpd_SOURCES = \ - taler-donau-httpd.c taler-donau-httpd.h \ - taler-donau-httpd_aml-decision.c taler-donau-httpd_aml-decision.h \ - taler-donau-httpd_aml-decision-get.c \ - taler-donau-httpd_aml-decisions-get.c \ - taler-donau-httpd_batch-deposit.c taler-donau-httpd_batch-deposit.h \ - taler-donau-httpd_batch-withdraw.c taler-donau-httpd_batch-withdraw.h \ - taler-donau-httpd_age-withdraw.c taler-donau-httpd_age-withdraw.h \ - taler-donau-httpd_age-withdraw_reveal.c taler-donau-httpd_age-withdraw_reveal.h \ - taler-donau-httpd_common_deposit.c taler-donau-httpd_common_deposit.h \ - taler-donau-httpd_common_kyc.c taler-donau-httpd_common_kyc.h \ - taler-donau-httpd_config.c taler-donau-httpd_config.h \ - taler-donau-httpd_contract.c taler-donau-httpd_contract.h \ - taler-donau-httpd_csr.c taler-donau-httpd_csr.h \ - taler-donau-httpd_db.c taler-donau-httpd_db.h \ - taler-donau-httpd_deposits_get.c taler-donau-httpd_deposits_get.h \ - taler-donau-httpd_extensions.c taler-donau-httpd_extensions.h \ - taler-donau-httpd_keys.c taler-donau-httpd_keys.h \ - taler-donau-httpd_kyc-check.c taler-donau-httpd_kyc-check.h \ - taler-donau-httpd_kyc-proof.c taler-donau-httpd_kyc-proof.h \ - taler-donau-httpd_kyc-wallet.c taler-donau-httpd_kyc-wallet.h \ - taler-donau-httpd_kyc-webhook.c taler-donau-httpd_kyc-webhook.h \ - taler-donau-httpd_link.c taler-donau-httpd_link.h \ - taler-donau-httpd_management.h \ - taler-donau-httpd_management_aml-officers.c \ - taler-donau-httpd_management_denominations_HDP_revoke.c \ - taler-donau-httpd_management_drain.c \ - taler-donau-httpd_management_extensions.c \ - taler-donau-httpd_management_global_fees.c \ - taler-donau-httpd_management_partners.c \ - taler-donau-httpd_management_post_keys.c \ - taler-donau-httpd_management_signkey_EP_revoke.c \ - taler-donau-httpd_management_wire_enable.c \ - taler-donau-httpd_management_wire_disable.c \ - taler-donau-httpd_management_wire_fees.c \ - taler-donau-httpd_melt.c taler-donau-httpd_melt.h \ - taler-donau-httpd_metrics.c taler-donau-httpd_metrics.h \ - taler-donau-httpd_mhd.c taler-donau-httpd_mhd.h \ - taler-donau-httpd_purses_create.c taler-donau-httpd_purses_create.h \ - taler-donau-httpd_purses_deposit.c taler-donau-httpd_purses_deposit.h \ - taler-donau-httpd_purses_delete.c taler-donau-httpd_purses_delete.h \ - taler-donau-httpd_purses_get.c taler-donau-httpd_purses_get.h \ - taler-donau-httpd_purses_merge.c taler-donau-httpd_purses_merge.h \ - taler-donau-httpd_recoup.c taler-donau-httpd_recoup.h \ - taler-donau-httpd_recoup-refresh.c taler-donau-httpd_recoup-refresh.h \ - taler-donau-httpd_refreshes_reveal.c taler-donau-httpd_refreshes_reveal.h \ - taler-donau-httpd_refund.c taler-donau-httpd_refund.h \ - taler-donau-httpd_reserves_attest.c taler-donau-httpd_reserves_attest.h \ - taler-donau-httpd_reserves_close.c taler-donau-httpd_reserves_close.h \ - taler-donau-httpd_reserves_get.c taler-donau-httpd_reserves_get.h \ - taler-donau-httpd_reserves_get_attest.c taler-donau-httpd_reserves_get_attest.h \ - taler-donau-httpd_reserves_history.c taler-donau-httpd_reserves_history.h \ - taler-donau-httpd_reserves_open.c taler-donau-httpd_reserves_open.h \ - taler-donau-httpd_reserves_purse.c taler-donau-httpd_reserves_purse.h \ - taler-donau-httpd_reserves_status.c taler-donau-httpd_reserves_status.h \ - taler-donau-httpd_responses.c taler-donau-httpd_responses.h \ - taler-donau-httpd_terms.c taler-donau-httpd_terms.h \ - taler-donau-httpd_transfers_get.c taler-donau-httpd_transfers_get.h \ - taler-donau-httpd_withdraw.c taler-donau-httpd_withdraw.h +# taler_donau_httpd_SOURCES = \ + donau-httpd.c donau-httpd.h \ + donau-httpd_responses.c donau-httpd_responses.h \ + donau-httpd_terms.c donau-httpd_terms.h taler_donau_httpd_LDADD = \ $(LIBGCRYPT_LIBS) \ @@ -181,7 +119,7 @@ taler_donau_httpd_LDADD = \ $(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/donaudb/libtalerdonaudb.la \ $(top_builddir)/src/templating/libtalertemplating.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/extensions/libtalerextensions.la \ -lmicrohttpd \ -lgnunetcurl \ diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c @@ -20,59 +20,19 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include <microhttpd.h> #include <sched.h> #include <sys/resource.h> #include <limits.h> -#include "taler_kyclogic_lib.h" -#include "taler_templating_lib.h" -#include "taler_mhd_lib.h" -#include "taler-donau-httpd_age-withdraw.h" -#include "taler-donau-httpd_age-withdraw_reveal.h" -#include "taler-donau-httpd_aml-decision.h" -#include "taler-donau-httpd_auditors.h" -#include "taler-donau-httpd_batch-deposit.h" -#include "taler-donau-httpd_batch-withdraw.h" -#include "taler-donau-httpd_config.h" -#include "taler-donau-httpd_contract.h" -#include "taler-donau-httpd_csr.h" -#include "taler-donau-httpd_deposits_get.h" -#include "taler-donau-httpd_extensions.h" -#include "taler-donau-httpd_keys.h" -#include "taler-donau-httpd_kyc-check.h" -#include "taler-donau-httpd_kyc-proof.h" -#include "taler-donau-httpd_kyc-wallet.h" -#include "taler-donau-httpd_link.h" -#include "taler-donau-httpd_management.h" -#include "taler-donau-httpd_melt.h" -#include "taler-donau-httpd_metrics.h" -#include "taler-donau-httpd_mhd.h" -#include "taler-donau-httpd_purses_create.h" -#include "taler-donau-httpd_purses_deposit.h" -#include "taler-donau-httpd_purses_get.h" -#include "taler-donau-httpd_purses_delete.h" -#include "taler-donau-httpd_purses_merge.h" -#include "taler-donau-httpd_recoup.h" -#include "taler-donau-httpd_recoup-refresh.h" -#include "taler-donau-httpd_refreshes_reveal.h" -#include "taler-donau-httpd_refund.h" -#include "taler-donau-httpd_reserves_attest.h" -#include "taler-donau-httpd_reserves_close.h" -#include "taler-donau-httpd_reserves_get.h" -#include "taler-donau-httpd_reserves_get_attest.h" -#include "taler-donau-httpd_reserves_history.h" -#include "taler-donau-httpd_reserves_open.h" -#include "taler-donau-httpd_reserves_purse.h" -#include "taler-donau-httpd_reserves_status.h" -#include "taler-donau-httpd_terms.h" -#include "taler-donau-httpd_transfers_get.h" -#include "taler-donau-httpd_withdraw.h" -#include "taler_donaudb_lib.h" -#include "taler_donaudb_plugin.h" -#include "taler_extensions.h" +#include "taler/taler_templating_lib.h" +#include "taler/taler_mhd_lib.h" +#include "donau-httpd_terms.h" +#include "donaudb_lib.h" +#include "donaudb_plugin.h" +#include "taler/taler_extensions.h" #include <gnunet/gnunet_mhd_compat.h> /** @@ -146,7 +106,7 @@ struct TALER_AttributeEncryptionKeyP TEH_attribute_key; /** * Our DB plugin. (global) */ -struct TALER_DONAUDB_Plugin *TEH_plugin; +struct DONAUDB_Plugin *TEH_plugin; /** * Absolute STEFAN parameter. @@ -290,570 +250,12 @@ r404 (struct MHD_Connection *connection, { return TALER_MHD_reply_with_error (connection, MHD_HTTP_NOT_FOUND, - TALER_EC_DONAU_GENERIC_OPERATION_UNKNOWN, + TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN, details); } /** - * Handle a "/coins/$COIN_PUB/$OP" POST request. Parses the "coin_pub" - * EdDSA key of the coin and demultiplexes based on $OP. - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_coins (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[2]) -{ - struct TALER_CoinSpendPublicKeyP coin_pub; - static const struct - { - /** - * Name of the operation (args[1]) - */ - const char *op; - - /** - * Function to call to perform the operation. - */ - CoinOpHandler handler; - - } h[] = { - { - .op = "melt", - .handler = &TEH_handler_melt - }, - { - .op = "recoup", - .handler = &TEH_handler_recoup - }, - { - .op = "recoup-refresh", - .handler = &TEH_handler_recoup_refresh - }, - { - .op = "refund", - .handler = &TEH_handler_refund - }, - { - .op = NULL, - .handler = NULL - }, - }; - - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &coin_pub, - sizeof (coin_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_DONAU_GENERIC_COINS_INVALID_COIN_PUB, - args[0]); - } - for (unsigned int i = 0; NULL != h[i].op; i++) - if (0 == strcmp (h[i].op, - args[1])) - return h[i].handler (rc->connection, - &coin_pub, - root); - return r404 (rc->connection, - args[1]); -} - - -/** - * Signature of functions that handle operations - * authorized by AML officers. - * - * @param rc request context - * @param officer_pub the public key of the AML officer - * @param root uploaded JSON data - * @return MHD result code - */ -typedef MHD_RESULT -(*AmlOpPostHandler)(struct TEH_RequestContext *rc, - const struct TALER_AmlOfficerPublicKeyP *officer_pub, - const json_t *root); - - -/** - * Handle a "/aml/$OFFICER_PUB/$OP" POST request. Parses the "officer_pub" - * EdDSA key of the officer and demultiplexes based on $OP. - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_aml (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[2]) -{ - struct TALER_AmlOfficerPublicKeyP officer_pub; - static const struct - { - /** - * Name of the operation (args[1]) - */ - const char *op; - - /** - * Function to call to perform the operation. - */ - AmlOpPostHandler handler; - - } h[] = { - { - .op = "decision", - .handler = &TEH_handler_post_aml_decision - }, - { - .op = NULL, - .handler = NULL - }, - }; - - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &officer_pub, - sizeof (officer_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_DONAU_GENERIC_AML_OFFICER_PUB_MALFORMED, - args[0]); - } - for (unsigned int i = 0; NULL != h[i].op; i++) - if (0 == strcmp (h[i].op, - args[1])) - return h[i].handler (rc, - &officer_pub, - root); - return r404 (rc->connection, - args[1]); -} - - -/** - * Signature of functions that handle operations - * authorized by AML officers. - * - * @param rc request context - * @param officer_pub the public key of the AML officer - * @param args remaining arguments - * @return MHD result code - */ -typedef MHD_RESULT -(*AmlOpGetHandler)(struct TEH_RequestContext *rc, - const struct TALER_AmlOfficerPublicKeyP *officer_pub, - const char *const args[]); - - -/** - * Handle a "/aml/$OFFICER_PUB/$OP" GET request. Parses the "officer_pub" - * EdDSA key of the officer, checks the authentication signature, and - * demultiplexes based on $OP. - * - * @param rc request context - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_get_aml (struct TEH_RequestContext *rc, - const char *const args[]) -{ - struct TALER_AmlOfficerPublicKeyP officer_pub; - static const struct - { - /** - * Name of the operation (args[1]) - */ - const char *op; - - /** - * Function to call to perform the operation. - */ - AmlOpGetHandler handler; - - } h[] = { - { - .op = "decisions", - .handler = &TEH_handler_aml_decisions_get - }, - { - .op = "decision", - .handler = &TEH_handler_aml_decision_get - }, - { - .op = NULL, - .handler = NULL - }, - }; - - if (NULL == args[0]) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_DONAU_GENERIC_AML_OFFICER_PUB_MALFORMED, - "argument missing"); - } - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &officer_pub, - sizeof (officer_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_DONAU_GENERIC_AML_OFFICER_PUB_MALFORMED, - args[0]); - } - if (NULL == args[1]) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_DONAU_GENERIC_WRONG_NUMBER_OF_SEGMENTS, - "AML GET operations must specify an operation identifier"); - } - { - const char *sig_hdr; - struct TALER_AmlOfficerSignatureP officer_sig; - - sig_hdr = MHD_lookup_connection_value (rc->connection, - MHD_HEADER_KIND, - TALER_AML_OFFICER_SIGNATURE_HEADER); - if ( (NULL == sig_hdr) || - (GNUNET_OK != - GNUNET_STRINGS_string_to_data (sig_hdr, - strlen (sig_hdr), - &officer_sig, - sizeof (officer_sig))) || - (GNUNET_OK != - TALER_officer_aml_query_verify (&officer_pub, - &officer_sig)) ) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_DONAU_GENERIC_AML_OFFICER_GET_SIGNATURE_INVALID, - sig_hdr); - } - TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; - } - - { - enum GNUNET_DB_QueryStatus qs; - - qs = TEH_plugin->test_aml_officer (TEH_plugin->cls, - &officer_pub); - switch (qs) - { - case GNUNET_DB_STATUS_HARD_ERROR: - case GNUNET_DB_STATUS_SOFT_ERROR: - GNUNET_break (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - NULL); - case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_FORBIDDEN, - TALER_EC_DONAU_GENERIC_AML_OFFICER_ACCESS_DENIED, - NULL); - case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: - break; - } - } - for (unsigned int i = 0; NULL != h[i].op; i++) - if (0 == strcmp (h[i].op, - args[1])) - return h[i].handler (rc, - &officer_pub, - &args[2]); - return r404 (rc->connection, - args[1]); -} - - -/** - * Handle a "/age-withdraw/$ACH/reveal" POST request. Parses the "ACH" - * hash of the commitment from a previous call to - * /reserves/$reserve_pub/age-withdraw - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_age_withdraw (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[2]) -{ - struct TALER_AgeWithdrawCommitmentHashP ach; - - if (0 != strcmp ("reveal", args[1])) - return r404 (rc->connection, - args[1]); - - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &ach, - sizeof (ach))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_RESERVE_PUB_MALFORMED, - args[0]); - } - - return TEH_handler_age_withdraw_reveal (rc, - &ach, - root); -} - - -/** - * Signature of functions that handle operations on reserves. - * - * @param rc request context - * @param reserve_pub the public key of the reserve - * @param root uploaded JSON data - * @return MHD result code - */ -typedef MHD_RESULT -(*ReserveOpHandler)(struct TEH_RequestContext *rc, - const struct TALER_ReservePublicKeyP *reserve_pub, - const json_t *root); - - -/** - * Handle a "/reserves/$RESERVE_PUB/$OP" POST request. Parses the "reserve_pub" - * EdDSA key of the reserve and demultiplexes based on $OP. - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_reserves (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[2]) -{ - struct TALER_ReservePublicKeyP reserve_pub; - static const struct - { - /** - * Name of the operation (args[1]) - */ - const char *op; - - /** - * Function to call to perform the operation. - */ - ReserveOpHandler handler; - - } h[] = { - { - .op = "batch-withdraw", - .handler = &TEH_handler_batch_withdraw - }, - { - .op = "age-withdraw", - .handler = &TEH_handler_age_withdraw - }, - { - .op = "withdraw", - .handler = &TEH_handler_withdraw - }, - { - .op = "status", - .handler = &TEH_handler_reserves_status - }, - { - .op = "history", - .handler = &TEH_handler_reserves_history - }, - { - .op = "purse", - .handler = &TEH_handler_reserves_purse - }, - { - .op = "open", - .handler = &TEH_handler_reserves_open - }, - { - .op = "close", - .handler = &TEH_handler_reserves_close - }, - { - .op = NULL, - .handler = NULL - }, - }; - - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &reserve_pub, - sizeof (reserve_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_RESERVE_PUB_MALFORMED, - args[0]); - } - for (unsigned int i = 0; NULL != h[i].op; i++) - if (0 == strcmp (h[i].op, - args[1])) - return h[i].handler (rc, - &reserve_pub, - root); - return r404 (rc->connection, - args[1]); -} - - -/** - * Signature of functions that handle operations on purses. - * - * @param connection HTTP request handle - * @param purse_pub the public key of the purse - * @param root uploaded JSON data - * @return MHD result code - */ -typedef MHD_RESULT -(*PurseOpHandler)(struct MHD_Connection *connection, - const struct TALER_PurseContractPublicKeyP *purse_pub, - const json_t *root); - - -/** - * Handle a "/purses/$RESERVE_PUB/$OP" POST request. Parses the "purse_pub" - * EdDSA key of the purse and demultiplexes based on $OP. - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_purses (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[2]) -{ - struct TALER_PurseContractPublicKeyP purse_pub; - static const struct - { - /** - * Name of the operation (args[1]) - */ - const char *op; - - /** - * Function to call to perform the operation. - */ - PurseOpHandler handler; - - } h[] = { - { - .op = "create", - .handler = &TEH_handler_purses_create - }, - { - .op = "deposit", - .handler = &TEH_handler_purses_deposit - }, - { - .op = "merge", - .handler = &TEH_handler_purses_merge - }, - { - .op = NULL, - .handler = NULL - }, - }; - - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &purse_pub, - sizeof (purse_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_DONAU_GENERIC_PURSE_PUB_MALFORMED, - args[0]); - } - for (unsigned int i = 0; NULL != h[i].op; i++) - if (0 == strcmp (h[i].op, - args[1])) - return h[i].handler (rc->connection, - &purse_pub, - root); - return r404 (rc->connection, - args[1]); -} - - -/** - * Increments our request counter and checks if this - * process should commit suicide. - */ -static void -check_suicide (void) -{ - int fd; - pid_t chld; - unsigned long long cnt; - - cnt = req_count++; - if (req_max != cnt) - return; - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Restarting donau service after %llu requests\n", - cnt); - /* Stop accepting new connections */ - fd = MHD_quiesce_daemon (mhd); - GNUNET_break (0 == close (fd)); - /* Continue handling existing connections in child, - so that this process can die and be replaced by - systemd with a fresh one */ - chld = fork (); - if (-1 == chld) - { - GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, - "fork"); - _exit (1); - } - if (0 != chld) - { - /* We are the parent, instant-suicide! */ - _exit (0); - } - TEH_suicide = true; -} - - -/** * Function called whenever MHD is done with a request. If the * request was a POST, we may have stored a `struct Buffer *` in the * @a con_cls that might still need to be cleaned up. Call the @@ -1093,304 +495,6 @@ handler_seed (struct TEH_RequestContext *rc, /** - * Handle POST "/management/..." requests. - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_management (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[]) -{ - if (NULL == args[0]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management"); - } - if (0 == strcmp (args[0], - "auditors")) - { - struct TALER_AuditorPublicKeyP auditor_pub; - - if (NULL == args[1]) - return TEH_handler_management_auditors (rc->connection, - root); - if ( (NULL == args[1]) || - (NULL == args[2]) || - (0 != strcmp (args[2], - "disable")) || - (NULL != args[3]) ) - return r404 (rc->connection, - "/management/auditors/$AUDITOR_PUB/disable"); - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[1], - strlen (args[1]), - &auditor_pub, - sizeof (auditor_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - args[1]); - } - return TEH_handler_management_auditors_AP_disable (rc->connection, - &auditor_pub, - root); - } - if (0 == strcmp (args[0], - "denominations")) - { - struct TALER_DenominationHashP h_denom_pub; - - if ( (NULL == args[0]) || - (NULL == args[1]) || - (NULL == args[2]) || - (0 != strcmp (args[2], - "revoke")) || - (NULL != args[3]) ) - return r404 (rc->connection, - "/management/denominations/$HDP/revoke"); - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[1], - strlen (args[1]), - &h_denom_pub, - sizeof (h_denom_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - args[1]); - } - return TEH_handler_management_denominations_HDP_revoke (rc->connection, - &h_denom_pub, - root); - } - if (0 == strcmp (args[0], - "signkeys")) - { - struct TALER_DonauPublicKeyP donau_pub; - - if ( (NULL == args[0]) || - (NULL == args[1]) || - (NULL == args[2]) || - (0 != strcmp (args[2], - "revoke")) || - (NULL != args[3]) ) - return r404 (rc->connection, - "/management/signkeys/$HDP/revoke"); - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[1], - strlen (args[1]), - &donau_pub, - sizeof (donau_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - args[1]); - } - return TEH_handler_management_signkeys_EP_revoke (rc->connection, - &donau_pub, - root); - } - /* FIXME-STYLE: all of the following can likely be nicely combined - into an array-based dispatcher to deduplicate the logic... */ - if (0 == strcmp (args[0], - "keys")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/keys/*"); - } - return TEH_handler_management_post_keys (rc->connection, - root); - } - if (0 == strcmp (args[0], - "wire")) - { - if (NULL == args[1]) - return TEH_handler_management_post_wire (rc->connection, - root); - if ( (0 != strcmp (args[1], - "disable")) || - (NULL != args[2]) ) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/wire/disable"); - } - return TEH_handler_management_post_wire_disable (rc->connection, - root); - } - if (0 == strcmp (args[0], - "wire-fee")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/wire-fee/*"); - } - return TEH_handler_management_post_wire_fees (rc->connection, - root); - } - if (0 == strcmp (args[0], - "global-fee")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/global-fee/*"); - } - return TEH_handler_management_post_global_fees (rc->connection, - root); - } - if (0 == strcmp (args[0], - "extensions")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/extensions/*"); - } - return TEH_handler_management_post_extensions (rc->connection, - root); - } - if (0 == strcmp (args[0], - "drain")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/drain/*"); - } - return TEH_handler_management_post_drain (rc->connection, - root); - } - if (0 == strcmp (args[0], - "aml-officers")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/aml-officers/*"); - } - return TEH_handler_management_aml_officers (rc->connection, - root); - } - if (0 == strcmp (args[0], - "partners")) - { - if (NULL != args[1]) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/partners/*"); - } - return TEH_handler_management_partners (rc->connection, - root); - } - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/*"); -} - - -/** - * Handle a GET "/management" request. - * - * @param rc request context - * @param args array of additional options (must be [0] == "keys") - * @return MHD result code - */ -static MHD_RESULT -handle_get_management (struct TEH_RequestContext *rc, - const char *const args[2]) -{ - if ( (NULL != args[0]) && - (0 == strcmp (args[0], - "keys")) && - (NULL == args[1]) ) - { - return TEH_keys_management_get_keys_handler (rc->rh, - rc->connection); - } - GNUNET_break_op (0); - return r404 (rc->connection, - "/management/*"); -} - - -/** - * Handle POST "/auditors/..." requests. - * - * @param rc request context - * @param root uploaded JSON data - * @param args array of additional options - * @return MHD result code - */ -static MHD_RESULT -handle_post_auditors (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[]) -{ - struct TALER_AuditorPublicKeyP auditor_pub; - struct TALER_DenominationHashP h_denom_pub; - - if ( (NULL == args[0]) || - (NULL == args[1]) || - (NULL != args[2]) ) - { - GNUNET_break_op (0); - return r404 (rc->connection, - "/auditors/$AUDITOR_PUB/$H_DENOM_PUB"); - } - - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &auditor_pub, - sizeof (auditor_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - args[0]); - } - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[1], - strlen (args[1]), - &h_denom_pub, - sizeof (h_denom_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_GENERIC_PARAMETER_MALFORMED, - args[1]); - } - return TEH_handler_auditors (rc->connection, - &auditor_pub, - &h_denom_pub, - root); -} - - -/** * Handle incoming HTTP request. * * @param cls closure for MHD daemon (unused) @@ -1477,12 +581,6 @@ handle_mhd_request (void *cls, .method = MHD_HTTP_METHOD_GET, .handler.get = &TEH_keys_get_handler, }, - { - .url = "batch-deposit", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &TEH_handler_batch_deposit, - .nargs = 0 - }, /* request R, used in clause schnorr withdraw and refresh */ { .url = "csr-melt", @@ -1490,161 +588,6 @@ handle_mhd_request (void *cls, .handler.post = &TEH_handler_csr_melt, .nargs = 0 }, - { - .url = "csr-withdraw", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &TEH_handler_csr_withdraw, - .nargs = 0 - }, - /* Withdrawing coins / interaction with reserves */ - { - .url = "reserves", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_reserves_get, - .nargs = 1 - }, - { - .url = "reserves", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_reserves, - .nargs = 2 - }, - { - .url = "age-withdraw", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_age_withdraw, - .nargs = 2 - }, - { - .url = "reserves-attest", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_reserves_get_attest, - .nargs = 1 - }, - { - .url = "reserves-attest", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &TEH_handler_reserves_attest, - .nargs = 1 - }, - /* coins */ - { - .url = "coins", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_coins, - .nargs = 2 - }, - { - .url = "coins", - .method = MHD_HTTP_METHOD_GET, - .handler.get = TEH_handler_link, - .nargs = 2, - }, - /* refreshes/$RCH/reveal */ - { - .url = "refreshes", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &TEH_handler_reveal, - .nargs = 2 - }, - /* tracking transfers */ - { - .url = "transfers", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_transfers_get, - .nargs = 1 - }, - /* tracking deposits */ - { - .url = "deposits", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_deposits_get, - .nargs = 4 - }, - /* Operating on purses */ - { - .url = "purses", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_purses, - .nargs = 2 - }, - /* Getting purse status */ - { - .url = "purses", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_purses_get, - .nargs = 2 - }, - /* Deleting purse */ - { - .url = "purses", - .method = MHD_HTTP_METHOD_DELETE, - .handler.delete = &TEH_handler_purses_delete, - .nargs = 1 - }, - /* Getting contracts */ - { - .url = "contracts", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_contracts_get, - .nargs = 1 - }, - /* KYC endpoints */ - { - .url = "kyc-check", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_kyc_check, - .nargs = 3 - }, - { - .url = "kyc-proof", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &TEH_handler_kyc_proof, - .nargs = 1 - }, - { - .url = "kyc-wallet", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &TEH_handler_kyc_wallet, - .nargs = 0 - }, - /* POST management endpoints */ - { - .url = "management", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_management, - .nargs = 4, - .nargs_is_upper_bound = true - }, - /* GET management endpoints (we only really have "/management/keys") */ - { - .url = "management", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &handle_get_management, - .nargs = 1 - }, - /* auditor endpoints */ - { - .url = "auditors", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_auditors, - .nargs = 4, - .nargs_is_upper_bound = true - }, - /* AML endpoints */ - { - .url = "aml", - .method = MHD_HTTP_METHOD_GET, - .handler.get = &handle_get_aml, - .nargs = 4, - .nargs_is_upper_bound = true - }, - { - .url = "aml", - .method = MHD_HTTP_METHOD_POST, - .handler.post = &handle_post_aml, - .nargs = 2 - }, /* mark end of list */ @@ -2089,7 +1032,7 @@ donau_serve_process_config (void) for (unsigned int i = 0; i<MAX_DB_RETRIES; i++) { - TEH_plugin = TALER_DONAUDB_plugin_load (TEH_cfg); + TEH_plugin = DONAUDB_plugin_load (TEH_cfg); if (NULL != TEH_plugin) break; GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -2348,7 +1291,7 @@ do_shutdown (void *cls) TEH_keys_finished (); if (NULL != TEH_plugin) { - TALER_DONAUDB_plugin_unload (TEH_plugin); + DONAUDB_plugin_unload (TEH_plugin); TEH_plugin = NULL; } if (NULL != TEH_curl_ctx) diff --git a/src/donau/donau-httpd.h b/src/donau/donau-httpd.h @@ -20,14 +20,13 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_H -#define TALER_DONAU_HTTPD_H +#ifndef DONAU_HTTPD_H +#define DONAU_HTTPD_H #include <microhttpd.h> -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_util.h" -#include "taler_kyclogic_plugin.h" -#include "taler_extensions.h" +#include "taler/taler_extensions.h" #include <gnunet/gnunet_mhd_compat.h> @@ -95,7 +94,7 @@ extern struct TALER_AttributeEncryptionKeyP TEH_attribute_key; /** * Our DB plugin. */ -extern struct TALER_DONAUDB_Plugin *TEH_plugin; +extern struct DONAUDB_Plugin *TEH_plugin; /** * Absolute STEFAN parameter. diff --git a/src/donau/donau-httpd_batch-issue_receipts.c b/src/donau/donau-httpd_batch-issue_receipts.c @@ -23,13 +23,13 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include "taler-donau-httpd.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_kyclogic_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_batch-withdraw.h" #include "taler-donau-httpd_responses.h" #include "taler-donau-httpd_keys.h" @@ -64,7 +64,7 @@ struct PlanchetContext /** * Set to the resulting signed coin data to be returned to the client. */ - struct TALER_DONAUDB_CollectableBlindcoin collectable; + struct DONAUDB_CollectableBlindcoin collectable; }; @@ -87,7 +87,7 @@ struct BatchWithdrawContext /** * KYC status of the reserve used for the operation. */ - struct TALER_DONAUDB_KycStatus kyc; + struct DONAUDB_KycStatus kyc; /** * Array of @e planchets_length planchets we are processing. @@ -141,7 +141,7 @@ struct BatchWithdrawContext static void batch_withdraw_amount_cb (void *cls, struct GNUNET_TIME_Absolute limit, - TALER_DONAUDB_KycAmountCallback cb, + DONAUDB_KycAmountCallback cb, void *cb_cls) { struct BatchWithdrawContext *wc = cls; diff --git a/src/donau/donau-httpd_batch-issue_receipts.h b/src/donau/donau-httpd_batch-issue_receipts.h @@ -20,8 +20,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_BATCH_WITHDRAW_H -#define TALER_DONAU_HTTPD_BATCH_WITHDRAW_H +#ifndef DONAU_HTTPD_BATCH_WITHDRAW_H +#define DONAU_HTTPD_BATCH_WITHDRAW_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_batch-submit_receipts.c b/src/donau/donau-httpd_batch-submit_receipts.c @@ -22,14 +22,14 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <jansson.h> #include <microhttpd.h> #include <pthread.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_batch-deposit.h" #include "taler-donau-httpd_responses.h" #include "taler_donaudb_lib.h" @@ -57,7 +57,7 @@ struct BatchDepositContext /** * Details about the batch deposit operation. */ - struct TALER_DONAUDB_BatchDeposit bd; + struct DONAUDB_BatchDeposit bd; /** * Additional details for policy extension relevant for this @@ -107,18 +107,18 @@ reply_batch_deposit_success ( struct MHD_Connection *connection, const struct BatchDepositContext *dc) { - const struct TALER_DONAUDB_BatchDeposit *bd = &dc->bd; + const struct DONAUDB_BatchDeposit *bd = &dc->bd; json_t *arr; - struct TALER_DonauPublicKeyP pub; + struct DONAU_DonauPublicKeyP pub; again: arr = json_array (); GNUNET_assert (NULL != arr); for (unsigned int i = 0; i<bd->num_cdis; i++) { - const struct TALER_DONAUDB_CoinDepositInformation *cdi + const struct DONAUDB_CoinDepositInformation *cdi = &bd->cdis[i]; - struct TALER_DonauPublicKeyP pubi; + struct DONAU_DonauPublicKeyP pubi; struct TALER_DonauSignatureP sig; enum TALER_ErrorCode ec; struct TALER_Amount amount_without_fee; @@ -199,7 +199,7 @@ batch_deposit_transaction (void *cls, MHD_RESULT *mhd_ret) { struct BatchDepositContext *dc = cls; - const struct TALER_DONAUDB_BatchDeposit *bd = &dc->bd; + const struct DONAUDB_BatchDeposit *bd = &dc->bd; enum GNUNET_DB_QueryStatus qs = GNUNET_SYSERR; uint32_t bad_balance_coin_index = UINT32_MAX; bool balance_ok; @@ -224,7 +224,7 @@ batch_deposit_transaction (void *cls, /* FIXME: replace by batch insert! */ for (unsigned int i = 0; i<bd->num_cdis; i++) { - const struct TALER_DONAUDB_CoinDepositInformation *cdi + const struct DONAUDB_CoinDepositInformation *cdi = &bd->cdis[i]; uint64_t known_coin_id; @@ -312,10 +312,10 @@ static enum GNUNET_GenericReturnValue parse_coin (struct MHD_Connection *connection, const struct BatchDepositContext *dc, json_t *jcoin, - struct TALER_DONAUDB_CoinDepositInformation *cdi, + struct DONAUDB_CoinDepositInformation *cdi, struct TALER_Amount *deposit_fee) { - const struct TALER_DONAUDB_BatchDeposit *bd = &dc->bd; + const struct DONAUDB_BatchDeposit *bd = &dc->bd; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount ("contribution", TEH_currency, @@ -501,7 +501,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, { struct MHD_Connection *connection = rc->connection; struct BatchDepositContext dc = { 0 }; - struct TALER_DONAUDB_BatchDeposit *bd = &dc.bd; + struct DONAUDB_BatchDeposit *bd = &dc.bd; const json_t *coins; bool no_refund_deadline = true; struct GNUNET_JSON_Specification spec[] = { @@ -592,8 +592,8 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, TALER_payto_hash (bd->receiver_wire_account, &bd->wire_target_h_payto); TALER_charity_wire_signature_hash (bd->receiver_wire_account, - &bd->wire_salt, - &dc.h_wire); + &bd->wire_salt, + &dc.h_wire); /* handle policy, if present */ if (NULL != dc.policy_json) @@ -635,7 +635,7 @@ TEH_handler_batch_deposit (struct TEH_RequestContext *rc, } { - struct TALER_DONAUDB_CoinDepositInformation cdis[ + struct DONAUDB_CoinDepositInformation cdis[ GNUNET_NZL (bd->num_cdis)]; struct TALER_Amount deposit_fees[GNUNET_NZL (bd->num_cdis)]; diff --git a/src/donau/donau-httpd_batch-submit_receipts.h b/src/donau/donau-httpd_batch-submit_receipts.h @@ -20,8 +20,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_BATCH_DEPOSIT_H -#define TALER_DONAU_HTTPD_BATCH_DEPOSIT_H +#ifndef DONAU_HTTPD_BATCH_DEPOSIT_H +#define DONAU_HTTPD_BATCH_DEPOSIT_H #include <gnunet/gnunet_util_lib.h> #include <microhttpd.h> diff --git a/src/donau/donau-httpd_charities_close.c b/src/donau/donau-httpd_charities_close.c @@ -20,12 +20,12 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include "taler_kyclogic_lib.h" -#include "taler_mhd_lib.h" -#include "taler_json_lib.h" +#include "taler/taler_mhd_lib.h" +#include "taler/taler_json_lib.h" #include "taler_dbevents.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_reserves_close.h" @@ -83,7 +83,7 @@ struct ReserveCloseContext /** * KYC status for the request. */ - struct TALER_DONAUDB_KycStatus kyc; + struct DONAUDB_KycStatus kyc; /** * Hash of the payto-URI that was used for the KYC decision. @@ -134,7 +134,7 @@ reply_reserve_close_success (struct MHD_Connection *connection, static void amount_it (void *cls, struct GNUNET_TIME_Absolute limit, - TALER_DONAUDB_KycAmountCallback cb, + DONAUDB_KycAmountCallback cb, void *cb_cls) { struct ReserveCloseContext *rcc = cls; diff --git a/src/donau/donau-httpd_charities_close.h b/src/donau/donau-httpd_charities_close.h @@ -18,8 +18,8 @@ * @brief Handle /reserves/$RESERVE_PUB/close requests * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_RESERVES_CLOSE_H -#define TALER_DONAU_HTTPD_RESERVES_CLOSE_H +#ifndef DONAU_HTTPD_RESERVES_CLOSE_H +#define DONAU_HTTPD_RESERVES_CLOSE_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_charities_get.c b/src/donau/donau-httpd_charities_get.c @@ -20,11 +20,11 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> -#include "taler_mhd_lib.h" -#include "taler_json_lib.h" +#include "taler/taler_mhd_lib.h" +#include "taler/taler_json_lib.h" #include "taler_dbevents.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_reserves_get.h" diff --git a/src/donau/donau-httpd_charities_get.h b/src/donau/donau-httpd_charities_get.h @@ -20,8 +20,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_RESERVES_GET_H -#define TALER_DONAU_HTTPD_RESERVES_GET_H +#ifndef DONAU_HTTPD_RESERVES_GET_H +#define DONAU_HTTPD_RESERVES_GET_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_charities_history.c b/src/donau/donau-httpd_charities_history.c @@ -20,11 +20,11 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> -#include "taler_mhd_lib.h" -#include "taler_json_lib.h" +#include "taler/taler_mhd_lib.h" +#include "taler/taler_json_lib.h" #include "taler_dbevents.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_reserves_history.h" @@ -62,7 +62,7 @@ struct ReserveHistoryContext /** * History of the reserve, set in the callback. */ - struct TALER_DONAUDB_ReserveHistory *rh; + struct DONAUDB_ReserveHistory *rh; /** * Global fees applying to the request. @@ -87,7 +87,7 @@ static MHD_RESULT reply_reserve_history_success (struct MHD_Connection *connection, const struct ReserveHistoryContext *rhc) { - const struct TALER_DONAUDB_ReserveHistory *rh = rhc->rh; + const struct DONAUDB_ReserveHistory *rh = rhc->rh; json_t *json_history; json_history = TEH_RESPONSE_compile_reserve_history (rh); diff --git a/src/donau/donau-httpd_charities_history.h b/src/donau/donau-httpd_charities_history.h @@ -19,8 +19,8 @@ * @author Florian Dold * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_RESERVES_HISTORY_H -#define TALER_DONAU_HTTPD_RESERVES_HISTORY_H +#ifndef DONAU_HTTPD_RESERVES_HISTORY_H +#define DONAU_HTTPD_RESERVES_HISTORY_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_charities_open.c b/src/donau/donau-httpd_charities_open.c @@ -18,11 +18,11 @@ * @brief Handle /reserves/$RESERVE_PUB/open requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> -#include "taler_mhd_lib.h" -#include "taler_json_lib.h" +#include "taler/taler_mhd_lib.h" +#include "taler/taler_json_lib.h" #include "taler_dbevents.h" #include "taler-donau-httpd_common_deposit.h" #include "taler-donau-httpd_keys.h" diff --git a/src/donau/donau-httpd_charities_open.h b/src/donau/donau-httpd_charities_open.h @@ -18,8 +18,8 @@ * @brief Handle /reserves/$RESERVE_PUB/open requests * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_RESERVES_OPEN_H -#define TALER_DONAU_HTTPD_RESERVES_OPEN_H +#ifndef DONAU_HTTPD_RESERVES_OPEN_H +#define DONAU_HTTPD_RESERVES_OPEN_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_charities_status.c b/src/donau/donau-httpd_charities_status.c @@ -20,11 +20,11 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> -#include "taler_mhd_lib.h" -#include "taler_json_lib.h" +#include "taler/taler_mhd_lib.h" +#include "taler/taler_json_lib.h" #include "taler_dbevents.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_reserves_status.h" @@ -51,7 +51,7 @@ struct ReserveStatusContext /** * History of the reserve, set in the callback. */ - struct TALER_DONAUDB_ReserveHistory *rh; + struct DONAUDB_ReserveHistory *rh; /** * Sum of incoming transactions within the returned history. @@ -83,7 +83,7 @@ static MHD_RESULT reply_reserve_status_success (struct MHD_Connection *connection, const struct ReserveStatusContext *rhc) { - const struct TALER_DONAUDB_ReserveHistory *rh = rhc->rh; + const struct DONAUDB_ReserveHistory *rh = rhc->rh; json_t *json_history; json_history = TEH_RESPONSE_compile_reserve_history (rh); diff --git a/src/donau/donau-httpd_charities_status.h b/src/donau/donau-httpd_charities_status.h @@ -20,8 +20,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_RESERVES_STATUS_H -#define TALER_DONAU_HTTPD_RESERVES_STATUS_H +#ifndef DONAU_HTTPD_RESERVES_STATUS_H +#define DONAU_HTTPD_RESERVES_STATUS_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_common_submit_receipts.c b/src/donau/donau-httpd_common_submit_receipts.c @@ -18,7 +18,7 @@ * @brief shared logic for handling deposited coins * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include "taler-donau-httpd_common_deposit.h" #include "taler-donau-httpd.h" #include "taler-donau-httpd_keys.h" diff --git a/src/donau/donau-httpd_common_submit_receipts.h b/src/donau/donau-httpd_common_submit_receipts.h @@ -18,15 +18,15 @@ * @brief shared logic for handling deposited coins * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_COMMON_DEPOSIT_H -#define TALER_DONAU_HTTPD_COMMON_DEPOSIT_H +#ifndef DONAU_HTTPD_COMMON_DEPOSIT_H +#define DONAU_HTTPD_COMMON_DEPOSIT_H #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <jansson.h> #include <microhttpd.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" /** diff --git a/src/donau/donau-httpd_config.c b/src/donau/donau-httpd_config.c @@ -18,13 +18,13 @@ * @brief Handle /config requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_json_lib.h> #include "taler_dbevents.h" #include "taler-donau-httpd_config.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_kyclogic_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_mhd_lib.h" #include <jansson.h> diff --git a/src/donau/donau-httpd_config.h b/src/donau/donau-httpd_config.h @@ -18,8 +18,8 @@ * @brief headers for /config handler * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_CONFIG_H -#define TALER_DONAU_HTTPD_CONFIG_H +#ifndef DONAU_HTTPD_CONFIG_H +#define DONAU_HTTPD_CONFIG_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_csr.c b/src/donau/donau-httpd_csr.c @@ -22,11 +22,11 @@ * @author Lucien Heuzeveldt * @author Gian Demarmles */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_csr.h" #include "taler-donau-httpd_responses.h" #include "taler-donau-httpd_keys.h" @@ -203,7 +203,7 @@ TEH_handler_csr_melt (struct TEH_RequestContext *rc, csr_obj = GNUNET_JSON_PACK ( TALER_JSON_pack_donau_withdraw_values ("ewv", - &ewvs[i])); + &ewvs[i])); GNUNET_assert (NULL != csr_obj); GNUNET_assert (0 == json_array_append_new (csr_response_ewvs, @@ -333,7 +333,7 @@ TEH_handler_csr_withdraw (struct TEH_RequestContext *rc, rc->connection, MHD_HTTP_OK, TALER_JSON_pack_donau_withdraw_values ("ewv", - &ewv)); + &ewv)); } diff --git a/src/donau/donau-httpd_csr.h b/src/donau/donau-httpd_csr.h @@ -19,8 +19,8 @@ * @author Lucien Heuzeveldt * @author Gian Demarmles */ -#ifndef TALER_DONAU_HTTPD_CSR_H -#define TALER_DONAU_HTTPD_CSR_H +#ifndef DONAU_HTTPD_CSR_H +#define DONAU_HTTPD_CSR_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_db.c b/src/donau/donau-httpd_db.c @@ -18,12 +18,12 @@ * @brief Generic database operations for the donau. * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <pthread.h> #include <jansson.h> #include <gnunet/gnunet_json_lib.h> -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler_donaudb_lib.h" #include "taler-donau-httpd_db.h" #include "taler-donau-httpd_responses.h" @@ -35,7 +35,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, uint64_t *known_coin_id, MHD_RESULT *mhd_ret) { - enum TALER_DONAUDB_CoinKnownStatus cks; + enum DONAUDB_CoinKnownStatus cks; struct TALER_DenominationHashP h_denom_pub; struct TALER_AgeCommitmentHash age_hash; @@ -47,20 +47,20 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, &age_hash); switch (cks) { - case TALER_DONAUDB_CKS_ADDED: + case DONAUDB_CKS_ADDED: return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; - case TALER_DONAUDB_CKS_PRESENT: + case DONAUDB_CKS_PRESENT: return GNUNET_DB_STATUS_SUCCESS_NO_RESULTS; - case TALER_DONAUDB_CKS_SOFT_FAIL: + case DONAUDB_CKS_SOFT_FAIL: return GNUNET_DB_STATUS_SOFT_ERROR; - case TALER_DONAUDB_CKS_HARD_FAIL: + case DONAUDB_CKS_HARD_FAIL: *mhd_ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_DB_STORE_FAILED, NULL); return GNUNET_DB_STATUS_HARD_ERROR; - case TALER_DONAUDB_CKS_DENOM_CONFLICT: + case DONAUDB_CKS_DENOM_CONFLICT: /* FIXME: insufficient_funds != denom conflict! See issue #7267, need new * strategy for evidence gathering */ *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds ( @@ -69,7 +69,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin, &h_denom_pub, &coin->coin_pub); return GNUNET_DB_STATUS_HARD_ERROR; - case TALER_DONAUDB_CKS_AGE_CONFLICT: + case DONAUDB_CKS_AGE_CONFLICT: /* FIXME: insufficient_funds != Age conflict! See issue #7267, need new * strategy for evidence gathering */ *mhd_ret = TEH_RESPONSE_reply_coin_insufficient_funds ( diff --git a/src/donau/donau-httpd_db.h b/src/donau/donau-httpd_db.h @@ -18,12 +18,12 @@ * @brief High-level (transactional-layer) database operations for the donau * @author Chrisitan Grothoff */ -#ifndef TALER_DONAU_HTTPD_DB_H -#define TALER_DONAU_HTTPD_DB_H +#ifndef DONAU_HTTPD_DB_H +#define DONAU_HTTPD_DB_H #include <microhttpd.h> -#include "taler_donaudb_plugin.h" -#include "taler-donau-httpd_metrics.h" +#include "donaudb_plugin.h" +// #include "taler-donau-httpd_metrics.h" #include <gnunet/gnunet_mhd_compat.h> @@ -103,4 +103,4 @@ TEH_DB_run_transaction (struct MHD_Connection *connection, #endif -/* TALER_DONAU_HTTPD_DB_H */ +/* DONAU_HTTPD_DB_H */ diff --git a/src/donau/donau-httpd_issue_receipts.c b/src/donau/donau-httpd_issue_receipts.c @@ -23,13 +23,13 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include "taler-donau-httpd.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_kyclogic_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_withdraw.h" #include "taler-donau-httpd_responses.h" #include "taler-donau-httpd_keys.h" @@ -54,12 +54,12 @@ struct WithdrawContext /** * Set to the resulting signed coin data to be returned to the client. */ - struct TALER_DONAUDB_CollectableBlindcoin collectable; + struct DONAUDB_CollectableBlindcoin collectable; /** * KYC status for the operation. */ - struct TALER_DONAUDB_KycStatus kyc; + struct DONAUDB_KycStatus kyc; /** * Hash of the payto-URI representing the account @@ -98,7 +98,7 @@ struct WithdrawContext static void withdraw_amount_cb (void *cls, struct GNUNET_TIME_Absolute limit, - TALER_DONAUDB_KycAmountCallback cb, + DONAUDB_KycAmountCallback cb, void *cb_cls) { struct WithdrawContext *wc = cls; diff --git a/src/donau/donau-httpd_issue_receipts.h b/src/donau/donau-httpd_issue_receipts.h @@ -20,8 +20,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_WITHDRAW_H -#define TALER_DONAU_HTTPD_WITHDRAW_H +#ifndef DONAU_HTTPD_WITHDRAW_H +#define DONAU_HTTPD_WITHDRAW_H #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c @@ -19,17 +19,17 @@ * @author Christian Grothoff * @author Özgür Kesim */ -#include "platform.h" -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler_kyclogic_lib.h" #include "taler_dbevents.h" #include "taler-donau-httpd.h" #include "taler-donau-httpd_config.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_responses.h" -#include "taler_donaudb_plugin.h" -#include "taler_extensions.h" +#include "donaudb_plugin.h" +#include "taler/taler_extensions.h" /** @@ -151,7 +151,7 @@ struct HelperSignkey /** * The public key. */ - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; /** * Signature over this key from the security module's key. @@ -253,12 +253,12 @@ struct SigningKey /** * The donau's (online signing) public key. */ - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; /** * Meta data about the signing key, such as validity periods. */ - struct TALER_DONAUDB_SignkeyMetaData meta; + struct DONAUDB_SignkeyMetaData meta; /** * The long-term offline master key's signature for this signing key. @@ -1639,7 +1639,7 @@ helper_esign_cb ( void *cls, struct GNUNET_TIME_Timestamp start_time, struct GNUNET_TIME_Relative validity_duration, - const struct TALER_DonauPublicKeyP *donau_pub, + const struct DONAU_DonauPublicKeyP *donau_pub, const struct TALER_SecurityModulePublicKeyP *sm_pub, const struct TALER_SecurityModuleSignatureP *sm_sig) { @@ -1951,7 +1951,7 @@ denomination_info_cb ( void *cls, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_DenominationHashP *h_denom_pub, - const struct TALER_DONAUDB_DenominationKeyMetaData *meta, + const struct DONAUDB_DenominationKeyMetaData *meta, const struct TALER_MasterSignatureP *master_sig, bool recoup_possible) { @@ -2015,8 +2015,8 @@ denomination_info_cb ( static void signkey_info_cb ( void *cls, - const struct TALER_DonauPublicKeyP *donau_pub, - const struct TALER_DONAUDB_SignkeyMetaData *meta, + const struct DONAU_DonauPublicKeyP *donau_pub, + const struct DONAUDB_SignkeyMetaData *meta, const struct TALER_MasterSignatureP *master_sig) { struct TEH_KeyStateHandle *ksh = cls; @@ -2428,9 +2428,9 @@ create_krd (struct TEH_KeyStateHandle *ksh, const struct GNUNET_HashCode *h_grouped) { struct KeysResponseData krd; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_DonauSignatureP donau_sig; - struct TALER_DonauPublicKeyP grouped_donau_pub; + struct DONAU_DonauPublicKeyP grouped_donau_pub; struct TALER_DonauSignatureP grouped_donau_sig; struct WireStateHandle *wsh; json_t *keys; @@ -3762,7 +3762,7 @@ TEH_keys_denomination_revoke (const struct TALER_DenominationHashP *h_denom_pub) enum TALER_ErrorCode TEH_keys_donau_sign_ ( const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct TALER_DonauPublicKeyP *pub, + struct DONAU_DonauPublicKeyP *pub, struct TALER_DonauSignatureP *sig) { struct TEH_KeyStateHandle *ksh; @@ -3777,9 +3777,9 @@ TEH_keys_donau_sign_ ( return TALER_EC_DONAU_GENERIC_KEYS_MISSING; } return TEH_keys_donau_sign2_ (ksh, - purpose, - pub, - sig); + purpose, + pub, + sig); } @@ -3787,7 +3787,7 @@ enum TALER_ErrorCode TEH_keys_donau_sign2_ ( void *cls, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct TALER_DonauPublicKeyP *pub, + struct DONAU_DonauPublicKeyP *pub, struct TALER_DonauSignatureP *sig) { struct TEH_KeyStateHandle *ksh = cls; @@ -3828,7 +3828,7 @@ TEH_keys_donau_sign2_ ( void -TEH_keys_donau_revoke (const struct TALER_DonauPublicKeyP *donau_pub) +TEH_keys_donau_revoke (const struct DONAU_DonauPublicKeyP *donau_pub) { struct TEH_KeyStateHandle *ksh; @@ -4012,7 +4012,7 @@ TEH_keys_get_handler (struct TEH_RequestContext *rc, */ static enum GNUNET_GenericReturnValue load_extension_data (const char *section_name, - struct TALER_DONAUDB_DenominationKeyMetaData *meta) + struct DONAUDB_DenominationKeyMetaData *meta) { struct GNUNET_TIME_Relative deposit_duration; struct GNUNET_TIME_Relative legal_duration; @@ -4083,7 +4083,7 @@ enum GNUNET_GenericReturnValue TEH_keys_load_fees (struct TEH_KeyStateHandle *ksh, const struct TALER_DenominationHashP *h_denom_pub, struct TALER_DenominationPublicKey *denom_pub, - struct TALER_DONAUDB_DenominationKeyMetaData *meta) + struct DONAUDB_DenominationKeyMetaData *meta) { struct HelperDenomination *hd; enum GNUNET_GenericReturnValue ok; @@ -4123,8 +4123,8 @@ TEH_keys_load_fees (struct TEH_KeyStateHandle *ksh, enum GNUNET_GenericReturnValue -TEH_keys_get_timing (const struct TALER_DonauPublicKeyP *donau_pub, - struct TALER_DONAUDB_SignkeyMetaData *meta) +TEH_keys_get_timing (const struct DONAU_DonauPublicKeyP *donau_pub, + struct DONAUDB_SignkeyMetaData *meta) { struct TEH_KeyStateHandle *ksh; struct HelperSignkey *hsk; @@ -4194,7 +4194,7 @@ add_future_denomkey_cb (void *cls, struct FutureBuilderContext *fbc = cls; struct HelperDenomination *hd = value; struct TEH_DenominationKey *dk; - struct TALER_DONAUDB_DenominationKeyMetaData meta = {0}; + struct DONAUDB_DenominationKeyMetaData meta = {0}; dk = GNUNET_CONTAINER_multihashmap_get (fbc->ksh->denomkey_map, h_denom_pub); diff --git a/src/donau/donau-httpd_keys.h b/src/donau/donau-httpd_keys.h @@ -18,14 +18,14 @@ * @brief management of our various keys * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_responses.h" -#ifndef TALER_DONAU_HTTPD_KEYS_H -#define TALER_DONAU_HTTPD_KEYS_H +#ifndef DONAU_HTTPD_KEYS_H +#define DONAU_HTTPD_KEYS_H /** * Signatures of an auditor over a denomination key of this donau. @@ -55,7 +55,7 @@ struct TEH_DenominationKey * Meta data about the type of the denomination, such as fees and validity * periods. */ - struct TALER_DONAUDB_DenominationKeyMetaData meta; + struct DONAUDB_DenominationKeyMetaData meta; /** * The long-term offline master key's signature for this denomination. @@ -430,7 +430,7 @@ TEH_resume_keys_requests (bool do_shutdown); enum TALER_ErrorCode TEH_keys_donau_sign_ ( const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct TALER_DonauPublicKeyP *pub, + struct DONAU_DonauPublicKeyP *pub, struct TALER_DonauSignatureP *sig); @@ -452,7 +452,7 @@ enum TALER_ErrorCode TEH_keys_donau_sign2_ ( void *cls, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, - struct TALER_DonauPublicKeyP *pub, + struct DONAU_DonauPublicKeyP *pub, struct TALER_DonauSignatureP *sig); @@ -478,8 +478,8 @@ TEH_keys_donau_sign2_ ( GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ TEH_keys_donau_sign_ (&(ps)->purpose, \ - pub, \ - sig); \ + pub, \ + sig); \ }) @@ -511,9 +511,9 @@ TEH_keys_donau_sign2_ ( GNUNET_static_assert (((void*) (ps)) == \ ((void*) &(ps)->purpose)); \ TEH_keys_donau_sign2_ (ksh, \ - &(ps)->purpose, \ - pub, \ - sig); \ + &(ps)->purpose, \ + pub, \ + sig); \ }) @@ -529,7 +529,7 @@ TEH_keys_donau_sign2_ ( * @param donau_pub key to revoke */ void -TEH_keys_donau_revoke (const struct TALER_DonauPublicKeyP *donau_pub); +TEH_keys_donau_revoke (const struct DONAU_DonauPublicKeyP *donau_pub); /** @@ -575,7 +575,7 @@ enum GNUNET_GenericReturnValue TEH_keys_load_fees (struct TEH_KeyStateHandle *ksh, const struct TALER_DenominationHashP *h_denom_pub, struct TALER_DenominationPublicKey *denom_pub, - struct TALER_DONAUDB_DenominationKeyMetaData *meta); + struct DONAUDB_DenominationKeyMetaData *meta); /** @@ -586,8 +586,8 @@ TEH_keys_load_fees (struct TEH_KeyStateHandle *ksh, * @return #GNUNET_OK on success */ enum GNUNET_GenericReturnValue -TEH_keys_get_timing (const struct TALER_DonauPublicKeyP *donau_pub, - struct TALER_DONAUDB_SignkeyMetaData *meta); +TEH_keys_get_timing (const struct DONAU_DonauPublicKeyP *donau_pub, + struct DONAUDB_SignkeyMetaData *meta); /** diff --git a/src/donau/donau-httpd_metrics.c b/src/donau/donau-httpd_metrics.c @@ -18,14 +18,14 @@ * @brief Handle /metrics requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_json_lib.h> #include "taler_dbevents.h" #include "taler-donau-httpd_responses.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_metrics.h" -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include <jansson.h> diff --git a/src/donau/donau-httpd_metrics.h b/src/donau/donau-httpd_metrics.h @@ -18,8 +18,8 @@ * @brief Handle /metrics requests * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_METRICS_H -#define TALER_DONAU_HTTPD_METRICS_H +#ifndef DONAU_HTTPD_METRICS_H +#define DONAU_HTTPD_METRICS_H #include <gnunet/gnunet_util_lib.h> #include <microhttpd.h> diff --git a/src/donau/donau-httpd_mhd.c b/src/donau/donau-httpd_mhd.c @@ -16,19 +16,19 @@ /** * @file taler-donau-httpd_mhd.c - * @brief helpers for MHD interaction; these are TALER_DONAU_handler_ functions + * @brief helpers for MHD interaction; these are DONAU_handler_ functions * that generate simple MHD replies that do not require any real operations * to be performed (error handling, static pages, etc.) * @author Florian Dold * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include <microhttpd.h> #include <pthread.h> -#include "taler_mhd_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_responses.h" #include "taler-donau-httpd.h" #include "taler-donau-httpd_mhd.h" diff --git a/src/donau/donau-httpd_mhd.h b/src/donau/donau-httpd_mhd.h @@ -21,8 +21,8 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_MHD_H -#define TALER_DONAU_HTTPD_MHD_H +#ifndef DONAU_HTTPD_MHD_H +#define DONAU_HTTPD_MHD_H #include <gnunet/gnunet_util_lib.h> #include <microhttpd.h> #include "taler-donau-httpd.h" diff --git a/src/donau/donau-httpd_responses.c b/src/donau/donau-httpd_responses.c @@ -22,13 +22,13 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <microhttpd.h> #include <zlib.h> #include "taler-donau-httpd_responses.h" #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_keys.h" @@ -42,7 +42,7 @@ json_t * TEH_RESPONSE_compile_transaction_history ( const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_DONAUDB_TransactionList *tl) + const struct DONAUDB_TransactionList *tl) { json_t *history; @@ -52,21 +52,21 @@ TEH_RESPONSE_compile_transaction_history ( GNUNET_break (0); /* out of memory!? */ return NULL; } - for (const struct TALER_DONAUDB_TransactionList *pos = tl; + for (const struct DONAUDB_TransactionList *pos = tl; NULL != pos; pos = pos->next) { switch (pos->type) { - case TALER_DONAUDB_TT_DEPOSIT: + case DONAUDB_TT_DEPOSIT: { - const struct TALER_DONAUDB_DepositListEntry *deposit = + const struct DONAUDB_DepositListEntry *deposit = pos->details.deposit; struct TALER_CharityWireHashP h_wire; TALER_charity_wire_signature_hash (deposit->receiver_wire_account, - &deposit->wire_salt, - &h_wire); + &deposit->wire_salt, + &h_wire); #if ENABLE_SANITY_CHECKS /* internal sanity check before we hand out a bogus sig... */ TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; @@ -131,9 +131,9 @@ TEH_RESPONSE_compile_transaction_history ( } break; } - case TALER_DONAUDB_TT_MELT: + case DONAUDB_TT_MELT: { - const struct TALER_DONAUDB_MeltListEntry *melt = + const struct DONAUDB_MeltListEntry *melt = pos->details.melt; const struct TALER_AgeCommitmentHash *phac = NULL; @@ -184,9 +184,9 @@ TEH_RESPONSE_compile_transaction_history ( } } break; - case TALER_DONAUDB_TT_REFUND: + case DONAUDB_TT_REFUND: { - const struct TALER_DONAUDB_RefundListEntry *refund = + const struct DONAUDB_RefundListEntry *refund = pos->details.refund; struct TALER_Amount value; @@ -240,11 +240,11 @@ TEH_RESPONSE_compile_transaction_history ( } } break; - case TALER_DONAUDB_TT_OLD_COIN_RECOUP: + case DONAUDB_TT_OLD_COIN_RECOUP: { - struct TALER_DONAUDB_RecoupRefreshListEntry *pr = + struct DONAUDB_RecoupRefreshListEntry *pr = pos->details.old_coin_recoup; - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; if (TALER_EC_NONE != @@ -289,11 +289,11 @@ TEH_RESPONSE_compile_transaction_history ( } break; } - case TALER_DONAUDB_TT_RECOUP: + case DONAUDB_TT_RECOUP: { - const struct TALER_DONAUDB_RecoupListEntry *recoup = + const struct DONAUDB_RecoupListEntry *recoup = pos->details.recoup; - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; if (TALER_EC_NONE != @@ -339,11 +339,11 @@ TEH_RESPONSE_compile_transaction_history ( } } break; - case TALER_DONAUDB_TT_RECOUP_REFRESH: + case DONAUDB_TT_RECOUP_REFRESH: { - struct TALER_DONAUDB_RecoupRefreshListEntry *pr = + struct DONAUDB_RecoupRefreshListEntry *pr = pos->details.recoup_refresh; - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; if (TALER_EC_NONE != @@ -393,9 +393,9 @@ TEH_RESPONSE_compile_transaction_history ( break; } - case TALER_DONAUDB_TT_PURSE_DEPOSIT: + case DONAUDB_TT_PURSE_DEPOSIT: { - struct TALER_DONAUDB_PurseDepositListEntry *pd + struct DONAUDB_PurseDepositListEntry *pd = pos->details.purse_deposit; const struct TALER_AgeCommitmentHash *phac = NULL; @@ -431,13 +431,13 @@ TEH_RESPONSE_compile_transaction_history ( break; } - case TALER_DONAUDB_TT_PURSE_REFUND: + case DONAUDB_TT_PURSE_REFUND: { - const struct TALER_DONAUDB_PurseRefundListEntry *prefund = + const struct DONAUDB_PurseRefundListEntry *prefund = pos->details.purse_refund; struct TALER_Amount value; enum TALER_ErrorCode ec; - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; if (0 > @@ -487,9 +487,9 @@ TEH_RESPONSE_compile_transaction_history ( } break; - case TALER_DONAUDB_TT_RESERVE_OPEN: + case DONAUDB_TT_RESERVE_OPEN: { - struct TALER_DONAUDB_ReserveOpenListEntry *role + struct DONAUDB_ReserveOpenListEntry *role = pos->details.reserve_open; if (0 != @@ -522,7 +522,7 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash ( struct MHD_Connection *connection, const struct TALER_DenominationHashP *dph) { - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; struct GNUNET_TIME_Timestamp now; enum TALER_ErrorCode ec; @@ -564,7 +564,7 @@ TEH_RESPONSE_reply_expired_denom_pub_hash ( enum TALER_ErrorCode ec, const char *oper) { - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; enum TALER_ErrorCode ecr; struct GNUNET_TIME_Timestamp now @@ -607,7 +607,7 @@ TEH_RESPONSE_reply_invalid_denom_cipher_for_operation ( struct MHD_Connection *connection, const struct TALER_DenominationHashP *dph) { - struct TALER_DonauPublicKeyP epub; + struct DONAU_DonauPublicKeyP epub; struct TALER_DonauSignatureP esig; struct GNUNET_TIME_Timestamp now; enum TALER_ErrorCode ec; @@ -650,7 +650,7 @@ TEH_RESPONSE_reply_coin_insufficient_funds ( const struct TALER_DenominationHashP *h_denom_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub) { - struct TALER_DONAUDB_TransactionList *tl; + struct DONAUDB_TransactionList *tl; enum GNUNET_DB_QueryStatus qs; json_t *history; @@ -705,21 +705,21 @@ TEH_RESPONSE_reply_coin_insufficient_funds ( json_t * TEH_RESPONSE_compile_reserve_history ( - const struct TALER_DONAUDB_ReserveHistory *rh) + const struct DONAUDB_ReserveHistory *rh) { json_t *json_history; json_history = json_array (); GNUNET_assert (NULL != json_history); - for (const struct TALER_DONAUDB_ReserveHistory *pos = rh; + for (const struct DONAUDB_ReserveHistory *pos = rh; NULL != pos; pos = pos->next) { switch (pos->type) { - case TALER_DONAUDB_RO_BANK_TO_DONAU: + case DONAUDB_RO_BANK_TO_DONAU: { - const struct TALER_DONAUDB_BankTransfer *bank = + const struct DONAUDB_BankTransfer *bank = pos->details.bank; if (0 != @@ -743,9 +743,9 @@ TEH_RESPONSE_compile_reserve_history ( } break; } - case TALER_DONAUDB_RO_WITHDRAW_COIN: + case DONAUDB_RO_WITHDRAW_COIN: { - const struct TALER_DONAUDB_CollectableBlindcoin *withdraw + const struct DONAUDB_CollectableBlindcoin *withdraw = pos->details.withdraw; if (0 != @@ -771,11 +771,11 @@ TEH_RESPONSE_compile_reserve_history ( } } break; - case TALER_DONAUDB_RO_RECOUP_COIN: + case DONAUDB_RO_RECOUP_COIN: { - const struct TALER_DONAUDB_Recoup *recoup + const struct DONAUDB_Recoup *recoup = pos->details.recoup; - struct TALER_DonauPublicKeyP pub; + struct DONAU_DonauPublicKeyP pub; struct TALER_DonauSignatureP sig; if (TALER_EC_NONE != @@ -816,11 +816,11 @@ TEH_RESPONSE_compile_reserve_history ( } } break; - case TALER_DONAUDB_RO_DONAU_TO_BANK: + case DONAUDB_RO_DONAU_TO_BANK: { - const struct TALER_DONAUDB_ClosingTransfer *closing = + const struct DONAUDB_ClosingTransfer *closing = pos->details.closing; - struct TALER_DonauPublicKeyP pub; + struct DONAU_DonauPublicKeyP pub; struct TALER_DonauSignatureP sig; if (TALER_EC_NONE != @@ -866,9 +866,9 @@ TEH_RESPONSE_compile_reserve_history ( } } break; - case TALER_DONAUDB_RO_PURSE_MERGE: + case DONAUDB_RO_PURSE_MERGE: { - const struct TALER_DONAUDB_PurseMerge *merge = + const struct DONAUDB_PurseMerge *merge = pos->details.merge; if (0 != @@ -906,9 +906,9 @@ TEH_RESPONSE_compile_reserve_history ( } } break; - case TALER_DONAUDB_RO_HISTORY_REQUEST: + case DONAUDB_RO_HISTORY_REQUEST: { - const struct TALER_DONAUDB_HistoryRequest *history = + const struct DONAUDB_HistoryRequest *history = pos->details.history; if (0 != @@ -931,9 +931,9 @@ TEH_RESPONSE_compile_reserve_history ( } break; - case TALER_DONAUDB_RO_OPEN_REQUEST: + case DONAUDB_RO_OPEN_REQUEST: { - const struct TALER_DONAUDB_OpenRequest *orq = + const struct DONAUDB_OpenRequest *orq = pos->details.open_request; if (0 != @@ -960,9 +960,9 @@ TEH_RESPONSE_compile_reserve_history ( } break; - case TALER_DONAUDB_RO_CLOSE_REQUEST: + case DONAUDB_RO_CLOSE_REQUEST: { - const struct TALER_DONAUDB_CloseRequest *crq = + const struct DONAUDB_CloseRequest *crq = pos->details.close_request; if (0 != @@ -1013,7 +1013,7 @@ reply_reserve_insufficient_funds ( enum TALER_ErrorCode ec, const struct TALER_Amount *ebalance, const struct TALER_Amount *withdraw_amount, - const struct TALER_DONAUDB_ReserveHistory *rh) + const struct DONAUDB_ReserveHistory *rh) { json_t *json_history; @@ -1047,7 +1047,7 @@ TEH_RESPONSE_reply_reserve_insufficient_balance ( const struct TALER_Amount *balance_required, const struct TALER_ReservePublicKeyP *reserve_pub) { - struct TALER_DONAUDB_ReserveHistory *rh = NULL; + struct DONAUDB_ReserveHistory *rh = NULL; struct TALER_Amount balance; enum GNUNET_DB_QueryStatus qs; MHD_RESULT mhd_ret; @@ -1111,7 +1111,7 @@ TEH_RESPONSE_reply_purse_created ( const struct TALER_Amount *purse_balance, const struct TEH_PurseDetails *pd) { - struct TALER_DonauPublicKeyP pub; + struct DONAU_DonauPublicKeyP pub; struct TALER_DonauSignatureP sig; enum TALER_ErrorCode ec; @@ -1149,7 +1149,7 @@ TEH_RESPONSE_reply_purse_created ( MHD_RESULT TEH_RESPONSE_reply_kyc_required (struct MHD_Connection *connection, const struct TALER_PaytoHashP *h_payto, - const struct TALER_DONAUDB_KycStatus *kyc) + const struct DONAUDB_KycStatus *kyc) { return TALER_MHD_REPLY_JSON_PACK ( connection, diff --git a/src/donau/donau-httpd_responses.h b/src/donau/donau-httpd_responses.h @@ -22,14 +22,14 @@ * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_RESPONSES_H -#define TALER_DONAU_HTTPD_RESPONSES_H +#ifndef DONAU_HTTPD_RESPONSES_H +#define DONAU_HTTPD_RESPONSES_H #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include <microhttpd.h> -#include "taler_error_codes.h" -#include "taler-donau-httpd.h" -#include "taler-donau-httpd_db.h" +#include "taler/taler_error_codes.h" +#include "donau-httpd.h" +#include "donau-httpd_db.h" #include <gnunet/gnunet_mhd_compat.h> @@ -41,7 +41,7 @@ */ json_t * TEH_RESPONSE_compile_reserve_history ( - const struct TALER_DONAUDB_ReserveHistory *rh); + const struct DONAUDB_ReserveHistory *rh); /** @@ -102,7 +102,7 @@ TEH_RESPONSE_reply_reserve_age_restriction_required ( MHD_RESULT TEH_RESPONSE_reply_kyc_required (struct MHD_Connection *connection, const struct TALER_PaytoHashP *h_payto, - const struct TALER_DONAUDB_KycStatus *kyc); + const struct DONAUDB_KycStatus *kyc); /** @@ -223,7 +223,7 @@ TEH_RESPONSE_reply_purse_created ( json_t * TEH_RESPONSE_compile_transaction_history ( const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_DONAUDB_TransactionList *tl); + const struct DONAUDB_TransactionList *tl); #endif diff --git a/src/donau/donau-httpd_submit_receipts_get.c b/src/donau/donau-httpd_submit_receipts_get.c @@ -18,14 +18,14 @@ * @brief Handle wire deposit tracking-related requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> #include <microhttpd.h> #include <pthread.h> #include "taler_dbevents.h" -#include "taler_json_lib.h" -#include "taler_mhd_lib.h" +#include "taler/taler_json_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler_signatures.h" #include "taler-donau-httpd_keys.h" #include "taler-donau-httpd_deposits_get.h" @@ -72,7 +72,7 @@ struct DepositWtidContext * The Charity's public key. The deposit inquiry request is to be * signed by the corresponding private key (using EdDSA). */ - struct TALER_CharityPublicKeyP charity; + struct DONAU_CharityPublicKeyP charity; /** * The coin's public key. This is the value that must have been @@ -88,7 +88,7 @@ struct DepositWtidContext /** * Signature by the charity. */ - struct TALER_CharitySignatureP charity_sig; + struct DONAU_CharitySignatureP charity_sig; /** @@ -120,7 +120,7 @@ struct DepositWtidContext /** * KYC status information for the receiving account. */ - struct TALER_DONAUDB_KycStatus kyc; + struct DONAUDB_KycStatus kyc; /** * AML status information for the receiving account. @@ -185,7 +185,7 @@ reply_deposit_details ( struct MHD_Connection *connection, const struct DepositWtidContext *ctx) { - struct TALER_DonauPublicKeyP pub; + struct DONAU_DonauPublicKeyP pub; struct TALER_DonauSignatureP sig; enum TALER_ErrorCode ec; @@ -498,10 +498,10 @@ TEH_handler_deposits_get (struct TEH_RequestContext *rc, { if (GNUNET_OK != TALER_charity_deposit_verify (&ctx->charity, - &ctx->coin_pub, - &ctx->h_contract_terms, - &ctx->h_wire, - &ctx->charity_sig)) + &ctx->coin_pub, + &ctx->h_contract_terms, + &ctx->h_wire, + &ctx->charity_sig)) { GNUNET_break_op (0); return TALER_MHD_reply_with_error (rc->connection, diff --git a/src/donau/donau-httpd_submit_receipts_get.h b/src/donau/donau-httpd_submit_receipts_get.h @@ -18,8 +18,8 @@ * @brief Handle wire transfer tracking-related requests * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_DEPOSITS_GET_H -#define TALER_DONAU_HTTPD_DEPOSITS_GET_H +#ifndef DONAU_HTTPD_DEPOSITS_GET_H +#define DONAU_HTTPD_DEPOSITS_GET_H #include <gnunet/gnunet_util_lib.h> #include <microhttpd.h> diff --git a/src/donau/donau-httpd_terms.c b/src/donau/donau-httpd_terms.c @@ -18,12 +18,12 @@ * @brief Handle /terms requests to return the terms of service * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <jansson.h> #include <microhttpd.h> -#include "taler_mhd_lib.h" +#include "taler/taler_mhd_lib.h" #include "taler-donau-httpd_responses.h" /** diff --git a/src/donau/donau-httpd_terms.h b/src/donau/donau-httpd_terms.h @@ -18,15 +18,15 @@ * @brief Handle /terms requests to return the terms of service * @author Christian Grothoff */ -#ifndef TALER_DONAU_HTTPD_TERMS_H -#define TALER_DONAU_HTTPD_TERMS_H -#include "platform.h" +#ifndef DONAU_HTTPD_TERMS_H +#define DONAU_HTTPD_TERMS_H +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <jansson.h> #include <microhttpd.h> -#include "taler_mhd_lib.h" -#include "taler-donau-httpd_responses.h" +#include "taler/taler_mhd_lib.h" +#include "donau-httpd_responses.h" /** diff --git a/src/donaudb/Makefile.am b/src/donaudb/Makefile.am @@ -53,7 +53,6 @@ check_SCRIPTS = \ EXTRA_DIST = \ donaudb.conf \ donaudb-postgres.conf \ - bench-db-postgres.conf \ test-donau-db-postgres.conf \ $(sqlinputs) \ $(sql_DATA) \ @@ -70,195 +69,14 @@ endif libtaler_plugin_donaudb_postgres_la_SOURCES = \ plugin_donaudb_common.c plugin_donaudb_common.h \ - pg_setup_wire_target.h pg_setup_wire_target.c \ - pg_compute_shard.h pg_compute_shard.c \ - plugin_donaudb_postgres.c pg_helper.h \ - pg_reserves_update.h pg_reserves_update.c \ - pg_select_aggregation_amounts_for_kyc_check.h pg_select_aggregation_amounts_for_kyc_check.c \ - pg_lookup_wire_fee_by_time.h pg_lookup_wire_fee_by_time.c \ - pg_select_satisfied_kyc_processes.h pg_select_satisfied_kyc_processes.c \ - pg_kyc_provider_account_lookup.h pg_kyc_provider_account_lookup.c \ - pg_lookup_kyc_requirement_by_row.h pg_lookup_kyc_requirement_by_row.c \ - pg_insert_kyc_requirement_for_account.h pg_insert_kyc_requirement_for_account.c \ - pg_lookup_kyc_process_by_account.h pg_lookup_kyc_process_by_account.c \ - pg_update_kyc_process_by_row.h pg_update_kyc_process_by_row.c \ - pg_insert_kyc_requirement_process.h pg_insert_kyc_requirement_process.c \ - pg_select_withdraw_amounts_for_kyc_check.h pg_select_withdraw_amounts_for_kyc_check.c \ - pg_select_merge_amounts_for_kyc_check.h pg_select_merge_amounts_for_kyc_check.c \ - pg_profit_drains_set_finished.h pg_profit_drains_set_finished.c \ - pg_profit_drains_get_pending.h pg_profit_drains_get_pending.c \ - pg_get_drain_profit.h pg_get_drain_profit.c \ - pg_get_purse_deposit.h pg_get_purse_deposit.c \ - pg_insert_contract.h pg_insert_contract.c \ - pg_select_aml_threshold.h pg_select_aml_threshold.c \ - pg_select_contract.h pg_select_contract.c \ - pg_select_purse_merge.h pg_select_purse_merge.c \ - pg_select_contract_by_purse.h pg_select_contract_by_purse.c \ - pg_insert_drain_profit.h pg_insert_drain_profit.c \ - pg_create_tables.h pg_create_tables.c \ - pg_event_listen.h pg_event_listen.c \ - pg_event_listen_cancel.h pg_event_listen_cancel.c \ - pg_event_notify.h pg_event_notify.c \ - pg_get_denomination_info.h pg_get_denomination_info.c \ - pg_iterate_denomination_info.h pg_iterate_denomination_info.c \ - pg_iterate_denominations.h pg_iterate_denominations.c \ - pg_iterate_active_auditors.h pg_iterate_active_auditors.c \ - pg_iterate_auditor_denominations.h pg_iterate_auditor_denominations.c \ - pg_reserves_get.h pg_reserves_get.c \ - pg_reserves_get_origin.h pg_reserves_get_origin.c \ - pg_drain_kyc_alert.h pg_drain_kyc_alert.c \ - pg_reserves_in_insert.h pg_reserves_in_insert.c \ - pg_get_withdraw_info.h pg_get_withdraw_info.c \ - pg_do_age_withdraw.h pg_do_age_withdraw.c \ - pg_get_age_withdraw.h pg_get_age_withdraw.c \ - pg_batch_ensure_coin_known.h pg_batch_ensure_coin_known.c \ - pg_do_batch_withdraw.h pg_do_batch_withdraw.c \ - pg_get_policy_details.h pg_get_policy_details.c \ - pg_persist_policy_details.h pg_persist_policy_details.c \ - pg_do_deposit.h pg_do_deposit.c \ - pg_add_policy_fulfillment_proof.h pg_add_policy_fulfillment_proof.c \ - pg_do_melt.h pg_do_melt.c \ - pg_do_refund.h pg_do_refund.c \ - pg_do_recoup.h pg_do_recoup.c \ - pg_do_recoup_refresh.h pg_do_recoup_refresh.c \ - pg_get_reserve_balance.h pg_get_reserve_balance.c \ - pg_count_known_coins.h pg_count_known_coins.c \ - pg_ensure_coin_known.h pg_ensure_coin_known.c \ - pg_get_known_coin.h pg_get_known_coin.c \ - pg_get_coin_denomination.h pg_get_coin_denomination.c \ - pg_have_deposit2.h pg_have_deposit2.c \ - pg_aggregate.h pg_aggregate.c \ - pg_create_aggregation_transient.h pg_create_aggregation_transient.c \ - pg_insert_kyc_attributes.h pg_insert_kyc_attributes.c \ - pg_select_similar_kyc_attributes.h pg_select_similar_kyc_attributes.c \ - pg_select_kyc_attributes.h pg_select_kyc_attributes.c \ - pg_insert_aml_officer.h pg_insert_aml_officer.c \ - pg_test_aml_officer.h pg_test_aml_officer.c \ - pg_lookup_aml_officer.h pg_lookup_aml_officer.c \ - pg_trigger_aml_process.h pg_trigger_aml_process.c \ - pg_select_aml_process.h pg_select_aml_process.c \ - pg_select_aml_history.h pg_select_aml_history.c \ - pg_insert_aml_decision.h pg_insert_aml_decision.c \ - pg_select_aggregation_transient.h pg_select_aggregation_transient.c \ - pg_find_aggregation_transient.h pg_find_aggregation_transient.c \ - pg_update_aggregation_transient.h pg_update_aggregation_transient.c \ - pg_get_ready_deposit.h pg_get_ready_deposit.c \ - pg_insert_refund.h pg_insert_refund.c \ - pg_select_refunds_by_coin.h pg_select_refunds_by_coin.c \ - pg_get_melt.h pg_get_melt.c \ - pg_insert_refresh_reveal.h pg_insert_refresh_reveal.c \ - pg_get_refresh_reveal.h pg_get_refresh_reveal.c \ - pg_lookup_wire_transfer.h pg_lookup_wire_transfer.c \ - pg_lookup_transfer_by_deposit.h pg_lookup_transfer_by_deposit.c \ - pg_insert_wire_fee.h pg_insert_wire_fee.c \ - pg_insert_global_fee.h pg_insert_global_fee.c \ - pg_get_wire_fee.h pg_get_wire_fee.c \ - pg_get_global_fee.h pg_get_global_fee.c \ - pg_get_global_fees.h pg_get_global_fees.c \ - pg_insert_reserve_closed.h pg_insert_reserve_closed.c \ - pg_wire_prepare_data_insert.h pg_wire_prepare_data_insert.c \ - pg_wire_prepare_data_mark_finished.h pg_wire_prepare_data_mark_finished.c \ - pg_wire_prepare_data_mark_failed.h pg_wire_prepare_data_mark_failed.c \ - pg_wire_prepare_data_get.h pg_wire_prepare_data_get.c \ - pg_start_deferred_wire_out.h pg_start_deferred_wire_out.c \ - pg_store_wire_transfer_out.h pg_store_wire_transfer_out.c \ - pg_gc.h pg_gc.c \ - pg_select_coin_deposits_above_serial_id.h pg_select_coin_deposits_above_serial_id.c \ - pg_select_history_requests_above_serial_id.h pg_select_history_requests_above_serial_id.c \ - pg_select_purse_decisions_above_serial_id.h pg_select_purse_decisions_above_serial_id.c \ - pg_select_purse_deposits_by_purse.h pg_select_purse_deposits_by_purse.c \ - pg_select_refreshes_above_serial_id.h pg_select_refreshes_above_serial_id.c \ - pg_select_refunds_above_serial_id.h pg_select_refunds_above_serial_id.c \ - pg_select_reserves_in_above_serial_id.h pg_select_reserves_in_above_serial_id.c \ - pg_select_reserves_in_above_serial_id_by_account.h pg_select_reserves_in_above_serial_id_by_account.c \ - pg_select_withdrawals_above_serial_id.h pg_select_withdrawals_above_serial_id.c \ - pg_select_wire_out_above_serial_id.h pg_select_wire_out_above_serial_id.c \ - pg_select_wire_out_above_serial_id_by_account.h pg_select_wire_out_above_serial_id_by_account.c \ - pg_select_recoup_above_serial_id.h pg_select_recoup_above_serial_id.c \ - pg_select_recoup_refresh_above_serial_id.h pg_select_recoup_refresh_above_serial_id.c \ - pg_get_reserve_by_h_blind.h pg_get_reserve_by_h_blind.c \ - pg_get_old_coin_by_h_blind.h pg_get_old_coin_by_h_blind.c \ - pg_insert_denomination_revocation.h pg_insert_denomination_revocation.c \ - pg_get_denomination_revocation.h pg_get_denomination_revocation.c \ - pg_select_batch_deposits_missing_wire.h pg_select_batch_deposits_missing_wire.c \ - pg_lookup_auditor_timestamp.h pg_lookup_auditor_timestamp.c \ - pg_lookup_auditor_status.h pg_lookup_auditor_status.c \ - pg_insert_auditor.h pg_insert_auditor.c \ - pg_lookup_wire_timestamp.h pg_lookup_wire_timestamp.c \ - pg_insert_wire.h pg_insert_wire.c \ - pg_update_wire.h pg_update_wire.c \ - pg_get_wire_accounts.h pg_get_wire_accounts.c \ - pg_get_wire_fees.h pg_get_wire_fees.c \ - pg_insert_signkey_revocation.h pg_insert_signkey_revocation.c \ - pg_lookup_signkey_revocation.h pg_lookup_signkey_revocation.c \ - pg_lookup_denomination_key.h pg_lookup_denomination_key.c \ - pg_insert_auditor_denom_sig.h pg_insert_auditor_denom_sig.c \ - pg_select_auditor_denom_sig.h pg_select_auditor_denom_sig.c \ - pg_add_denomination_key.h pg_add_denomination_key.c \ - pg_lookup_signing_key.h pg_lookup_signing_key.c \ - pg_begin_shard.h pg_begin_shard.c \ - pg_abort_shard.h pg_abort_shard.c \ - pg_complete_shard.h pg_complete_shard.c \ - pg_release_revolving_shard.h pg_release_revolving_shard.c \ - pg_delete_shard_locks.h pg_delete_shard_locks.c \ - pg_set_extension_manifest.h pg_set_extension_manifest.c \ - pg_insert_partner.h pg_insert_partner.c \ - pg_expire_purse.h pg_expire_purse.c \ - pg_select_purse_by_merge_pub.h pg_select_purse_by_merge_pub.c \ - pg_set_purse_balance.h pg_set_purse_balance.c \ - pg_do_reserve_purse.h pg_do_reserve_purse.c \ - pg_lookup_global_fee_by_time.h pg_lookup_global_fee_by_time.c \ - pg_do_purse_deposit.h pg_do_purse_deposit.c \ - pg_activate_signing_key.h pg_activate_signing_key.c \ - pg_update_auditor.h pg_update_auditor.c \ - pg_begin_revolving_shard.h pg_begin_revolving_shard.c \ - pg_get_extension_manifest.h pg_get_extension_manifest.c \ - pg_insert_history_request.h pg_insert_history_request.c \ - pg_do_purse_merge.h pg_do_purse_merge.c \ - pg_start_read_committed.h pg_start_read_committed.c \ - pg_start_read_only.h pg_start_read_only.c \ - pg_insert_denomination_info.h pg_insert_denomination_info.c \ - pg_do_batch_withdraw_insert.h pg_do_batch_withdraw_insert.c \ - pg_do_reserve_open.c pg_do_reserve_open.h \ - pg_do_purse_delete.c pg_do_purse_delete.h \ - pg_do_withdraw.h pg_do_withdraw.c \ - pg_preflight.h pg_preflight.c \ - pg_iterate_active_signkeys.h pg_iterate_active_signkeys.c \ - pg_commit.h pg_commit.c \ - pg_get_coin_transactions.c pg_get_coin_transactions.h \ - pg_get_expired_reserves.c pg_get_expired_reserves.h \ - pg_start.h pg_start.c \ - pg_rollback.h pg_rollback.c \ - pg_get_purse_request.c pg_get_purse_request.h \ - pg_get_reserve_history.c pg_get_reserve_history.h \ - pg_get_unfinished_close_requests.c pg_get_unfinished_close_requests.h \ - pg_insert_close_request.c pg_insert_close_request.h \ - pg_delete_aggregation_transient.h pg_delete_aggregation_transient.c \ - pg_get_link_data.h pg_get_link_data.c \ - pg_drop_tables.h pg_drop_tables.c \ - pg_insert_purse_request.h pg_insert_purse_request.c \ - pg_insert_records_by_table.c pg_insert_records_by_table.h \ - pg_insert_reserve_open_deposit.c pg_insert_reserve_open_deposit.h \ - pg_iterate_kyc_reference.c pg_iterate_kyc_reference.h \ - pg_iterate_reserve_close_info.c pg_iterate_reserve_close_info.h \ - pg_lookup_records_by_table.c pg_lookup_records_by_table.h \ - pg_lookup_serial_by_table.c pg_lookup_serial_by_table.h \ - pg_select_reserve_close_info.c pg_select_reserve_close_info.h \ - pg_select_reserve_closed_above_serial_id.c pg_select_reserve_closed_above_serial_id.h \ - pg_select_purse.h pg_select_purse.c \ - pg_select_purse_requests_above_serial_id.h pg_select_purse_requests_above_serial_id.c \ - pg_select_purse_merges_above_serial_id.h pg_select_purse_merges_above_serial_id.c \ - pg_select_purse_deposits_above_serial_id.h pg_select_purse_deposits_above_serial_id.c \ - pg_select_account_merges_above_serial_id.h pg_select_account_merges_above_serial_id.c \ - pg_select_all_purse_decisions_above_serial_id.h pg_select_all_purse_decisions_above_serial_id.c \ - pg_select_reserve_open_above_serial_id.c pg_select_reserve_open_above_serial_id.h + plugin_donaudb_postgres.c pg_helper.h libtaler_plugin_donaudb_postgres_la_LIBADD = \ $(LTLIBINTL) libtaler_plugin_donaudb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) \ $(top_builddir)/src/pq/libtalerpq.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lpq \ -lpthread \ -lgnunetpq \ @@ -270,12 +88,10 @@ lib_LTLIBRARIES = \ libtalerdonaudb.la libtalerdonaudb_la_SOURCES = \ - donaudb_accounts.c \ donaudb_plugin.c \ donaudb_transactions.c libtalerdonaudb_la_LIBADD = \ - $(top_builddir)/src/bank-lib/libtalerbank.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lgnunetutil \ $(XLIB) libtalerdonaudb_la_LDFLAGS = \ @@ -287,13 +103,6 @@ libtalerdonaudb_la_LDFLAGS = \ check_PROGRAMS = \ test-donaudb-postgres -noinst_PROGRAMS = \ - bench-db-postgres\ - perf_get_link_data-postgres\ - perf_select_refunds_by_coin-postgres\ - perf_reserves_in_insert-postgres \ - perf_deposits_get_ready-postgres - AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; TESTS = \ $(check_SCRIPTS) \ @@ -304,29 +113,19 @@ test_donaudb_postgres_SOURCES = \ test_donaudb_postgres_LDADD = \ libtalerdonaudb.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/pq/libtalerpq.la \ -ljansson \ -lgnunetjson \ -lgnunetutil \ $(XLIB) -bench_db_postgres_SOURCES = \ - bench_db.c -bench_db_postgres_LDADD = \ - libtalerdonaudb.la \ - $(top_builddir)/src/util/libtalerutil.la \ - $(top_builddir)/src/pq/libtalerpq.la \ - -lgnunetpq \ - -lgnunetutil \ - $(XLIB) - perf_reserves_in_insert_postgres_SOURCES = \ perf_reserves_in_insert.c perf_reserves_in_insert_postgres_LDADD = \ libtalerdonaudb.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/pq/libtalerpq.la \ -ljansson \ -lgnunetjson \ @@ -339,7 +138,7 @@ perf_select_refunds_by_coin_postgres_SOURCES = \ perf_select_refunds_by_coin_postgres_LDADD = \ libtalerdonaudb.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/pq/libtalerpq.la \ -ljansson \ -lgnunetjson \ @@ -352,7 +151,7 @@ perf_get_link_data_postgres_SOURCES = \ perf_get_link_data_postgres_LDADD = \ libtalerdonaudb.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/pq/libtalerpq.la \ -ljansson \ -lgnunetjson \ @@ -365,7 +164,7 @@ perf_deposits_get_ready_postgres_SOURCES = \ perf_deposits_get_ready_postgres_LDADD = \ libtalerdonaudb.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/pq/libtalerpq.la \ -ljansson \ -lgnunetjson \ diff --git a/src/donaudb/donaudb_plugin.c b/src/donaudb/donaudb_plugin.c @@ -19,55 +19,55 @@ * @author Christian Grothoff * @author Sree Harsha Totakura <sreeharsha@totakura.in> */ -#include "platform.h" -#include "taler_donaudb_plugin.h" +#include "taler/platform.h" +#include "donaudb_plugin.h" #include <ltdl.h> -struct TALER_DONAUDB_Plugin * -TALER_DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) -{ - char *plugin_name; - char *lib_name; - struct TALER_DONAUDB_Plugin *plugin; +// struct DONAUDB_Plugin * +// DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) +// { +// char *plugin_name; +// char *lib_name; +// struct DONAUDB_Plugin *plugin; - if (GNUNET_SYSERR == - GNUNET_CONFIGURATION_get_value_string (cfg, - "donau", - "db", - &plugin_name)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "donau", - "db"); - return NULL; - } - GNUNET_asprintf (&lib_name, - "libtaler_plugin_donaudb_%s", - plugin_name); - GNUNET_free (plugin_name); - plugin = GNUNET_PLUGIN_load (lib_name, - (void *) cfg); - if (NULL != plugin) - plugin->library_name = lib_name; - else - GNUNET_free (lib_name); - return plugin; -} +// if (GNUNET_SYSERR == +// GNUNET_CONFIGURATION_get_value_string (cfg, +// "donau", +// "db", +// &plugin_name)) +// { +// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +// "donau", +// "db"); +// return NULL; +// } +// GNUNET_asprintf (&lib_name, +// "libtaler_plugin_donaudb_%s", +// plugin_name); +// GNUNET_free (plugin_name); +// plugin = GNUNET_PLUGIN_load (lib_name, +// (void *) cfg); +// if (NULL != plugin) +// plugin->library_name = lib_name; +// else +// GNUNET_free (lib_name); +// return plugin; +// } -void -TALER_DONAUDB_plugin_unload (struct TALER_DONAUDB_Plugin *plugin) -{ - char *lib_name; +// void +// DONAUDB_plugin_unload (struct DONAUDB_Plugin *plugin) +// { +// char *lib_name; - if (NULL == plugin) - return; - lib_name = plugin->library_name; - GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name, - plugin)); - GNUNET_free (lib_name); -} +// if (NULL == plugin) +// return; +// lib_name = plugin->library_name; +// GNUNET_assert (NULL == GNUNET_PLUGIN_unload (lib_name, +// plugin)); +// GNUNET_free (lib_name); +// } /* end of donaudb_plugin.c */ diff --git a/src/donaudb/donaudb_transactions.c b/src/donaudb/donaudb_transactions.c @@ -18,173 +18,173 @@ * @brief Logic to compute transaction totals of a transaction list for a coin * @author Christian Grothoff */ -#include "platform.h" -#include "taler_donaudb_lib.h" +#include "taler/platform.h" +#include "donaudb_lib.h" -enum GNUNET_GenericReturnValue -TALER_DONAUDB_calculate_transaction_list_totals ( - struct TALER_DONAUDB_TransactionList *tl, - const struct TALER_Amount *off, - struct TALER_Amount *ret) -{ - struct TALER_Amount spent = *off; - struct TALER_Amount refunded; - struct TALER_Amount deposit_fee; - bool have_refund; +// enum GNUNET_GenericReturnValue +// DONAUDB_calculate_transaction_list_totals ( +// struct DONAUDB_TransactionList *tl, +// const struct TALER_Amount *off, +// struct TALER_Amount *ret) +// { +// struct TALER_Amount spent = *off; +// struct TALER_Amount refunded; +// struct TALER_Amount deposit_fee; +// bool have_refund; - GNUNET_assert (GNUNET_OK == - TALER_amount_set_zero (spent.currency, - &refunded)); - have_refund = false; - for (struct TALER_DONAUDB_TransactionList *pos = tl; - NULL != pos; - pos = pos->next) - { - switch (pos->type) - { - case TALER_DONAUDB_TT_DEPOSIT: - /* spent += pos->amount_with_fee */ - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.deposit->amount_with_fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - deposit_fee = pos->details.deposit->deposit_fee; - break; - case TALER_DONAUDB_TT_MELT: - /* spent += pos->amount_with_fee */ - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.melt->amount_with_fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - break; - case TALER_DONAUDB_TT_REFUND: - /* refunded += pos->refund_amount - pos->refund_fee */ - if (0 > - TALER_amount_add (&refunded, - &refunded, - &pos->details.refund->refund_amount)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.refund->refund_fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - have_refund = true; - break; - case TALER_DONAUDB_TT_OLD_COIN_RECOUP: - /* refunded += pos->value */ - if (0 > - TALER_amount_add (&refunded, - &refunded, - &pos->details.old_coin_recoup->value)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - break; - case TALER_DONAUDB_TT_RECOUP: - /* spent += pos->value */ - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.recoup->value)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - break; - case TALER_DONAUDB_TT_RECOUP_REFRESH: - /* spent += pos->value */ - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.recoup_refresh->value)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - break; - case TALER_DONAUDB_TT_PURSE_DEPOSIT: - /* spent += pos->amount_with_fee */ - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.purse_deposit->amount)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - deposit_fee = pos->details.purse_deposit->deposit_fee; - break; - case TALER_DONAUDB_TT_PURSE_REFUND: - /* refunded += pos->refund_amount - pos->refund_fee */ - if (0 > - TALER_amount_add (&refunded, - &refunded, - &pos->details.purse_refund->refund_amount)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.purse_refund->refund_fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - have_refund = true; - break; - case TALER_DONAUDB_TT_RESERVE_OPEN: - /* spent += pos->amount_with_fee */ - if (0 > - TALER_amount_add (&spent, - &spent, - &pos->details.reserve_open->coin_contribution)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - break; - } - } - if (have_refund) - { - /* If we gave any refund, also discount ONE deposit fee */ - if (0 > - TALER_amount_add (&refunded, - &refunded, - &deposit_fee)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - } - /* spent = spent - refunded */ - if (0 > - TALER_amount_subtract (&spent, - &spent, - &refunded)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - *ret = spent; - return GNUNET_OK; -} +// GNUNET_assert (GNUNET_OK == +// TALER_amount_set_zero (spent.currency, +// &refunded)); +// have_refund = false; +// for (struct DONAUDB_TransactionList *pos = tl; +// NULL != pos; +// pos = pos->next) +// { +// switch (pos->type) +// { +// case DONAUDB_TT_DEPOSIT: +// /* spent += pos->amount_with_fee */ +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.deposit->amount_with_fee)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// deposit_fee = pos->details.deposit->deposit_fee; +// break; +// case DONAUDB_TT_MELT: +// /* spent += pos->amount_with_fee */ +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.melt->amount_with_fee)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// break; +// case DONAUDB_TT_REFUND: +// /* refunded += pos->refund_amount - pos->refund_fee */ +// if (0 > +// TALER_amount_add (&refunded, +// &refunded, +// &pos->details.refund->refund_amount)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.refund->refund_fee)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// have_refund = true; +// break; +// case DONAUDB_TT_OLD_COIN_RECOUP: +// /* refunded += pos->value */ +// if (0 > +// TALER_amount_add (&refunded, +// &refunded, +// &pos->details.old_coin_recoup->value)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// break; +// case DONAUDB_TT_RECOUP: +// /* spent += pos->value */ +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.recoup->value)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// break; +// case DONAUDB_TT_RECOUP_REFRESH: +// /* spent += pos->value */ +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.recoup_refresh->value)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// break; +// case DONAUDB_TT_PURSE_DEPOSIT: +// /* spent += pos->amount_with_fee */ +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.purse_deposit->amount)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// deposit_fee = pos->details.purse_deposit->deposit_fee; +// break; +// case DONAUDB_TT_PURSE_REFUND: +// /* refunded += pos->refund_amount - pos->refund_fee */ +// if (0 > +// TALER_amount_add (&refunded, +// &refunded, +// &pos->details.purse_refund->refund_amount)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.purse_refund->refund_fee)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// have_refund = true; +// break; +// case DONAUDB_TT_RESERVE_OPEN: +// /* spent += pos->amount_with_fee */ +// if (0 > +// TALER_amount_add (&spent, +// &spent, +// &pos->details.reserve_open->coin_contribution)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// break; +// } +// } +// if (have_refund) +// { +// /* If we gave any refund, also discount ONE deposit fee */ +// if (0 > +// TALER_amount_add (&refunded, +// &refunded, +// &deposit_fee)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// } +// /* spent = spent - refunded */ +// if (0 > +// TALER_amount_subtract (&spent, +// &spent, +// &refunded)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// *ret = spent; +// return GNUNET_OK; +// } diff --git a/src/donaudb/pg_activate_signing_key.c b/src/donaudb/pg_activate_signing_key.c @@ -18,8 +18,8 @@ * @brief Implementation of the activate_signing_key function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_activate_signing_key.h" diff --git a/src/donaudb/pg_activate_signing_key.h b/src/donaudb/pg_activate_signing_key.h @@ -22,8 +22,8 @@ #define PG_ACTIVATE_SIGNING_KEY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Add signing key. diff --git a/src/donaudb/pg_add_donation_unit_key.c b/src/donaudb/pg_add_donation_unit_key.c @@ -18,8 +18,8 @@ * @brief Implementation of the add_donation_unit_key function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_add_donation_unit_key.h" diff --git a/src/donaudb/pg_add_donation_unit_key.h b/src/donaudb/pg_add_donation_unit_key.h @@ -22,8 +22,8 @@ #define PG_ADD_DONATION_UNIT_KEY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Activate donation unit key, turning it into a "current" or "valid" diff --git a/src/donaudb/pg_commit.c b/src/donaudb/pg_commit.c @@ -18,8 +18,8 @@ * @brief Implementation of the commit function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_commit.h" diff --git a/src/donaudb/pg_commit.h b/src/donaudb/pg_commit.h @@ -22,8 +22,8 @@ #define PG_COMMIT_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Commit the current transaction of a database connection. diff --git a/src/donaudb/pg_create_tables.c b/src/donaudb/pg_create_tables.c @@ -18,8 +18,8 @@ * @brief Implementation of the create_tables function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_create_tables.h" diff --git a/src/donaudb/pg_create_tables.h b/src/donaudb/pg_create_tables.h @@ -22,8 +22,8 @@ #define PG_CREATE_TABLES_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Create the necessary tables if they are not present diff --git a/src/donaudb/pg_drop_tables.c b/src/donaudb/pg_drop_tables.c @@ -18,8 +18,8 @@ * @brief Implementation of the drop_tables function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_drop_tables.h" diff --git a/src/donaudb/pg_drop_tables.h b/src/donaudb/pg_drop_tables.h @@ -22,8 +22,8 @@ #define PG_DROP_TABLES_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** diff --git a/src/donaudb/pg_event_listen.c b/src/donaudb/pg_event_listen.c @@ -18,8 +18,8 @@ * @brief Implementation of the event_listen function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_event_listen.h" diff --git a/src/donaudb/pg_event_listen.h b/src/donaudb/pg_event_listen.h @@ -22,8 +22,8 @@ #define PG_EVENT_LISTEN_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Register callback to be invoked on events of type @a es. * diff --git a/src/donaudb/pg_event_listen_cancel.c b/src/donaudb/pg_event_listen_cancel.c @@ -18,8 +18,8 @@ * @brief Implementation of the event_listen_cancel function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_event_listen_cancel.h" diff --git a/src/donaudb/pg_event_listen_cancel.h b/src/donaudb/pg_event_listen_cancel.h @@ -22,8 +22,8 @@ #define PG_EVENT_LISTEN_CANCEL_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** diff --git a/src/donaudb/pg_event_notify.c b/src/donaudb/pg_event_notify.c @@ -18,8 +18,8 @@ * @brief Implementation of the event_notify function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_event_notify.h" diff --git a/src/donaudb/pg_event_notify.h b/src/donaudb/pg_event_notify.h @@ -22,8 +22,8 @@ #define PG_EVENT_NOTIFY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Notify all that listen on @a es of an event. diff --git a/src/donaudb/pg_get_donation_unit_info.c b/src/donaudb/pg_get_donation_unit_info.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2022 Taler Systems SA + 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 @@ -16,10 +16,10 @@ /** * @file donaudb/pg_get_denomination_info.c * @brief Implementation of the get_denomination_info function for Postgres - * @author Christian Grothoff + * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_get_donation_unit_info.h" @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_donation_unit_info ( void *cls, const struct DONAU_DonationUnitHashP *donation_unit_pub_hash, - struct DONAUDB_DenominationKeyMetaData *meta) + struct DONAUDB_DonationUnitKeyMetaData *meta) { struct PostgresClosure *pg = cls; enum GNUNET_DB_QueryStatus qs; diff --git a/src/donaudb/pg_get_donation_unit_info.h b/src/donaudb/pg_get_donation_unit_info.h @@ -22,8 +22,8 @@ #define PG_GET_DONATION_UNIT_INFO_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Fetch information about a donation unit key. * @@ -35,7 +35,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_donation_unit_info ( void *cls, - const struct DONAU_DonationUNitHashP *donation_unit_pub_hash, + const struct DONAU_DonationUnitHashP *donation_unit_pub_hash, struct DONAUDB_DonationUnitKeyMetaData *meta); #endif diff --git a/src/donaudb/pg_insert_charity.c b/src/donaudb/pg_insert_charity.c @@ -18,8 +18,8 @@ * @brief Implementation of the insert_charity function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_insert_charity.h" @@ -30,6 +30,7 @@ TEH_PG_insert_charity (void *cls, const struct DONAU_CharityPublicKeyP *charity_pub, const char *charity_url, const char *charity_name, + struct TALER_Amount *receipts_to_date, uint64_t current_year) { struct PostgresClosure *pg = cls; @@ -37,6 +38,7 @@ TEH_PG_insert_charity (void *cls, GNUNET_PQ_query_param_auto_from_type (charity_pub), GNUNET_PQ_query_param_string (charity_name), GNUNET_PQ_query_param_string (charity_url), + TALER_PQ_query_param_amount (receipts_to_date), GNUNET_PQ_query_param_uint64 (¤t_year), GNUNET_PQ_query_param_end }; @@ -47,9 +49,10 @@ TEH_PG_insert_charity (void *cls, "(charity_pub" ",charity_name" ",charity_url" + ",receipts_to_date" ",current_year" ") VALUES " - "($1, $2, $3, $4);"); + "($1, $2, $3, $4, $5);"); return GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_charity", params); diff --git a/src/donaudb/pg_insert_charity.h b/src/donaudb/pg_insert_charity.h @@ -22,16 +22,18 @@ #define PG_INSERT_CHARITY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** - * Activate donation unit key, turning it into a "current" or "valid" - * denomination key by adding the master signature. + * Add a new charity * * @param cls closure - * @param denom_pub the actual denomination key - * @param meta meta information about the donation unit key + * @param charity_pub charity public key + * @param charity_name name + * @param charity_url url + * @param receipts_to_date current amount of donations in the current year + * @param current_year current year * @return transaction status code */ enum GNUNET_DB_QueryStatus @@ -42,4 +44,5 @@ TEH_PG_insert_charity ( const char *charity_url, struct TALER_Amount *receipts_to_date, uint64_t current_year); + #endif diff --git a/src/donaudb/pg_insert_history_entry.c b/src/donaudb/pg_insert_history_entry.c @@ -18,8 +18,8 @@ * @brief Implementation of the insert_history_entry function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_insert_history_entry.h" @@ -27,9 +27,9 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_history_entry (void *cls, - const uint64_t charity_id, - const struct TALER_Amount *final_amount, - const uint64_t donation_year) + const uint64_t charity_id, + const struct TALER_Amount *final_amount, + const uint64_t donation_year) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -39,7 +39,6 @@ TEH_PG_insert_history_entry (void *cls, GNUNET_PQ_query_param_end }; - /* used in #postgres_insert_history_entry() */ PREPARE (pg, "insert_history_entry", "INSERT INTO history " diff --git a/src/donaudb/pg_insert_history_entry.h b/src/donaudb/pg_insert_history_entry.h @@ -22,23 +22,22 @@ #define PG_INSERT_HISTORY_ENTRY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** - * Insert information about an auditor that will audit this exchange. + * Insert history entry of a charity * * @param cls closure - * @param auditor_pub key of the auditor - * @param auditor_url base URL of the auditor's REST service - * @param auditor_name name of the auditor (for humans) - * @param start_date date when the auditor was added by the offline system - * (only to be used for replay detection) + * @param charity_id charity id + * @param final_amount final donation amount at the end of the donation year + * @param donation_year year of the donations * @return transaction status code */ enum GNUNET_DB_QueryStatus TEH_PG_insert_history_entry (void *cls, - const uint64_t charity_id, - const struct TALER_Amount *final_amount, - const uint64_t donation_year); + const uint64_t charity_id, + const struct TALER_Amount *final_amount, + const uint64_t donation_year); + #endif diff --git a/src/donaudb/pg_insert_issued_receipt.c b/src/donaudb/pg_insert_issued_receipt.c @@ -18,8 +18,8 @@ * @brief Implementation of the insert_issued_receipt function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_insert_issued_receipt.h" @@ -27,10 +27,10 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_issued_receipt (void *cls, - const struct DONAU_CharitySignatureP *charity_sig, - const uint64_t charity_id, - const struct DONAU_DonationReceiptHashP h_receipt, - const struct TALER_Amount *amount) + const struct DONAU_CharitySignatureP *charity_sig, + const uint64_t charity_id, + const struct DONAU_DonationReceiptHashP h_receipt, + const struct TALER_Amount *amount) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -41,7 +41,6 @@ TEH_PG_insert_issued_receipt (void *cls, GNUNET_PQ_query_param_end }; - /* used in #postgres_insert_issued_receipt() */ PREPARE (pg, "insert_issued_receipts", "INSERT INTO receipts_issued " diff --git a/src/donaudb/pg_insert_issued_receipt.h b/src/donaudb/pg_insert_issued_receipt.h @@ -22,22 +22,25 @@ #define PG_INSERT_ISSUED_RECEIPT_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** - * Insert information about an auditor that will audit this exchange. + * Insert issued blinded donation receipt to the charity. * * @param cls closure * @param charity_sig signature from the charity * @param charity_id identifier of the charity * @param h_receipt hash of the donation receipt + * @param amount donation amount * @return transaction status code */ enum GNUNET_DB_QueryStatus TEH_PG_insert_issued_receipt (void *cls, - const struct DONAU_CharitySignatureP *charity_sig, - const uint64_t charity_id, - const struct DONAU_DonationReceiptHashP *h_receipt, - const struct TALER_Amount *amount); + const struct DONAU_CharitySignatureP *charity_sig, + const uint64_t charity_id, + const struct + DONAU_DonationReceiptHashP *h_receipt, + const struct TALER_Amount *amount); + #endif diff --git a/src/donaudb/pg_insert_submitted_receipt.c b/src/donaudb/pg_insert_submitted_receipt.c @@ -18,8 +18,8 @@ * @brief Implementation of the insert_submitted_receipt function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_insert_submitted_receipt.h" @@ -27,11 +27,13 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_submitted_receipt (void *cls, - const struct TALER_TaxNumberHashP *h_tax_number, - const struct TALER_CsNonce *nonce, - const struct TALER_DonationUnitPublicKey *donation_unit_pub, - const struct TALER_DonauSignatureP *donau_sig, - const uint64_t donation_year) + const struct + TALER_TaxNumberHashP *h_tax_number, + const struct TALER_CsNonce *nonce, + const struct + DONAU_DonationUnitPublicKey *donation_unit_pub, + const struct TALER_DonauSignatureP *donau_sig, + const uint64_t donation_year) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { @@ -42,7 +44,6 @@ TEH_PG_insert_submitted_receipt (void *cls, GNUNET_PQ_query_param_end }; - /* used in #postgres_insert_submitted_receipt() */ PREPARE (pg, "insert_submitted_receipt", "INSERT INTO receipts_submitted " diff --git a/src/donaudb/pg_insert_submitted_receipt.h b/src/donaudb/pg_insert_submitted_receipt.h @@ -22,25 +22,28 @@ #define PG_INSERT_SUBMITTED_RECEIPT_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** - * Insert information about an auditor that will audit this exchange. + * Insert submitted donation receipt from the donor. * * @param cls closure - * @param auditor_pub key of the auditor - * @param auditor_url base URL of the auditor's REST service - * @param auditor_name name of the auditor (for humans) - * @param start_date date when the auditor was added by the offline system - * (only to be used for replay detection) + * @param h_tax_number salted hash of the donors tax number + * @param nonce nonce that is part of the unique donation identifier + * @param donation_unit_pub donation unit public key + * @param donau_sig donau signature in case the sign keys changed + * @param donation_year year of the donation * @return transaction status code */ enum GNUNET_DB_QueryStatus TEH_PG_insert_submitted_receipt (void *cls, - const struct TALER_TaxNumberHashP *h_tax_number, - const struct TALER_CsNonce *nonce, - const struct TALER_DonationUnitPublicKey *donation_unit_pub, - const struct TALER_DonauSignatureP *donau_sig, - const uint64_t donation_year); + const struct + TALER_TaxNumberHashP *h_tax_number, + const struct TALER_CsNonce *nonce, + const struct + DONAU_DonationUnitPublicKey *donation_unit_pub, + const struct TALER_DonauSignatureP *donau_sig, + const uint64_t donation_year); + #endif diff --git a/src/donaudb/pg_lookup_donation_unit_key.c b/src/donaudb/pg_lookup_donation_unit_key.c @@ -18,8 +18,8 @@ * @brief Implementation of the lookup_donation_unit_key function for Postgres * @author Johannes Casaburi */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_lookup_donation_unit_key.h" @@ -38,15 +38,14 @@ TEH_PG_lookup_donation_unit_key ( }; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("donation_unit_pub", - &meta->donation_unit_pub), + &meta->donation_unit_pub), GNUNET_PQ_query_param_uint64 ("validity_year", - &meta->validity_year), + &meta->validity_year), TALER_PQ_RESULT_SPEC_AMOUNT ("amount", &meta->value), GNUNET_PQ_result_spec_end }; - /* used in #postgres_lookup_donation_unit_key() */ PREPARE (pg, "lookup_donation_unit_key", "SELECT" diff --git a/src/donaudb/pg_lookup_donation_unit_key.h b/src/donaudb/pg_lookup_donation_unit_key.h @@ -22,10 +22,10 @@ #define PG_LOOKUP_DONATION_UNIT_KEY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** - * Lookup information about current donation_unit key. + * Lookup information about current donation unit key. * * @param cls closure * @param h_denom_pub hash of the donation_unit public key diff --git a/src/donaudb/pg_lookup_signing_key.c b/src/donaudb/pg_lookup_signing_key.c @@ -18,8 +18,8 @@ * @brief Implementation of the lookup_signing_key function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_lookup_signing_key.h" diff --git a/src/donaudb/pg_lookup_signing_key.h b/src/donaudb/pg_lookup_signing_key.h @@ -22,15 +22,15 @@ #define PG_LOOKUP_SIGNING_KEY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Lookup signing key meta data. * * @param cls closure - * @param donau_pub the donau online signing public key + * @param donau_pub the donau signing public key * @param[out] meta meta data about @a donau_pub * @return transaction status code */ @@ -39,4 +39,5 @@ TEH_PG_lookup_signing_key ( void *cls, const struct DONAU_DonauPublicKeyP *donau_pub, struct DONAUDB_SignkeyMetaData *meta); + #endif diff --git a/src/donaudb/pg_preflight.c b/src/donaudb/pg_preflight.c @@ -18,8 +18,8 @@ * @brief Implementation of the preflight function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_preflight.h" diff --git a/src/donaudb/pg_preflight.h b/src/donaudb/pg_preflight.h @@ -22,8 +22,8 @@ #define PG_PREFLIGTH_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** diff --git a/src/donaudb/pg_rollback.c b/src/donaudb/pg_rollback.c @@ -18,8 +18,8 @@ * @brief Implementation of the rollback function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_rollback.h" diff --git a/src/donaudb/pg_rollback.h b/src/donaudb/pg_rollback.h @@ -22,8 +22,8 @@ #define PG_ROLLBACK_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Roll back the current transaction of a database connection. diff --git a/src/donaudb/pg_start.c b/src/donaudb/pg_start.c @@ -18,8 +18,8 @@ * @brief Implementation of the start function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_preflight.h" diff --git a/src/donaudb/pg_start.h b/src/donaudb/pg_start.h @@ -22,8 +22,8 @@ #define PG_START_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Start a transaction. diff --git a/src/donaudb/pg_start_read_committed.c b/src/donaudb/pg_start_read_committed.c @@ -18,8 +18,8 @@ * @brief Implementation of the start_read_committed function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_start_read_committed.h" diff --git a/src/donaudb/pg_start_read_committed.h b/src/donaudb/pg_start_read_committed.h @@ -22,8 +22,8 @@ #define PG_START_READ_COMMITTED_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Start a READ COMMITTED transaction. * diff --git a/src/donaudb/pg_start_read_only.c b/src/donaudb/pg_start_read_only.c @@ -18,8 +18,8 @@ * @brief Implementation of the start_read_only function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_start_read_only.h" diff --git a/src/donaudb/pg_start_read_only.h b/src/donaudb/pg_start_read_only.h @@ -22,8 +22,8 @@ #define PG_START_READ_ONLY_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Start a READ ONLY serializable transaction. diff --git a/src/donaudb/pg_template.c b/src/donaudb/pg_template.c @@ -18,8 +18,8 @@ * @brief Implementation of the template function for Postgres * @author Christian Grothoff */ -#include "platform.h" -#include "taler_error_codes.h" +#include "taler/platform.h" +#include "taler/taler_error_codes.h" #include "taler_dbevents.h" #include "taler_pq_lib.h" #include "pg_template.h" diff --git a/src/donaudb/pg_template.h b/src/donaudb/pg_template.h @@ -22,8 +22,8 @@ #define PG_TEMPLATE_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" #endif diff --git a/src/donaudb/plugin_donaudb_common.c b/src/donaudb/plugin_donaudb_common.c @@ -19,181 +19,181 @@ * included in each plugin. * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include "plugin_donaudb_common.h" -void -TEH_COMMON_free_reserve_history ( - void *cls, - struct TALER_DONAUDB_ReserveHistory *rh) -{ - (void) cls; - while (NULL != rh) - { - switch (rh->type) - { - case TALER_DONAUDB_RO_BANK_TO_DONAU: - { - struct TALER_DONAUDB_BankTransfer *bt; - - bt = rh->details.bank; - GNUNET_free (bt->sender_account_details); - GNUNET_free (bt); - break; - } - case TALER_DONAUDB_RO_WITHDRAW_COIN: - { - struct TALER_DONAUDB_CollectableBlindcoin *cbc; - - cbc = rh->details.withdraw; - TALER_blinded_denom_sig_free (&cbc->sig); - GNUNET_free (cbc); - break; - } - case TALER_DONAUDB_RO_RECOUP_COIN: - { - struct TALER_DONAUDB_Recoup *recoup; - - recoup = rh->details.recoup; - TALER_denom_sig_free (&recoup->coin.denom_sig); - GNUNET_free (recoup); - break; - } - case TALER_DONAUDB_RO_DONAU_TO_BANK: - { - struct TALER_DONAUDB_ClosingTransfer *closing; - - closing = rh->details.closing; - GNUNET_free (closing->receiver_account_details); - GNUNET_free (closing); - break; - } - case TALER_DONAUDB_RO_PURSE_MERGE: - { - struct TALER_DONAUDB_PurseMerge *merge; - - merge = rh->details.merge; - GNUNET_free (merge); - break; - } - case TALER_DONAUDB_RO_HISTORY_REQUEST: - { - struct TALER_DONAUDB_HistoryRequest *history; - - history = rh->details.history; - GNUNET_free (history); - break; - } - case TALER_DONAUDB_RO_OPEN_REQUEST: - { - struct TALER_DONAUDB_OpenRequest *or; - - or = rh->details.open_request; - GNUNET_free (or); - break; - } - case TALER_DONAUDB_RO_CLOSE_REQUEST: - { - struct TALER_DONAUDB_CloseRequest *cr; - - cr = rh->details.close_request; - GNUNET_free (cr); - break; - } - } - { - struct TALER_DONAUDB_ReserveHistory *next; - - next = rh->next; - GNUNET_free (rh); - rh = next; - } - } -} - - -void -TEH_COMMON_free_coin_transaction_list ( - void *cls, - struct TALER_DONAUDB_TransactionList *tl) -{ - (void) cls; - while (NULL != tl) - { - switch (tl->type) - { - case TALER_DONAUDB_TT_DEPOSIT: - { - struct TALER_DONAUDB_DepositListEntry *deposit; - - deposit = tl->details.deposit; - GNUNET_free (deposit->receiver_wire_account); - GNUNET_free (deposit); - break; - } - case TALER_DONAUDB_TT_MELT: - GNUNET_free (tl->details.melt); - break; - case TALER_DONAUDB_TT_OLD_COIN_RECOUP: - { - struct TALER_DONAUDB_RecoupRefreshListEntry *rr; - - rr = tl->details.old_coin_recoup; - TALER_denom_sig_free (&rr->coin.denom_sig); - GNUNET_free (rr); - break; - } - case TALER_DONAUDB_TT_REFUND: - GNUNET_free (tl->details.refund); - break; - case TALER_DONAUDB_TT_RECOUP: - GNUNET_free (tl->details.recoup); - break; - case TALER_DONAUDB_TT_RECOUP_REFRESH: - { - struct TALER_DONAUDB_RecoupRefreshListEntry *rr; - - rr = tl->details.recoup_refresh; - TALER_denom_sig_free (&rr->coin.denom_sig); - GNUNET_free (rr); - break; - } - case TALER_DONAUDB_TT_PURSE_DEPOSIT: - { - struct TALER_DONAUDB_PurseDepositListEntry *deposit; - - deposit = tl->details.purse_deposit; - GNUNET_free (deposit->donau_base_url); - GNUNET_free (deposit); - break; - } - case TALER_DONAUDB_TT_PURSE_REFUND: - { - struct TALER_DONAUDB_PurseRefundListEntry *prefund; - - prefund = tl->details.purse_refund; - GNUNET_free (prefund); - break; - } - case TALER_DONAUDB_TT_RESERVE_OPEN: - { - struct TALER_DONAUDB_ReserveOpenListEntry *role; - - role = tl->details.reserve_open; - GNUNET_free (role); - break; - } - } - { - struct TALER_DONAUDB_TransactionList *next; - - next = tl->next; - GNUNET_free (tl); - tl = next; - } - } -} +// void +// TEH_COMMON_free_reserve_history ( +// void *cls, +// struct DONAUDB_ReserveHistory *rh) +// { +// (void) cls; +// while (NULL != rh) +// { +// switch (rh->type) +// { +// case DONAUDB_RO_BANK_TO_DONAU: +// { +// struct DONAUDB_BankTransfer *bt; + +// bt = rh->details.bank; +// GNUNET_free (bt->sender_account_details); +// GNUNET_free (bt); +// break; +// } +// case DONAUDB_RO_WITHDRAW_COIN: +// { +// struct DONAUDB_CollectableBlindcoin *cbc; + +// cbc = rh->details.withdraw; +// TALER_blinded_denom_sig_free (&cbc->sig); +// GNUNET_free (cbc); +// break; +// } +// case DONAUDB_RO_RECOUP_COIN: +// { +// struct DONAUDB_Recoup *recoup; + +// recoup = rh->details.recoup; +// TALER_denom_sig_free (&recoup->coin.denom_sig); +// GNUNET_free (recoup); +// break; +// } +// case DONAUDB_RO_DONAU_TO_BANK: +// { +// struct DONAUDB_ClosingTransfer *closing; + +// closing = rh->details.closing; +// GNUNET_free (closing->receiver_account_details); +// GNUNET_free (closing); +// break; +// } +// case DONAUDB_RO_PURSE_MERGE: +// { +// struct DONAUDB_PurseMerge *merge; + +// merge = rh->details.merge; +// GNUNET_free (merge); +// break; +// } +// case DONAUDB_RO_HISTORY_REQUEST: +// { +// struct DONAUDB_HistoryRequest *history; + +// history = rh->details.history; +// GNUNET_free (history); +// break; +// } +// case DONAUDB_RO_OPEN_REQUEST: +// { +// struct DONAUDB_OpenRequest *or; + +// or = rh->details.open_request; +// GNUNET_free (or); +// break; +// } +// case DONAUDB_RO_CLOSE_REQUEST: +// { +// struct DONAUDB_CloseRequest *cr; + +// cr = rh->details.close_request; +// GNUNET_free (cr); +// break; +// } +// } +// { +// struct DONAUDB_ReserveHistory *next; + +// next = rh->next; +// GNUNET_free (rh); +// rh = next; +// } +// } +// } + + +// void +// TEH_COMMON_free_coin_transaction_list ( +// void *cls, +// struct DONAUDB_TransactionList *tl) +// { +// (void) cls; +// while (NULL != tl) +// { +// switch (tl->type) +// { +// case DONAUDB_TT_DEPOSIT: +// { +// struct DONAUDB_DepositListEntry *deposit; + +// deposit = tl->details.deposit; +// GNUNET_free (deposit->receiver_wire_account); +// GNUNET_free (deposit); +// break; +// } +// case DONAUDB_TT_MELT: +// GNUNET_free (tl->details.melt); +// break; +// case DONAUDB_TT_OLD_COIN_RECOUP: +// { +// struct DONAUDB_RecoupRefreshListEntry *rr; + +// rr = tl->details.old_coin_recoup; +// TALER_denom_sig_free (&rr->coin.denom_sig); +// GNUNET_free (rr); +// break; +// } +// case DONAUDB_TT_REFUND: +// GNUNET_free (tl->details.refund); +// break; +// case DONAUDB_TT_RECOUP: +// GNUNET_free (tl->details.recoup); +// break; +// case DONAUDB_TT_RECOUP_REFRESH: +// { +// struct DONAUDB_RecoupRefreshListEntry *rr; + +// rr = tl->details.recoup_refresh; +// TALER_denom_sig_free (&rr->coin.denom_sig); +// GNUNET_free (rr); +// break; +// } +// case DONAUDB_TT_PURSE_DEPOSIT: +// { +// struct DONAUDB_PurseDepositListEntry *deposit; + +// deposit = tl->details.purse_deposit; +// GNUNET_free (deposit->donau_base_url); +// GNUNET_free (deposit); +// break; +// } +// case DONAUDB_TT_PURSE_REFUND: +// { +// struct DONAUDB_PurseRefundListEntry *prefund; + +// prefund = tl->details.purse_refund; +// GNUNET_free (prefund); +// break; +// } +// case DONAUDB_TT_RESERVE_OPEN: +// { +// struct DONAUDB_ReserveOpenListEntry *role; + +// role = tl->details.reserve_open; +// GNUNET_free (role); +// break; +// } +// } +// { +// struct DONAUDB_TransactionList *next; + +// next = tl->next; +// GNUNET_free (tl); +// tl = next; +// } +// } +// } /* end of plugin_donaudb_common.c */ diff --git a/src/donaudb/plugin_donaudb_common.h b/src/donaudb/plugin_donaudb_common.h @@ -22,9 +22,10 @@ #define PLUGIN_DONAUDB_COMMON_H #include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" +struct DONAUDB_ReserveHistory; /** * Free memory associated with the given reserve history. * @@ -34,7 +35,7 @@ void TEH_COMMON_free_reserve_history ( void *cls, - struct TALER_DONAUDB_ReserveHistory *rh); + struct DONAUDB_ReserveHistory *rh); /** @@ -46,6 +47,6 @@ TEH_COMMON_free_reserve_history ( void TEH_COMMON_free_coin_transaction_list ( void *cls, - struct TALER_DONAUDB_TransactionList *tl); + struct DONAUDB_TransactionList *tl); #endif diff --git a/src/donaudb/plugin_donaudb_postgres.c b/src/donaudb/plugin_donaudb_postgres.c @@ -23,784 +23,248 @@ * @author Marcello Stanisci * @author Özgür Kesim */ -#include "platform.h" +#include "taler/platform.h" #include <poll.h> #include <pthread.h> #include <libpq-fe.h> -#include "taler_error_codes.h" -#include "taler_dbevents.h" -#include "taler_pq_lib.h" -#include "taler_util.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_error_codes.h" +#include "taler/taler_dbevents.h" +#include "taler/taler_pq_lib.h" +#include "taler/taler_util.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" #include "plugin_donaudb_common.h" -#include "pg_delete_aggregation_transient.h" -#include "pg_get_link_data.h" +// #include "pg_delete_aggregation_transient.h" +// #include "pg_get_link_data.h" #include "pg_helper.h" -#include "pg_do_reserve_open.h" -#include "pg_do_withdraw.h" -#include "pg_get_coin_transactions.h" -#include "pg_get_expired_reserves.h" -#include "pg_get_purse_request.h" -#include "pg_get_reserve_history.h" -#include "pg_get_unfinished_close_requests.h" -#include "pg_insert_close_request.h" -#include "pg_insert_records_by_table.h" -#include "pg_insert_reserve_open_deposit.h" -#include "pg_iterate_kyc_reference.h" -#include "pg_iterate_reserve_close_info.h" -#include "pg_lookup_records_by_table.h" -#include "pg_lookup_serial_by_table.h" -#include "pg_select_account_merges_above_serial_id.h" -#include "pg_select_aml_threshold.h" -#include "pg_select_all_purse_decisions_above_serial_id.h" -#include "pg_select_purse.h" -#include "pg_select_purse_deposits_above_serial_id.h" -#include "pg_select_purse_merges_above_serial_id.h" -#include "pg_select_purse_requests_above_serial_id.h" -#include "pg_select_reserve_close_info.h" -#include "pg_select_reserve_closed_above_serial_id.h" -#include "pg_select_reserve_open_above_serial_id.h" -#include "pg_insert_purse_request.h" -#include "pg_iterate_active_signkeys.h" -#include "pg_preflight.h" -#include "pg_commit.h" -#include "pg_drop_tables.h" -#include "pg_select_satisfied_kyc_processes.h" -#include "pg_select_aggregation_amounts_for_kyc_check.h" -#include "pg_kyc_provider_account_lookup.h" -#include "pg_lookup_kyc_requirement_by_row.h" -#include "pg_insert_kyc_requirement_for_account.h" -#include "pg_lookup_kyc_process_by_account.h" -#include "pg_update_kyc_process_by_row.h" -#include "pg_insert_kyc_requirement_process.h" -#include "pg_select_withdraw_amounts_for_kyc_check.h" -#include "pg_select_merge_amounts_for_kyc_check.h" -#include "pg_profit_drains_set_finished.h" -#include "pg_profit_drains_get_pending.h" -#include "pg_get_drain_profit.h" -#include "pg_get_purse_deposit.h" -#include "pg_insert_contract.h" -#include "pg_select_contract.h" -#include "pg_select_purse_merge.h" -#include "pg_select_contract_by_purse.h" -#include "pg_insert_drain_profit.h" -#include "pg_do_reserve_purse.h" -#include "pg_lookup_global_fee_by_time.h" -#include "pg_do_purse_deposit.h" -#include "pg_activate_signing_key.h" -#include "pg_update_auditor.h" -#include "pg_begin_revolving_shard.h" -#include "pg_get_extension_manifest.h" -#include "pg_insert_history_request.h" -#include "pg_do_purse_delete.h" -#include "pg_do_purse_merge.h" -#include "pg_start_read_committed.h" -#include "pg_start_read_only.h" -#include "pg_insert_denomination_info.h" -#include "pg_do_batch_withdraw_insert.h" -#include "pg_lookup_wire_fee_by_time.h" -#include "pg_start.h" -#include "pg_rollback.h" -#include "pg_create_tables.h" -#include "pg_event_listen.h" -#include "pg_event_listen_cancel.h" -#include "pg_event_notify.h" -#include "pg_get_denomination_info.h" -#include "pg_iterate_denomination_info.h" -#include "pg_iterate_denominations.h" -#include "pg_iterate_active_auditors.h" -#include "pg_iterate_auditor_denominations.h" -#include "pg_reserves_get.h" -#include "pg_reserves_get_origin.h" -#include "pg_drain_kyc_alert.h" -#include "pg_reserves_in_insert.h" -#include "pg_get_withdraw_info.h" -#include "pg_get_age_withdraw.h" -#include "pg_do_batch_withdraw.h" -#include "pg_do_age_withdraw.h" -#include "pg_get_policy_details.h" -#include "pg_persist_policy_details.h" -#include "pg_do_deposit.h" -#include "pg_add_policy_fulfillment_proof.h" -#include "pg_do_melt.h" -#include "pg_do_refund.h" -#include "pg_do_recoup.h" -#include "pg_do_recoup_refresh.h" -#include "pg_get_reserve_balance.h" -#include "pg_count_known_coins.h" -#include "pg_ensure_coin_known.h" -#include "pg_get_known_coin.h" -#include "pg_get_coin_denomination.h" -#include "pg_have_deposit2.h" -#include "pg_aggregate.h" -#include "pg_create_aggregation_transient.h" -#include "pg_select_aggregation_transient.h" -#include "pg_find_aggregation_transient.h" -#include "pg_update_aggregation_transient.h" -#include "pg_get_ready_deposit.h" -#include "pg_insert_refund.h" -#include "pg_select_refunds_by_coin.h" -#include "pg_get_melt.h" -#include "pg_insert_refresh_reveal.h" -#include "pg_get_refresh_reveal.h" -#include "pg_lookup_wire_transfer.h" -#include "pg_lookup_transfer_by_deposit.h" -#include "pg_insert_wire_fee.h" -#include "pg_insert_global_fee.h" -#include "pg_get_wire_fee.h" -#include "pg_get_global_fee.h" -#include "pg_get_global_fees.h" -#include "pg_insert_reserve_closed.h" -#include "pg_wire_prepare_data_insert.h" -#include "pg_wire_prepare_data_mark_finished.h" -#include "pg_wire_prepare_data_mark_failed.h" -#include "pg_wire_prepare_data_get.h" -#include "pg_start_deferred_wire_out.h" -#include "pg_store_wire_transfer_out.h" -#include "pg_gc.h" -#include "pg_select_coin_deposits_above_serial_id.h" -#include "pg_select_history_requests_above_serial_id.h" -#include "pg_select_purse_decisions_above_serial_id.h" -#include "pg_select_purse_deposits_by_purse.h" -#include "pg_select_refreshes_above_serial_id.h" -#include "pg_select_refunds_above_serial_id.h" -#include "pg_select_reserves_in_above_serial_id.h" -#include "pg_select_reserves_in_above_serial_id_by_account.h" -#include "pg_select_withdrawals_above_serial_id.h" -#include "pg_select_wire_out_above_serial_id.h" -#include "pg_select_wire_out_above_serial_id_by_account.h" -#include "pg_select_recoup_above_serial_id.h" -#include "pg_select_recoup_refresh_above_serial_id.h" -#include "pg_get_reserve_by_h_blind.h" -#include "pg_get_old_coin_by_h_blind.h" -#include "pg_insert_denomination_revocation.h" -#include "pg_get_denomination_revocation.h" -#include "pg_select_batch_deposits_missing_wire.h" -#include "pg_lookup_auditor_timestamp.h" -#include "pg_lookup_auditor_status.h" -#include "pg_insert_auditor.h" -#include "pg_lookup_wire_timestamp.h" -#include "pg_insert_wire.h" -#include "pg_update_wire.h" -#include "pg_get_wire_accounts.h" -#include "pg_get_wire_fees.h" -#include "pg_insert_signkey_revocation.h" -#include "pg_lookup_signkey_revocation.h" -#include "pg_lookup_denomination_key.h" -#include "pg_insert_auditor_denom_sig.h" -#include "pg_select_auditor_denom_sig.h" -#include "pg_add_denomination_key.h" -#include "pg_lookup_signing_key.h" -#include "pg_begin_shard.h" -#include "pg_abort_shard.h" -#include "pg_complete_shard.h" -#include "pg_release_revolving_shard.h" -#include "pg_delete_shard_locks.h" -#include "pg_set_extension_manifest.h" -#include "pg_insert_partner.h" -#include "pg_expire_purse.h" -#include "pg_select_purse_by_merge_pub.h" -#include "pg_set_purse_balance.h" -#include "pg_reserves_update.h" -#include "pg_setup_wire_target.h" -#include "pg_compute_shard.h" -#include "pg_insert_kyc_attributes.h" -#include "pg_select_similar_kyc_attributes.h" -#include "pg_select_kyc_attributes.h" -#include "pg_insert_aml_officer.h" -#include "pg_test_aml_officer.h" -#include "pg_lookup_aml_officer.h" -#include "pg_trigger_aml_process.h" -#include "pg_select_aml_process.h" -#include "pg_select_aml_history.h" -#include "pg_insert_aml_decision.h" -#include "pg_batch_ensure_coin_known.h" -/** - * Set to 1 to enable Postgres auto_explain module. This will - * slow down things a _lot_, but also provide extensive logging - * in the Postgres database logger for performance analysis. - */ -#define AUTO_EXPLAIN 1 +// /** +// * Set to 1 to enable Postgres auto_explain module. This will +// * slow down things a _lot_, but also provide extensive logging +// * in the Postgres database logger for performance analysis. +// */ +// #define AUTO_EXPLAIN 1 -/** - * Log a really unexpected PQ error with all the details we can get hold of. - * - * @param result PQ result object of the PQ operation that failed - * @param conn SQL connection that was used - */ -#define BREAK_DB_ERR(result,conn) do { \ - GNUNET_break (0); \ - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ - "Database failure: %s/%s/%s/%s/%s", \ - PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY), \ - PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL), \ - PQresultErrorMessage (result), \ - PQresStatus (PQresultStatus (result)), \ - PQerrorMessage (conn)); \ -} while (0) +// /** +// * Log a really unexpected PQ error with all the details we can get hold of. +// * +// * @param result PQ result object of the PQ operation that failed +// * @param conn SQL connection that was used +// */ +// #define BREAK_DB_ERR(result,conn) do { \ +// GNUNET_break (0); \ +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ +// "Database failure: %s/%s/%s/%s/%s", \ +// PQresultErrorField (result, PG_DIAG_MESSAGE_PRIMARY), \ +// PQresultErrorField (result, PG_DIAG_MESSAGE_DETAIL), \ +// PQresultErrorMessage (result), \ +// PQresStatus (PQresultStatus (result)), \ +// PQerrorMessage (conn)); \ +// } while (0) -/** - * Connect to the database if the connection does not exist yet. - * - * @param pg the plugin-specific state - * @return #GNUNET_OK on success - */ -enum GNUNET_GenericReturnValue -TEH_PG_internal_setup (struct PostgresClosure *pg) -{ - if (NULL == pg->conn) - { -#if AUTO_EXPLAIN - /* Enable verbose logging to see where queries do not - properly use indices */ - struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_try_execute ("LOAD 'auto_explain';"), - GNUNET_PQ_make_try_execute ("SET auto_explain.log_min_duration=50;"), - GNUNET_PQ_make_try_execute ("SET auto_explain.log_timing=TRUE;"), - GNUNET_PQ_make_try_execute ("SET auto_explain.log_analyze=TRUE;"), - /* https://wiki.postgresql.org/wiki/Serializable suggests to really - force the default to 'serializable' if SSI is to be used. */ - GNUNET_PQ_make_try_execute ( - "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), - GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), - GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), - GNUNET_PQ_make_try_execute ("SET search_path TO donau;"), - GNUNET_PQ_EXECUTE_STATEMENT_END - }; -#else - struct GNUNET_PQ_ExecuteStatement es[] = { - GNUNET_PQ_make_try_execute ( - "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), - GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), - GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), - GNUNET_PQ_make_try_execute ("SET autocommit=OFF;"), - GNUNET_PQ_make_try_execute ("SET search_path TO donau;"), - GNUNET_PQ_EXECUTE_STATEMENT_END - }; -#endif - struct GNUNET_PQ_Context *db_conn; +// /** +// * Connect to the database if the connection does not exist yet. +// * +// * @param pg the plugin-specific state +// * @return #GNUNET_OK on success +// */ +// enum GNUNET_GenericReturnValue +// TEH_PG_internal_setup (struct PostgresClosure *pg) +// { +// if (NULL == pg->conn) +// { +// #if AUTO_EXPLAIN +// /* Enable verbose logging to see where queries do not +// properly use indices */ +// struct GNUNET_PQ_ExecuteStatement es[] = { +// GNUNET_PQ_make_try_execute ("LOAD 'auto_explain';"), +// GNUNET_PQ_make_try_execute ("SET auto_explain.log_min_duration=50;"), +// GNUNET_PQ_make_try_execute ("SET auto_explain.log_timing=TRUE;"), +// GNUNET_PQ_make_try_execute ("SET auto_explain.log_analyze=TRUE;"), +// /* https://wiki.postgresql.org/wiki/Serializable suggests to really +// force the default to 'serializable' if SSI is to be used. */ +// GNUNET_PQ_make_try_execute ( +// "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), +// GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), +// GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), +// GNUNET_PQ_make_try_execute ("SET search_path TO donau;"), +// GNUNET_PQ_EXECUTE_STATEMENT_END +// }; +// #else +// struct GNUNET_PQ_ExecuteStatement es[] = { +// GNUNET_PQ_make_try_execute ( +// "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;"), +// GNUNET_PQ_make_try_execute ("SET enable_sort=OFF;"), +// GNUNET_PQ_make_try_execute ("SET enable_seqscan=OFF;"), +// GNUNET_PQ_make_try_execute ("SET autocommit=OFF;"), +// GNUNET_PQ_make_try_execute ("SET search_path TO donau;"), +// GNUNET_PQ_EXECUTE_STATEMENT_END +// }; +// #endif +// struct GNUNET_PQ_Context *db_conn; - db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg, - "donaudb-postgres", - NULL, - es, - NULL); - if (NULL == db_conn) - return GNUNET_SYSERR; +// db_conn = GNUNET_PQ_connect_with_cfg (pg->cfg, +// "donaudb-postgres", +// NULL, +// es, +// NULL); +// if (NULL == db_conn) +// return GNUNET_SYSERR; - pg->prep_gen++; - pg->conn = db_conn; - } - if (NULL == pg->transaction_name) - GNUNET_PQ_reconnect_if_down (pg->conn); - return GNUNET_OK; -} +// pg->prep_gen++; +// pg->conn = db_conn; +// } +// if (NULL == pg->transaction_name) +// GNUNET_PQ_reconnect_if_down (pg->conn); +// return GNUNET_OK; +// } -/** - * Initialize Postgres database subsystem. - * - * @param cls a configuration instance - * @return NULL on error, otherwise a `struct - * TALER_DONAUDB_Plugin` - */ -void * -libtaler_plugin_donaudb_postgres_init (void *cls) -{ - const struct GNUNET_CONFIGURATION_Handle *cfg = cls; - struct PostgresClosure *pg; - struct TALER_DONAUDB_Plugin *plugin; - unsigned long long dpl; - - pg = GNUNET_new (struct PostgresClosure); - pg->cfg = cfg; - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "donaudb-postgres", - "SQL_DIR", - &pg->sql_dir)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "donaudb-postgres", - "SQL_DIR"); - GNUNET_free (pg); - return NULL; - } - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, - "donau", - "BASE_URL", - &pg->donau_url)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "donau", - "BASE_URL"); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; - } - if ( (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "donaudb", - "IDLE_RESERVE_EXPIRATION_TIME", - &pg->idle_reserve_expiration_time)) - || - (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "donaudb", - "LEGAL_RESERVE_EXPIRATION_TIME", - &pg->legal_reserve_expiration_time)) ) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "donaudb", - "LEGAL/IDLE_RESERVE_EXPIRATION_TIME"); - GNUNET_free (pg->donau_url); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; - } - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_time (cfg, - "donaudb", - "AGGREGATOR_SHIFT", - &pg->aggregator_shift)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, - "donaudb", - "AGGREGATOR_SHIFT"); - } - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_number (cfg, - "donaudb", - "DEFAULT_PURSE_LIMIT", - &dpl)) - { - GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, - "donaudb", - "DEFAULT_PURSE_LIMIT"); - pg->def_purse_limit = 1; - } - else - { - pg->def_purse_limit = (uint32_t) dpl; - } +// /** +// * Initialize Postgres database subsystem. +// * +// * @param cls a configuration instance +// * @return NULL on error, otherwise a `struct +// * DONAUDB_Plugin` +// */ +// void * +// libtaler_plugin_donaudb_postgres_init (void *cls) +// { +// const struct GNUNET_CONFIGURATION_Handle *cfg = cls; +// struct PostgresClosure *pg; +// struct DONAUDB_Plugin *plugin; +// unsigned long long dpl; - if (GNUNET_OK != - TALER_config_get_currency (cfg, - &pg->currency)) - { - GNUNET_free (pg->donau_url); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; - } - if (GNUNET_OK != - TEH_PG_internal_setup (pg)) - { - GNUNET_free (pg->donau_url); - GNUNET_free (pg->currency); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg); - return NULL; - } - plugin = GNUNET_new (struct TALER_DONAUDB_Plugin); - plugin->cls = pg; - plugin->do_reserve_open - = &TEH_PG_do_reserve_open; - plugin->drop_tables - = &TEH_PG_drop_tables; - plugin->do_withdraw - = &TEH_PG_do_withdraw; - plugin->free_coin_transaction_list - = &TEH_COMMON_free_coin_transaction_list; - plugin->free_reserve_history - = &TEH_COMMON_free_reserve_history; - plugin->get_coin_transactions - = &TEH_PG_get_coin_transactions; - plugin->get_expired_reserves - = &TEH_PG_get_expired_reserves; - plugin->get_purse_request - = &TEH_PG_get_purse_request; - plugin->get_reserve_history - = &TEH_PG_get_reserve_history; - plugin->get_reserve_status - = &TEH_PG_get_reserve_status; - plugin->get_unfinished_close_requests - = &TEH_PG_get_unfinished_close_requests; - plugin->insert_records_by_table - = &TEH_PG_insert_records_by_table; - plugin->insert_reserve_open_deposit - = &TEH_PG_insert_reserve_open_deposit; - plugin->insert_close_request - = &TEH_PG_insert_close_request; - plugin->delete_aggregation_transient - = &TEH_PG_delete_aggregation_transient; - plugin->get_link_data - = &TEH_PG_get_link_data; - plugin->iterate_reserve_close_info - = &TEH_PG_iterate_reserve_close_info; - plugin->iterate_kyc_reference - = &TEH_PG_iterate_kyc_reference; - plugin->lookup_records_by_table - = &TEH_PG_lookup_records_by_table; - plugin->lookup_serial_by_table - = &TEH_PG_lookup_serial_by_table; - plugin->select_account_merges_above_serial_id - = &TEH_PG_select_account_merges_above_serial_id; - plugin->select_all_purse_decisions_above_serial_id - = &TEH_PG_select_all_purse_decisions_above_serial_id; - plugin->select_aml_threshold - = &TEH_PG_select_aml_threshold; - plugin->select_purse - = &TEH_PG_select_purse; - plugin->select_purse_deposits_above_serial_id - = &TEH_PG_select_purse_deposits_above_serial_id; - plugin->select_purse_merges_above_serial_id - = &TEH_PG_select_purse_merges_above_serial_id; - plugin->select_purse_requests_above_serial_id - = &TEH_PG_select_purse_requests_above_serial_id; - plugin->select_reserve_close_info - = &TEH_PG_select_reserve_close_info; - plugin->select_reserve_closed_above_serial_id - = &TEH_PG_select_reserve_closed_above_serial_id; - plugin->select_reserve_open_above_serial_id - = &TEH_PG_select_reserve_open_above_serial_id; - plugin->insert_purse_request - = &TEH_PG_insert_purse_request; - plugin->iterate_active_signkeys - = &TEH_PG_iterate_active_signkeys; - plugin->commit - = &TEH_PG_commit; - plugin->preflight - = &TEH_PG_preflight; - plugin->select_aggregation_amounts_for_kyc_check - = &TEH_PG_select_aggregation_amounts_for_kyc_check; - plugin->select_satisfied_kyc_processes - = &TEH_PG_select_satisfied_kyc_processes; - plugin->kyc_provider_account_lookup - = &TEH_PG_kyc_provider_account_lookup; - plugin->lookup_kyc_requirement_by_row - = &TEH_PG_lookup_kyc_requirement_by_row; - plugin->insert_kyc_requirement_for_account - = &TEH_PG_insert_kyc_requirement_for_account; - plugin->lookup_kyc_process_by_account - = &TEH_PG_lookup_kyc_process_by_account; - plugin->update_kyc_process_by_row - = &TEH_PG_update_kyc_process_by_row; - plugin->insert_kyc_requirement_process - = &TEH_PG_insert_kyc_requirement_process; - plugin->select_withdraw_amounts_for_kyc_check - = &TEH_PG_select_withdraw_amounts_for_kyc_check; - plugin->select_merge_amounts_for_kyc_check - = &TEH_PG_select_merge_amounts_for_kyc_check; - plugin->profit_drains_set_finished - = &TEH_PG_profit_drains_set_finished; - plugin->profit_drains_get_pending - = &TEH_PG_profit_drains_get_pending; - plugin->get_drain_profit - = &TEH_PG_get_drain_profit; - plugin->get_purse_deposit - = &TEH_PG_get_purse_deposit; - plugin->insert_contract - = &TEH_PG_insert_contract; - plugin->select_contract - = &TEH_PG_select_contract; - plugin->select_purse_merge - = &TEH_PG_select_purse_merge; - plugin->select_contract_by_purse - = &TEH_PG_select_contract_by_purse; - plugin->insert_drain_profit - = &TEH_PG_insert_drain_profit; - plugin->do_reserve_purse - = &TEH_PG_do_reserve_purse; - plugin->lookup_global_fee_by_time - = &TEH_PG_lookup_global_fee_by_time; - plugin->do_purse_deposit - = &TEH_PG_do_purse_deposit; - plugin->activate_signing_key - = &TEH_PG_activate_signing_key; - plugin->update_auditor - = &TEH_PG_update_auditor; - plugin->begin_revolving_shard - = &TEH_PG_begin_revolving_shard; - plugin->get_extension_manifest - = &TEH_PG_get_extension_manifest; - plugin->insert_history_request - = &TEH_PG_insert_history_request; - plugin->do_purse_merge - = &TEH_PG_do_purse_merge; - plugin->do_purse_delete - = &TEH_PG_do_purse_delete; - plugin->start_read_committed - = &TEH_PG_start_read_committed; - plugin->start_read_only - = &TEH_PG_start_read_only; - plugin->insert_denomination_info - = &TEH_PG_insert_denomination_info; - plugin->do_batch_withdraw_insert - = &TEH_PG_do_batch_withdraw_insert; - plugin->lookup_wire_fee_by_time - = &TEH_PG_lookup_wire_fee_by_time; - plugin->start - = &TEH_PG_start; - plugin->rollback - = &TEH_PG_rollback; - plugin->create_tables - = &TEH_PG_create_tables; - plugin->event_listen - = &TEH_PG_event_listen; - plugin->event_listen_cancel - = &TEH_PG_event_listen_cancel; - plugin->event_notify - = &TEH_PG_event_notify; - plugin->get_denomination_info - = &TEH_PG_get_denomination_info; - plugin->iterate_denomination_info - = &TEH_PG_iterate_denomination_info; - plugin->iterate_denominations - = &TEH_PG_iterate_denominations; - plugin->iterate_active_auditors - = &TEH_PG_iterate_active_auditors; - plugin->iterate_auditor_denominations - = &TEH_PG_iterate_auditor_denominations; - plugin->reserves_get - = &TEH_PG_reserves_get; - plugin->reserves_get_origin - = &TEH_PG_reserves_get_origin; - plugin->drain_kyc_alert - = &TEH_PG_drain_kyc_alert; - plugin->reserves_in_insert - = &TEH_PG_reserves_in_insert; - plugin->get_withdraw_info - = &TEH_PG_get_withdraw_info; - plugin->do_batch_withdraw - = &TEH_PG_do_batch_withdraw; - plugin->do_age_withdraw - = &TEH_PG_do_age_withdraw; - plugin->get_age_withdraw - = &TEH_PG_get_age_withdraw; - plugin->get_policy_details - = &TEH_PG_get_policy_details; - plugin->persist_policy_details - = &TEH_PG_persist_policy_details; - plugin->do_deposit - = &TEH_PG_do_deposit; - plugin->add_policy_fulfillment_proof - = &TEH_PG_add_policy_fulfillment_proof; - plugin->do_melt - = &TEH_PG_do_melt; - plugin->do_refund - = &TEH_PG_do_refund; - plugin->do_recoup - = &TEH_PG_do_recoup; - plugin->do_recoup_refresh - = &TEH_PG_do_recoup_refresh; - plugin->get_reserve_balance - = &TEH_PG_get_reserve_balance; - plugin->count_known_coins - = &TEH_PG_count_known_coins; - plugin->ensure_coin_known - = &TEH_PG_ensure_coin_known; - plugin->get_known_coin - = &TEH_PG_get_known_coin; - plugin->get_coin_denomination - = &TEH_PG_get_coin_denomination; - plugin->have_deposit2 - = &TEH_PG_have_deposit2; - plugin->aggregate - = &TEH_PG_aggregate; - plugin->create_aggregation_transient - = &TEH_PG_create_aggregation_transient; - plugin->select_aggregation_transient - = &TEH_PG_select_aggregation_transient; - plugin->find_aggregation_transient - = &TEH_PG_find_aggregation_transient; - plugin->update_aggregation_transient - = &TEH_PG_update_aggregation_transient; - plugin->get_ready_deposit - = &TEH_PG_get_ready_deposit; - plugin->insert_refund - = &TEH_PG_insert_refund; - plugin->select_refunds_by_coin - = &TEH_PG_select_refunds_by_coin; - plugin->get_melt - = &TEH_PG_get_melt; - plugin->insert_refresh_reveal - = &TEH_PG_insert_refresh_reveal; - plugin->get_refresh_reveal - = &TEH_PG_get_refresh_reveal; - plugin->lookup_wire_transfer - = &TEH_PG_lookup_wire_transfer; - plugin->lookup_transfer_by_deposit - = &TEH_PG_lookup_transfer_by_deposit; - plugin->insert_wire_fee - = &TEH_PG_insert_wire_fee; - plugin->insert_global_fee - = &TEH_PG_insert_global_fee; - plugin->get_wire_fee - = &TEH_PG_get_wire_fee; - plugin->get_global_fee - = &TEH_PG_get_global_fee; - plugin->get_global_fees - = &TEH_PG_get_global_fees; - plugin->insert_reserve_closed - = &TEH_PG_insert_reserve_closed; - plugin->wire_prepare_data_insert - = &TEH_PG_wire_prepare_data_insert; - plugin->wire_prepare_data_mark_finished - = &TEH_PG_wire_prepare_data_mark_finished; - plugin->wire_prepare_data_mark_failed - = &TEH_PG_wire_prepare_data_mark_failed; - plugin->wire_prepare_data_get - = &TEH_PG_wire_prepare_data_get; - plugin->start_deferred_wire_out - = &TEH_PG_start_deferred_wire_out; - plugin->store_wire_transfer_out - = &TEH_PG_store_wire_transfer_out; - plugin->gc - = &TEH_PG_gc; - plugin->select_coin_deposits_above_serial_id - = &TEH_PG_select_coin_deposits_above_serial_id; - plugin->select_history_requests_above_serial_id - = &TEH_PG_select_history_requests_above_serial_id; - plugin->select_purse_decisions_above_serial_id - = &TEH_PG_select_purse_decisions_above_serial_id; - plugin->select_purse_deposits_by_purse - = &TEH_PG_select_purse_deposits_by_purse; - plugin->select_refreshes_above_serial_id - = &TEH_PG_select_refreshes_above_serial_id; - plugin->select_refunds_above_serial_id - = &TEH_PG_select_refunds_above_serial_id; - plugin->select_reserves_in_above_serial_id - = &TEH_PG_select_reserves_in_above_serial_id; - plugin->select_reserves_in_above_serial_id_by_account - = &TEH_PG_select_reserves_in_above_serial_id_by_account; - plugin->select_withdrawals_above_serial_id - = &TEH_PG_select_withdrawals_above_serial_id; - plugin->select_wire_out_above_serial_id - = &TEH_PG_select_wire_out_above_serial_id; - plugin->select_wire_out_above_serial_id_by_account - = &TEH_PG_select_wire_out_above_serial_id_by_account; - plugin->select_recoup_above_serial_id - = &TEH_PG_select_recoup_above_serial_id; - plugin->select_recoup_refresh_above_serial_id - = &TEH_PG_select_recoup_refresh_above_serial_id; - plugin->get_reserve_by_h_blind - = &TEH_PG_get_reserve_by_h_blind; - plugin->get_old_coin_by_h_blind - = &TEH_PG_get_old_coin_by_h_blind; - plugin->insert_denomination_revocation - = &TEH_PG_insert_denomination_revocation; - plugin->get_denomination_revocation - = &TEH_PG_get_denomination_revocation; - plugin->select_batch_deposits_missing_wire - = &TEH_PG_select_batch_deposits_missing_wire; - plugin->lookup_auditor_timestamp - = &TEH_PG_lookup_auditor_timestamp; - plugin->lookup_auditor_status - = &TEH_PG_lookup_auditor_status; - plugin->insert_auditor - = &TEH_PG_insert_auditor; - plugin->lookup_wire_timestamp - = &TEH_PG_lookup_wire_timestamp; - plugin->insert_wire - = &TEH_PG_insert_wire; - plugin->update_wire - = &TEH_PG_update_wire; - plugin->get_wire_accounts - = &TEH_PG_get_wire_accounts; - plugin->get_wire_fees - = &TEH_PG_get_wire_fees; - plugin->insert_signkey_revocation - = &TEH_PG_insert_signkey_revocation; - plugin->lookup_signkey_revocation - = &TEH_PG_lookup_signkey_revocation; - plugin->lookup_denomination_key - = &TEH_PG_lookup_denomination_key; - plugin->insert_auditor_denom_sig - = &TEH_PG_insert_auditor_denom_sig; - plugin->select_auditor_denom_sig - = &TEH_PG_select_auditor_denom_sig; - plugin->add_denomination_key - = &TEH_PG_add_denomination_key; - plugin->lookup_signing_key - = &TEH_PG_lookup_signing_key; - plugin->begin_shard - = &TEH_PG_begin_shard; - plugin->abort_shard - = &TEH_PG_abort_shard; - plugin->complete_shard - = &TEH_PG_complete_shard; - plugin->release_revolving_shard - = &TEH_PG_release_revolving_shard; - plugin->delete_shard_locks - = &TEH_PG_delete_shard_locks; - plugin->set_extension_manifest - = &TEH_PG_set_extension_manifest; - plugin->insert_partner - = &TEH_PG_insert_partner; - plugin->expire_purse - = &TEH_PG_expire_purse; - plugin->select_purse_by_merge_pub - = &TEH_PG_select_purse_by_merge_pub; - plugin->set_purse_balance - = &TEH_PG_set_purse_balance; - plugin->insert_kyc_attributes - = &TEH_PG_insert_kyc_attributes; - plugin->select_similar_kyc_attributes - = &TEH_PG_select_similar_kyc_attributes; - plugin->select_kyc_attributes - = &TEH_PG_select_kyc_attributes; - plugin->insert_aml_officer - = &TEH_PG_insert_aml_officer; - plugin->test_aml_officer - = &TEH_PG_test_aml_officer; - plugin->lookup_aml_officer - = &TEH_PG_lookup_aml_officer; - plugin->trigger_aml_process - = &TEH_PG_trigger_aml_process; - plugin->select_aml_process - = &TEH_PG_select_aml_process; - plugin->select_aml_history - = &TEH_PG_select_aml_history; - plugin->insert_aml_decision - = &TEH_PG_insert_aml_decision; +// pg = GNUNET_new (struct PostgresClosure); +// pg->cfg = cfg; +// if (GNUNET_OK != +// GNUNET_CONFIGURATION_get_value_filename (cfg, +// "donaudb-postgres", +// "SQL_DIR", +// &pg->sql_dir)) +// { +// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +// "donaudb-postgres", +// "SQL_DIR"); +// GNUNET_free (pg); +// return NULL; +// } +// if (GNUNET_OK != +// GNUNET_CONFIGURATION_get_value_string (cfg, +// "donau", +// "BASE_URL", +// &pg->donau_url)) +// { +// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +// "donau", +// "BASE_URL"); +// GNUNET_free (pg->sql_dir); +// GNUNET_free (pg); +// return NULL; +// } +// if ( (GNUNET_OK != +// GNUNET_CONFIGURATION_get_value_time (cfg, +// "donaudb", +// "IDLE_RESERVE_EXPIRATION_TIME", +// &pg->idle_reserve_expiration_time)) +// || +// (GNUNET_OK != +// GNUNET_CONFIGURATION_get_value_time (cfg, +// "donaudb", +// "LEGAL_RESERVE_EXPIRATION_TIME", +// &pg->legal_reserve_expiration_time)) ) +// { +// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, +// "donaudb", +// "LEGAL/IDLE_RESERVE_EXPIRATION_TIME"); +// GNUNET_free (pg->donau_url); +// GNUNET_free (pg->sql_dir); +// GNUNET_free (pg); +// return NULL; +// } +// if (GNUNET_OK != +// GNUNET_CONFIGURATION_get_value_time (cfg, +// "donaudb", +// "AGGREGATOR_SHIFT", +// &pg->aggregator_shift)) +// { +// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, +// "donaudb", +// "AGGREGATOR_SHIFT"); +// } +// if (GNUNET_OK != +// GNUNET_CONFIGURATION_get_value_number (cfg, +// "donaudb", +// "DEFAULT_PURSE_LIMIT", +// &dpl)) +// { +// GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING, +// "donaudb", +// "DEFAULT_PURSE_LIMIT"); +// pg->def_purse_limit = 1; +// } +// else +// { +// pg->def_purse_limit = (uint32_t) dpl; +// } - plugin->batch_ensure_coin_known - = &TEH_PG_batch_ensure_coin_known; +// if (GNUNET_OK != +// TALER_config_get_currency (cfg, +// &pg->currency)) +// { +// GNUNET_free (pg->donau_url); +// GNUNET_free (pg->sql_dir); +// GNUNET_free (pg); +// return NULL; +// } +// if (GNUNET_OK != +// TEH_PG_internal_setup (pg)) +// { +// GNUNET_free (pg->donau_url); +// GNUNET_free (pg->currency); +// GNUNET_free (pg->sql_dir); +// GNUNET_free (pg); +// return NULL; +// } +// plugin = GNUNET_new (struct DONAUDB_Plugin); +// plugin->cls = pg; +// plugin->do_reserve_open +// = &TEH_PG_do_reserve_open; +// plugin->drop_tables +// = &TEH_PG_drop_tables; +// plugin->do_withdraw +// = &TEH_PG_do_withdraw; - return plugin; -} +// return plugin; +// } -/** - * Shutdown Postgres database subsystem. - * - * @param cls a `struct TALER_DONAUDB_Plugin` - * @return NULL (always) - */ -void * -libtaler_plugin_donaudb_postgres_done (void *cls) -{ - struct TALER_DONAUDB_Plugin *plugin = cls; - struct PostgresClosure *pg = plugin->cls; +// /** +// * Shutdown Postgres database subsystem. +// * +// * @param cls a `struct DONAUDB_Plugin` +// * @return NULL (always) +// */ +// void * +// libtaler_plugin_donaudb_postgres_done (void *cls) +// { +// struct DONAUDB_Plugin *plugin = cls; +// struct PostgresClosure *pg = plugin->cls; - if (NULL != pg->conn) - { - GNUNET_PQ_disconnect (pg->conn); - pg->conn = NULL; - } - GNUNET_free (pg->donau_url); - GNUNET_free (pg->sql_dir); - GNUNET_free (pg->currency); - GNUNET_free (pg); - GNUNET_free (plugin); - return NULL; -} +// if (NULL != pg->conn) +// { +// GNUNET_PQ_disconnect (pg->conn); +// pg->conn = NULL; +// } +// GNUNET_free (pg->donau_url); +// GNUNET_free (pg->sql_dir); +// GNUNET_free (pg->currency); +// GNUNET_free (pg); +// GNUNET_free (plugin); +// return NULL; +// } /* end of plugin_donaudb_postgres.c */ diff --git a/src/donaudb/test_donaudb.c b/src/donaudb/test_donaudb.c @@ -20,10 +20,10 @@ * @author Christian Grothoff * @author Marcello Stanisci */ -#include "platform.h" +#include "taler/platform.h" #include "taler_donaudb_lib.h" -#include "taler_json_lib.h" -#include "taler_donaudb_plugin.h" +#include "taler/taler_json_lib.h" +#include "donaudb_plugin.h" /** * Global result from the testcase. @@ -62,7 +62,7 @@ static int result; /** * Database plugin under test. */ -static struct TALER_DONAUDB_Plugin *plugin; +static struct DONAUDB_Plugin *plugin; /** @@ -219,7 +219,7 @@ check_reserve (const struct TALER_ReservePublicKeyP *pub, uint32_t fraction, const char *currency) { - struct TALER_DONAUDB_Reserve reserve; + struct DONAUDB_Reserve reserve; reserve.pub = *pub; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -271,8 +271,8 @@ create_denom_key_pair (unsigned int size, const struct TALER_DenomFeeSet *fees) { struct DenomKeyPair *dkp; - struct TALER_DONAUDB_DenominationKey dki; - struct TALER_DONAUDB_DenominationKeyInformation issue2; + struct DONAUDB_DenominationKey dki; + struct DONAUDB_DenominationKeyInformation issue2; dkp = GNUNET_new (struct DenomKeyPair); GNUNET_assert (GNUNET_OK == @@ -284,7 +284,7 @@ create_denom_key_pair (unsigned int size, are not properly initialized for this test. */ memset (&dki, 0, - sizeof (struct TALER_DONAUDB_DenominationKey)); + sizeof (struct DONAUDB_DenominationKey)); dki.denom_pub = dkp->pub; dki.issue.start = now; dki.issue.expire_withdraw @@ -359,7 +359,7 @@ static struct TALER_Amount amount_with_fee; */ #define RSA_KEY_SIZE 1024 -static struct TALER_DONAUDB_RefreshRevealedCoin *revealed_coins; +static struct DONAUDB_RefreshRevealedCoin *revealed_coins; static struct TALER_TransferPrivateKeyP tprivs[TALER_CNC_KAPPA]; @@ -378,7 +378,7 @@ static struct TALER_TransferPublicKeyP tpub; static void never_called_cb (void *cls, uint32_t num_freshcoins, - const struct TALER_DONAUDB_RefreshRevealedCoin *rrcs) + const struct DONAUDB_RefreshRevealedCoin *rrcs) { (void) cls; (void) num_freshcoins; @@ -400,15 +400,15 @@ static void check_refresh_reveal_cb ( void *cls, uint32_t num_freshcoins, - const struct TALER_DONAUDB_RefreshRevealedCoin *rrcs) + const struct DONAUDB_RefreshRevealedCoin *rrcs) { (void) cls; /* compare the refresh commit coin arrays */ for (unsigned int cnt = 0; cnt < num_freshcoins; cnt++) { - const struct TALER_DONAUDB_RefreshRevealedCoin *acoin = + const struct DONAUDB_RefreshRevealedCoin *acoin = &revealed_coins[cnt]; - const struct TALER_DONAUDB_RefreshRevealedCoin *bcoin = &rrcs[cnt]; + const struct DONAUDB_RefreshRevealedCoin *bcoin = &rrcs[cnt]; GNUNET_assert (0 == TALER_blinded_planchet_cmp (&acoin->blinded_planchet, @@ -487,11 +487,11 @@ static struct DenomKeyPair **new_dkp; static void handle_link_data_cb (void *cls, const struct TALER_TransferPublicKeyP *transfer_pub, - const struct TALER_DONAUDB_LinkList *ldl) + const struct DONAUDB_LinkList *ldl) { (void) cls; (void) transfer_pub; - for (const struct TALER_DONAUDB_LinkList *ldlp = ldl; + for (const struct DONAUDB_LinkList *ldlp = ldl; NULL != ldlp; ldlp = ldlp->next) { @@ -522,7 +522,7 @@ handle_link_data_cb (void *cls, static void cb_wt_never (void *cls, uint64_t serial_id, - const struct TALER_CharityPublicKeyP *charity_pub, + const struct DONAU_CharityPublicKeyP *charity_pub, const char *account_payto_uri, const struct TALER_PaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, @@ -547,7 +547,7 @@ cb_wt_never (void *cls, } -static struct TALER_CharityPublicKeyP charity_pub_wt; +static struct DONAU_CharityPublicKeyP charity_pub_wt; static struct TALER_CharityWireHashP h_wire_wt; static struct TALER_PrivateContractHashP h_contract_terms_wt; static struct TALER_CoinSpendPublicKeyP coin_pub_wt; @@ -564,7 +564,7 @@ static struct TALER_WireTransferIdentifierRawP wire_out_wtid; static void cb_wt_check (void *cls, uint64_t rowid, - const struct TALER_CharityPublicKeyP *charity_pub, + const struct DONAU_CharityPublicKeyP *charity_pub, const char *account_payto_uri, const struct TALER_PaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, @@ -617,7 +617,7 @@ static enum GNUNET_GenericReturnValue audit_deposit_cb (void *cls, uint64_t rowid, struct GNUNET_TIME_Timestamp donau_timestamp, - const struct TALER_DONAUDB_Deposit *deposit, + const struct DONAUDB_Deposit *deposit, const struct TALER_DenominationPublicKey *denom_pub, bool done) { @@ -654,8 +654,8 @@ audit_refund_cb (void *cls, uint64_t rowid, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub, - const struct TALER_CharityPublicKeyP *charity_pub, - const struct TALER_CharitySignatureP *charity_sig, + const struct DONAU_CharityPublicKeyP *charity_pub, + const struct DONAU_CharitySignatureP *charity_sig, const struct TALER_PrivateContractHashP *h_contract_terms, uint64_t rtransaction_id, bool full_refund, @@ -756,7 +756,7 @@ test_gc (void) struct DenomKeyPair *dkp; struct GNUNET_TIME_Timestamp now; struct GNUNET_TIME_Timestamp past; - struct TALER_DONAUDB_DenominationKeyInformation issue2; + struct DONAUDB_DenominationKeyInformation issue2; struct TALER_DenominationHashP denom_hash; now = GNUNET_TIME_timestamp_get (); @@ -934,9 +934,9 @@ audit_wire_cb (void *cls, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -test_wire_out (const struct TALER_DONAUDB_BatchDeposit *bd) +test_wire_out (const struct DONAUDB_BatchDeposit *bd) { - const struct TALER_DONAUDB_CoinDepositInformation *deposit = &bd->cdis[0]; + const struct DONAUDB_CoinDepositInformation *deposit = &bd->cdis[0]; struct TALER_PaytoHashP h_payto; GNUNET_assert (0 < bd->num_cdis); @@ -982,7 +982,7 @@ test_wire_out (const struct TALER_DONAUDB_BatchDeposit *bd) struct TALER_Amount coin_contribution2; struct TALER_Amount coin_fee2; struct GNUNET_TIME_Timestamp execution_time2; - struct TALER_DONAUDB_KycStatus kyc; + struct DONAUDB_KycStatus kyc; enum TALER_AmlDecisionState aml; h_contract_terms_wt2.hash.bits[0]++; @@ -1029,7 +1029,7 @@ test_wire_out (const struct TALER_DONAUDB_BatchDeposit *bd) struct TALER_Amount coin_contribution2; struct TALER_Amount coin_fee2; struct GNUNET_TIME_Timestamp execution_time2; - struct TALER_DONAUDB_KycStatus kyc; + struct DONAUDB_KycStatus kyc; enum TALER_AmlDecisionState aml = TALER_AML_FROZEN; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -1116,7 +1116,7 @@ drop: * Function called on deposits that are past their due date * and have not yet seen a wire transfer. * - * @param cls closure a `struct TALER_DONAUDB_Deposit *` + * @param cls closure a `struct DONAUDB_Deposit *` * @param rowid deposit table row of the coin's deposit * @param coin_pub public key of the coin * @param amount value of the deposit, including fee @@ -1133,7 +1133,7 @@ wire_missing_cb (void *cls, struct GNUNET_TIME_Timestamp deadline, bool done) { - const struct TALER_DONAUDB_CoinDepositInformation *deposit = cls; + const struct DONAUDB_CoinDepositInformation *deposit = cls; (void) payto_uri; (void) deadline; @@ -1162,7 +1162,7 @@ wire_missing_cb (void *cls, * Callback invoked with information about refunds applicable * to a particular coin. * - * @param cls closure with the `struct TALER_DONAUDB_Refund *` we expect to get + * @param cls closure with the `struct DONAUDB_Refund *` we expect to get * @param amount_with_fee amount being refunded * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ @@ -1170,7 +1170,7 @@ static enum GNUNET_GenericReturnValue check_refund_cb (void *cls, const struct TALER_Amount *amount_with_fee) { - const struct TALER_DONAUDB_Refund *refund = cls; + const struct DONAUDB_Refund *refund = cls; if (0 != TALER_amount_cmp (amount_with_fee, &refund->details.refund_amount)) @@ -1199,19 +1199,19 @@ run (void *cls) struct TALER_ReservePublicKeyP reserve_pub3; struct DenomKeyPair *dkp = NULL; struct TALER_MasterSignatureP master_sig; - struct TALER_DONAUDB_CollectableBlindcoin cbc; - struct TALER_DONAUDB_CollectableBlindcoin cbc2; - struct TALER_DONAUDB_ReserveHistory *rh = NULL; - struct TALER_DONAUDB_ReserveHistory *rh_head; - struct TALER_DONAUDB_BankTransfer *bt; - struct TALER_DONAUDB_CollectableBlindcoin *withdraw; - struct TALER_DONAUDB_CoinDepositInformation deposit; - struct TALER_DONAUDB_BatchDeposit bd; + struct DONAUDB_CollectableBlindcoin cbc; + struct DONAUDB_CollectableBlindcoin cbc2; + struct DONAUDB_ReserveHistory *rh = NULL; + struct DONAUDB_ReserveHistory *rh_head; + struct DONAUDB_BankTransfer *bt; + struct DONAUDB_CollectableBlindcoin *withdraw; + struct DONAUDB_CoinDepositInformation deposit; + struct DONAUDB_BatchDeposit bd; struct TALER_CoinSpendPublicKeyP cpub2; - struct TALER_CharityPublicKeyP mpub2; - struct TALER_DONAUDB_Refund refund; - struct TALER_DONAUDB_TransactionList *tl; - struct TALER_DONAUDB_TransactionList *tlp; + struct DONAU_CharityPublicKeyP mpub2; + struct DONAUDB_Refund refund; + struct DONAUDB_TransactionList *tl; + struct DONAUDB_TransactionList *tlp; const char *sndr = "payto://x-taler-bank/localhost:8080/1"; const char *rcvr = "payto://x-taler-bank/localhost:8080/2"; const uint32_t num_partitions = 10; @@ -1223,7 +1223,7 @@ run (void *cls) struct TALER_CoinPubHashP c_hash; uint64_t known_coin_id; uint64_t rrc_serial; - struct TALER_DONAUDB_Refresh refresh; + struct DONAUDB_Refresh refresh; struct TALER_DenominationPublicKey *new_denom_pubs = NULL; uint64_t reserve_out_serial_id; uint64_t melt_serial_id; @@ -1253,7 +1253,7 @@ run (void *cls) ZR_BLK (&cbc); ZR_BLK (&cbc2); if (NULL == - (plugin = TALER_DONAUDB_plugin_load (cfg))) + (plugin = DONAUDB_plugin_load (cfg))) { result = 77; return; @@ -1306,7 +1306,7 @@ run (void *cls) plugin->commit (plugin->cls)); now = GNUNET_TIME_timestamp_get (); { - struct TALER_DONAUDB_ReserveInInfo reserve = { + struct DONAUDB_ReserveInInfo reserve = { .reserve_pub = &reserve_pub, .balance = &value, .execution_time = now, @@ -1332,7 +1332,7 @@ run (void *cls) now = GNUNET_TIME_timestamp_get (); RND_BLK (&reserve_pub2); { - struct TALER_DONAUDB_ReserveInInfo reserve = { + struct DONAUDB_ReserveInInfo reserve = { .reserve_pub = &reserve_pub2, .balance = &value, .execution_time = now, @@ -1512,7 +1512,7 @@ run (void *cls) struct TALER_DenominationHashP dph; struct TALER_AgeCommitmentHash agh; - FAILIF (TALER_DONAUDB_CKS_ADDED != + FAILIF (DONAUDB_CKS_ADDED != plugin->ensure_coin_known (plugin->cls, &deposit.coin, &known_coin_id, @@ -1606,7 +1606,7 @@ run (void *cls) /* test get_melt */ { - struct TALER_DONAUDB_Melt ret_refresh_session; + struct DONAUDB_Melt ret_refresh_session; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_melt (plugin->cls, @@ -1653,10 +1653,10 @@ run (void *cls) struct TALER_DenominationPublicKey); revealed_coins = GNUNET_new_array (MELT_NEW_COINS, - struct TALER_DONAUDB_RefreshRevealedCoin); + struct DONAUDB_RefreshRevealedCoin); for (unsigned int cnt = 0; cnt < MELT_NEW_COINS; cnt++) { - struct TALER_DONAUDB_RefreshRevealedCoin *ccoin; + struct DONAUDB_RefreshRevealedCoin *ccoin; struct GNUNET_TIME_Timestamp now; struct TALER_BlindedRsaPlanchet *rp; struct TALER_BlindedPlanchet *bp; @@ -1737,7 +1737,7 @@ run (void *cls) FAILIF (0 >= qs); { /* Just to test fetching a coin with melt history */ - struct TALER_DONAUDB_TransactionList *tl; + struct DONAUDB_TransactionList *tl; enum GNUNET_DB_QueryStatus qs; qs = plugin->get_coin_transactions (plugin->cls, @@ -1763,7 +1763,7 @@ run (void *cls) new_coin = deposit.coin; /* steal basic data */ RND_BLK (&new_coin.coin_pub); - FAILIF (TALER_DONAUDB_CKS_ADDED != + FAILIF (DONAUDB_CKS_ADDED != plugin->ensure_coin_known (plugin->cls, &new_coin, &new_known_coin_id, @@ -1787,8 +1787,8 @@ run (void *cls) /* do recoup */ { - struct TALER_DONAUDB_Reserve pre_reserve; - struct TALER_DONAUDB_Reserve post_reserve; + struct DONAUDB_Reserve pre_reserve; + struct DONAUDB_Reserve post_reserve; struct TALER_Amount delta; bool recoup_ok; bool internal_failure; @@ -1887,7 +1887,7 @@ run (void *cls) { switch (rh_head->type) { - case TALER_DONAUDB_RO_BANK_TO_DONAU: + case DONAUDB_RO_BANK_TO_DONAU: bt = rh_head->details.bank; FAILIF (0 != GNUNET_memcmp (&bt->reserve_pub, @@ -1898,7 +1898,7 @@ run (void *cls) FAILIF (0 != strcmp (CURRENCY, bt->amount.currency)); FAILIF (NULL == bt->sender_account_details); break; - case TALER_DONAUDB_RO_WITHDRAW_COIN: + case DONAUDB_RO_WITHDRAW_COIN: withdraw = rh_head->details.withdraw; FAILIF (0 != GNUNET_memcmp (&withdraw->reserve_pub, @@ -1907,9 +1907,9 @@ run (void *cls) GNUNET_memcmp (&withdraw->h_coin_envelope, &cbc.h_coin_envelope)); break; - case TALER_DONAUDB_RO_RECOUP_COIN: + case DONAUDB_RO_RECOUP_COIN: { - struct TALER_DONAUDB_Recoup *recoup = rh_head->details.recoup; + struct DONAUDB_Recoup *recoup = rh_head->details.recoup; FAILIF (0 != GNUNET_memcmp (&recoup->coin_sig, @@ -1928,9 +1928,9 @@ run (void *cls) &value)); } break; - case TALER_DONAUDB_RO_DONAU_TO_BANK: + case DONAUDB_RO_DONAU_TO_BANK: { - struct TALER_DONAUDB_ClosingTransfer *closing + struct DONAUDB_ClosingTransfer *closing = rh_head->details.closing; FAILIF (0 != @@ -1942,22 +1942,22 @@ run (void *cls) &fee_closing)); } break; - case TALER_DONAUDB_RO_PURSE_MERGE: + case DONAUDB_RO_PURSE_MERGE: { /* FIXME: not yet tested */ break; } - case TALER_DONAUDB_RO_HISTORY_REQUEST: + case DONAUDB_RO_HISTORY_REQUEST: { /* FIXME: not yet tested */ break; } - case TALER_DONAUDB_RO_OPEN_REQUEST: + case DONAUDB_RO_OPEN_REQUEST: { /* FIXME: not yet tested */ break; } - case TALER_DONAUDB_RO_CLOSE_REQUEST: + case DONAUDB_RO_CLOSE_REQUEST: { /* FIXME: not yet tested */ break; @@ -1998,9 +1998,9 @@ run (void *cls) { switch (tlp->type) { - case TALER_DONAUDB_TT_DEPOSIT: + case DONAUDB_TT_DEPOSIT: { - struct TALER_DONAUDB_DepositListEntry *have = tlp->details.deposit; + struct DONAUDB_DepositListEntry *have = tlp->details.deposit; /* Note: we're not comparing the denomination keys, as there is still the question of whether we should even bother exporting @@ -2032,15 +2032,15 @@ run (void *cls) break; } /* this coin pub was actually never melted... */ - case TALER_DONAUDB_TT_MELT: + case DONAUDB_TT_MELT: FAILIF (0 != GNUNET_memcmp (&refresh.rc, &tlp->details.melt->rc)); matched |= 2; break; - case TALER_DONAUDB_TT_REFUND: + case DONAUDB_TT_REFUND: { - struct TALER_DONAUDB_RefundListEntry *have = tlp->details.refund; + struct DONAUDB_RefundListEntry *have = tlp->details.refund; /* Note: we're not comparing the denomination keys, as there is still the question of whether we should even bother exporting @@ -2059,9 +2059,9 @@ run (void *cls) matched |= 4; break; } - case TALER_DONAUDB_TT_RECOUP: + case DONAUDB_TT_RECOUP: { - struct TALER_DONAUDB_RecoupListEntry *recoup = + struct DONAUDB_RecoupListEntry *recoup = tlp->details.recoup; FAILIF (0 != GNUNET_memcmp (&recoup->coin_sig, @@ -2075,7 +2075,7 @@ run (void *cls) matched |= 8; break; } - case TALER_DONAUDB_TT_OLD_COIN_RECOUP: + case DONAUDB_TT_OLD_COIN_RECOUP: /* TODO: check fields better... */ matched |= 16; break; @@ -2127,7 +2127,7 @@ run (void *cls) struct TALER_DenominationHashP dph; struct TALER_AgeCommitmentHash agh; - FAILIF (TALER_DONAUDB_CKS_ADDED != + FAILIF (DONAUDB_CKS_ADDED != plugin->ensure_coin_known (plugin->cls, &deposit.coin, &known_coin_id, @@ -2154,8 +2154,8 @@ run (void *cls) &bad_idx, &ctr_conflict)); TALER_charity_wire_signature_hash (bd.receiver_wire_account, - &bd.wire_salt, - &h_wire); + &bd.wire_salt, + &h_wire); FAILIF (1 != plugin->have_deposit2 (plugin->cls, &bd.h_contract_terms, @@ -2197,7 +2197,7 @@ run (void *cls) result = 8; sleep (2); /* give deposit time to be ready */ { - struct TALER_CharityPublicKeyP charity_pub2; + struct DONAU_CharityPublicKeyP charity_pub2; char *payto_uri2; FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != @@ -2322,8 +2322,8 @@ run (void *cls) struct TALER_Amount deposit_fee; TALER_charity_wire_signature_hash (bd.receiver_wire_account, - &bd.wire_salt, - &h_wire); + &bd.wire_salt, + &h_wire); FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS != plugin->have_deposit2 (plugin->cls, &bd.h_contract_terms, @@ -2432,7 +2432,7 @@ cleanup: TALER_blinded_denom_sig_free (&cbc.sig); TALER_blinded_denom_sig_free (&cbc2.sig); dkp = NULL; - TALER_DONAUDB_plugin_unload (plugin); + DONAUDB_plugin_unload (plugin); plugin = NULL; } diff --git a/src/include/donau_service.h b/src/include/donau_service.h @@ -21,13 +21,13 @@ * @author Özgür Kesim * @author Lukas Matyja */ -#ifndef _TALER_DONAU_SERVICE_H -#define _TALER_DONAU_SERVICE_H +#ifndef _DONAU_SERVICE_H +#define _DONAU_SERVICE_H #include <jansson.h> #include "taler_util.h" #include "taler_donau_util.h" -#include "taler_error_codes.h" +#include "taler/taler_error_codes.h" #include "taler_kyclogic_lib.h" #include <gnunet/gnunet_curl_lib.h> @@ -38,12 +38,12 @@ /** * @brief Donau's statement signing public key */ -struct TALER_DONAU_SigningPublicKeyAndValidity +struct DONAU_SigningPublicKeyAndValidity { /** * The signing public key */ - struct TALER_DONAU_EddsaPublicKeyP key; + struct DONAU_EddsaPublicKeyP key; /** * Tax year this key is valid for. @@ -52,7 +52,6 @@ struct TALER_DONAU_SigningPublicKeyAndValidity }; - /** * @brief Public information about a donau's donation unit signing key */ @@ -61,7 +60,7 @@ struct TALER_DonationUnitInformation /** * The public key */ - struct TALER_DonationUnitPublicKey key; + struct DONAU_DonationUnitPublicKey key; /** * amount of the donation @@ -78,13 +77,13 @@ struct TALER_DonationUnitInformation /** * @brief Information about keys from the donau. */ -struct TALER_DONAU_Keys +struct DONAU_Keys { /** * Array of the donau's online signing keys. */ - struct TALER_DONAU_SigningPublicKeyAndValidity *sign_keys; + struct DONAU_SigningPublicKeyAndValidity *sign_keys; /** * Array of the donau'sdonation unit keys. @@ -145,49 +144,49 @@ struct TALER_DONAU_Keys * client? The bits (1,2,4) can be used to test if the donau's * version is incompatible, older or newer respectively. */ -enum TALER_DONAU_VersionCompatibility +enum DONAU_VersionCompatibility { /** * The donau runs exactly the same protocol version. */ - TALER_DONAU_VC_MATCH = 0, + DONAU_VC_MATCH = 0, /** * The donau is too old or too new to be compatible with this * implementation (bit) */ - TALER_DONAU_VC_INCOMPATIBLE = 1, + DONAU_VC_INCOMPATIBLE = 1, /** * The donau is older than this implementation (bit) */ - TALER_DONAU_VC_OLDER = 2, + DONAU_VC_OLDER = 2, /** * The donau is too old to be compatible with * this implementation. */ - TALER_DONAU_VC_INCOMPATIBLE_OUTDATED - = TALER_DONAU_VC_INCOMPATIBLE - | TALER_DONAU_VC_OLDER, + DONAU_VC_INCOMPATIBLE_OUTDATED + = DONAU_VC_INCOMPATIBLE + | DONAU_VC_OLDER, /** * The donau is more recent than this implementation (bit). */ - TALER_DONAU_VC_NEWER = 4, + DONAU_VC_NEWER = 4, /** * The donau is too recent for this implementation. */ - TALER_DONAU_VC_INCOMPATIBLE_NEWER - = TALER_DONAU_VC_INCOMPATIBLE - | TALER_DONAU_VC_NEWER, + DONAU_VC_INCOMPATIBLE_NEWER + = DONAU_VC_INCOMPATIBLE + | DONAU_VC_NEWER, /** * We could not even parse the version data. */ - TALER_DONAU_VC_PROTOCOL_ERROR = 8 + DONAU_VC_PROTOCOL_ERROR = 8 }; @@ -196,7 +195,7 @@ enum TALER_DONAU_VersionCompatibility * General information about the HTTP response we obtained * from the donau for a request. */ -struct TALER_DONAU_HttpResponse +struct DONAU_HttpResponse { /** @@ -235,12 +234,12 @@ struct TALER_DONAU_HttpResponse /** * Response from /keys. */ -struct TALER_DONAU_KeysResponse +struct DONAU_KeysResponse { /** * HTTP response dataclosure */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; /** * Details depending on the HTTP status code. @@ -256,12 +255,12 @@ struct TALER_DONAU_KeysResponse /** * Information about the various keys used by the donau. */ - const struct TALER_DONAU_Keys *keys; + const struct DONAU_Keys *keys; /** * Protocol compatibility information */ - enum TALER_DONAU_VersionCompatibility compat; + enum DONAU_VersionCompatibility compat; } ok; } details; @@ -279,19 +278,19 @@ struct TALER_DONAU_KeysResponse * @param kr response from /keys * @param[in] keys keys object passed to callback with * reference counter of 1. Must be freed by callee - * using #TALER_DONAU_keys_decref(). NULL on failure. + * using #DONAU_keys_decref(). NULL on failure. */ typedef void -(*TALER_DONAU_GetKeysCallback) ( +(*DONAU_GetKeysCallback) ( void *cls, - const struct TALER_DONAU_KeysResponse *kr, - struct TALER_DONAU_Keys *keys); + const struct DONAU_KeysResponse *kr, + struct DONAU_Keys *keys); /** * @brief Handle for a GET /keys request. */ -struct TALER_DONAU_GetKeysHandle; +struct DONAU_GetKeysHandle; /** @@ -309,12 +308,12 @@ struct TALER_DONAU_GetKeysHandle; * @param cert_cb_cls closure for @a cert_cb * @return the donau handle; NULL upon error */ -struct TALER_DONAU_GetKeysHandle * -TALER_DONAU_get_keys ( +struct DONAU_GetKeysHandle * +DONAU_get_keys ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *last_keys, - TALER_DONAU_GetKeysCallback cert_cb, + struct DONAU_Keys *last_keys, + DONAU_GetKeysCallback cert_cb, void *cert_cb_cls); @@ -326,18 +325,18 @@ TALER_DONAU_get_keys ( * @return NULL on error; otherwise JSON object owned by the caller */ json_t * -TALER_DONAU_keys_to_json (const struct TALER_DONAU_Keys *kd); +DONAU_keys_to_json (const struct DONAU_Keys *kd); /** * Deserialize keys data stored in @a j. * - * @param j JSON keys data previously returned from #TALER_DONAU_keys_to_json() + * @param j JSON keys data previously returned from #DONAU_keys_to_json() * @return NULL on error (i.e. invalid JSON); otherwise * keys object with reference counter 1 owned by the caller */ -struct TALER_DONAU_Keys * -TALER_DONAU_keys_from_json (const json_t *j); +struct DONAU_Keys * +DONAU_keys_from_json (const json_t *j); /** @@ -346,7 +345,7 @@ TALER_DONAU_keys_from_json (const json_t *j); * @param[in] gkh the GET /keys handle */ void -TALER_DONAU_get_keys_cancel (struct TALER_DONAU_GetKeysHandle *gkh); +DONAU_get_keys_cancel (struct DONAU_GetKeysHandle *gkh); /** @@ -355,8 +354,8 @@ TALER_DONAU_get_keys_cancel (struct TALER_DONAU_GetKeysHandle *gkh); * @param[in,out] keys object to increment reference counter for * @return keys, with incremented reference counter */ -struct TALER_DONAU_Keys * -TALER_DONAU_keys_incref (struct TALER_DONAU_Keys *keys); +struct DONAU_Keys * +DONAU_keys_incref (struct DONAU_Keys *keys); /** @@ -366,7 +365,7 @@ TALER_DONAU_keys_incref (struct TALER_DONAU_Keys *keys); * @param[in,out] keys object to decrement reference counter for */ void -TALER_DONAU_keys_decref (struct TALER_DONAU_Keys *keys); +DONAU_keys_decref (struct DONAU_Keys *keys); /** * Test if the given @a pub is a the current signing key from the donau @@ -378,10 +377,10 @@ TALER_DONAU_keys_decref (struct TALER_DONAU_Keys *keys); * @return #GNUNET_OK if @a pub is (according to /keys and @a year) the corresponding signing key */ enum GNUNET_GenericReturnValue -TALER_DONAU_test_signing_key ( - const struct TALER_DONAU_Keys *keys, +DONAU_test_signing_key ( + const struct DONAU_Keys *keys, const unsigned int year, - const struct TALER_DONAU_EddsaPublicKeyP *pub); + const struct DONAU_EddsaPublicKeyP *pub); /** @@ -393,9 +392,9 @@ TALER_DONAU_test_signing_key ( * found */ const struct TALER_DonationUnitInformation * -TALER_DONAU_get_donation_unit_key ( - const struct TALER_DONAU_Keys *keys, - const struct TALER_DonationUnitPublicKey *pk); +DONAU_get_donation_unit_key ( + const struct DONAU_Keys *keys, + const struct DONAU_DonationUnitPublicKey *pk); /** @@ -406,10 +405,10 @@ TALER_DONAU_get_donation_unit_key ( * @return details about the given donation unit key, returns NULL * if the key is not available or deprecated. */ -const struct TALER_DonationUnitPublicKey * -TALER_DONAU_get_donation_unit_key_by_hash ( - const struct TALER_DONAU_Keys *keys, - const struct TALER_DonationUnitHashP *hc); +const struct DONAU_DonationUnitPublicKey * +DONAU_get_donation_unit_key_by_hash ( + const struct DONAU_Keys *keys, + const struct DONAU_DonationUnitHashP *hc); /** @@ -420,10 +419,10 @@ TALER_DONAU_get_donation_unit_key_by_hash ( * @param donau_pub public key to lookup * @return NULL on error (@a donau_pub not known) */ -const struct TALER_DONAU_SigningPublicKeyAndValidity * -TALER_DONAU_get_signing_key_info ( - const struct TALER_DONAU_Keys *keys, - const struct TALER_DONAU_EddsaPublicKeyP *donau_pub); +const struct DONAU_SigningPublicKeyAndValidity * +DONAU_get_signing_key_info ( + const struct DONAU_Keys *keys, + const struct DONAU_EddsaPublicKeyP *donau_pub); /* ********************* POST / issue receipt *********************** */ @@ -460,19 +459,19 @@ struct TALER_BlindedUniqueDonationIdentifier /** * @brief A Batch Submit Handle */ -struct TALER_DONAU_BatchIssueReceiptHandle; +struct DONAU_BatchIssueReceiptHandle; /** * Structure with information about a batch * of issue receipts. */ -struct TALER_DONAU_BatchIssueReceipts +struct DONAU_BatchIssueReceipts { /** * HTTP response data */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; union { @@ -515,9 +514,9 @@ struct TALER_DONAU_BatchIssueReceipts * @param dr response details */ typedef void -(*TALER_DONAU_BatchIssueReceiptsCallback) ( +(*DONAU_BatchIssueReceiptsCallback) ( void *cls, - const struct TALER_DONAU_BatchIssueReceipts*dr); + const struct DONAU_BatchIssueReceipts*dr); /** @@ -544,14 +543,14 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_BatchIssueReceiptHandle * -TALER_DONAU_charity_issue_receipt ( +struct DONAU_BatchIssueReceiptHandle * +DONAU_charity_issue_receipt ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_DONAU_CharityPrivateKeyP *charity_priv, + const struct DONAU_CharityPrivateKeyP *charity_priv, unsigned int num_bkp, const struct TALER_BlindedUniqueDonationIdentifierKeyPair bkp[static num_bkp], - TALER_DONAU_BatchIssueReceiptsCallback cb, + DONAU_BatchIssueReceiptsCallback cb, void *cb_cls); /** @@ -561,8 +560,8 @@ TALER_DONAU_charity_issue_receipt ( * @param[in] the issue receipt request handle */ void -TALER_DONAU_charity_issue_receipt_cancel ( - struct TALER_DONAU_BatchIssueReceiptHandle *); +DONAU_charity_issue_receipt_cancel ( + struct DONAU_BatchIssueReceiptHandle *); /** * unblinded donation unit signature from Donau @@ -579,18 +578,18 @@ struct TALER_DonationUnitSignature /** * Donation Receipt */ -struct TALER_DONAU_DonationReceipt +struct DONAU_DonationReceipt { /** * The hash of the donation unit's public key. */ - struct TALER_DonationUnitHashP h_donation_unit_pub; + struct DONAU_DonationUnitHashP h_donation_unit_pub; /** * Donor's hashed and salted unique donation identifier. */ - struct TALER_DONAU_HashDonorTaxId donor_id; + struct DONAU_HashDonorTaxId donor_id; /** * Unblinded donation unit signature from the donau. @@ -602,19 +601,19 @@ struct TALER_DONAU_DonationReceipt /** * @brief A Batch Submit receipts Handle */ -struct TALER_DONAU_DonorReceiptsToStatementHandle; +struct DONAU_DonorReceiptsToStatementHandle; /** * Structure with information about a batch * operation's result. */ -struct TALER_DONAU_DonorReceiptsToStatementResult +struct DONAU_DonorReceiptsToStatementResult { /** * HTTP response data */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; union { @@ -655,9 +654,9 @@ struct TALER_DONAU_DonorReceiptsToStatementResult * @param dr response details */ typedef void -(*TALER_DONAU_DonorReceiptsToStatementResultCallback) ( +(*DONAU_DonorReceiptsToStatementResultCallback) ( void *cls, - const struct TALER_DONAU_DonorReceiptsToStatementResult *dr); + const struct DONAU_DonorReceiptsToStatementResult *dr); /** @@ -683,13 +682,13 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_DonorReceiptsToStatementHandle * -TALER_DONAU_donor_receipts_to_statement ( +struct DONAU_DonorReceiptsToStatementHandle * +DONAU_donor_receipts_to_statement ( struct GNUNET_CURL_Context *ctx, const char *url, unsigned int num_drs, - const struct TALER_DONAU_DonationReceipt drs[static num_drs], - TALER_DONAU_DonorReceiptsToStatementResultCallback cb, + const struct DONAU_DonationReceipt drs[static num_drs], + DONAU_DonorReceiptsToStatementResultCallback cb, void *cls); /** @@ -699,8 +698,8 @@ TALER_DONAU_donor_receipts_to_statement ( * @param[in] the Batch Submit recipts handle */ void -TALER_DONAU_donor_receipts_to_statement_cancel ( - struct TALER_DONAU_DonorReceiptsToStatementHandle *); +DONAU_donor_receipts_to_statement_cancel ( + struct DONAU_DonorReceiptsToStatementHandle *); /* ********************* POST /csr batch-issue *********************** */ @@ -709,18 +708,18 @@ TALER_DONAU_donor_receipts_to_statement_cancel ( /** * @brief A /csr-batch-issue Handle */ -struct TALER_DONAU_CsRBatchIssueHandle; +struct DONAU_CsRBatchIssueHandle; /** * Details about a response for a CS R request. */ -struct TALER_DONAU_CsRBatchIssueResponse +struct DONAU_CsRBatchIssueResponse { /** * HTTP response data. */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; /** * Details about the response. @@ -759,9 +758,9 @@ struct TALER_DONAU_CsRBatchIssueResponse * @param csrr response details */ typedef void -(*TALER_DONAU_CsRBatchIssueCallback) ( +(*DONAU_CsRBatchIssueCallback) ( void *cls, - const struct TALER_DONAU_CsRBatchIssueResponse *csrr); + const struct DONAU_CsRBatchIssueResponse *csrr); /** @@ -777,13 +776,13 @@ typedef void * if the inputs are invalid (i.e.donation unit key not with this donau). * In this case, the callback is not called. */ -struct TALER_DONAU_CsRBatchIssueHandle * -TALER_DONAU_csr_batch_issue ( +struct DONAU_CsRBatchIssueHandle * +DONAU_csr_batch_issue ( struct GNUNET_CURL_Context *curl_ctx, const char *donau_url, - const struct TALER_DonationUnitPublicKey *pk, + const struct DONAU_DonationUnitPublicKey *pk, const struct TALER_CsNonce *nonce, - TALER_DONAU_CsRBatchIssueCallback res_cb, + DONAU_CsRBatchIssueCallback res_cb, void *res_cb_cls); @@ -795,8 +794,8 @@ TALER_DONAU_csr_batch_issue ( * @param csrh the batch-issue handle */ void -TALER_DONAU_csr_batch_issue_cancel ( - struct TALER_DONAU_CsRBatchIssueHandle *csrh); +DONAU_csr_batch_issue_cancel ( + struct DONAU_CsRBatchIssueHandle *csrh); /* ********************* GET /charities/ *********************** */ @@ -832,19 +831,19 @@ struct CharitySummary /** * @brief A /charities/ GET Handle */ -struct TALER_DONAU_CharitiesGetHandle; +struct DONAU_CharitiesGetHandle; /** * @brief summary of every charity */ -struct TALER_DONAU_GetCharitiesResponse +struct DONAU_GetCharitiesResponse { /** * High-level HTTP response details. */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; /** * Details depending on @e hr.http_status. @@ -884,9 +883,9 @@ struct TALER_DONAU_GetCharitiesResponse * @param rs HTTP response data */ typedef void -(*TALER_DONAU_GetCharitiesResponseCallback) ( +(*DONAU_GetCharitiesResponseCallback) ( void *cls, - const struct TALER_DONAU_GetCharitiesResponse *rs); + const struct DONAU_GetCharitiesResponse *rs); /** @@ -907,11 +906,11 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_CharitiesGetHandle * -TALER_DONAU_charities_get ( +struct DONAU_CharitiesGetHandle * +DONAU_charities_get ( struct GNUNET_CURL_Context *ctx, const char *url, - TALER_DONAU_GetCharitiesResponseCallback cb, + DONAU_GetCharitiesResponseCallback cb, void *cb_cls); @@ -922,8 +921,8 @@ TALER_DONAU_charities_get ( * @param rgh the charity request handle */ void -TALER_DONAU_charities_get_cancel ( - struct TALER_DONAU_charitiesGetHandle *rgh); +DONAU_charities_get_cancel ( + struct DONAU_charitiesGetHandle *rgh); /* ********************* GET /charities/$CHARITY_ID *********************** */ @@ -955,7 +954,7 @@ struct Charity /** * public key of the charity */ - struct TALER_DONAU_CharitySignatureP pub_key; + struct DONAU_CharitySignatureP pub_key; /** * Max donation amout for this charitiy and year. @@ -978,19 +977,19 @@ struct Charity /** * @brief A /charities/ GET Handle */ -struct TALER_DONAU_CharityGetHandle; +struct DONAU_CharityGetHandle; /** * @brief summary of a charity */ -struct TALER_DONAU_GetCharityResponse +struct DONAU_GetCharityResponse { /** * High-level HTTP response details. */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; /** * Details depending on @e hr.http_status. @@ -1026,9 +1025,9 @@ struct TALER_DONAU_GetCharityResponse * @param rs HTTP response data */ typedef void -(*TALER_DONAU_GetCharityResponseCallback) ( +(*DONAU_GetCharityResponseCallback) ( void *cls, - const struct TALER_DONAU_GetCharityResponse *rs); + const struct DONAU_GetCharityResponse *rs); /** @@ -1046,11 +1045,11 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_CharityGetHandle * -TALER_DONAU_charity_get ( +struct DONAU_CharityGetHandle * +DONAU_charity_get ( struct GNUNET_CURL_Context *ctx, const char *url, - TALER_DONAU_GetCharityResponseCallback cb, + DONAU_GetCharityResponseCallback cb, void *cb_cls); @@ -1061,8 +1060,8 @@ TALER_DONAU_charity_get ( * @param rgh the charity request handle */ void -TALER_DONAU_charity_get_cancel ( - struct TALER_DONAU_charityGetHandle *rgh); +DONAU_charity_get_cancel ( + struct DONAU_charityGetHandle *rgh); /* ********************* POST /charities/ *********************** */ @@ -1085,25 +1084,25 @@ struct charityRequest /** * public key of the charity */ - struct TALER_DONAU_EddsaPublicKeyP charity_pub; + struct DONAU_EddsaPublicKeyP charity_pub; }; /** * @brief A /charities Post Handle */ -struct TALER_DONAU_CharityPostHandle; +struct DONAU_CharityPostHandle; /** * @brief new charity ID Response */ -struct TALER_DONAU_PostCharityResponse +struct DONAU_PostCharityResponse { /** * High-level HTTP response details. */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; /** * Details depending on @e hr.http_status. @@ -1139,9 +1138,9 @@ struct TALER_DONAU_PostCharityResponse * @param rs HTTP response data */ typedef void -(*TALER_DONAU_PostCharityResponseCallback) ( +(*DONAU_PostCharityResponseCallback) ( void *cls, - const struct TALER_DONAU_PostCharityResponse *rs); + const struct DONAU_PostCharityResponse *rs); /** @@ -1161,13 +1160,13 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_CharityPostHandle * -TALER_DONAU_charity_post ( +struct DONAU_CharityPostHandle * +DONAU_charity_post ( struct GNUNET_CURL_Context *ctx, const char *url, const charityRequest charity_req, - const struct TALER_DONAU_BearerToken bearer, - TALER_DONAU_PostCharityResponseCallback cb, + const struct DONAU_BearerToken bearer, + DONAU_PostCharityResponseCallback cb, void *cb_cls); /** @@ -1177,27 +1176,27 @@ TALER_DONAU_charity_post ( * @param rgh the charity post handle */ void -TALER_DONAU_charity_post_cancel ( - struct TALER_DONAU_charityPostHandle *rgh); +DONAU_charity_post_cancel ( + struct DONAU_charityPostHandle *rgh); /* ********************* PATCH /charities/$CHARITY_ID *********************** */ /** * @brief A /charities/$CHARITY_ID Patch Handle */ -struct TALER_DONAU_CharityPatchHandle; +struct DONAU_CharityPatchHandle; /** * @brief charity patch response */ -struct TALER_DONAU_PatchCharityResponse +struct DONAU_PatchCharityResponse { /** * High-level HTTP response details. */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; }; @@ -1210,9 +1209,9 @@ struct TALER_DONAU_PatchCharityResponse * @param rs HTTP response data */ typedef void -(*TALER_DONAU_PatchCharityResponseCallback) ( +(*DONAU_PatchCharityResponseCallback) ( void *cls, - const struct TALER_DONAU_PatchCharityResponse *rs); + const struct DONAU_PatchCharityResponse *rs); /** @@ -1231,13 +1230,13 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_CharityPatchHandle * -TALER_DONAU_charity_patch ( +struct DONAU_CharityPatchHandle * +DONAU_charity_patch ( struct GNUNET_CURL_Context *ctx, const char *url, const struct charityRequest charity_req, - const struct TALER_DONAU_BearerToken bearer, - TALER_DONAU_PatchCharityResponseCallback cb, + const struct DONAU_BearerToken bearer, + DONAU_PatchCharityResponseCallback cb, void *cb_cls); /** @@ -1247,8 +1246,8 @@ TALER_DONAU_charity_patch ( * @param rgh the charity patch handle */ void -TALER_DONAU_charity_patch_cancel ( - struct TALER_DONAU_charityPatchHandle *rgh); +DONAU_charity_patch_cancel ( + struct DONAU_charityPatchHandle *rgh); /* ********************* DELETE /charities/$CHARITY_ID *********************** */ @@ -1256,19 +1255,19 @@ TALER_DONAU_charity_patch_cancel ( /** * @brief A /charities/$CHARITY_ID Delete Handle */ -struct TALER_DONAU_CharityDeleteHandle; +struct DONAU_CharityDeleteHandle; /** * @brief new charity ID Response */ -struct TALER_DONAU_DeleteCharityResponse +struct DONAU_DeleteCharityResponse { /** * High-level HTTP response details. */ - struct TALER_DONAU_HttpResponse hr; + struct DONAU_HttpResponse hr; }; @@ -1281,9 +1280,9 @@ struct TALER_DONAU_DeleteCharityResponse * @param rs HTTP response data */ typedef void -(*TALER_DONAU_DeleteCharityResponseCallback) ( +(*DONAU_DeleteCharityResponseCallback) ( void *cls, - const struct TALER_DONAU_DeleteCharityResponse *rs); + const struct DONAU_DeleteCharityResponse *rs); /** @@ -1302,12 +1301,12 @@ typedef void * @return a handle for this request; NULL if the inputs are invalid (i.e. * signatures fail to verify). In this case, the callback is not called. */ -struct TALER_DONAU_CharityDeleteHandle * -TALER_DONAU_charity_delete ( +struct DONAU_CharityDeleteHandle * +DONAU_charity_delete ( struct GNUNET_CURL_Context *ctx, const char *url, - const struct TALER_DONAU_BearerToken bearer, - TALER_DONAU_DeleteCharityResponseCallback cb, + const struct DONAU_BearerToken bearer, + DONAU_DeleteCharityResponseCallback cb, void *cb_cls); /** @@ -1317,5 +1316,5 @@ TALER_DONAU_charity_delete ( * @param rgh the charity request handle */ void -TALER_DONAU_charity_post_delete ( - struct TALER_DONAU_CharityDeleteHandle *rgh); +DONAU_charity_post_delete ( + struct DONAU_CharityDeleteHandle *rgh); diff --git a/src/include/donaudb_lib.h b/src/include/donaudb_lib.h @@ -1,3 +1,4 @@ +/* This file is part of TALER Copyright (C) 2014 - 2020 Taler Systems SA @@ -14,7 +15,7 @@ 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/> * -// ** +** *@file include / taler_donaudb_lib.h * @brief IO operations for the donau @@ -23,12 +24,12 @@ COPYING.If not, see <http: // www.gnu.org/licenses/> * @author Benedikt Mueller * @author Christian Grothoff */ -#ifndef TALER_DONAUDB_LIB_H -#define TALER_DONAUDB_LIB_H +#ifndef DONAUDB_LIB_H +#define DONAUDB_LIB_H #include "taler_signatures.h" -#include "taler_donaudb_plugin.h" -#include "taler_bank_service.h" +#include "donaudb_plugin.h" +#include "taler/taler_bank_service.h" /** @@ -37,8 +38,8 @@ COPYING.If not, see <http: // www.gnu.org/licenses/> * @param cfg configuration to use * @return NULL on failure */ -struct TALER_DONAUDB_Plugin * -TALER_DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); +struct DONAUDB_Plugin * +DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); /** @@ -47,16 +48,16 @@ TALER_DONAUDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg); * @param plugin plugin to unload */ void -TALER_DONAUDB_plugin_unload (struct TALER_DONAUDB_Plugin *plugin); +DONAUDB_plugin_unload (struct DONAUDB_Plugin *plugin); /** * Information about an account from the configuration. */ -struct TALER_DONAUDB_AccountInfo +struct DONAUDB_AccountInfo { /** * Authentication data. Only parsed if - * #TALER_DONAUDB_ALO_AUTHDATA was set. + * #DONAUDB_ALO_AUTHDATA was set. */ const struct TALER_BANK_AuthenticationData *auth; @@ -86,7 +87,7 @@ struct TALER_DONAUDB_AccountInfo bool credit_enabled; }; - +struct DONAUDB_TransactionList; /** * Calculate the total value of all transactions performed. * Stores @a off plus the cost of all transactions in @a tl @@ -98,8 +99,8 @@ struct TALER_DONAUDB_AccountInfo * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors */ enum GNUNET_GenericReturnValue -TALER_DONAUDB_calculate_transaction_list_totals ( - struct TALER_DONAUDB_TransactionList *tl, +DONAUDB_calculate_transaction_list_totals ( + struct DONAUDB_TransactionList *tl, const struct TALER_Amount *off, struct TALER_Amount *ret); @@ -111,70 +112,70 @@ TALER_DONAUDB_calculate_transaction_list_totals ( * @param ai account information */ typedef void -(*TALER_DONAUDB_AccountCallback)( +(*DONAUDB_AccountCallback)( void *cls, - const struct TALER_DONAUDB_AccountInfo *ai); + const struct DONAUDB_AccountInfo *ai); /** * Return information about all accounts that - * were loaded by #TALER_DONAUDB_load_accounts(). + * were loaded by #DONAUDB_load_accounts(). * * @param cb callback to invoke * @param cb_cls closure for @a cb */ void -TALER_DONAUDB_find_accounts (TALER_DONAUDB_AccountCallback cb, - void *cb_cls); +DONAUDB_find_accounts (DONAUDB_AccountCallback cb, + void *cb_cls); /** * Find the wire plugin for the given payto:// URL. * Only useful after the accounts have been loaded - * using #TALER_DONAUDB_load_accounts(). + * using #DONAUDB_load_accounts(). * * @param method wire method we need an account for * @return NULL on error */ -const struct TALER_DONAUDB_AccountInfo * -TALER_DONAUDB_find_account_by_method (const char *method); +const struct DONAUDB_AccountInfo * +DONAUDB_find_account_by_method (const char *method); /** * Find the wire plugin for the given payto:// URL * Only useful after the accounts have been loaded - * using #TALER_DONAUDB_load_accounts(). + * using #DONAUDB_load_accounts(). * * @param url wire address we need an account for * @return NULL on error */ -const struct TALER_DONAUDB_AccountInfo * -TALER_DONAUDB_find_account_by_payto_uri (const char *url); +const struct DONAUDB_AccountInfo * +DONAUDB_find_account_by_payto_uri (const char *url); /** - * Options for #TALER_DONAUDB_load_accounts() + * Options for #DONAUDB_load_accounts() */ -enum TALER_DONAUDB_AccountLoaderOptions +enum DONAUDB_AccountLoaderOptions { - TALER_DONAUDB_ALO_NONE = 0, + DONAUDB_ALO_NONE = 0, /** * Load accounts enabled for DEBITs. */ - TALER_DONAUDB_ALO_DEBIT = 1, + DONAUDB_ALO_DEBIT = 1, /** * Load accounts enabled for CREDITs. */ - TALER_DONAUDB_ALO_CREDIT = 2, + DONAUDB_ALO_CREDIT = 2, /** * Load authentication data from the * "taler-accountcredentials-" section * to access the account at the bank. */ - TALER_DONAUDB_ALO_AUTHDATA = 4 + DONAUDB_ALO_AUTHDATA = 4 }; @@ -187,16 +188,16 @@ enum TALER_DONAUDB_AccountLoaderOptions * @return #GNUNET_OK on success, #GNUNET_NO if no accounts are configured */ enum GNUNET_GenericReturnValue -TALER_DONAUDB_load_accounts ( +DONAUDB_load_accounts ( const struct GNUNET_CONFIGURATION_Handle *cfg, - enum TALER_DONAUDB_AccountLoaderOptions options); + enum DONAUDB_AccountLoaderOptions options); /** * Free resources allocated by - * #TALER_DONAUDB_load_accounts(). + * #DONAUDB_load_accounts(). */ void -TALER_DONAUDB_unload_accounts (void); +DONAUDB_unload_accounts (void); #endif diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h @@ -18,19 +18,20 @@ * @brief Low-level (statement-level) database access for the donau * @author Johannes Casaburi */ -#ifndef TALER_DONAUDB_PLUGIN_H -#define TALER_DONAUDB_PLUGIN_H +#ifndef DONAUDB_PLUGIN_H +#define DONAUDB_PLUGIN_H #include <jansson.h> #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_db_lib.h> -#include "taler_json_lib.h" -#include "taler_signatures.h" -#include "taler_extensions_policy.h" +#include "taler/taler_json_lib.h" +#include "donau_signatures.h" +#include "donau_util.h" +#include "taler/taler_extensions_policy.h" /** * Meta data about a donation unit key. */ -struct TALER_DONAUDB_DonationUnitKeyMetaData +struct DONAUDB_DonationUnitKeyMetaData { /** * The value of the donation unit. @@ -45,14 +46,14 @@ struct TALER_DONAUDB_DonationUnitKeyMetaData /** * Hash code of the donation unit public key. */ - struct TALER_DonationUnitHashP donation_unit_hash; + struct DONAU_DonationUnitHashP donation_unit_hash; }; /** * Meta data about an donau signing key. */ -struct TALER_DONAUDB_SignkeyMetaData +struct DONAUDB_SignkeyMetaData { /** * Start time of the validity period for this key. @@ -78,18 +79,18 @@ struct TALER_DONAUDB_SignkeyMetaData /** * @brief All information about a donation unit key. */ -struct TALER_DONAUDB_DonationUnitKey +struct DONAUDB_DonationUnitKey { /** * The private key of the donation unit. Will be NULL if the private * key is not available. */ - struct TALER_DonationUnitPrivateKey donation_unit_priv; + // struct DONAU_DonationUnitPublicKey donation_unit_priv; /** * Decoded donation unit public key. */ - struct TALER_DonationUnitPublicKey donation_unit_pub; + // struct DONAU_DonationUnitPublicKey donation_unit_pub; }; @@ -103,10 +104,10 @@ struct TALER_DONAUDB_DonationUnitKey * @param info donation unit key information */ typedef void -(*TALER_DONAUDB_DonationUnitsCallback)( +(*DONAUDB_DonationUnitsCallback)( void *cls, - const struct TALER_DonationUnitPublicKey *donation_unit_pub, - const struct TALER_DONAUDB_DonationUnitKeyInformation *info); + const struct DONAU_DonationUnitPublicKey *donation_unit_pub, + const struct DONAUDB_DonationUnitKeyInformation *info); /** @@ -118,7 +119,10 @@ typedef void * @param meta meta data information about the signing type (expirations) */ typedef void -(*TALER_DONAUDB_ActiveSignkeysCallback)( +(*DONAUDB_ActiveSignkeysCallback)( void *cls, - const struct TALER_DonauPublicKeyP *donau_pub, - const struct TALER_DONAUDB_SignkeyMetaData *meta); + const struct DONAU_DonauPublicKeyP *donau_pub, + const struct DONAUDB_SignkeyMetaData *meta); + + +#endif diff --git a/src/json/Makefile.am b/src/json/Makefile.am @@ -36,6 +36,6 @@ test_json_SOURCES = \ test_json_LDADD = \ $(top_builddir)/src/json/libtalerjson.la \ -lgnunetjson \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lgnunetutil \ -ljansson diff --git a/src/json/test_json.c b/src/json/test_json.c @@ -19,9 +19,9 @@ * @brief Tests for Taler-specific crypto logic * @author Christian Grothoff <christian@grothoff.org> */ -#include "platform.h" +#include "taler/platform.h" #include "taler_util.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" /** diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am @@ -83,7 +83,7 @@ libtalerdonau_la_LIBADD = \ $(top_builddir)/src/json/libtalerjson.la \ $(top_builddir)/src/kyclogic/libtalerkyclogic.la \ $(top_builddir)/src/curl/libtalercurl.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ $(top_builddir)/src/extensions/libtalerextensions.la \ -lgnunetcurl \ -lgnunetjson \ @@ -103,7 +103,7 @@ libtalerauditor_la_SOURCES = \ libtalerauditor_la_LIBADD = \ $(top_builddir)/src/curl/libtalercurl.la \ $(top_builddir)/src/json/libtalerjson.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lgnunetcurl \ -lgnunetjson \ -lgnunetutil \ @@ -124,5 +124,5 @@ test_stefan_SOURCES = \ test_stefan.c test_stefan_LDADD = \ $(top_builddir)/src/lib/libtalerdonau.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lgnunetutil diff --git a/src/lib/donau_api_batch_issue_receipts.c b/src/lib/donau_api_batch_issue_receipts.c @@ -19,14 +19,14 @@ * @brief Implementation of /reserves/$RESERVE_PUB/batch-withdraw requests with blinding/unblinding * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -41,7 +41,7 @@ struct CoinData /** * Denomination key we are withdrawing. */ - struct TALER_DONAU_DenomPublicKey pk; + struct DONAU_DenomPublicKey pk; /** * Master key material for the coin. @@ -81,19 +81,19 @@ struct CoinData /** * Handler for the CS R request (only used for TALER_DENOMINATION_CS denominations) */ - struct TALER_DONAU_CsRWithdrawHandle *csrh; + struct DONAU_CsRWithdrawHandle *csrh; /** * Batch withdraw this coin is part of. */ - struct TALER_DONAU_BatchWithdrawHandle *wh; + struct DONAU_BatchWithdrawHandle *wh; }; /** * @brief A batch withdraw handle */ -struct TALER_DONAU_BatchWithdrawHandle +struct DONAU_BatchWithdrawHandle { /** @@ -109,18 +109,18 @@ struct TALER_DONAU_BatchWithdrawHandle /** * The /keys information from the donau */ - const struct TALER_DONAU_Keys *keys; + const struct DONAU_Keys *keys; /** * Handle for the actual (internal) batch withdraw operation. */ - struct TALER_DONAU_BatchWithdraw2Handle *wh2; + struct DONAU_BatchWithdraw2Handle *wh2; /** * Function to call with the result. */ - TALER_DONAU_BatchWithdrawCallback cb; + DONAU_BatchWithdrawCallback cb; /** * Closure for @a cb. @@ -154,19 +154,19 @@ struct TALER_DONAU_BatchWithdrawHandle * Function called when we're done processing the * HTTP /reserves/$RESERVE_PUB/batch-withdraw request. * - * @param cls the `struct TALER_DONAU_BatchWithdrawHandle` + * @param cls the `struct DONAU_BatchWithdrawHandle` * @param bw2r response data */ static void handle_reserve_batch_withdraw_finished ( void *cls, - const struct TALER_DONAU_BatchWithdraw2Response *bw2r) + const struct DONAU_BatchWithdraw2Response *bw2r) { - struct TALER_DONAU_BatchWithdrawHandle *wh = cls; - struct TALER_DONAU_BatchWithdrawResponse wr = { + struct DONAU_BatchWithdrawHandle *wh = cls; + struct DONAU_BatchWithdrawResponse wr = { .hr = bw2r->hr }; - struct TALER_DONAU_PrivateCoinDetails coins[GNUNET_NZL (wh->num_coins)]; + struct DONAU_PrivateCoinDetails coins[GNUNET_NZL (wh->num_coins)]; wh->wh2 = NULL; memset (coins, @@ -186,7 +186,7 @@ handle_reserve_batch_withdraw_finished ( for (unsigned int i = 0; i<wh->num_coins; i++) { struct CoinData *cd = &wh->coins[i]; - struct TALER_DONAU_PrivateCoinDetails *coin = &coins[i]; + struct DONAU_PrivateCoinDetails *coin = &coins[i]; struct TALER_FreshCoin fc; if (GNUNET_OK != @@ -243,7 +243,7 @@ handle_reserve_batch_withdraw_finished ( &wr); for (unsigned int i = 0; i<wh->num_coins; i++) TALER_denom_sig_free (&coins[i].sig); - TALER_DONAU_batch_withdraw_cancel (wh); + DONAU_batch_withdraw_cancel (wh); } @@ -255,7 +255,7 @@ handle_reserve_batch_withdraw_finished ( * @param[in,out] wh batch withdraw to start phase 2 for */ static void -phase_two (struct TALER_DONAU_BatchWithdrawHandle *wh) +phase_two (struct DONAU_BatchWithdrawHandle *wh) { struct TALER_PlanchetDetail pds[wh->num_coins]; @@ -265,7 +265,7 @@ phase_two (struct TALER_DONAU_BatchWithdrawHandle *wh) pds[i] = cd->pd; } - wh->wh2 = TALER_DONAU_batch_withdraw2 ( + wh->wh2 = DONAU_batch_withdraw2 ( wh->curl_ctx, wh->donau_url, wh->keys, @@ -286,11 +286,11 @@ phase_two (struct TALER_DONAU_BatchWithdrawHandle *wh) static void withdraw_cs_stage_two_callback ( void *cls, - const struct TALER_DONAU_CsRWithdrawResponse *csrr) + const struct DONAU_CsRWithdrawResponse *csrr) { struct CoinData *cd = cls; - struct TALER_DONAU_BatchWithdrawHandle *wh = cd->wh; - struct TALER_DONAU_BatchWithdrawResponse wr = { + struct DONAU_BatchWithdrawHandle *wh = cd->wh; + struct DONAU_BatchWithdrawResponse wr = { .hr = csrr->hr }; @@ -318,7 +318,7 @@ withdraw_cs_stage_two_callback ( &cd->pd)) { GNUNET_break (0); - TALER_DONAU_batch_withdraw_cancel (wh); + DONAU_batch_withdraw_cancel (wh); } wh->cs_pending--; if (0 == wh->cs_pending) @@ -329,24 +329,24 @@ withdraw_cs_stage_two_callback ( } wh->cb (wh->cb_cls, &wr); - TALER_DONAU_batch_withdraw_cancel (wh); + DONAU_batch_withdraw_cancel (wh); } -struct TALER_DONAU_BatchWithdrawHandle * -TALER_DONAU_batch_withdraw ( +struct DONAU_BatchWithdrawHandle * +DONAU_batch_withdraw ( struct GNUNET_CURL_Context *curl_ctx, const char *donau_url, - const struct TALER_DONAU_Keys *keys, + const struct DONAU_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, unsigned int wci_length, - const struct TALER_DONAU_WithdrawCoinInput wcis[static wci_length], - TALER_DONAU_BatchWithdrawCallback res_cb, + const struct DONAU_WithdrawCoinInput wcis[static wci_length], + DONAU_BatchWithdrawCallback res_cb, void *res_cb_cls) { - struct TALER_DONAU_BatchWithdrawHandle *wh; + struct DONAU_BatchWithdrawHandle *wh; - wh = GNUNET_new (struct TALER_DONAU_BatchWithdrawHandle); + wh = GNUNET_new (struct DONAU_BatchWithdrawHandle); wh->curl_ctx = curl_ctx; wh->donau_url = donau_url; wh->keys = keys; @@ -359,7 +359,7 @@ TALER_DONAU_batch_withdraw ( for (unsigned int i = 0; i<wci_length; i++) { struct CoinData *cd = &wh->coins[i]; - const struct TALER_DONAU_WithdrawCoinInput *wci = &wcis[i]; + const struct DONAU_WithdrawCoinInput *wci = &wcis[i]; cd->wh = wh; cd->ps = *wci->ps; @@ -388,7 +388,7 @@ TALER_DONAU_batch_withdraw ( &cd->pd)) { GNUNET_break (0); - TALER_DONAU_batch_withdraw_cancel (wh); + DONAU_batch_withdraw_cancel (wh); return NULL; } break; @@ -402,7 +402,7 @@ TALER_DONAU_batch_withdraw ( of the blinded_planchet here; the other part will be done after the /csr-withdraw request! */ cd->pd.blinded_planchet.cipher = TALER_DENOMINATION_CS; - cd->csrh = TALER_DONAU_csr_withdraw ( + cd->csrh = DONAU_csr_withdraw ( curl_ctx, donau_url, &cd->pk, @@ -412,7 +412,7 @@ TALER_DONAU_batch_withdraw ( if (NULL == cd->csrh) { GNUNET_break (0); - TALER_DONAU_batch_withdraw_cancel (wh); + DONAU_batch_withdraw_cancel (wh); return NULL; } wh->cs_pending++; @@ -420,7 +420,7 @@ TALER_DONAU_batch_withdraw ( } default: GNUNET_break (0); - TALER_DONAU_batch_withdraw_cancel (wh); + DONAU_batch_withdraw_cancel (wh); return NULL; } } @@ -431,8 +431,8 @@ TALER_DONAU_batch_withdraw ( void -TALER_DONAU_batch_withdraw_cancel ( - struct TALER_DONAU_BatchWithdrawHandle *wh) +DONAU_batch_withdraw_cancel ( + struct DONAU_BatchWithdrawHandle *wh) { for (unsigned int i = 0; i<wh->num_coins; i++) { @@ -440,7 +440,7 @@ TALER_DONAU_batch_withdraw_cancel ( if (NULL != cd->csrh) { - TALER_DONAU_csr_withdraw_cancel (cd->csrh); + DONAU_csr_withdraw_cancel (cd->csrh); cd->csrh = NULL; } TALER_blinded_planchet_free (&cd->pd.blinded_planchet); @@ -449,7 +449,7 @@ TALER_DONAU_batch_withdraw_cancel ( GNUNET_free (wh->coins); if (NULL != wh->wh2) { - TALER_DONAU_batch_withdraw2_cancel (wh->wh2); + DONAU_batch_withdraw2_cancel (wh->wh2); wh->wh2 = NULL; } GNUNET_free (wh); diff --git a/src/lib/donau_api_batch_issue_receipts2.c b/src/lib/donau_api_batch_issue_receipts2.c @@ -19,14 +19,14 @@ * @brief Implementation of /reserves/$RESERVE_PUB/batch-withdraw requests without blinding/unblinding * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,7 +35,7 @@ /** * @brief A batch withdraw handle */ -struct TALER_DONAU_BatchWithdraw2Handle +struct DONAU_BatchWithdraw2Handle { /** @@ -46,7 +46,7 @@ struct TALER_DONAU_BatchWithdraw2Handle /** * The /keys material from the donau */ - const struct TALER_DONAU_Keys *keys; + const struct DONAU_Keys *keys; /** * Handle for the request. @@ -56,7 +56,7 @@ struct TALER_DONAU_BatchWithdraw2Handle /** * Function to call with the result. */ - TALER_DONAU_BatchWithdraw2Callback cb; + DONAU_BatchWithdraw2Callback cb; /** * Closure for @a cb. @@ -100,7 +100,7 @@ struct TALER_DONAU_BatchWithdraw2Handle * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors */ static enum GNUNET_GenericReturnValue -reserve_batch_withdraw_ok (struct TALER_DONAU_BatchWithdraw2Handle *wh, +reserve_batch_withdraw_ok (struct DONAU_BatchWithdraw2Handle *wh, const json_t *json) { struct TALER_BlindedDenominationSignature blind_sigs[wh->num_coins]; @@ -108,7 +108,7 @@ reserve_batch_withdraw_ok (struct TALER_DONAU_BatchWithdraw2Handle *wh, "ev_sigs"); const json_t *j; unsigned int index; - struct TALER_DONAU_BatchWithdraw2Response bwr = { + struct DONAU_BatchWithdraw2Response bwr = { .hr.reply = json, .hr.http_status = MHD_HTTP_OK }; @@ -168,7 +168,7 @@ reserve_batch_withdraw_ok (struct TALER_DONAU_BatchWithdraw2Handle *wh, */ static enum GNUNET_GenericReturnValue reserve_batch_withdraw_payment_required ( - struct TALER_DONAU_BatchWithdraw2Handle *wh, + struct DONAU_BatchWithdraw2Handle *wh, const json_t *json) { struct TALER_Amount balance; @@ -202,14 +202,14 @@ reserve_batch_withdraw_payment_required ( total incoming and outgoing amounts */ len = json_array_size (history); { - struct TALER_DONAU_ReserveHistoryEntry *rhistory; + struct DONAU_ReserveHistoryEntry *rhistory; /* Use heap allocation as "len" may be very big and thus this may not fit on the stack. Use "GNUNET_malloc_large" as a malicious donau may theoretically try to crash us by giving a history that does not fit into our memory. */ rhistory = GNUNET_malloc_large ( - sizeof (struct TALER_DONAU_ReserveHistoryEntry) + sizeof (struct DONAU_ReserveHistoryEntry) * len); if (NULL == rhistory) { @@ -218,7 +218,7 @@ reserve_batch_withdraw_payment_required ( } if (GNUNET_OK != - TALER_DONAU_parse_reserve_history ( + DONAU_parse_reserve_history ( wh->keys, history, &wh->reserve_pub, @@ -229,12 +229,12 @@ reserve_batch_withdraw_payment_required ( rhistory)) { GNUNET_break_op (0); - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); return GNUNET_SYSERR; } - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); } /* Check that funds were really insufficient */ @@ -254,7 +254,7 @@ reserve_batch_withdraw_payment_required ( * Function called when we're done processing the * HTTP /reserves/$RESERVE_PUB/batch-withdraw request. * - * @param cls the `struct TALER_DONAU_BatchWithdraw2Handle` + * @param cls the `struct DONAU_BatchWithdraw2Handle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -263,9 +263,9 @@ handle_reserve_batch_withdraw_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_BatchWithdraw2Handle *wh = cls; + struct DONAU_BatchWithdraw2Handle *wh = cls; const json_t *j = response; - struct TALER_DONAU_BatchWithdraw2Response bwr = { + struct DONAU_BatchWithdraw2Response bwr = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -287,7 +287,7 @@ handle_reserve_batch_withdraw_finished (void *cls, break; } GNUNET_assert (NULL == wh->cb); - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); return; case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS: /* only validate reply is well-formed */ @@ -381,30 +381,30 @@ handle_reserve_batch_withdraw_finished (void *cls, &bwr); wh->cb = NULL; } - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); } -struct TALER_DONAU_BatchWithdraw2Handle * -TALER_DONAU_batch_withdraw2 ( +struct DONAU_BatchWithdraw2Handle * +DONAU_batch_withdraw2 ( struct GNUNET_CURL_Context *curl_ctx, const char *donau_url, - const struct TALER_DONAU_Keys *keys, + const struct DONAU_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, unsigned int pds_length, const struct TALER_PlanchetDetail pds[static pds_length], - TALER_DONAU_BatchWithdraw2Callback res_cb, + DONAU_BatchWithdraw2Callback res_cb, void *res_cb_cls) { - struct TALER_DONAU_BatchWithdraw2Handle *wh; - const struct TALER_DONAU_DenomPublicKey *dk; + struct DONAU_BatchWithdraw2Handle *wh; + const struct DONAU_DenomPublicKey *dk; struct TALER_ReserveSignatureP reserve_sig; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; struct TALER_BlindedCoinHashP bch; json_t *jc; GNUNET_assert (NULL != keys); - wh = GNUNET_new (struct TALER_DONAU_BatchWithdraw2Handle); + wh = GNUNET_new (struct DONAU_BatchWithdraw2Handle); wh->keys = keys; wh->cb = res_cb; wh->cb_cls = res_cb_cls; @@ -438,7 +438,7 @@ TALER_DONAU_batch_withdraw2 ( if (NULL == wh->url) { GNUNET_break (0); - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); return NULL; } jc = json_array (); @@ -449,11 +449,11 @@ TALER_DONAU_batch_withdraw2 ( struct TALER_Amount coin_total; json_t *withdraw_obj; - dk = TALER_DONAU_get_denomination_key_by_hash (keys, - &pd->denom_pub_hash); + dk = DONAU_get_denomination_key_by_hash (keys, + &pd->denom_pub_hash); if (NULL == dk) { - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); json_decref (jc); GNUNET_break (0); return NULL; @@ -466,7 +466,7 @@ TALER_DONAU_batch_withdraw2 ( { /* Overflow here? Very strange, our CPU must be fried... */ GNUNET_break (0); - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); json_decref (jc); return NULL; } @@ -477,7 +477,7 @@ TALER_DONAU_batch_withdraw2 ( { /* Overflow here? Very strange, our CPU must be fried... */ GNUNET_break (0); - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); json_decref (jc); return NULL; } @@ -487,7 +487,7 @@ TALER_DONAU_batch_withdraw2 ( &bch)) { GNUNET_break (0); - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); json_decref (jc); return NULL; } @@ -515,7 +515,7 @@ TALER_DONAU_batch_withdraw2 ( req = GNUNET_JSON_PACK ( GNUNET_JSON_pack_array_steal ("planchets", jc)); - eh = TALER_DONAU_curl_easy_get_ (wh->url); + eh = DONAU_curl_easy_get_ (wh->url); if ( (NULL == eh) || (GNUNET_OK != TALER_curl_easy_post (&wh->post_ctx, @@ -526,7 +526,7 @@ TALER_DONAU_batch_withdraw2 ( if (NULL != eh) curl_easy_cleanup (eh); json_decref (req); - TALER_DONAU_batch_withdraw2_cancel (wh); + DONAU_batch_withdraw2_cancel (wh); return NULL; } json_decref (req); @@ -541,8 +541,8 @@ TALER_DONAU_batch_withdraw2 ( void -TALER_DONAU_batch_withdraw2_cancel ( - struct TALER_DONAU_BatchWithdraw2Handle *wh) +DONAU_batch_withdraw2_cancel ( + struct DONAU_BatchWithdraw2Handle *wh) { if (NULL != wh->job) { diff --git a/src/lib/donau_api_batch_submit_receipts.c b/src/lib/donau_api_batch_submit_receipts.c @@ -20,13 +20,13 @@ * @author Sree Harsha Totakura <sreeharsha@totakura.in> * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_auditor_service.h" #include "taler_donau_service.h" #include "donau_api_common.h" @@ -73,20 +73,20 @@ struct TEAH_AuditorInteractionEntry /** * Batch deposit this is for. */ - struct TALER_DONAU_BatchDepositHandle *dh; + struct DONAU_BatchDepositHandle *dh; }; /** * @brief A Deposit Handle */ -struct TALER_DONAU_BatchDepositHandle +struct DONAU_BatchDepositHandle { /** * The keys of the donau. */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * Context for our curl request(s). @@ -112,7 +112,7 @@ struct TALER_DONAU_BatchDepositHandle /** * Function to call with the result. */ - TALER_DONAU_BatchDepositResultCallback cb; + DONAU_BatchDepositResultCallback cb; /** * Closure for @a cb. @@ -122,12 +122,12 @@ struct TALER_DONAU_BatchDepositHandle /** * Details about the contract. */ - struct TALER_DONAU_DepositContractDetail dcd; + struct DONAU_DepositContractDetail dcd; /** * Array with details about the coins. */ - struct TALER_DONAU_CoinDepositDetail *cdds; + struct DONAU_CoinDepositDetail *cdds; /** * Hash of the charity's wire details. @@ -163,12 +163,12 @@ struct TALER_DONAU_BatchDepositHandle /** * Result to return to the application once @e ai_head is empty. */ - struct TALER_DONAU_BatchDepositResult dr; + struct DONAU_BatchDepositResult dr; /** * Donau signing public key, set for #auditor_cb. */ - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; /** * Response object to free at the end. @@ -195,11 +195,11 @@ struct TALER_DONAU_BatchDepositHandle * @param[in] dh handle to finished batch deposit operation */ static void -finish_dh (struct TALER_DONAU_BatchDepositHandle *dh) +finish_dh (struct DONAU_BatchDepositHandle *dh) { dh->cb (dh->cb_cls, &dh->dr); - TALER_DONAU_batch_deposit_cancel (dh); + DONAU_batch_deposit_cancel (dh); } @@ -216,7 +216,7 @@ acc_confirmation_cb ( const struct TALER_AUDITOR_DepositConfirmationResponse *dcr) { struct TEAH_AuditorInteractionEntry *aie = cls; - struct TALER_DONAU_BatchDepositHandle *dh = aie->dh; + struct DONAU_BatchDepositHandle *dh = aie->dh; if (MHD_HTTP_OK != dcr->hr.http_status) { @@ -248,11 +248,11 @@ auditor_cb (void *cls, const char *auditor_url, const struct TALER_AuditorPublicKeyP *auditor_pub) { - struct TALER_DONAU_BatchDepositHandle *dh = cls; - const struct TALER_DONAU_SigningPublicKey *spk; + struct DONAU_BatchDepositHandle *dh = cls; + const struct DONAU_SigningPublicKey *spk; struct TEAH_AuditorInteractionEntry *aie; struct TALER_Amount amount_without_fee; - const struct TALER_DONAU_DenomPublicKey *dki; + const struct DONAU_DenomPublicKey *dki; unsigned int coin; if (0 != @@ -268,11 +268,11 @@ auditor_cb (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Will provide deposit confirmation to auditor `%s'\n", TALER_B2S (auditor_pub)); - dki = TALER_DONAU_get_denomination_key_by_hash (dh->keys, - &dh->cdds[coin].h_denom_pub); + dki = DONAU_get_denomination_key_by_hash (dh->keys, + &dh->cdds[coin].h_denom_pub); GNUNET_assert (NULL != dki); - spk = TALER_DONAU_get_signing_key_info (dh->keys, - &dh->donau_pub); + spk = DONAU_get_signing_key_info (dh->keys, + &dh->donau_pub); if (NULL == spk) { GNUNET_break_op (0); @@ -316,7 +316,7 @@ auditor_cb (void *cls, * Function called when we're done processing the * HTTP /deposit request. * - * @param cls the `struct TALER_DONAU_BatchDepositHandle` + * @param cls the `struct DONAU_BatchDepositHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -325,9 +325,9 @@ handle_deposit_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_BatchDepositHandle *dh = cls; + struct DONAU_BatchDepositHandle *dh = cls; const json_t *j = response; - struct TALER_DONAU_BatchDepositResult *dr = &dh->dr; + struct DONAU_BatchDepositResult *dr = &dh->dr; dh->job = NULL; dh->response = json_incref ((json_t*) j); @@ -375,10 +375,10 @@ handle_deposit_finished (void *cls, break; } dh->donau_sigs = GNUNET_new_array (dh->num_cdds, - struct TALER_DonauSignatureP); + struct TALER_DonauSignatureP); if (GNUNET_OK != - TALER_DONAU_test_signing_key (dh->keys, - &dh->donau_pub)) + DONAU_test_signing_key (dh->keys, + &dh->donau_pub)) { GNUNET_break_op (0); dr->hr.http_status = 0; @@ -393,7 +393,7 @@ handle_deposit_finished (void *cls, GNUNET_JSON_spec_end () }; struct TALER_Amount amount_without_fee; - const struct TALER_DONAU_DenomPublicKey *dki; + const struct DONAU_DenomPublicKey *dki; if (GNUNET_OK != GNUNET_JSON_parse (sig, @@ -405,9 +405,9 @@ handle_deposit_finished (void *cls, dr->hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - dki = TALER_DONAU_get_denomination_key_by_hash (dh->keys, - &dh->cdds[idx]. - h_denom_pub); + dki = DONAU_get_denomination_key_by_hash (dh->keys, + &dh->cdds[idx]. + h_denom_pub); GNUNET_assert (NULL != dki); GNUNET_assert (0 <= TALER_amount_subtract (&amount_without_fee, @@ -470,7 +470,7 @@ handle_deposit_finished (void *cls, &coin_pub), GNUNET_JSON_spec_end () }; - const struct TALER_DONAU_DenomPublicKey *dki; + const struct DONAU_DenomPublicKey *dki; bool found = false; if (GNUNET_OK != @@ -489,12 +489,12 @@ handle_deposit_finished (void *cls, GNUNET_memcmp (&coin_pub, &dh->cdds[i].coin_pub)) continue; - dki = TALER_DONAU_get_denomination_key_by_hash (dh->keys, - &dh->cdds[i]. - h_denom_pub); + dki = DONAU_get_denomination_key_by_hash (dh->keys, + &dh->cdds[i]. + h_denom_pub); GNUNET_assert (NULL != dki); if (GNUNET_OK != - TALER_DONAU_check_coin_conflict_ ( + DONAU_check_coin_conflict_ ( dh->keys, j, dki, @@ -552,19 +552,19 @@ handle_deposit_finished (void *cls, } -struct TALER_DONAU_BatchDepositHandle * -TALER_DONAU_batch_deposit ( +struct DONAU_BatchDepositHandle * +DONAU_batch_deposit ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *keys, - const struct TALER_DONAU_DepositContractDetail *dcd, + struct DONAU_Keys *keys, + const struct DONAU_DepositContractDetail *dcd, unsigned int num_cdds, - const struct TALER_DONAU_CoinDepositDetail cdds[static num_cdds], - TALER_DONAU_BatchDepositResultCallback cb, + const struct DONAU_CoinDepositDetail cdds[static num_cdds], + DONAU_BatchDepositResultCallback cb, void *cb_cls, enum TALER_ErrorCode *ec) { - struct TALER_DONAU_BatchDepositHandle *dh; + struct DONAU_BatchDepositHandle *dh; json_t *deposit_obj; json_t *deposits; CURL *eh; @@ -579,7 +579,7 @@ TALER_DONAU_batch_deposit ( *ec = TALER_EC_DONAU_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE; return NULL; } - dh = GNUNET_new (struct TALER_DONAU_BatchDepositHandle); + dh = GNUNET_new (struct DONAU_BatchDepositHandle); dh->auditor_chance = AUDITOR_CHANCE; dh->cb = cb; dh->cb_cls = cb_cls; @@ -592,18 +592,18 @@ TALER_DONAU_batch_deposit ( TALER_deposit_policy_hash (dcd->policy_details, &dh->h_policy); TALER_charity_wire_signature_hash (dcd->charity_payto_uri, - &dcd->wire_salt, - &dh->h_wire); + &dcd->wire_salt, + &dh->h_wire); deposits = json_array (); GNUNET_assert (NULL != deposits); for (unsigned int i = 0; i<num_cdds; i++) { - const struct TALER_DONAU_CoinDepositDetail *cdd = &cdds[i]; - const struct TALER_DONAU_DenomPublicKey *dki; + const struct DONAU_CoinDepositDetail *cdd = &cdds[i]; + const struct DONAU_DenomPublicKey *dki; const struct TALER_AgeCommitmentHash *h_age_commitmentp; - dki = TALER_DONAU_get_denomination_key_by_hash (keys, - &cdd->h_denom_pub); + dki = DONAU_get_denomination_key_by_hash (keys, + &cdd->h_denom_pub); if (NULL == dki) { *ec = TALER_EC_DONAU_GENERIC_DENOMINATION_KEY_UNKNOWN; @@ -629,11 +629,11 @@ TALER_DONAU_batch_deposit ( } if (GNUNET_OK != - TALER_DONAU_verify_deposit_signature_ (dcd, - &dh->h_policy, - &dh->h_wire, - cdd, - dki)) + DONAU_verify_deposit_signature_ (dcd, + &dh->h_policy, + &dh->h_wire, + cdd, + dki)) { *ec = TALER_EC_DONAU_DEPOSIT_COIN_SIGNATURE_INVALID; GNUNET_break_op (0); @@ -708,7 +708,7 @@ TALER_DONAU_batch_deposit ( GNUNET_JSON_pack_timestamp ("wire_transfer_deadline", dcd->wire_deadline)); GNUNET_assert (NULL != deposit_obj); - eh = TALER_DONAU_curl_easy_get_ (dh->url); + eh = DONAU_curl_easy_get_ (dh->url); if ( (NULL == eh) || (GNUNET_OK != TALER_curl_easy_post (&dh->post_ctx, @@ -730,7 +730,7 @@ TALER_DONAU_batch_deposit ( "URL for deposit: `%s'\n", dh->url); dh->ctx = ctx; - dh->keys = TALER_DONAU_keys_incref (keys); + dh->keys = DONAU_keys_incref (keys); dh->job = GNUNET_CURL_job_add2 (ctx, eh, dh->post_ctx.headers, @@ -741,16 +741,16 @@ TALER_DONAU_batch_deposit ( void -TALER_DONAU_batch_deposit_force_dc ( - struct TALER_DONAU_BatchDepositHandle *deposit) +DONAU_batch_deposit_force_dc ( + struct DONAU_BatchDepositHandle *deposit) { deposit->auditor_chance = 1; } void -TALER_DONAU_batch_deposit_cancel ( - struct TALER_DONAU_BatchDepositHandle *deposit) +DONAU_batch_deposit_cancel ( + struct DONAU_BatchDepositHandle *deposit) { struct TEAH_AuditorInteractionEntry *aie; @@ -771,7 +771,7 @@ TALER_DONAU_batch_deposit_cancel ( GNUNET_CURL_job_cancel (deposit->job); deposit->job = NULL; } - TALER_DONAU_keys_decref (deposit->keys); + DONAU_keys_decref (deposit->keys); GNUNET_free (deposit->url); GNUNET_free (deposit->cdds); GNUNET_free (deposit->donau_sigs); diff --git a/src/lib/donau_api_charities_close.c b/src/lib/donau_api_charities_close.c @@ -19,14 +19,14 @@ * @brief Implementation of the POST /reserves/$RESERVE_PUB/close requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP close codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,7 +35,7 @@ /** * @brief A /reserves/$RID/close Handle */ -struct TALER_DONAU_ReservesCloseHandle +struct DONAU_ReservesCloseHandle { /** @@ -57,7 +57,7 @@ struct TALER_DONAU_ReservesCloseHandle /** * Function to call with the result. */ - TALER_DONAU_ReservesCloseCallback cb; + DONAU_ReservesCloseCallback cb; /** * Closure for @a cb. @@ -91,10 +91,10 @@ struct TALER_DONAU_ReservesCloseHandle * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_close_ok (struct TALER_DONAU_ReservesCloseHandle *rch, +handle_reserves_close_ok (struct DONAU_ReservesCloseHandle *rch, const json_t *j) { - struct TALER_DONAU_ReserveCloseResult rs = { + struct DONAU_ReserveCloseResult rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_OK, }; @@ -130,10 +130,10 @@ handle_reserves_close_ok (struct TALER_DONAU_ReservesCloseHandle *rch, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_close_kyc (struct TALER_DONAU_ReservesCloseHandle *rch, +handle_reserves_close_kyc (struct DONAU_ReservesCloseHandle *rch, const json_t *j) { - struct TALER_DONAU_ReserveCloseResult rs = { + struct DONAU_ReserveCloseResult rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, }; @@ -168,7 +168,7 @@ handle_reserves_close_kyc (struct TALER_DONAU_ReservesCloseHandle *rch, * Function called when we're done processing the * HTTP /reserves/$RID/close request. * - * @param cls the `struct TALER_DONAU_ReservesCloseHandle` + * @param cls the `struct DONAU_ReservesCloseHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -177,9 +177,9 @@ handle_reserves_close_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_ReservesCloseHandle *rch = cls; + struct DONAU_ReservesCloseHandle *rch = cls; const json_t *j = response; - struct TALER_DONAU_ReserveCloseResult rs = { + struct DONAU_ReserveCloseResult rs = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -258,25 +258,25 @@ handle_reserves_close_finished (void *cls, &rs); rch->cb = NULL; } - TALER_DONAU_reserves_close_cancel (rch); + DONAU_reserves_close_cancel (rch); } -struct TALER_DONAU_ReservesCloseHandle * -TALER_DONAU_reserves_close ( +struct DONAU_ReservesCloseHandle * +DONAU_reserves_close ( struct GNUNET_CURL_Context *ctx, const char *url, const struct TALER_ReservePrivateKeyP *reserve_priv, const char *target_payto_uri, - TALER_DONAU_ReservesCloseCallback cb, + DONAU_ReservesCloseCallback cb, void *cb_cls) { - struct TALER_DONAU_ReservesCloseHandle *rch; + struct DONAU_ReservesCloseHandle *rch; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; struct TALER_PaytoHashP h_payto; - rch = GNUNET_new (struct TALER_DONAU_ReservesCloseHandle); + rch = GNUNET_new (struct DONAU_ReservesCloseHandle); rch->cb = cb; rch->cb_cls = cb_cls; rch->ts = GNUNET_TIME_timestamp_get (); @@ -305,7 +305,7 @@ TALER_DONAU_reserves_close ( GNUNET_free (rch); return NULL; } - eh = TALER_DONAU_curl_easy_get_ (rch->url); + eh = DONAU_curl_easy_get_ (rch->url); if (NULL == eh) { GNUNET_break (0); @@ -356,8 +356,8 @@ TALER_DONAU_reserves_close ( void -TALER_DONAU_reserves_close_cancel ( - struct TALER_DONAU_ReservesCloseHandle *rch) +DONAU_reserves_close_cancel ( + struct DONAU_ReservesCloseHandle *rch) { if (NULL != rch->job) { diff --git a/src/lib/donau_api_charities_get.c b/src/lib/donau_api_charities_get.c @@ -19,14 +19,14 @@ * @brief Implementation of the GET /reserves/$RESERVE_PUB requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,7 +35,7 @@ /** * @brief A /reserves/ GET Handle */ -struct TALER_DONAU_ReservesGetHandle +struct DONAU_ReservesGetHandle { /** @@ -51,7 +51,7 @@ struct TALER_DONAU_ReservesGetHandle /** * Function to call with the result. */ - TALER_DONAU_ReservesGetCallback cb; + DONAU_ReservesGetCallback cb; /** * Public key of the reserve we are querying. @@ -75,10 +75,10 @@ struct TALER_DONAU_ReservesGetHandle * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_get_ok (struct TALER_DONAU_ReservesGetHandle *rgh, +handle_reserves_get_ok (struct DONAU_ReservesGetHandle *rgh, const json_t *j) { - struct TALER_DONAU_ReserveSummary rs = { + struct DONAU_ReserveSummary rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_OK }; @@ -108,7 +108,7 @@ handle_reserves_get_ok (struct TALER_DONAU_ReservesGetHandle *rgh, * Function called when we're done processing the * HTTP /reserves/ GET request. * - * @param cls the `struct TALER_DONAU_ReservesGetHandle` + * @param cls the `struct DONAU_ReservesGetHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -117,9 +117,9 @@ handle_reserves_get_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_ReservesGetHandle *rgh = cls; + struct DONAU_ReservesGetHandle *rgh = cls; const json_t *j = response; - struct TALER_DONAU_ReserveSummary rs = { + struct DONAU_ReserveSummary rs = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -175,20 +175,20 @@ handle_reserves_get_finished (void *cls, &rs); rgh->cb = NULL; } - TALER_DONAU_reserves_get_cancel (rgh); + DONAU_reserves_get_cancel (rgh); } -struct TALER_DONAU_ReservesGetHandle * -TALER_DONAU_reserves_get ( +struct DONAU_ReservesGetHandle * +DONAU_reserves_get ( struct GNUNET_CURL_Context *ctx, const char *url, const struct TALER_ReservePublicKeyP *reserve_pub, struct GNUNET_TIME_Relative timeout, - TALER_DONAU_ReservesGetCallback cb, + DONAU_ReservesGetCallback cb, void *cb_cls) { - struct TALER_DONAU_ReservesGetHandle *rgh; + struct DONAU_ReservesGetHandle *rgh; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 16 + 32]; @@ -221,7 +221,7 @@ TALER_DONAU_reserves_get ( pub_str, timeout_str); } - rgh = GNUNET_new (struct TALER_DONAU_ReservesGetHandle); + rgh = GNUNET_new (struct DONAU_ReservesGetHandle); rgh->cb = cb; rgh->cb_cls = cb_cls; rgh->reserve_pub = *reserve_pub; @@ -233,7 +233,7 @@ TALER_DONAU_reserves_get ( GNUNET_free (rgh); return NULL; } - eh = TALER_DONAU_curl_easy_get_ (rgh->url); + eh = DONAU_curl_easy_get_ (rgh->url); if (NULL == eh) { GNUNET_break (0); @@ -250,8 +250,8 @@ TALER_DONAU_reserves_get ( void -TALER_DONAU_reserves_get_cancel ( - struct TALER_DONAU_ReservesGetHandle *rgh) +DONAU_reserves_get_cancel ( + struct DONAU_ReservesGetHandle *rgh) { if (NULL != rgh->job) { diff --git a/src/lib/donau_api_charities_history.c b/src/lib/donau_api_charities_history.c @@ -19,14 +19,14 @@ * @brief Implementation of the POST /reserves/$RESERVE_PUB/history requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP history codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,13 +35,13 @@ /** * @brief A /reserves/$RID/history Handle */ -struct TALER_DONAU_ReservesHistoryHandle +struct DONAU_ReservesHistoryHandle { /** * The keys of the donau this request handle will use */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * The url for this request. @@ -62,7 +62,7 @@ struct TALER_DONAU_ReservesHistoryHandle /** * Function to call with the result. */ - TALER_DONAU_ReservesHistoryCallback cb; + DONAU_ReservesHistoryCallback cb; /** * Closure for @a cb. @@ -96,12 +96,12 @@ struct TALER_DONAU_ReservesHistoryHandle * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_history_ok (struct TALER_DONAU_ReservesHistoryHandle *rsh, +handle_reserves_history_ok (struct DONAU_ReservesHistoryHandle *rsh, const json_t *j) { const json_t *history; unsigned int len; - struct TALER_DONAU_ReserveHistory rs = { + struct DONAU_ReserveHistory rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_OK, .ts = rsh->ts, @@ -126,23 +126,23 @@ handle_reserves_history_ok (struct TALER_DONAU_ReservesHistoryHandle *rsh, } len = json_array_size (history); { - struct TALER_DONAU_ReserveHistoryEntry *rhistory; + struct DONAU_ReserveHistoryEntry *rhistory; rhistory = GNUNET_new_array (len, - struct TALER_DONAU_ReserveHistoryEntry); + struct DONAU_ReserveHistoryEntry); if (GNUNET_OK != - TALER_DONAU_parse_reserve_history (rsh->keys, - history, - &rsh->reserve_pub, - rs.details.ok.balance.currency, - &rs.details.ok.total_in, - &rs.details.ok.total_out, - len, - rhistory)) + DONAU_parse_reserve_history (rsh->keys, + history, + &rsh->reserve_pub, + rs.details.ok.balance.currency, + &rs.details.ok.total_in, + &rs.details.ok.total_out, + len, + rhistory)) { GNUNET_break_op (0); - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); return GNUNET_SYSERR; } if (NULL != rsh->cb) @@ -153,8 +153,8 @@ handle_reserves_history_ok (struct TALER_DONAU_ReservesHistoryHandle *rsh, &rs); rsh->cb = NULL; } - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); } return GNUNET_OK; } @@ -164,7 +164,7 @@ handle_reserves_history_ok (struct TALER_DONAU_ReservesHistoryHandle *rsh, * Function called when we're done processing the * HTTP /reserves/$RID/history request. * - * @param cls the `struct TALER_DONAU_ReservesHistoryHandle` + * @param cls the `struct DONAU_ReservesHistoryHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -173,9 +173,9 @@ handle_reserves_history_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_ReservesHistoryHandle *rsh = cls; + struct DONAU_ReservesHistoryHandle *rsh = cls; const json_t *j = response; - struct TALER_DONAU_ReserveHistory rs = { + struct DONAU_ReserveHistory rs = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -244,25 +244,25 @@ handle_reserves_history_finished (void *cls, &rs); rsh->cb = NULL; } - TALER_DONAU_reserves_history_cancel (rsh); + DONAU_reserves_history_cancel (rsh); } -struct TALER_DONAU_ReservesHistoryHandle * -TALER_DONAU_reserves_history ( +struct DONAU_ReservesHistoryHandle * +DONAU_reserves_history ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, - TALER_DONAU_ReservesHistoryCallback cb, + DONAU_ReservesHistoryCallback cb, void *cb_cls) { - struct TALER_DONAU_ReservesHistoryHandle *rsh; + struct DONAU_ReservesHistoryHandle *rsh; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; - const struct TALER_DONAU_GlobalFee *gf; + const struct DONAU_GlobalFee *gf; - rsh = GNUNET_new (struct TALER_DONAU_ReservesHistoryHandle); + rsh = GNUNET_new (struct DONAU_ReservesHistoryHandle); rsh->cb = cb; rsh->cb_cls = cb_cls; rsh->ts = GNUNET_TIME_timestamp_get (); @@ -291,7 +291,7 @@ TALER_DONAU_reserves_history ( GNUNET_free (rsh); return NULL; } - eh = TALER_DONAU_curl_easy_get_ (rsh->url); + eh = DONAU_curl_easy_get_ (rsh->url); if (NULL == eh) { GNUNET_break (0); @@ -299,8 +299,8 @@ TALER_DONAU_reserves_history ( GNUNET_free (rsh); return NULL; } - gf = TALER_DONAU_get_global_fee (keys, - rsh->ts); + gf = DONAU_get_global_fee (keys, + rsh->ts); if (NULL == gf) { GNUNET_break_op (0); @@ -334,7 +334,7 @@ TALER_DONAU_reserves_history ( } json_decref (history_obj); } - rsh->keys = TALER_DONAU_keys_incref (keys); + rsh->keys = DONAU_keys_incref (keys); rsh->job = GNUNET_CURL_job_add2 (ctx, eh, rsh->post_ctx.headers, @@ -345,8 +345,8 @@ TALER_DONAU_reserves_history ( void -TALER_DONAU_reserves_history_cancel ( - struct TALER_DONAU_ReservesHistoryHandle *rsh) +DONAU_reserves_history_cancel ( + struct DONAU_ReservesHistoryHandle *rsh) { if (NULL != rsh->job) { @@ -355,7 +355,7 @@ TALER_DONAU_reserves_history_cancel ( } TALER_curl_easy_post_finished (&rsh->post_ctx); GNUNET_free (rsh->url); - TALER_DONAU_keys_decref (rsh->keys); + DONAU_keys_decref (rsh->keys); GNUNET_free (rsh); } diff --git a/src/lib/donau_api_charities_open.c b/src/lib/donau_api_charities_open.c @@ -19,14 +19,14 @@ * @brief Implementation of the POST /reserves/$RESERVE_PUB/open requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP open codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_common.h" #include "donau_api_handle.h" #include "taler_signatures.h" @@ -63,13 +63,13 @@ struct CoinData /** * @brief A /reserves/$RID/open Handle */ -struct TALER_DONAU_ReservesOpenHandle +struct DONAU_ReservesOpenHandle { /** * The keys of the donau this request handle will use */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * The url for this request. @@ -90,7 +90,7 @@ struct TALER_DONAU_ReservesOpenHandle /** * Function to call with the result. */ - TALER_DONAU_ReservesOpenCallback cb; + DONAU_ReservesOpenCallback cb; /** * Closure for @a cb. @@ -134,10 +134,10 @@ struct TALER_DONAU_ReservesOpenHandle * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_open_ok (struct TALER_DONAU_ReservesOpenHandle *roh, +handle_reserves_open_ok (struct DONAU_ReservesOpenHandle *roh, const json_t *j) { - struct TALER_DONAU_ReserveOpenResult rs = { + struct DONAU_ReserveOpenResult rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_OK, }; @@ -175,10 +175,10 @@ handle_reserves_open_ok (struct TALER_DONAU_ReservesOpenHandle *roh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_open_pr (struct TALER_DONAU_ReservesOpenHandle *roh, +handle_reserves_open_pr (struct DONAU_ReservesOpenHandle *roh, const json_t *j) { - struct TALER_DONAU_ReserveOpenResult rs = { + struct DONAU_ReserveOpenResult rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_PAYMENT_REQUIRED, }; @@ -216,10 +216,10 @@ handle_reserves_open_pr (struct TALER_DONAU_ReservesOpenHandle *roh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_open_kyc (struct TALER_DONAU_ReservesOpenHandle *roh, +handle_reserves_open_kyc (struct DONAU_ReservesOpenHandle *roh, const json_t *j) { - struct TALER_DONAU_ReserveOpenResult rs = { + struct DONAU_ReserveOpenResult rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS, }; @@ -254,7 +254,7 @@ handle_reserves_open_kyc (struct TALER_DONAU_ReservesOpenHandle *roh, * Function called when we're done processing the * HTTP /reserves/$RID/open request. * - * @param cls the `struct TALER_DONAU_ReservesOpenHandle` + * @param cls the `struct DONAU_ReservesOpenHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -263,9 +263,9 @@ handle_reserves_open_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_ReservesOpenHandle *roh = cls; + struct DONAU_ReservesOpenHandle *roh = cls; const json_t *j = response; - struct TALER_DONAU_ReserveOpenResult rs = { + struct DONAU_ReserveOpenResult rs = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -323,7 +323,7 @@ handle_reserves_open_finished (void *cls, { const struct CoinData *cd = NULL; struct TALER_CoinSpendPublicKeyP coin_pub; - const struct TALER_DONAU_DenomPublicKey *dk; + const struct DONAU_DenomPublicKey *dk; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub), @@ -359,8 +359,8 @@ handle_reserves_open_finished (void *cls, rs.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; break; } - dk = TALER_DONAU_get_denomination_key_by_hash (roh->keys, - &cd->h_denom_pub); + dk = DONAU_get_denomination_key_by_hash (roh->keys, + &cd->h_denom_pub); if (NULL == dk) { GNUNET_break_op (0); @@ -369,12 +369,12 @@ handle_reserves_open_finished (void *cls, break; } if (GNUNET_OK != - TALER_DONAU_check_coin_conflict_ (roh->keys, - j, - dk, - &coin_pub, - &cd->coin_sig, - &cd->contribution)) + DONAU_check_coin_conflict_ (roh->keys, + j, + dk, + &coin_pub, + &cd->coin_sig, + &cd->contribution)) { GNUNET_break_op (0); rs.hr.http_status = 0; @@ -418,31 +418,31 @@ handle_reserves_open_finished (void *cls, &rs); roh->cb = NULL; } - TALER_DONAU_reserves_open_cancel (roh); + DONAU_reserves_open_cancel (roh); } -struct TALER_DONAU_ReservesOpenHandle * -TALER_DONAU_reserves_open ( +struct DONAU_ReservesOpenHandle * +DONAU_reserves_open ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, const struct TALER_Amount *reserve_contribution, unsigned int coin_payments_length, - const struct TALER_DONAU_PurseDeposit coin_payments[ + const struct DONAU_PurseDeposit coin_payments[ static coin_payments_length], struct GNUNET_TIME_Timestamp expiration_time, uint32_t min_purses, - TALER_DONAU_ReservesOpenCallback cb, + DONAU_ReservesOpenCallback cb, void *cb_cls) { - struct TALER_DONAU_ReservesOpenHandle *roh; + struct DONAU_ReservesOpenHandle *roh; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; json_t *cpa; - roh = GNUNET_new (struct TALER_DONAU_ReservesOpenHandle); + roh = GNUNET_new (struct DONAU_ReservesOpenHandle); roh->cb = cb; roh->cb_cls = cb_cls; roh->ts = GNUNET_TIME_timestamp_get (); @@ -471,7 +471,7 @@ TALER_DONAU_reserves_open ( GNUNET_free (roh); return NULL; } - eh = TALER_DONAU_curl_easy_get_ (roh->url); + eh = DONAU_curl_easy_get_ (roh->url); if (NULL == eh) { GNUNET_break (0); @@ -491,7 +491,7 @@ TALER_DONAU_reserves_open ( GNUNET_assert (NULL != cpa); for (unsigned int i = 0; i<coin_payments_length; i++) { - const struct TALER_DONAU_PurseDeposit *pd = &coin_payments[i]; + const struct DONAU_PurseDeposit *pd = &coin_payments[i]; const struct TALER_AgeCommitmentProof *acp = pd->age_commitment_proof; struct TALER_AgeCommitmentHash ahac; struct TALER_AgeCommitmentHash *achp = NULL; @@ -561,7 +561,7 @@ TALER_DONAU_reserves_open ( } json_decref (open_obj); } - roh->keys = TALER_DONAU_keys_incref (keys); + roh->keys = DONAU_keys_incref (keys); roh->job = GNUNET_CURL_job_add2 (ctx, eh, roh->post_ctx.headers, @@ -572,8 +572,8 @@ TALER_DONAU_reserves_open ( void -TALER_DONAU_reserves_open_cancel ( - struct TALER_DONAU_ReservesOpenHandle *roh) +DONAU_reserves_open_cancel ( + struct DONAU_ReservesOpenHandle *roh) { if (NULL != roh->job) { @@ -583,7 +583,7 @@ TALER_DONAU_reserves_open_cancel ( TALER_curl_easy_post_finished (&roh->post_ctx); GNUNET_free (roh->coins); GNUNET_free (roh->url); - TALER_DONAU_keys_decref (roh->keys); + DONAU_keys_decref (roh->keys); GNUNET_free (roh); } diff --git a/src/lib/donau_api_charities_status.c b/src/lib/donau_api_charities_status.c @@ -19,14 +19,14 @@ * @brief Implementation of the POST /reserves/$RESERVE_PUB/status requests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,13 +35,13 @@ /** * @brief A /reserves/$RID/status Handle */ -struct TALER_DONAU_ReservesStatusHandle +struct DONAU_ReservesStatusHandle { /** * The keys of the donau this request handle will use */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * The url for this request. @@ -62,7 +62,7 @@ struct TALER_DONAU_ReservesStatusHandle /** * Function to call with the result. */ - TALER_DONAU_ReservesStatusCallback cb; + DONAU_ReservesStatusCallback cb; /** * Public key of the reserve we are querying. @@ -86,12 +86,12 @@ struct TALER_DONAU_ReservesStatusHandle * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -handle_reserves_status_ok (struct TALER_DONAU_ReservesStatusHandle *rsh, +handle_reserves_status_ok (struct DONAU_ReservesStatusHandle *rsh, const json_t *j) { const json_t *history; unsigned int len; - struct TALER_DONAU_ReserveStatus rs = { + struct DONAU_ReserveStatus rs = { .hr.reply = j, .hr.http_status = MHD_HTTP_OK }; @@ -114,23 +114,23 @@ handle_reserves_status_ok (struct TALER_DONAU_ReservesStatusHandle *rsh, } len = json_array_size (history); { - struct TALER_DONAU_ReserveHistoryEntry *rhistory; + struct DONAU_ReserveHistoryEntry *rhistory; rhistory = GNUNET_new_array (len, - struct TALER_DONAU_ReserveHistoryEntry); + struct DONAU_ReserveHistoryEntry); if (GNUNET_OK != - TALER_DONAU_parse_reserve_history (rsh->keys, - history, - &rsh->reserve_pub, - rs.details.ok.balance.currency, - &rs.details.ok.total_in, - &rs.details.ok.total_out, - len, - rhistory)) + DONAU_parse_reserve_history (rsh->keys, + history, + &rsh->reserve_pub, + rs.details.ok.balance.currency, + &rs.details.ok.total_in, + &rs.details.ok.total_out, + len, + rhistory)) { GNUNET_break_op (0); - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); GNUNET_JSON_parse_free (spec); return GNUNET_SYSERR; } @@ -142,8 +142,8 @@ handle_reserves_status_ok (struct TALER_DONAU_ReservesStatusHandle *rsh, &rs); rsh->cb = NULL; } - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); } return GNUNET_OK; } @@ -153,7 +153,7 @@ handle_reserves_status_ok (struct TALER_DONAU_ReservesStatusHandle *rsh, * Function called when we're done processing the * HTTP /reserves/$RID/status request. * - * @param cls the `struct TALER_DONAU_ReservesStatusHandle` + * @param cls the `struct DONAU_ReservesStatusHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -162,9 +162,9 @@ handle_reserves_status_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_ReservesStatusHandle *rsh = cls; + struct DONAU_ReservesStatusHandle *rsh = cls; const json_t *j = response; - struct TALER_DONAU_ReserveStatus rs = { + struct DONAU_ReserveStatus rs = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -227,27 +227,27 @@ handle_reserves_status_finished (void *cls, &rs); rsh->cb = NULL; } - TALER_DONAU_reserves_status_cancel (rsh); + DONAU_reserves_status_cancel (rsh); } -struct TALER_DONAU_ReservesStatusHandle * -TALER_DONAU_reserves_status ( +struct DONAU_ReservesStatusHandle * +DONAU_reserves_status ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, - TALER_DONAU_ReservesStatusCallback cb, + DONAU_ReservesStatusCallback cb, void *cb_cls) { - struct TALER_DONAU_ReservesStatusHandle *rsh; + struct DONAU_ReservesStatusHandle *rsh; CURL *eh; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; struct TALER_ReserveSignatureP reserve_sig; struct GNUNET_TIME_Timestamp ts = GNUNET_TIME_timestamp_get (); - rsh = GNUNET_new (struct TALER_DONAU_ReservesStatusHandle); + rsh = GNUNET_new (struct DONAU_ReservesStatusHandle); rsh->cb = cb; rsh->cb_cls = cb_cls; GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, @@ -275,7 +275,7 @@ TALER_DONAU_reserves_status ( GNUNET_free (rsh); return NULL; } - eh = TALER_DONAU_curl_easy_get_ (rsh->url); + eh = DONAU_curl_easy_get_ (rsh->url); if (NULL == eh) { GNUNET_break (0); @@ -307,7 +307,7 @@ TALER_DONAU_reserves_status ( } json_decref (status_obj); } - rsh->keys = TALER_DONAU_keys_incref (keys); + rsh->keys = DONAU_keys_incref (keys); rsh->job = GNUNET_CURL_job_add2 (ctx, eh, rsh->post_ctx.headers, @@ -318,8 +318,8 @@ TALER_DONAU_reserves_status ( void -TALER_DONAU_reserves_status_cancel ( - struct TALER_DONAU_ReservesStatusHandle *rsh) +DONAU_reserves_status_cancel ( + struct DONAU_ReservesStatusHandle *rsh) { if (NULL != rsh->job) { @@ -328,7 +328,7 @@ TALER_DONAU_reserves_status_cancel ( } TALER_curl_easy_post_finished (&rsh->post_ctx); GNUNET_free (rsh->url); - TALER_DONAU_keys_decref (rsh->keys); + DONAU_keys_decref (rsh->keys); GNUNET_free (rsh); } diff --git a/src/lib/donau_api_common.c b/src/lib/donau_api_common.c @@ -19,8 +19,8 @@ * @brief common functions for the donau API * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "donau_api_common.h" #include "donau_api_handle.h" @@ -36,7 +36,7 @@ struct HistoryParseContext /** * Keys of the donau we use. */ - const struct TALER_DONAU_Keys *keys; + const struct DONAU_Keys *keys; /** * Our reserve public key. @@ -75,7 +75,7 @@ struct HistoryParseContext * @return #GNUNET_OK on success */ typedef enum GNUNET_GenericReturnValue -(*ParseHelper)(struct TALER_DONAU_ReserveHistoryEntry *rh, +(*ParseHelper)(struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction); @@ -89,7 +89,7 @@ typedef enum GNUNET_GenericReturnValue * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_credit (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_credit (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { @@ -106,7 +106,7 @@ parse_credit (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_CREDIT; + rh->type = DONAU_RTT_CREDIT; if (0 > TALER_amount_add (uc->total_in, uc->total_in, @@ -140,7 +140,7 @@ parse_credit (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_withdraw (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_withdraw (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { @@ -160,7 +160,7 @@ parse_withdraw (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_WITHDRAWAL; + rh->type = DONAU_RTT_WITHDRAWAL; if (GNUNET_OK != GNUNET_JSON_parse (transaction, withdraw_spec, @@ -184,12 +184,12 @@ parse_withdraw (struct TALER_DONAU_ReserveHistoryEntry *rh, } /* check that withdraw fee matches expectations! */ { - const struct TALER_DONAU_Keys *key_state; - const struct TALER_DONAU_DenomPublicKey *dki; + const struct DONAU_Keys *key_state; + const struct DONAU_DenomPublicKey *dki; key_state = uc->keys; - dki = TALER_DONAU_get_denomination_key_by_hash (key_state, - &h_denom_pub); + dki = DONAU_get_denomination_key_by_hash (key_state, + &h_denom_pub); if ( (GNUNET_YES != TALER_amount_cmp_currency (&withdraw_fee, &dki->fees.withdraw)) || @@ -249,11 +249,11 @@ parse_withdraw (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_recoup (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_recoup (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { - const struct TALER_DONAU_Keys *key_state; + const struct DONAU_Keys *key_state; struct GNUNET_JSON_Specification recoup_spec[] = { GNUNET_JSON_spec_fixed_auto ("coin_pub", &rh->details.recoup_details.coin_pub), @@ -266,7 +266,7 @@ parse_recoup (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_RECOUP; + rh->type = DONAU_RTT_RECOUP; if (GNUNET_OK != GNUNET_JSON_parse (transaction, recoup_spec, @@ -277,9 +277,9 @@ parse_recoup (struct TALER_DONAU_ReserveHistoryEntry *rh, } key_state = uc->keys; if (GNUNET_OK != - TALER_DONAU_test_signing_key (key_state, - &rh->details. - recoup_details.donau_pub)) + DONAU_test_signing_key (key_state, + &rh->details. + recoup_details.donau_pub)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -318,11 +318,11 @@ parse_recoup (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_closing (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_closing (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { - const struct TALER_DONAU_Keys *key_state; + const struct DONAU_Keys *key_state; struct GNUNET_JSON_Specification closing_spec[] = { GNUNET_JSON_spec_string ( "receiver_account_details", @@ -340,7 +340,7 @@ parse_closing (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_CLOSING; + rh->type = DONAU_RTT_CLOSING; if (GNUNET_OK != GNUNET_JSON_parse (transaction, closing_spec, @@ -351,7 +351,7 @@ parse_closing (struct TALER_DONAU_ReserveHistoryEntry *rh, } key_state = uc->keys; if (GNUNET_OK != - TALER_DONAU_test_signing_key ( + DONAU_test_signing_key ( key_state, &rh->details.close_details.donau_pub)) { @@ -394,7 +394,7 @@ parse_closing (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_merge (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_merge (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { @@ -423,7 +423,7 @@ parse_merge (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_MERGE; + rh->type = DONAU_RTT_MERGE; if (GNUNET_OK != GNUNET_JSON_parse (transaction, merge_spec, @@ -487,7 +487,7 @@ parse_merge (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_history (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_history (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { @@ -499,7 +499,7 @@ parse_history (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_HISTORY; + rh->type = DONAU_RTT_HISTORY; if (GNUNET_OK != GNUNET_JSON_parse (transaction, history_spec, @@ -540,7 +540,7 @@ parse_history (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_open (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_open (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { @@ -558,7 +558,7 @@ parse_open (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_OPEN; + rh->type = DONAU_RTT_OPEN; if (GNUNET_OK != GNUNET_JSON_parse (transaction, open_spec, @@ -601,7 +601,7 @@ parse_open (struct TALER_DONAU_ReserveHistoryEntry *rh, * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -parse_close (struct TALER_DONAU_ReserveHistoryEntry *rh, +parse_close (struct DONAU_ReserveHistoryEntry *rh, struct HistoryParseContext *uc, const json_t *transaction) { @@ -618,7 +618,7 @@ parse_close (struct TALER_DONAU_ReserveHistoryEntry *rh, GNUNET_JSON_spec_end () }; - rh->type = TALER_DONAU_RTT_CLOSE; + rh->type = DONAU_RTT_CLOSE; if (GNUNET_OK != GNUNET_JSON_parse (transaction, close_spec, @@ -646,15 +646,15 @@ parse_close (struct TALER_DONAU_ReserveHistoryEntry *rh, enum GNUNET_GenericReturnValue -TALER_DONAU_parse_reserve_history ( - const struct TALER_DONAU_Keys *keys, +DONAU_parse_reserve_history ( + const struct DONAU_Keys *keys, const json_t *history, const struct TALER_ReservePublicKeyP *reserve_pub, const char *currency, struct TALER_Amount *total_in, struct TALER_Amount *total_out, unsigned int history_length, - struct TALER_DONAU_ReserveHistoryEntry rhistory[static history_length]) + struct DONAU_ReserveHistoryEntry rhistory[static history_length]) { const struct { @@ -688,7 +688,7 @@ TALER_DONAU_parse_reserve_history ( total_out)); for (unsigned int off = 0; off<history_length; off++) { - struct TALER_DONAU_ReserveHistoryEntry *rh = &rhistory[off]; + struct DONAU_ReserveHistoryEntry *rh = &rhistory[off]; json_t *transaction; struct TALER_Amount amount; const char *type; @@ -752,32 +752,32 @@ TALER_DONAU_parse_reserve_history ( void -TALER_DONAU_free_reserve_history ( +DONAU_free_reserve_history ( unsigned int len, - struct TALER_DONAU_ReserveHistoryEntry rhistory[static len]) + struct DONAU_ReserveHistoryEntry rhistory[static len]) { for (unsigned int i = 0; i<len; i++) { switch (rhistory[i].type) { - case TALER_DONAU_RTT_CREDIT: + case DONAU_RTT_CREDIT: GNUNET_free (rhistory[i].details.in_details.sender_url); break; - case TALER_DONAU_RTT_WITHDRAWAL: + case DONAU_RTT_WITHDRAWAL: break; - case TALER_DONAU_RTT_AGEWITHDRAWAL: + case DONAU_RTT_AGEWITHDRAWAL: break; - case TALER_DONAU_RTT_RECOUP: + case DONAU_RTT_RECOUP: break; - case TALER_DONAU_RTT_CLOSING: + case DONAU_RTT_CLOSING: break; - case TALER_DONAU_RTT_HISTORY: + case DONAU_RTT_HISTORY: break; - case TALER_DONAU_RTT_MERGE: + case DONAU_RTT_MERGE: break; - case TALER_DONAU_RTT_OPEN: + case DONAU_RTT_OPEN: break; - case TALER_DONAU_RTT_CLOSE: + case DONAU_RTT_CLOSE: break; } } @@ -794,7 +794,7 @@ struct CoinHistoryParseContext /** * Denomination of the coin. */ - const struct TALER_DONAU_DenomPublicKey *dk; + const struct DONAU_DenomPublicKey *dk; /** * Our coin public key. @@ -851,7 +851,7 @@ help_deposit (struct CoinHistoryParseContext *pc, struct GNUNET_HashCode wallet_data_hash; bool no_wallet_data_hash; struct GNUNET_TIME_Timestamp wallet_timestamp; - struct TALER_CharityPublicKeyP charity_pub; + struct DONAU_CharityPublicKeyP charity_pub; struct GNUNET_TIME_Timestamp refund_deadline = {0}; struct TALER_CoinSpendSignatureP sig; struct TALER_AgeCommitmentHash hac; @@ -1018,8 +1018,8 @@ help_refund (struct CoinHistoryParseContext *pc, json_t *transaction) { struct TALER_PrivateContractHashP h_contract_terms; - struct TALER_CharityPublicKeyP charity_pub; - struct TALER_CharitySignatureP sig; + struct DONAU_CharityPublicKeyP charity_pub; + struct DONAU_CharitySignatureP sig; struct TALER_Amount refund_fee; struct TALER_Amount sig_amount; uint64_t rtransaction_id; @@ -1055,11 +1055,11 @@ help_refund (struct CoinHistoryParseContext *pc, } if (GNUNET_OK != TALER_charity_refund_verify (pc->coin_pub, - &h_contract_terms, - rtransaction_id, - &sig_amount, - &charity_pub, - &sig)) + &h_contract_terms, + rtransaction_id, + &sig_amount, + &charity_pub, + &sig)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -1104,7 +1104,7 @@ help_recoup (struct CoinHistoryParseContext *pc, struct TALER_ReservePublicKeyP reserve_pub; struct GNUNET_TIME_Timestamp timestamp; union TALER_DenominationBlindingKeyP coin_bks; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_DonauSignatureP donau_sig; struct TALER_CoinSpendSignatureP coin_sig; struct GNUNET_JSON_Specification spec[] = { @@ -1175,7 +1175,7 @@ help_recoup_refresh (struct CoinHistoryParseContext *pc, struct TALER_CoinSpendPublicKeyP old_coin_pub; union TALER_DenominationBlindingKeyP coin_bks; struct GNUNET_TIME_Timestamp timestamp; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_DonauSignatureP donau_sig; struct TALER_CoinSpendSignatureP coin_sig; struct GNUNET_JSON_Specification spec[] = { @@ -1243,7 +1243,7 @@ help_old_coin_recoup (struct CoinHistoryParseContext *pc, { /* This is the coin that was credited in a recoup, the value being credited to the this coin. */ - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_DonauSignatureP donau_sig; struct TALER_CoinSpendPublicKeyP new_coin_pub; struct GNUNET_TIME_Timestamp timestamp; @@ -1376,7 +1376,7 @@ help_purse_refund (struct CoinHistoryParseContext *pc, { struct TALER_PurseContractPublicKeyP purse_pub; struct TALER_Amount refund_fee; - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; struct TALER_DonauSignatureP donau_sig; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount_any ("refund_fee", @@ -1471,8 +1471,8 @@ help_reserve_open_deposit (struct CoinHistoryParseContext *pc, enum GNUNET_GenericReturnValue -TALER_DONAU_verify_coin_history ( - const struct TALER_DONAU_DenomPublicKey *dk, +DONAU_verify_coin_history ( + const struct DONAU_DenomPublicKey *dk, const struct TALER_CoinSpendPublicKeyP *coin_pub, const json_t *history, struct TALER_Amount *total) @@ -1619,14 +1619,14 @@ TALER_DONAU_verify_coin_history ( } -const struct TALER_DONAU_SigningPublicKey * -TALER_DONAU_get_signing_key_info ( - const struct TALER_DONAU_Keys *keys, - const struct TALER_DonauPublicKeyP *donau_pub) +const struct DONAU_SigningPublicKey * +DONAU_get_signing_key_info ( + const struct DONAU_Keys *keys, + const struct DONAU_DonauPublicKeyP *donau_pub) { for (unsigned int i = 0; i<keys->num_sign_keys; i++) { - const struct TALER_DONAU_SigningPublicKey *spk + const struct DONAU_SigningPublicKey *spk = &keys->sign_keys[i]; if (0 == GNUNET_memcmp (donau_pub, @@ -1638,7 +1638,7 @@ TALER_DONAU_get_signing_key_info ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_create_conflict_ ( +DONAU_check_purse_create_conflict_ ( const struct TALER_PurseContractSignatureP *cpurse_sig, const struct TALER_PurseContractPublicKeyP *purse_pub, const json_t *proof) @@ -1698,7 +1698,7 @@ TALER_DONAU_check_purse_create_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_merge_conflict_ ( +DONAU_check_purse_merge_conflict_ ( const struct TALER_PurseMergeSignatureP *cmerge_sig, const struct TALER_PurseMergePublicKeyP *merge_pub, const struct TALER_PurseContractPublicKeyP *purse_pub, @@ -1762,7 +1762,7 @@ TALER_DONAU_check_purse_merge_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_coin_conflict_ ( +DONAU_check_purse_coin_conflict_ ( const struct TALER_PurseContractPublicKeyP *purse_pub, const char *donau_url, const json_t *proof, @@ -1819,7 +1819,7 @@ TALER_DONAU_check_purse_coin_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_econtract_conflict_ ( +DONAU_check_purse_econtract_conflict_ ( const struct TALER_PurseContractSignatureP *ccontract_sig, const struct TALER_PurseContractPublicKeyP *purse_pub, const json_t *proof) @@ -1868,8 +1868,8 @@ TALER_DONAU_check_purse_econtract_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_amount_conflict_ ( - const struct TALER_DONAU_Keys *keys, +DONAU_check_coin_amount_conflict_ ( + const struct DONAU_Keys *keys, const json_t *proof, struct TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount *remaining) @@ -1877,7 +1877,7 @@ TALER_DONAU_check_coin_amount_conflict_ ( const json_t *history; struct TALER_Amount total; struct TALER_DenominationHashP h_denom_pub; - const struct TALER_DONAU_DenomPublicKey *dki; + const struct DONAU_DenomPublicKey *dki; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("coin_pub", coin_pub), @@ -1896,7 +1896,7 @@ TALER_DONAU_check_coin_amount_conflict_ ( GNUNET_break_op (0); return GNUNET_SYSERR; } - dki = TALER_DONAU_get_denomination_key_by_hash ( + dki = DONAU_get_denomination_key_by_hash ( keys, &h_denom_pub); if (NULL == dki) @@ -1905,10 +1905,10 @@ TALER_DONAU_check_coin_amount_conflict_ ( return GNUNET_SYSERR; } if (GNUNET_OK != - TALER_DONAU_verify_coin_history (dki, - coin_pub, - history, - &total)) + DONAU_verify_coin_history (dki, + coin_pub, + history, + &total)) { GNUNET_break_op (0); return GNUNET_SYSERR; @@ -1938,7 +1938,7 @@ TALER_DONAU_check_coin_amount_conflict_ ( * @return #GNUNET_OK if @a coin_sig is not in @a proof */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_signature_conflict_ ( +DONAU_check_coin_signature_conflict_ ( const json_t *proof, const struct TALER_CoinSpendSignatureP *coin_sig) { @@ -1980,7 +1980,7 @@ TALER_DONAU_check_coin_signature_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_denomination_conflict_ ( +DONAU_check_coin_denomination_conflict_ ( const json_t *proof, const struct TALER_DenominationHashP *ch_denom_pub) { @@ -2012,10 +2012,10 @@ TALER_DONAU_check_coin_denomination_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_conflict_ ( - const struct TALER_DONAU_Keys *keys, +DONAU_check_coin_conflict_ ( + const struct DONAU_Keys *keys, const json_t *proof, - const struct TALER_DONAU_DenomPublicKey *dk, + const struct DONAU_DenomPublicKey *dk, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendSignatureP *coin_sig, const struct TALER_Amount *required) @@ -2031,7 +2031,7 @@ TALER_DONAU_check_coin_conflict_ ( struct TALER_CoinSpendPublicKeyP pcoin_pub; if (GNUNET_OK != - TALER_DONAU_check_coin_amount_conflict_ ( + DONAU_check_coin_amount_conflict_ ( keys, proof, &pcoin_pub, @@ -2057,7 +2057,7 @@ TALER_DONAU_check_coin_conflict_ ( return GNUNET_SYSERR; } if (GNUNET_OK != - TALER_DONAU_check_coin_signature_conflict_ ( + DONAU_check_coin_signature_conflict_ ( proof, coin_sig)) { @@ -2073,7 +2073,7 @@ TALER_DONAU_check_coin_conflict_ ( struct TALER_CoinSpendPublicKeyP pcoin_pub; if (GNUNET_OK != - TALER_DONAU_check_coin_amount_conflict_ ( + DONAU_check_coin_amount_conflict_ ( keys, proof, &pcoin_pub, @@ -2091,7 +2091,7 @@ TALER_DONAU_check_coin_conflict_ ( return GNUNET_SYSERR; } if (GNUNET_OK != - TALER_DONAU_check_coin_denomination_conflict_ ( + DONAU_check_coin_denomination_conflict_ ( proof, &dk->h_key)) { @@ -2110,14 +2110,14 @@ TALER_DONAU_check_coin_conflict_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_get_min_denomination_ ( - const struct TALER_DONAU_Keys *keys, +DONAU_get_min_denomination_ ( + const struct DONAU_Keys *keys, struct TALER_Amount *min) { bool have_min = false; for (unsigned int i = 0; i<keys->num_denom_keys; i++) { - const struct TALER_DONAU_DenomPublicKey *dk = &keys->denom_keys[i]; + const struct DONAU_DenomPublicKey *dk = &keys->denom_keys[i]; if (! have_min) { @@ -2140,12 +2140,12 @@ TALER_DONAU_get_min_denomination_ ( enum GNUNET_GenericReturnValue -TALER_DONAU_verify_deposit_signature_ ( - const struct TALER_DONAU_DepositContractDetail *dcd, +DONAU_verify_deposit_signature_ ( + const struct DONAU_DepositContractDetail *dcd, const struct TALER_ExtensionPolicyHashP *ech, const struct TALER_CharityWireHashP *h_wire, - const struct TALER_DONAU_CoinDepositDetail *cdd, - const struct TALER_DONAU_DenomPublicKey *dki) + const struct DONAU_CoinDepositDetail *cdd, + const struct DONAU_DenomPublicKey *dki) { if (GNUNET_OK != TALER_wallet_deposit_verify (&cdd->amount, @@ -2213,7 +2213,7 @@ TALER_DONAU_verify_deposit_signature_ ( static enum GNUNET_GenericReturnValue parse_restrictions (const json_t *jresta, unsigned int *resta_len, - struct TALER_DONAU_AccountRestriction **resta) + struct DONAU_AccountRestriction **resta) { if (! json_is_array (jresta)) { @@ -2228,12 +2228,12 @@ parse_restrictions (const json_t *jresta, return GNUNET_OK; } *resta = GNUNET_new_array (*resta_len, - struct TALER_DONAU_AccountRestriction); + struct DONAU_AccountRestriction); for (unsigned int i = 0; i<*resta_len; i++) { const json_t *jr = json_array_get (jresta, i); - struct TALER_DONAU_AccountRestriction *ar = &(*resta)[i]; + struct DONAU_AccountRestriction *ar = &(*resta)[i]; const char *type = json_string_value (json_object_get (jr, "type")); @@ -2245,7 +2245,7 @@ parse_restrictions (const json_t *jresta, if (0 == strcmp (type, "deny")) { - ar->type = TALER_DONAU_AR_DENY; + ar->type = DONAU_AR_DENY; continue; } if (0 == strcmp (type, @@ -2277,7 +2277,7 @@ parse_restrictions (const json_t *jresta, GNUNET_break_op (0); goto fail; } - ar->type = TALER_DONAU_AR_REGEX; + ar->type = DONAU_AR_REGEX; ar->details.regex.posix_egrep = GNUNET_strdup (regex); ar->details.regex.human_hint = GNUNET_strdup (hint); continue; @@ -2295,22 +2295,22 @@ fail: enum GNUNET_GenericReturnValue -TALER_DONAU_parse_accounts ( +DONAU_parse_accounts ( const struct TALER_MasterPublicKeyP *master_pub, const json_t *accounts, unsigned int was_length, - struct TALER_DONAU_WireAccount was[static was_length]) + struct DONAU_WireAccount was[static was_length]) { memset (was, 0, - sizeof (struct TALER_DONAU_WireAccount) * was_length); + sizeof (struct DONAU_WireAccount) * was_length); GNUNET_assert (was_length == json_array_size (accounts)); for (unsigned int i = 0; i<was_length; i++) { - struct TALER_DONAU_WireAccount *wa = &was[i]; + struct DONAU_WireAccount *wa = &was[i]; const char *payto_uri; const char *conversion_url; const json_t *credit_restrictions; @@ -2398,19 +2398,19 @@ TALER_DONAU_parse_accounts ( */ static void free_restrictions (unsigned int ar_len, - struct TALER_DONAU_AccountRestriction ar[static ar_len]) + struct DONAU_AccountRestriction ar[static ar_len]) { for (unsigned int i = 0; i<ar_len; i++) { - struct TALER_DONAU_AccountRestriction *a = &ar[i]; + struct DONAU_AccountRestriction *a = &ar[i]; switch (a->type) { - case TALER_DONAU_AR_INVALID: + case DONAU_AR_INVALID: GNUNET_break (0); break; - case TALER_DONAU_AR_DENY: + case DONAU_AR_DENY: break; - case TALER_DONAU_AR_REGEX: + case DONAU_AR_REGEX: GNUNET_free (ar->details.regex.posix_egrep); GNUNET_free (ar->details.regex.human_hint); json_decref (ar->details.regex.human_hint_i18n); @@ -2421,13 +2421,13 @@ free_restrictions (unsigned int ar_len, void -TALER_DONAU_free_accounts ( +DONAU_free_accounts ( unsigned int was_len, - struct TALER_DONAU_WireAccount was[static was_len]) + struct DONAU_WireAccount was[static was_len]) { for (unsigned int i = 0; i<was_len; i++) { - struct TALER_DONAU_WireAccount *wa = &was[i]; + struct DONAU_WireAccount *wa = &was[i]; GNUNET_free (wa->payto_uri); GNUNET_free (wa->conversion_url); diff --git a/src/lib/donau_api_common.h b/src/lib/donau_api_common.h @@ -22,7 +22,7 @@ #ifndef DONAU_API_COMMON_H #define DONAU_API_COMMON_H -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_donau_service.h" @@ -37,7 +37,7 @@ * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and conflicts with @a cpurse_sig */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_create_conflict_ ( +DONAU_check_purse_create_conflict_ ( const struct TALER_PurseContractSignatureP *cpurse_sig, const struct TALER_PurseContractPublicKeyP *purse_pub, const json_t *proof); @@ -56,7 +56,7 @@ TALER_DONAU_check_purse_create_conflict_ ( * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and @a merge_pub and conflicts with @a cmerge_sig */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_merge_conflict_ ( +DONAU_check_purse_merge_conflict_ ( const struct TALER_PurseMergeSignatureP *cmerge_sig, const struct TALER_PurseMergePublicKeyP *merge_pub, const struct TALER_PurseContractPublicKeyP *purse_pub, @@ -82,7 +82,7 @@ TALER_DONAU_check_purse_merge_conflict_ ( * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and showing that @a coin_pub was spent using @a coin_sig. */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_coin_conflict_ ( +DONAU_check_purse_coin_conflict_ ( const struct TALER_PurseContractPublicKeyP *purse_pub, const char *donau_url, const json_t *proof, @@ -102,7 +102,7 @@ TALER_DONAU_check_purse_coin_conflict_ ( * @return #GNUNET_OK if the @a proof is OK for @a purse_pub and conflicts with @a ccontract_sig */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_purse_econtract_conflict_ ( +DONAU_check_purse_econtract_conflict_ ( const struct TALER_PurseContractSignatureP *ccontract_sig, const struct TALER_PurseContractPublicKeyP *purse_pub, const json_t *proof); @@ -121,8 +121,8 @@ TALER_DONAU_check_purse_econtract_conflict_ ( * @return #GNUNET_OK if the @a proof is OK for @a purse_pub demonstrating that @a coin_pub has only @a remaining balance. */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_amount_conflict_ ( - const struct TALER_DONAU_Keys *keys, +DONAU_check_coin_amount_conflict_ ( + const struct DONAU_Keys *keys, const json_t *proof, struct TALER_CoinSpendPublicKeyP *coin_pub, struct TALER_Amount *remaining); @@ -132,7 +132,7 @@ TALER_DONAU_check_coin_amount_conflict_ ( * Verify that @a proof contains a coin history that demonstrates that @a * coin_pub was previously used with a denomination key that is different from * @a ch_denom_pub. Note that the coin history MUST have been checked before - * using #TALER_DONAU_check_coin_amount_conflict_(). + * using #DONAU_check_coin_amount_conflict_(). * * @param proof a proof to check * @param ch_denom_pub hash of the conflicting denomination @@ -140,7 +140,7 @@ TALER_DONAU_check_coin_amount_conflict_ ( * denomination hash given by the history of the coin */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_denomination_conflict_ ( +DONAU_check_coin_denomination_conflict_ ( const json_t *proof, const struct TALER_DenominationHashP *ch_denom_pub); @@ -156,7 +156,7 @@ TALER_DONAU_check_coin_denomination_conflict_ ( * @return #GNUNET_OK if @a coin_sig is not in @a proof */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_signature_conflict_ ( +DONAU_check_coin_signature_conflict_ ( const json_t *proof, const struct TALER_CoinSpendSignatureP *coin_sig); @@ -175,10 +175,10 @@ TALER_DONAU_check_coin_signature_conflict_ ( * @return #GNUNET_OK if @a proof holds */ enum GNUNET_GenericReturnValue -TALER_DONAU_check_coin_conflict_ ( - const struct TALER_DONAU_Keys *keys, +DONAU_check_coin_conflict_ ( + const struct DONAU_Keys *keys, const json_t *proof, - const struct TALER_DONAU_DenomPublicKey *dk, + const struct DONAU_DenomPublicKey *dk, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_CoinSpendSignatureP *coin_sig, const struct TALER_Amount *required); @@ -192,8 +192,8 @@ TALER_DONAU_check_coin_conflict_ ( * @return #GNUNET_SYSERR if there are no denominations in @a keys enum GNUNET_GenericReturnValue -TALER_DONAU_get_min_denomination_ ( - const struct TALER_DONAU_Keys *keys, +DONAU_get_min_denomination_ ( + const struct DONAU_Keys *keys, struct TALER_Amount *min); @@ -208,12 +208,12 @@ TALER_DONAU_get_min_denomination_ ( * @return #GNUNET_OK if signatures are OK, #GNUNET_SYSERR if not */ enum GNUNET_GenericReturnValue -TALER_DONAU_verify_deposit_signature_ ( - const struct TALER_DONAU_DepositContractDetail *dcd, +DONAU_verify_deposit_signature_ ( + const struct DONAU_DepositContractDetail *dcd, const struct TALER_ExtensionPolicyHashP *ech, const struct TALER_CharityWireHashP *h_wire, - const struct TALER_DONAU_CoinDepositDetail *cdd, - const struct TALER_DONAU_DenomPublicKey *dki); + const struct DONAU_CoinDepositDetail *cdd, + const struct DONAU_DenomPublicKey *dki); #endif diff --git a/src/lib/donau_api_csr_issue_receipts.c b/src/lib/donau_api_csr_issue_receipts.c @@ -20,14 +20,14 @@ * @author Lucien Heuzeveldt * @author Gian Demarmels */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -36,12 +36,12 @@ /** * @brief A Clause Schnorr R Handle */ -struct TALER_DONAU_CsRWithdrawHandle +struct DONAU_CsRWithdrawHandle { /** * Function to call with the result. */ - TALER_DONAU_CsRWithdrawCallback cb; + DONAU_CsRWithdrawCallback cb; /** * Closure for @a cb. @@ -81,11 +81,11 @@ struct TALER_DONAU_CsRWithdrawHandle * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors */ static enum GNUNET_GenericReturnValue -csr_ok (struct TALER_DONAU_CsRWithdrawHandle *csrh, +csr_ok (struct DONAU_CsRWithdrawHandle *csrh, const json_t *av, - struct TALER_DONAU_HttpResponse *hr) + struct DONAU_HttpResponse *hr) { - struct TALER_DONAU_CsRWithdrawResponse csrr = { + struct DONAU_CsRWithdrawResponse csrr = { .hr = *hr, }; struct GNUNET_JSON_Specification spec[] = { @@ -112,7 +112,7 @@ csr_ok (struct TALER_DONAU_CsRWithdrawHandle *csrh, /** * Function called when we're done processing the HTTP /csr request. * - * @param cls the `struct TALER_DONAU_CsRWithdrawHandle` + * @param cls the `struct DONAU_CsRWithdrawHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -121,13 +121,13 @@ handle_csr_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_CsRWithdrawHandle *csrh = cls; + struct DONAU_CsRWithdrawHandle *csrh = cls; const json_t *j = response; - struct TALER_DONAU_HttpResponse hr = { + struct DONAU_HttpResponse hr = { .reply = j, .http_status = (unsigned int) response_code }; - struct TALER_DONAU_CsRWithdrawResponse csrr = { + struct DONAU_CsRWithdrawResponse csrr = { .hr = hr }; @@ -150,7 +150,7 @@ handle_csr_finished (void *cls, break; } } - TALER_DONAU_csr_withdraw_cancel (csrh); + DONAU_csr_withdraw_cancel (csrh); return; case MHD_HTTP_BAD_REQUEST: /* This should never happen, either us or the donau is buggy @@ -194,27 +194,27 @@ handle_csr_finished (void *cls, csrh->cb (csrh->cb_cls, &csrr); csrh->cb = NULL; - TALER_DONAU_csr_withdraw_cancel (csrh); + DONAU_csr_withdraw_cancel (csrh); } -struct TALER_DONAU_CsRWithdrawHandle * -TALER_DONAU_csr_withdraw ( +struct DONAU_CsRWithdrawHandle * +DONAU_csr_withdraw ( struct GNUNET_CURL_Context *curl_ctx, const char *donau_url, - const struct TALER_DONAU_DenomPublicKey *pk, + const struct DONAU_DenomPublicKey *pk, const struct TALER_CsNonce *nonce, - TALER_DONAU_CsRWithdrawCallback res_cb, + DONAU_CsRWithdrawCallback res_cb, void *res_cb_cls) { - struct TALER_DONAU_CsRWithdrawHandle *csrh; + struct DONAU_CsRWithdrawHandle *csrh; if (TALER_DENOMINATION_CS != pk->key.cipher) { GNUNET_break (0); return NULL; } - csrh = GNUNET_new (struct TALER_DONAU_CsRWithdrawHandle); + csrh = GNUNET_new (struct DONAU_CsRWithdrawHandle); csrh->cb = res_cb; csrh->cb_cls = res_cb_cls; csrh->url = TALER_url_join (donau_url, @@ -238,7 +238,7 @@ TALER_DONAU_csr_withdraw ( &pk->h_key, sizeof(struct TALER_DenominationHashP))); GNUNET_assert (NULL != req); - eh = TALER_DONAU_curl_easy_get_ (csrh->url); + eh = DONAU_curl_easy_get_ (csrh->url); if ( (NULL == eh) || (GNUNET_OK != TALER_curl_easy_post (&csrh->post_ctx, @@ -265,8 +265,8 @@ TALER_DONAU_csr_withdraw ( void -TALER_DONAU_csr_withdraw_cancel (struct - TALER_DONAU_CsRWithdrawHandle *csrh) +DONAU_csr_withdraw_cancel (struct + DONAU_CsRWithdrawHandle *csrh) { if (NULL != csrh->job) { diff --git a/src/lib/donau_api_curl_defaults.c b/src/lib/donau_api_curl_defaults.c @@ -24,7 +24,7 @@ CURL * -TALER_DONAU_curl_easy_get_ (const char *url) +DONAU_curl_easy_get_ (const char *url) { CURL *eh; diff --git a/src/lib/donau_api_curl_defaults.h b/src/lib/donau_api_curl_defaults.h @@ -35,6 +35,6 @@ * @param url URL to query */ CURL * -TALER_DONAU_curl_easy_get_ (const char *url); +DONAU_curl_easy_get_ (const char *url); #endif /* _TALER_CURL_DEFAULTS_H */ diff --git a/src/lib/donau_api_handle.c b/src/lib/donau_api_handle.c @@ -24,10 +24,10 @@ * @author Christian Grothoff * @author Lukas Matyja */ -#include "platform.h" +#include "taler/platform.h" #include <microhttpd.h> #include <gnunet/gnunet_curl_lib.h> -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_donau_service.h" #include "taler_signatures.h" #include "donau_api_handle.h" @@ -80,7 +80,7 @@ /** * Handle for a GET /keys request. */ -struct TALER_DONAU_GetKeysHandle +struct DONAU_GetKeysHandle { /** @@ -96,7 +96,7 @@ struct TALER_DONAU_GetKeysHandle /** * Previous /keys response, NULL for none. */ - struct TALER_DONAU_Keys *prev_keys; + struct DONAU_Keys *prev_keys; /** * Entry for this request with the `struct GNUNET_CURL_Context`. @@ -113,7 +113,7 @@ struct TALER_DONAU_GetKeysHandle * Function to call with the donau's certification data, * NULL if this has already been done. */ - TALER_DONAU_GetKeysCallback cert_cb; + DONAU_GetKeysCallback cert_cb; /** * Closure to pass to @e cert_cb. @@ -138,7 +138,7 @@ struct TALER_DONAU_GetKeysHandle * invalid or the @a sign_key_obj is malformed. */ static enum GNUNET_GenericReturnValue -parse_json_signkey (struct TALER_DONAU_SigningPublicKeyAndValidity *sign_key, +parse_json_signkey (struct DONAU_SigningPublicKeyAndValidity *sign_key, const json_t *sign_key_obj) { struct GNUNET_JSON_Specification spec[] = { @@ -200,7 +200,7 @@ parse_json_signkey (struct TALER_DONAU_SigningPublicKeyAndValidity *sign_key, */ static enum GNUNET_GenericReturnValue parse_json_denomkey_partially ( - struct TALER_DONAU_DenomPublicKey *denom_key, + struct DONAU_DenomPublicKey *denom_key, enum TALER_DenominationCipher cipher, bool check_sigs, const json_t *denom_key_obj, @@ -280,11 +280,11 @@ EXITIF_exit: static enum GNUNET_GenericReturnValue decode_keys_json (const json_t *resp_obj, bool check_sig, - struct TALER_DONAU_Keys *key_data, - enum TALER_DONAU_VersionCompatibility *vc) + struct DONAU_Keys *key_data, + enum DONAU_VersionCompatibility *vc) { struct TALER_DonauSignatureP denominations_sig; - struct TALER_DonauPublicKeyP pub; + struct DONAU_DonauPublicKeyP pub; const json_t *sign_keys_array; const json_t *donation_units_by_group; bool no_signature = false; @@ -330,18 +330,18 @@ decode_keys_json (const json_t *resp_obj, GNUNET_break_op (0); return GNUNET_SYSERR; } - *vc = TALER_DONAU_VC_MATCH; + *vc = DONAU_VC_MATCH; if (DONAU_PROTOCOL_CURRENT < current) { - *vc |= TALER_DONAU_VC_NEWER; + *vc |= DONAU_VC_NEWER; if (DONAU_PROTOCOL_CURRENT < current - age) - *vc |= TALER_DONAU_VC_INCOMPATIBLE; + *vc |= DONAU_VC_INCOMPATIBLE; } if (DONAU_PROTOCOL_CURRENT > current) { - *vc |= TALER_DONAU_VC_OLDER; + *vc |= DONAU_VC_OLDER; if (DONAU_PROTOCOL_CURRENT - DONAU_PROTOCOL_AGE > current) - *vc |= TALER_DONAU_VC_INCOMPATIBLE; + *vc |= DONAU_VC_INCOMPATIBLE; } key_data->version = GNUNET_strdup (ver); } @@ -472,7 +472,7 @@ decode_keys_json (const json_t *resp_obj, key_data->global_fees = GNUNET_new_array (key_data->num_global_fees, - struct TALER_DONAU_GlobalFee); + struct DONAU_GlobalFee); json_array_foreach (global_fees, index, global_fee) { EXITIF (GNUNET_SYSERR == @@ -493,7 +493,7 @@ decode_keys_json (const json_t *resp_obj, key_data->sign_keys = GNUNET_new_array (key_data->num_sign_keys, - struct TALER_DONAU_SigningPublicKey); + struct DONAU_SigningPublicKey); json_array_foreach (sign_keys_array, index, sign_key_obj) { EXITIF (GNUNET_SYSERR == parse_json_signkey (&key_data->sign_keys[index], @@ -540,10 +540,10 @@ decode_keys_json (const json_t *resp_obj, key_data->accounts_len, json_array_size (accounts)); EXITIF (GNUNET_OK != - TALER_DONAU_parse_accounts (&key_data->master_pub, - accounts, - key_data->accounts_len, - key_data->accounts)); + DONAU_parse_accounts (&key_data->master_pub, + accounts, + key_data->accounts_len, + key_data->accounts)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Parsed %u wire accounts from JSON\n", @@ -622,7 +622,7 @@ decode_keys_json (const json_t *resp_obj, /* Set the common fields from the group for this particular denomination. Required to make the validity check inside parse_json_denomkey_partially pass */ - struct TALER_DONAU_DenomPublicKey dk = { + struct DONAU_DenomPublicKey dk = { .key.cipher = group.cipher, .value = group.value, .fees = group.fees, @@ -647,7 +647,7 @@ decode_keys_json (const json_t *resp_obj, j++) { if (0 == GNUNET_CRYPTO_bsign_pub_cmp (&dk, - &key_data->denom_keys[j])) + &key_data->denom_keys[j])) { found = true; break; @@ -693,7 +693,7 @@ decode_keys_json (const json_t *resp_obj, /* Merge with the existing auditor information we have (/keys cherry picking) */ json_array_foreach (auditors_array, index, auditor_info) { - struct TALER_DONAU_AuditorInformation ai; + struct DONAU_AuditorInformation ai; bool found = false; memset (&ai, @@ -706,7 +706,7 @@ decode_keys_json (const json_t *resp_obj, key_data)); for (unsigned int j = 0; j<key_data->num_auditors; j++) { - struct TALER_DONAU_AuditorInformation *aix = &key_data->auditors[j]; + struct DONAU_AuditorInformation *aix = &key_data->auditors[j]; if (0 == GNUNET_memcmp (&ai.auditor_pub, &aix->auditor_pub)) @@ -792,8 +792,8 @@ decode_keys_json (const json_t *resp_obj, if (check_sig) { EXITIF (GNUNET_OK != - TALER_DONAU_test_signing_key (key_data, - &pub)); + DONAU_test_signing_key (key_data, + &pub)); EXITIF (GNUNET_OK != TALER_donau_online_key_set_verify ( key_data->list_issue_date, @@ -804,7 +804,7 @@ decode_keys_json (const json_t *resp_obj, return GNUNET_OK; EXITIF_exit: - *vc = TALER_DONAU_VC_PROTOCOL_ERROR; + *vc = DONAU_VC_PROTOCOL_ERROR; return GNUNET_SYSERR; } @@ -822,13 +822,13 @@ keys_completed_cb (void *cls, long response_code, const void *resp_obj) { - struct TALER_DONAU_GetKeysHandle *gkh = cls; + struct DONAU_GetKeysHandle *gkh = cls; const json_t *j = resp_obj; - struct TALER_DONAU_Keys *kd = NULL; - struct TALER_DONAU_KeysResponse kresp = { + struct DONAU_Keys *kd = NULL; + struct DONAU_KeysResponse kresp = { .hr.reply = j, .hr.http_status = (unsigned int) response_code, - .details.ok.compat = TALER_DONAU_VC_PROTOCOL_ERROR, + .details.ok.compat = DONAU_VC_PROTOCOL_ERROR, }; gkh->job = NULL; @@ -861,11 +861,11 @@ keys_completed_cb (void *cls, response_code = 0; break; } - kd = GNUNET_new (struct TALER_DONAU_Keys); + kd = GNUNET_new (struct DONAU_Keys); kd->donau_url = GNUNET_strdup (gkh->donau_url); if (NULL != gkh->prev_keys) { - const struct TALER_DONAU_Keys *kd_old = gkh->prev_keys; + const struct DONAU_Keys *kd_old = gkh->prev_keys; /* We keep the denomination keys and auditor signatures from the previous iteration (/keys cherry picking) */ @@ -880,19 +880,19 @@ keys_completed_cb (void *cls, GNUNET_memcpy (kd->denom_keys, kd_old->denom_keys, kd_old->num_denom_keys - * sizeof (struct TALER_DONAU_DenomPublicKey)); + * sizeof (struct DONAU_DenomPublicKey)); for (unsigned int i = 0; i<kd_old->num_denom_keys; i++) TALER_denom_pub_deep_copy (&kd->denom_keys[i].key, &kd_old->denom_keys[i].key); kd->num_auditors = kd_old->num_auditors; kd->auditors = GNUNET_new_array (kd->num_auditors, - struct TALER_DONAU_AuditorInformation); + struct DONAU_AuditorInformation); /* Now the necessary deep copy... */ for (unsigned int i = 0; i<kd_old->num_auditors; i++) { - const struct TALER_DONAU_AuditorInformation *aold = + const struct DONAU_AuditorInformation *aold = &kd_old->auditors[i]; - struct TALER_DONAU_AuditorInformation *anew = &kd->auditors[i]; + struct DONAU_AuditorInformation *anew = &kd->auditors[i]; anew->auditor_pub = aold->auditor_pub; anew->auditor_url = GNUNET_strdup (aold->auditor_url); @@ -903,7 +903,7 @@ keys_completed_cb (void *cls, anew->denom_keys, aold->denom_keys, aold->num_denom_keys - * sizeof (struct TALER_DONAU_AuditorDenominationInfo)); + * sizeof (struct DONAU_AuditorDenominationInfo)); } } /* Now decode fresh /keys response */ @@ -915,7 +915,7 @@ keys_completed_cb (void *cls, { TALER_LOG_ERROR ("Could not decode /keys response\n"); kd->rc = 1; - TALER_DONAU_keys_decref (kd); + DONAU_keys_decref (kd); kd = NULL; kresp.hr.http_status = 0; kresp.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED; @@ -973,7 +973,7 @@ keys_completed_cb (void *cls, gkh->cert_cb (gkh->cert_cb_cls, &kresp, kd); - TALER_DONAU_get_keys_cancel (gkh); + DONAU_get_keys_cancel (gkh); } @@ -1087,7 +1087,7 @@ parse_date_string (const char *dateline, * @param buffer header data received * @param size size of an item in @a buffer * @param nitems number of items in @a buffer - * @param userdata the `struct TALER_DONAU_GetKeysHandle` + * @param userdata the `struct DONAU_GetKeysHandle` * @return `size * nitems` on success (everything else aborts) */ static size_t @@ -1096,7 +1096,7 @@ header_cb (char *buffer, size_t nitems, void *userdata) { - struct TALER_DONAU_GetKeysHandle *kr = userdata; + struct DONAU_GetKeysHandle *kr = userdata; size_t total = size * nitems; char *val; @@ -1127,20 +1127,20 @@ header_cb (char *buffer, } -struct TALER_DONAU_GetKeysHandle * -TALER_DONAU_get_keys ( +struct DONAU_GetKeysHandle * +DONAU_get_keys ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *last_keys, - TALER_DONAU_GetKeysCallback cert_cb, + struct DONAU_Keys *last_keys, + DONAU_GetKeysCallback cert_cb, void *cert_cb_cls) { - struct TALER_DONAU_GetKeysHandle *gkh; + struct DONAU_GetKeysHandle *gkh; CURL *eh; TALER_LOG_DEBUG ("Connecting to the donau (%s)\n", url); - gkh = GNUNET_new (struct TALER_DONAU_GetKeysHandle); + gkh = GNUNET_new (struct DONAU_GetKeysHandle); gkh->donau_url = GNUNET_strdup (url); gkh->cert_cb = cert_cb; gkh->cert_cb_cls = cert_cb_cls; @@ -1149,7 +1149,7 @@ TALER_DONAU_get_keys ( GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting keys with URL `%s'.\n", gkh->url); - eh = TALER_DONAU_curl_easy_get_ (gkh->url); + eh = DONAU_curl_easy_get_ (gkh->url); if (NULL == eh) { GNUNET_break (0); @@ -1183,15 +1183,15 @@ TALER_DONAU_get_keys ( void -TALER_DONAU_get_keys_cancel ( - struct TALER_DONAU_GetKeysHandle *gkh) +DONAU_get_keys_cancel ( + struct DONAU_GetKeysHandle *gkh) { if (NULL != gkh->job) { GNUNET_CURL_job_cancel (gkh->job); gkh->job = NULL; } - TALER_DONAU_keys_decref (gkh->prev_keys); + DONAU_keys_decref (gkh->prev_keys); GNUNET_free (gkh->donau_url); GNUNET_free (gkh->url); GNUNET_free (gkh); @@ -1199,9 +1199,9 @@ TALER_DONAU_get_keys_cancel ( enum GNUNET_GenericReturnValue -TALER_DONAU_test_signing_key ( - const struct TALER_DONAU_Keys *keys, - const struct TALER_DonauPublicKeyP *pub) +DONAU_test_signing_key ( + const struct DONAU_Keys *keys, + const struct DONAU_DonauPublicKeyP *pub) { struct GNUNET_TIME_Absolute now; @@ -1228,9 +1228,9 @@ TALER_DONAU_test_signing_key ( } -const struct TALER_DONAU_DenomPublicKey * -TALER_DONAU_get_denomination_key ( - const struct TALER_DONAU_Keys *keys, +const struct DONAU_DenomPublicKey * +DONAU_get_denomination_key ( + const struct DONAU_Keys *keys, const struct TALER_DenominationPublicKey *pk) { for (unsigned int i = 0; i<keys->num_denom_keys; i++) @@ -1242,13 +1242,13 @@ TALER_DONAU_get_denomination_key ( } -struct TALER_DONAU_DenomPublicKey * -TALER_DONAU_copy_denomination_key ( - const struct TALER_DONAU_DenomPublicKey *key) +struct DONAU_DenomPublicKey * +DONAU_copy_denomination_key ( + const struct DONAU_DenomPublicKey *key) { - struct TALER_DONAU_DenomPublicKey *copy; + struct DONAU_DenomPublicKey *copy; - copy = GNUNET_new (struct TALER_DONAU_DenomPublicKey); + copy = GNUNET_new (struct DONAU_DenomPublicKey); *copy = *key; TALER_denom_pub_deep_copy (©->key, &key->key); @@ -1257,17 +1257,17 @@ TALER_DONAU_copy_denomination_key ( void -TALER_DONAU_destroy_denomination_key ( - struct TALER_DONAU_DenomPublicKey *key) +DONAU_destroy_denomination_key ( + struct DONAU_DenomPublicKey *key) { TALER_denom_pub_free (&key->key); GNUNET_free (key); } -const struct TALER_DONAU_DenomPublicKey * -TALER_DONAU_get_denomination_key_by_hash ( - const struct TALER_DONAU_Keys *keys, +const struct DONAU_DenomPublicKey * +DONAU_get_denomination_key_by_hash ( + const struct DONAU_Keys *keys, const struct TALER_DenominationHashP *hc) { for (unsigned int i = 0; i<keys->num_denom_keys; i++) @@ -1278,8 +1278,8 @@ TALER_DONAU_get_denomination_key_by_hash ( } -struct TALER_DONAU_Keys * -TALER_DONAU_keys_incref (struct TALER_DONAU_Keys *keys) +struct DONAU_Keys * +DONAU_keys_incref (struct DONAU_Keys *keys) { GNUNET_assert (keys->rc < UINT_MAX); keys->rc++; @@ -1288,7 +1288,7 @@ TALER_DONAU_keys_incref (struct TALER_DONAU_Keys *keys) void -TALER_DONAU_keys_decref (struct TALER_DONAU_Keys *keys) +DONAU_keys_decref (struct DONAU_Keys *keys) { if (NULL == keys) return; @@ -1315,8 +1315,8 @@ TALER_DONAU_keys_decref (struct TALER_DONAU_Keys *keys) GNUNET_array_grow (keys->auditors, keys->auditors_size, 0); - TALER_DONAU_free_accounts (keys->accounts_len, - keys->accounts); + DONAU_free_accounts (keys->accounts_len, + keys->accounts); GNUNET_array_grow (keys->accounts, keys->accounts_len, 0); @@ -1333,8 +1333,8 @@ TALER_DONAU_keys_decref (struct TALER_DONAU_Keys *keys) } -struct TALER_DONAU_Keys * -TALER_DONAU_keys_from_json (const json_t *j) +struct DONAU_Keys * +DONAU_keys_from_json (const json_t *j) { const json_t *jkeys; const char *url; @@ -1354,8 +1354,8 @@ TALER_DONAU_keys_from_json (const json_t *j) NULL), GNUNET_JSON_spec_end () }; - struct TALER_DONAU_Keys *keys; - enum TALER_DONAU_VersionCompatibility compat; + struct DONAU_Keys *keys; + enum DONAU_VersionCompatibility compat; if (NULL == j) return NULL; @@ -1371,7 +1371,7 @@ TALER_DONAU_keys_from_json (const json_t *j) { return NULL; /* unsupported version */ } - keys = GNUNET_new (struct TALER_DONAU_Keys); + keys = GNUNET_new (struct DONAU_Keys); if (GNUNET_OK != decode_keys_json (jkeys, false, @@ -1455,8 +1455,68 @@ add_grp (void *cls, } +/** + * Convert array of account restrictions @a ars to JSON. + * + * @param ar_len length of @a ars + * @param ars account restrictions to convert + * @return JSON representation + */ +static json_t * +ar_to_json (unsigned int ar_len, + const struct TALER_DONAU_AccountRestriction ars[static ar_len]) +{ + json_t *rval; + + rval = json_array (); + GNUNET_assert (NULL != rval); + for (unsigned int i = 0; i<ar_len; i++) + { + const struct TALER_DONAU_AccountRestriction *ar = &ars[i]; + + switch (ar->type) + { + case TALER_DONAU_AR_INVALID: + GNUNET_break (0); + json_decref (rval); + return NULL; + case TALER_DONAU_AR_DENY: + GNUNET_assert ( + 0 == + json_array_append_new ( + rval, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "deny")))); + break; + case TALER_DONAU_AR_REGEX: + GNUNET_assert ( + 0 == + json_array_append_new ( + rval, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ( + "type", + "regex"), + GNUNET_JSON_pack_string ( + "regex", + ar->details.regex.posix_egrep), + GNUNET_JSON_pack_string ( + "human_hint", + ar->details.regex.human_hint), + GNUNET_JSON_pack_object_incref ( + "human_hint_i18n", + (json_t *) ar->details.regex.human_hint_i18n) + ))); + break; + } + } + return rval; +} + + json_t * -TALER_DONAU_keys_to_json (const struct TALER_DONAU_Keys *kd) +DONAU_keys_to_json (const struct DONAU_Keys *kd) { json_t *keys; json_t *signkeys; @@ -1468,7 +1528,7 @@ TALER_DONAU_keys_to_json (const struct TALER_DONAU_Keys *kd) GNUNET_assert (NULL != signkeys); for (unsigned int i = 0; i<kd->num_sign_keys; i++) { - const struct TALER_DONAU_SigningPublicKeyAndValidity *sk = &kd->sign_keys[i]; + const struct TALER_DONAU_SigningPublicKey *sk = &kd->sign_keys[i]; json_t *signkey; signkey = GNUNET_JSON_PACK ( @@ -1491,9 +1551,9 @@ TALER_DONAU_keys_to_json (const struct TALER_DONAU_Keys *kd) false); for (unsigned int i = 0; i<kd->num_donation_unit_keys; i++) { - const struct TALER_DonationUnitInformation *dk = &kd->donation_unit_keys[i]; - struct DONAU_DonationUnitGroup meta = { - .cipher = dk->key.bsign_pub_key->cipher, + const struct TALER_DONAU_DenomPublicKey *dk = &kd->denom_keys[i]; + struct TALER_DenominationGroup meta = { + .cipher = dk->key.cipher, .value = dk->value, .year = dk->year }; @@ -1567,6 +1627,184 @@ TALER_DONAU_keys_to_json (const struct TALER_DONAU_Keys *kd) GNUNET_CONTAINER_multihashmap_destroy (dbg); } + auditors = json_array (); + GNUNET_assert (NULL != auditors); + for (unsigned int i = 0; i<kd->num_auditors; i++) + { + const struct TALER_DONAU_AuditorInformation *ai = &kd->auditors[i]; + json_t *a; + json_t *adenoms; + + adenoms = json_array (); + GNUNET_assert (NULL != adenoms); + for (unsigned int j = 0; j<ai->num_denom_keys; j++) + { + const struct TALER_DONAU_AuditorDenominationInfo *adi = + &ai->denom_keys[j]; + const struct TALER_DONAU_DenomPublicKey *dk = + &kd->denom_keys[adi->denom_key_offset]; + json_t *k; + + GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); + if (GNUNET_TIME_timestamp_cmp (now, + >, + dk->expire_deposit)) + continue; /* skip auditor signatures for denomination keys that have expired */ + GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); + k = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("denom_pub_h", + &dk->h_key), + GNUNET_JSON_pack_data_auto ("auditor_sig", + &adi->auditor_sig)); + GNUNET_assert (0 == + json_array_append_new (adenoms, + k)); + } + + a = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("auditor_pub", + &ai->auditor_pub), + GNUNET_JSON_pack_string ("auditor_url", + ai->auditor_url), + GNUNET_JSON_pack_array_steal ("denomination_keys", + adenoms)); + GNUNET_assert (0 == + json_array_append_new (auditors, + a)); + } + + global_fees = json_array (); + GNUNET_assert (NULL != global_fees); + for (unsigned int i = 0; i<kd->num_global_fees; i++) + { + const struct TALER_DONAU_GlobalFee *gf + = &kd->global_fees[i]; + + if (GNUNET_TIME_absolute_is_past (gf->end_date.abs_time)) + continue; + GNUNET_assert ( + 0 == + json_array_append_new ( + global_fees, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_timestamp ("start_date", + gf->start_date), + GNUNET_JSON_pack_timestamp ("end_date", + gf->end_date), + TALER_JSON_PACK_GLOBAL_FEES (&gf->fees), + GNUNET_JSON_pack_time_rel ("history_expiration", + gf->history_expiration), + GNUNET_JSON_pack_time_rel ("purse_timeout", + gf->purse_timeout), + GNUNET_JSON_pack_uint64 ("purse_account_limit", + gf->purse_account_limit), + GNUNET_JSON_pack_data_auto ("master_sig", + &gf->master_sig)))); + } + + accounts = json_array (); + GNUNET_assert (NULL != accounts); + for (unsigned int i = 0; i<kd->accounts_len; i++) + { + const struct TALER_DONAU_WireAccount *acc + = &kd->accounts[i]; + json_t *credit_restrictions; + json_t *debit_restrictions; + + credit_restrictions + = ar_to_json (acc->credit_restrictions_length, + acc->credit_restrictions); + GNUNET_assert (NULL != credit_restrictions); + debit_restrictions + = ar_to_json (acc->debit_restrictions_length, + acc->debit_restrictions); + GNUNET_assert (NULL != debit_restrictions); + GNUNET_assert ( + 0 == + json_array_append_new ( + accounts, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("payto_uri", + acc->payto_uri), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("conversion_url", + acc->conversion_url)), + GNUNET_JSON_pack_array_steal ("debit_restrictions", + debit_restrictions), + GNUNET_JSON_pack_array_steal ("credit_restrictions", + credit_restrictions), + GNUNET_JSON_pack_data_auto ("master_sig", + &acc->master_sig)))); + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Serialized %u/%u wire accounts to JSON\n", + (unsigned int) json_array_size (accounts), + kd->accounts_len); + + wire_fees = json_object (); + GNUNET_assert (NULL != wire_fees); + for (unsigned int i = 0; i<kd->fees_len; i++) + { + const struct TALER_DONAU_WireFeesByMethod *fbw + = &kd->fees[i]; + json_t *wf; + + wf = json_array (); + GNUNET_assert (NULL != wf); + for (struct TALER_DONAU_WireAggregateFees *p = fbw->fees_head; + NULL != p; + p = p->next) + { + GNUNET_assert ( + 0 == + json_array_append_new ( + wf, + GNUNET_JSON_PACK ( + TALER_JSON_pack_amount ("wire_fee", + &p->fees.wire), + TALER_JSON_pack_amount ("closing_fee", + &p->fees.closing), + GNUNET_JSON_pack_timestamp ("start_date", + p->start_date), + GNUNET_JSON_pack_timestamp ("end_date", + p->end_date), + GNUNET_JSON_pack_data_auto ("sig", + &p->master_sig)))); + } + GNUNET_assert (0 == + json_object_set_new (wire_fees, + fbw->method, + wf)); + } + + recoup = json_array (); + GNUNET_assert (NULL != recoup); + for (unsigned int i = 0; i<kd->num_denom_keys; i++) + { + const struct TALER_DONAU_DenomPublicKey *dk + = &kd->denom_keys[i]; + if (! dk->revoked) + continue; + GNUNET_assert (0 == + json_array_append_new ( + recoup, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("h_denom_pub", + &dk->h_key)))); + } + + wblwk = json_array (); + GNUNET_assert (NULL != wblwk); + for (unsigned int i = 0; i<kd->wblwk_length; i++) + { + const struct TALER_Amount *a = &kd->wallet_balance_limit_without_kyc[i]; + + GNUNET_assert (0 == + json_array_append_new ( + wblwk, + TALER_JSON_from_amount (a))); + } + keys = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("version", kd->version), diff --git a/src/lib/donau_api_handle.h b/src/lib/donau_api_handle.h @@ -55,7 +55,7 @@ typedef void */ void TEAH_get_auditors_for_dc ( - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, TEAH_AuditorCallback ac, void *ac_cls); diff --git a/src/lib/donau_api_issue_receipts.c b/src/lib/donau_api_issue_receipts.c @@ -19,14 +19,14 @@ * @brief Implementation of /reserves/$RESERVE_PUB/withdraw requests with blinding/unblinding * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,7 +35,7 @@ /** * @brief A Withdraw Handle */ -struct TALER_DONAU_WithdrawHandle +struct DONAU_WithdrawHandle { /** @@ -51,17 +51,17 @@ struct TALER_DONAU_WithdrawHandle /** * The /keys material from the donau */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * Handle for the actual (internal) withdraw operation. */ - struct TALER_DONAU_Withdraw2Handle *wh2; + struct DONAU_Withdraw2Handle *wh2; /** * Function to call with the result. */ - TALER_DONAU_WithdrawCallback cb; + DONAU_WithdrawCallback cb; /** * Closure for @a cb. @@ -106,7 +106,7 @@ struct TALER_DONAU_WithdrawHandle /** * Denomination key we are withdrawing. */ - struct TALER_DONAU_DenomPublicKey pk; + struct DONAU_DenomPublicKey pk; /** * Hash of the public key of the coin we are signing. @@ -116,7 +116,7 @@ struct TALER_DONAU_WithdrawHandle /** * Handler for the CS R request (only used for TALER_DENOMINATION_CS denominations) */ - struct TALER_DONAU_CsRWithdrawHandle *csrh; + struct DONAU_CsRWithdrawHandle *csrh; }; @@ -125,16 +125,16 @@ struct TALER_DONAU_WithdrawHandle * Function called when we're done processing the * HTTP /reserves/$RESERVE_PUB/withdraw request. * - * @param cls the `struct TALER_DONAU_WithdrawHandle` + * @param cls the `struct DONAU_WithdrawHandle` * @param w2r response data */ static void handle_reserve_withdraw_finished ( void *cls, - const struct TALER_DONAU_Withdraw2Response *w2r) + const struct DONAU_Withdraw2Response *w2r) { - struct TALER_DONAU_WithdrawHandle *wh = cls; - struct TALER_DONAU_WithdrawResponse wr = { + struct DONAU_WithdrawHandle *wh = cls; + struct DONAU_WithdrawResponse wr = { .hr = w2r->hr }; @@ -196,23 +196,23 @@ handle_reserve_withdraw_finished ( &wr); if (MHD_HTTP_OK == w2r->hr.http_status) TALER_denom_sig_free (&wr.details.ok.sig); - TALER_DONAU_withdraw_cancel (wh); + DONAU_withdraw_cancel (wh); } /** * Function called when stage 1 of CS withdraw is finished (request r_pub's) * - * @param cls the `struct TALER_DONAU_WithdrawHandle` + * @param cls the `struct DONAU_WithdrawHandle` * @param csrr replies from the /csr-withdraw request */ static void withdraw_cs_stage_two_callback ( void *cls, - const struct TALER_DONAU_CsRWithdrawResponse *csrr) + const struct DONAU_CsRWithdrawResponse *csrr) { - struct TALER_DONAU_WithdrawHandle *wh = cls; - struct TALER_DONAU_WithdrawResponse wr = { + struct DONAU_WithdrawHandle *wh = cls; + struct DONAU_WithdrawResponse wr = { .hr = csrr->hr }; @@ -242,37 +242,37 @@ withdraw_cs_stage_two_callback ( GNUNET_break (0); break; } - wh->wh2 = TALER_DONAU_withdraw2 (wh->curl_ctx, - wh->donau_url, - wh->keys, - &wh->pd, - wh->reserve_priv, - &handle_reserve_withdraw_finished, - wh); + wh->wh2 = DONAU_withdraw2 (wh->curl_ctx, + wh->donau_url, + wh->keys, + &wh->pd, + wh->reserve_priv, + &handle_reserve_withdraw_finished, + wh); return; default: break; } wh->cb (wh->cb_cls, &wr); - TALER_DONAU_withdraw_cancel (wh); + DONAU_withdraw_cancel (wh); } -struct TALER_DONAU_WithdrawHandle * -TALER_DONAU_withdraw ( +struct DONAU_WithdrawHandle * +DONAU_withdraw ( struct GNUNET_CURL_Context *curl_ctx, const char *donau_url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_ReservePrivateKeyP *reserve_priv, - const struct TALER_DONAU_WithdrawCoinInput *wci, - TALER_DONAU_WithdrawCallback res_cb, + const struct DONAU_WithdrawCoinInput *wci, + DONAU_WithdrawCallback res_cb, void *res_cb_cls) { - struct TALER_DONAU_WithdrawHandle *wh; + struct DONAU_WithdrawHandle *wh; - wh = GNUNET_new (struct TALER_DONAU_WithdrawHandle); - wh->keys = TALER_DONAU_keys_incref (keys); + wh = GNUNET_new (struct DONAU_WithdrawHandle); + wh->keys = DONAU_keys_incref (keys); wh->donau_url = donau_url; wh->curl_ctx = curl_ctx; wh->cb = res_cb; @@ -308,13 +308,13 @@ TALER_DONAU_withdraw ( GNUNET_free (wh); return NULL; } - wh->wh2 = TALER_DONAU_withdraw2 (curl_ctx, - donau_url, - keys, - &wh->pd, - wh->reserve_priv, - &handle_reserve_withdraw_finished, - wh); + wh->wh2 = DONAU_withdraw2 (curl_ctx, + donau_url, + keys, + &wh->pd, + wh->reserve_priv, + &handle_reserve_withdraw_finished, + wh); break; } case TALER_DENOMINATION_CS: @@ -326,7 +326,7 @@ TALER_DONAU_withdraw ( of the blinded_planchet here; the other part will be done after the /csr-withdraw request! */ wh->pd.blinded_planchet.cipher = TALER_DENOMINATION_CS; - wh->csrh = TALER_DONAU_csr_withdraw ( + wh->csrh = DONAU_csr_withdraw ( curl_ctx, donau_url, &wh->pk, @@ -345,20 +345,20 @@ TALER_DONAU_withdraw ( void -TALER_DONAU_withdraw_cancel (struct TALER_DONAU_WithdrawHandle *wh) +DONAU_withdraw_cancel (struct DONAU_WithdrawHandle *wh) { TALER_blinded_planchet_free (&wh->pd.blinded_planchet); if (NULL != wh->csrh) { - TALER_DONAU_csr_withdraw_cancel (wh->csrh); + DONAU_csr_withdraw_cancel (wh->csrh); wh->csrh = NULL; } if (NULL != wh->wh2) { - TALER_DONAU_withdraw2_cancel (wh->wh2); + DONAU_withdraw2_cancel (wh->wh2); wh->wh2 = NULL; } - TALER_DONAU_keys_decref (wh->keys); + DONAU_keys_decref (wh->keys); TALER_denom_pub_free (&wh->pk.key); GNUNET_free (wh); } diff --git a/src/lib/donau_api_issue_receipts2.c b/src/lib/donau_api_issue_receipts2.c @@ -19,14 +19,14 @@ * @brief Implementation of /reserves/$RESERVE_PUB/withdraw requests without blinding/unblinding * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -35,13 +35,13 @@ /** * @brief A Withdraw Handle */ -struct TALER_DONAU_Withdraw2Handle +struct DONAU_Withdraw2Handle { /** * The /keys material from the donau */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * The url for this request. @@ -56,7 +56,7 @@ struct TALER_DONAU_Withdraw2Handle /** * Function to call with the result. */ - TALER_DONAU_Withdraw2Callback cb; + DONAU_Withdraw2Callback cb; /** * Closure for @a cb. @@ -96,10 +96,10 @@ struct TALER_DONAU_Withdraw2Handle * @return #GNUNET_OK on success, #GNUNET_SYSERR on errors */ static enum GNUNET_GenericReturnValue -reserve_withdraw_ok (struct TALER_DONAU_Withdraw2Handle *wh, +reserve_withdraw_ok (struct DONAU_Withdraw2Handle *wh, const json_t *json) { - struct TALER_DONAU_Withdraw2Response w2r = { + struct DONAU_Withdraw2Response w2r = { .hr.reply = json, .hr.http_status = MHD_HTTP_OK }; @@ -142,7 +142,7 @@ reserve_withdraw_ok (struct TALER_DONAU_Withdraw2Handle *wh, */ static enum GNUNET_GenericReturnValue reserve_withdraw_payment_required ( - struct TALER_DONAU_Withdraw2Handle *wh, + struct DONAU_Withdraw2Handle *wh, const json_t *json) { struct TALER_Amount balance; @@ -176,14 +176,14 @@ reserve_withdraw_payment_required ( total incoming and outgoing amounts */ len = json_array_size (history); { - struct TALER_DONAU_ReserveHistoryEntry *rhistory; + struct DONAU_ReserveHistoryEntry *rhistory; /* Use heap allocation as "len" may be very big and thus this may not fit on the stack. Use "GNUNET_malloc_large" as a malicious donau may theoretically try to crash us by giving a history that does not fit into our memory. */ rhistory = GNUNET_malloc_large ( - sizeof (struct TALER_DONAU_ReserveHistoryEntry) + sizeof (struct DONAU_ReserveHistoryEntry) * len); if (NULL == rhistory) { @@ -192,22 +192,22 @@ reserve_withdraw_payment_required ( } if (GNUNET_OK != - TALER_DONAU_parse_reserve_history (wh->keys, - history, - &wh->reserve_pub, - balance.currency, - &total_in_from_history, - &total_out_from_history, - len, - rhistory)) + DONAU_parse_reserve_history (wh->keys, + history, + &wh->reserve_pub, + balance.currency, + &total_in_from_history, + &total_out_from_history, + len, + rhistory)) { GNUNET_break_op (0); - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); return GNUNET_SYSERR; } - TALER_DONAU_free_reserve_history (len, - rhistory); + DONAU_free_reserve_history (len, + rhistory); } /* Check that funds were really insufficient */ @@ -227,7 +227,7 @@ reserve_withdraw_payment_required ( * Function called when we're done processing the * HTTP /reserves/$RESERVE_PUB/withdraw request. * - * @param cls the `struct TALER_DONAU_WithdrawHandle` + * @param cls the `struct DONAU_WithdrawHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -236,9 +236,9 @@ handle_reserve_withdraw_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_Withdraw2Handle *wh = cls; + struct DONAU_Withdraw2Handle *wh = cls; const json_t *j = response; - struct TALER_DONAU_Withdraw2Response w2r = { + struct DONAU_Withdraw2Response w2r = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -260,7 +260,7 @@ handle_reserve_withdraw_finished (void *cls, break; } GNUNET_assert (NULL == wh->cb); - TALER_DONAU_withdraw2_cancel (wh); + DONAU_withdraw2_cancel (wh); return; case MHD_HTTP_BAD_REQUEST: /* This should never happen, either us or the donau is buggy @@ -355,36 +355,36 @@ handle_reserve_withdraw_finished (void *cls, &w2r); wh->cb = NULL; } - TALER_DONAU_withdraw2_cancel (wh); + DONAU_withdraw2_cancel (wh); } -struct TALER_DONAU_Withdraw2Handle * -TALER_DONAU_withdraw2 ( +struct DONAU_Withdraw2Handle * +DONAU_withdraw2 ( struct GNUNET_CURL_Context *curl_ctx, const char *donau_url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_PlanchetDetail *pd, const struct TALER_ReservePrivateKeyP *reserve_priv, - TALER_DONAU_Withdraw2Callback res_cb, + DONAU_Withdraw2Callback res_cb, void *res_cb_cls) { - struct TALER_DONAU_Withdraw2Handle *wh; - const struct TALER_DONAU_DenomPublicKey *dk; + struct DONAU_Withdraw2Handle *wh; + const struct DONAU_DenomPublicKey *dk; struct TALER_ReserveSignatureP reserve_sig; char arg_str[sizeof (struct TALER_ReservePublicKeyP) * 2 + 32]; struct TALER_BlindedCoinHashP bch; GNUNET_assert (NULL != keys); - dk = TALER_DONAU_get_denomination_key_by_hash (keys, - &pd->denom_pub_hash); + dk = DONAU_get_denomination_key_by_hash (keys, + &pd->denom_pub_hash); if (NULL == dk) { GNUNET_break (0); return NULL; } - wh = GNUNET_new (struct TALER_DONAU_Withdraw2Handle); - wh->keys = TALER_DONAU_keys_incref (keys); + wh = GNUNET_new (struct DONAU_Withdraw2Handle); + wh->keys = DONAU_keys_incref (keys); wh->cb = res_cb; wh->cb_cls = res_cb_cls; /* Compute how much we expected to charge to the reserve */ @@ -456,7 +456,7 @@ TALER_DONAU_withdraw2 ( { CURL *eh; - eh = TALER_DONAU_curl_easy_get_ (wh->url); + eh = DONAU_curl_easy_get_ (wh->url); if ( (NULL == eh) || (GNUNET_OK != TALER_curl_easy_post (&wh->post_ctx, @@ -484,7 +484,7 @@ TALER_DONAU_withdraw2 ( void -TALER_DONAU_withdraw2_cancel (struct TALER_DONAU_Withdraw2Handle *wh) +DONAU_withdraw2_cancel (struct DONAU_Withdraw2Handle *wh) { if (NULL != wh->job) { @@ -493,6 +493,6 @@ TALER_DONAU_withdraw2_cancel (struct TALER_DONAU_Withdraw2Handle *wh) } GNUNET_free (wh->url); TALER_curl_easy_post_finished (&wh->post_ctx); - TALER_DONAU_keys_decref (wh->keys); + DONAU_keys_decref (wh->keys); GNUNET_free (wh); } diff --git a/src/lib/donau_api_submit_receipts_get.c b/src/lib/donau_api_submit_receipts_get.c @@ -19,13 +19,13 @@ * @brief Implementation of the /deposits/ GET request * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_curl_lib.h> -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "taler_donau_service.h" #include "donau_api_handle.h" #include "taler_signatures.h" @@ -35,13 +35,13 @@ /** * @brief A Deposit Get Handle */ -struct TALER_DONAU_DepositGetHandle +struct DONAU_DepositGetHandle { /** * The keys of the this request handle will use */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * The url for this request. @@ -62,7 +62,7 @@ struct TALER_DONAU_DepositGetHandle /** * Function to call with the result. */ - TALER_DONAU_DepositGetCallback cb; + DONAU_DepositGetCallback cb; /** * Closure for @a cb. @@ -92,7 +92,7 @@ struct TALER_DONAU_DepositGetHandle * Function called when we're done processing the * HTTP /track/transaction request. * - * @param cls the `struct TALER_DONAU_DepositGetHandle` + * @param cls the `struct DONAU_DepositGetHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -101,9 +101,9 @@ handle_deposit_wtid_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_DepositGetHandle *dwh = cls; + struct DONAU_DepositGetHandle *dwh = cls; const json_t *j = response; - struct TALER_DONAU_GetDepositResponse dr = { + struct DONAU_GetDepositResponse dr = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -129,7 +129,7 @@ handle_deposit_wtid_finished (void *cls, &dr.details.ok.donau_pub), GNUNET_JSON_spec_end () }; - const struct TALER_DONAU_Keys *key_state; + const struct DONAU_Keys *key_state; key_state = dwh->keys; GNUNET_assert (NULL != key_state); @@ -144,8 +144,8 @@ handle_deposit_wtid_finished (void *cls, break; } if (GNUNET_OK != - TALER_DONAU_test_signing_key (key_state, - &dr.details.ok.donau_pub)) + DONAU_test_signing_key (key_state, + &dr.details.ok.donau_pub)) { GNUNET_break_op (0); dr.hr.http_status = 0; @@ -170,7 +170,7 @@ handle_deposit_wtid_finished (void *cls, } dwh->cb (dwh->cb_cls, &dr); - TALER_DONAU_deposits_get_cancel (dwh); + DONAU_deposits_get_cancel (dwh); return; } case MHD_HTTP_ACCEPTED: @@ -208,7 +208,7 @@ handle_deposit_wtid_finished (void *cls, dr.details.accepted.requirement_row = 0; dwh->cb (dwh->cb_cls, &dr); - TALER_DONAU_deposits_get_cancel (dwh); + DONAU_deposits_get_cancel (dwh); return; } case MHD_HTTP_BAD_REQUEST: @@ -249,44 +249,44 @@ handle_deposit_wtid_finished (void *cls, } dwh->cb (dwh->cb_cls, &dr); - TALER_DONAU_deposits_get_cancel (dwh); + DONAU_deposits_get_cancel (dwh); } -struct TALER_DONAU_DepositGetHandle * -TALER_DONAU_deposits_get ( +struct DONAU_DepositGetHandle * +DONAU_deposits_get ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_CharityPrivateKeyP *charity_priv, const struct TALER_CharityWireHashP *h_wire, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_CoinSpendPublicKeyP *coin_pub, struct GNUNET_TIME_Relative timeout, - TALER_DONAU_DepositGetCallback cb, + DONAU_DepositGetCallback cb, void *cb_cls) { - struct TALER_CharityPublicKeyP charity; - struct TALER_CharitySignatureP charity_sig; - struct TALER_DONAU_DepositGetHandle *dwh; + struct DONAU_CharityPublicKeyP charity; + struct DONAU_CharitySignatureP charity_sig; + struct DONAU_DepositGetHandle *dwh; CURL *eh; char arg_str[(sizeof (struct TALER_CoinSpendPublicKeyP) + sizeof (struct TALER_CharityWireHashP) - + sizeof (struct TALER_CharityPublicKeyP) + + sizeof (struct DONAU_CharityPublicKeyP) + sizeof (struct TALER_PrivateContractHashP) - + sizeof (struct TALER_CharitySignatureP)) * 2 + 48]; + + sizeof (struct DONAU_CharitySignatureP)) * 2 + 48]; GNUNET_CRYPTO_eddsa_key_get_public (&charity_priv->eddsa_priv, &charity.eddsa_pub); TALER_charity_deposit_sign (h_contract_terms, - h_wire, - coin_pub, - charity_priv, - &charity_sig); + h_wire, + coin_pub, + charity_priv, + &charity_sig); { char cpub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; - char mpub_str[sizeof (struct TALER_CharityPublicKeyP) * 2]; - char msig_str[sizeof (struct TALER_CharitySignatureP) * 2]; + char mpub_str[sizeof (struct DONAU_CharityPublicKeyP) * 2]; + char msig_str[sizeof (struct DONAU_CharitySignatureP) * 2]; char chash_str[sizeof (struct TALER_PrivateContractHashP) * 2]; char whash_str[sizeof (struct TALER_CharityWireHashP) * 2]; char timeout_str[24]; @@ -346,7 +346,7 @@ TALER_DONAU_deposits_get ( timeout_str); } - dwh = GNUNET_new (struct TALER_DONAU_DepositGetHandle); + dwh = GNUNET_new (struct DONAU_DepositGetHandle); dwh->cb = cb; dwh->cb_cls = cb_cls; dwh->url = TALER_url_join (url, @@ -360,7 +360,7 @@ TALER_DONAU_deposits_get ( dwh->h_wire = *h_wire; dwh->h_contract_terms = *h_contract_terms; dwh->coin_pub = *coin_pub; - eh = TALER_DONAU_curl_easy_get_ (dwh->url); + eh = DONAU_curl_easy_get_ (dwh->url); if (NULL == eh) { GNUNET_break (0); @@ -372,13 +372,13 @@ TALER_DONAU_deposits_get ( eh, &handle_deposit_wtid_finished, dwh); - dwh->keys = TALER_DONAU_keys_incref (keys); + dwh->keys = DONAU_keys_incref (keys); return dwh; } void -TALER_DONAU_deposits_get_cancel (struct TALER_DONAU_DepositGetHandle *dwh) +DONAU_deposits_get_cancel (struct DONAU_DepositGetHandle *dwh) { if (NULL != dwh->job) { @@ -387,7 +387,7 @@ TALER_DONAU_deposits_get_cancel (struct TALER_DONAU_DepositGetHandle *dwh) } GNUNET_free (dwh->url); TALER_curl_easy_post_finished (&dwh->ctx); - TALER_DONAU_keys_decref (dwh->keys); + DONAU_keys_decref (dwh->keys); GNUNET_free (dwh); } diff --git a/src/lib/donau_api_transfers_get.c b/src/lib/donau_api_transfers_get.c @@ -19,13 +19,13 @@ * @brief Implementation of the GET /transfers/ request * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <jansson.h> #include <microhttpd.h> /* just for HTTP status codes */ #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include "donau_api_handle.h" #include "taler_signatures.h" #include "donau_api_curl_defaults.h" @@ -34,13 +34,13 @@ /** * @brief A /transfers/ GET Handle */ -struct TALER_DONAU_TransfersGetHandle +struct DONAU_TransfersGetHandle { /** * The keys of the donau this request handle will use */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * The url for this request. @@ -55,7 +55,7 @@ struct TALER_DONAU_TransfersGetHandle /** * Function to call with the result. */ - TALER_DONAU_TransfersGetCallback cb; + DONAU_TransfersGetCallback cb; /** * Closure for @a cb. @@ -81,17 +81,17 @@ struct TALER_DONAU_TransfersGetHandle */ static enum GNUNET_GenericReturnValue check_transfers_get_response_ok ( - struct TALER_DONAU_TransfersGetHandle *wdh, + struct DONAU_TransfersGetHandle *wdh, const json_t *json) { const json_t *details_j; struct TALER_Amount total_expected; - struct TALER_CharityPublicKeyP charity_pub; - struct TALER_DONAU_TransfersGetResponse tgr = { + struct DONAU_CharityPublicKeyP charity_pub; + struct DONAU_TransfersGetResponse tgr = { .hr.reply = json, .hr.http_status = MHD_HTTP_OK }; - struct TALER_DONAU_TransferData *td + struct DONAU_TransferData *td = &tgr.details.ok.td; struct GNUNET_JSON_Specification spec[] = { TALER_JSON_spec_amount_any ("total", @@ -129,7 +129,7 @@ check_transfers_get_response_ok ( return GNUNET_SYSERR; } if (GNUNET_OK != - TALER_DONAU_test_signing_key ( + DONAU_test_signing_key ( wdh->keys, &td->donau_pub)) { @@ -242,7 +242,7 @@ check_transfers_get_response_ok ( * Function called when we're done processing the * HTTP /transfers/ request. * - * @param cls the `struct TALER_DONAU_TransfersGetHandle` + * @param cls the `struct DONAU_TransfersGetHandle` * @param response_code HTTP response code, 0 on error * @param response parsed JSON result, NULL on error */ @@ -251,9 +251,9 @@ handle_transfers_get_finished (void *cls, long response_code, const void *response) { - struct TALER_DONAU_TransfersGetHandle *wdh = cls; + struct DONAU_TransfersGetHandle *wdh = cls; const json_t *j = response; - struct TALER_DONAU_TransfersGetResponse tgr = { + struct DONAU_TransfersGetResponse tgr = { .hr.reply = j, .hr.http_status = (unsigned int) response_code }; @@ -269,7 +269,7 @@ handle_transfers_get_finished (void *cls, check_transfers_get_response_ok (wdh, j)) { - TALER_DONAU_transfers_get_cancel (wdh); + DONAU_transfers_get_cancel (wdh); return; } GNUNET_break_op (0); @@ -314,24 +314,24 @@ handle_transfers_get_finished (void *cls, } wdh->cb (wdh->cb_cls, &tgr); - TALER_DONAU_transfers_get_cancel (wdh); + DONAU_transfers_get_cancel (wdh); } -struct TALER_DONAU_TransfersGetHandle * -TALER_DONAU_transfers_get ( +struct DONAU_TransfersGetHandle * +DONAU_transfers_get ( struct GNUNET_CURL_Context *ctx, const char *url, - struct TALER_DONAU_Keys *keys, + struct DONAU_Keys *keys, const struct TALER_WireTransferIdentifierRawP *wtid, - TALER_DONAU_TransfersGetCallback cb, + DONAU_TransfersGetCallback cb, void *cb_cls) { - struct TALER_DONAU_TransfersGetHandle *wdh; + struct DONAU_TransfersGetHandle *wdh; CURL *eh; char arg_str[sizeof (struct TALER_WireTransferIdentifierRawP) * 2 + 32]; - wdh = GNUNET_new (struct TALER_DONAU_TransfersGetHandle); + wdh = GNUNET_new (struct DONAU_TransfersGetHandle); wdh->cb = cb; wdh->cb_cls = cb_cls; @@ -358,7 +358,7 @@ TALER_DONAU_transfers_get ( GNUNET_free (wdh); return NULL; } - eh = TALER_DONAU_curl_easy_get_ (wdh->url); + eh = DONAU_curl_easy_get_ (wdh->url); if (NULL == eh) { GNUNET_break (0); @@ -366,7 +366,7 @@ TALER_DONAU_transfers_get ( GNUNET_free (wdh); return NULL; } - wdh->keys = TALER_DONAU_keys_incref (keys); + wdh->keys = DONAU_keys_incref (keys); wdh->job = GNUNET_CURL_job_add_with_ct_json (ctx, eh, &handle_transfers_get_finished, @@ -382,8 +382,8 @@ TALER_DONAU_transfers_get ( * @param wdh the wire deposits request handle */ void -TALER_DONAU_transfers_get_cancel ( - struct TALER_DONAU_TransfersGetHandle *wdh) +DONAU_transfers_get_cancel ( + struct DONAU_TransfersGetHandle *wdh) { if (NULL != wdh->job) { @@ -391,7 +391,7 @@ TALER_DONAU_transfers_get_cancel ( wdh->job = NULL; } GNUNET_free (wdh->url); - TALER_DONAU_keys_decref (wdh->keys); + DONAU_keys_decref (wdh->keys); GNUNET_free (wdh); } diff --git a/src/pq/Makefile.am b/src/pq/Makefile.am @@ -13,7 +13,7 @@ libtalerpq_la_SOURCES = \ pq_query_helper.c \ pq_result_helper.c libtalerpq_la_LIBADD = \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lgnunetutil -ljansson \ -lgnunetpq \ -lpq \ @@ -33,7 +33,7 @@ test_pq_SOURCES = \ test_pq.c test_pq_LDADD = \ libtalerpq.la \ - $(top_builddir)/src/util/libtalerutil.la \ + $(top_builddir)/src/util/libtalerdonauutil.la \ -lgnunetpq \ -lgnunetutil \ -ljansson \ diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c @@ -16,9 +16,7 @@ /** * @file pq/pq_query_helper.c * @brief helper functions for Taler-specific libpq (PostGres) interactions - * @author Sree Harsha Totakura <sreeharsha@totakura.in> - * @author Florian Dold - * @author Christian Grothoff + * @author Johannes Casaburi */ #include <gnunet/gnunet_common.h> #include <gnunet/gnunet_util_lib.h> @@ -27,282 +25,6 @@ /** - * Function called to convert input amount into SQL parameter as tuple. - * - * @param cls closure - * @param data pointer to input argument, here a `struct TALER_Amount` - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_amount_currency_tuple (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - struct GNUNET_PQ_Context *db = cls; - const struct TALER_Amount *amount = data; - size_t sz; - - GNUNET_assert (NULL != db); - GNUNET_assert (NULL != amount); - GNUNET_assert (1 == param_length); - GNUNET_assert (1 <= scratch_length); - GNUNET_assert (sizeof (struct TALER_Amount) == data_len); - GNUNET_static_assert (sizeof(uint32_t) == sizeof(Oid)); - { - char *out; - Oid oid_v; - Oid oid_f; - Oid oid_c; - struct TALER_PQ_AmountCurrencyP d; - - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "int8", - &oid_v)); - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "int4", - &oid_f)); - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "varchar", - &oid_c)); - sz = TALER_PQ_make_taler_pq_amount_currency_ (amount, - oid_v, - oid_f, - oid_c, - &d); - out = GNUNET_malloc (sz); - memcpy (out, - &d, - sz); - scratch[0] = out; - } - - param_values[0] = scratch[0]; - param_lengths[0] = sz; - param_formats[0] = 1; - - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_amount_with_currency ( - const struct GNUNET_PQ_Context *db, - const struct TALER_Amount *amount) -{ - struct GNUNET_PQ_QueryParam res = { - .conv_cls = (void *) db, - .conv = &qconv_amount_currency_tuple, - .data = amount, - .size = sizeof (*amount), - .num_params = 1, - }; - - return res; -} - - -/** - * Function called to convert input amount into SQL parameter as tuple. - * - * @param cls closure - * @param data pointer to input argument, here a `struct TALER_Amount` - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_amount_tuple (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - struct GNUNET_PQ_Context *db = cls; - const struct TALER_Amount *amount = data; - size_t sz; - - GNUNET_assert (NULL != db); - GNUNET_assert (NULL != amount); - GNUNET_assert (1 == param_length); - GNUNET_assert (1 <= scratch_length); - GNUNET_assert (sizeof (struct TALER_Amount) == data_len); - GNUNET_static_assert (sizeof(uint32_t) == sizeof(Oid)); - { - char *out; - Oid oid_v; - Oid oid_f; - - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "int8", - &oid_v)); - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "int4", - &oid_f)); - - { - struct TALER_PQ_AmountP d - = TALER_PQ_make_taler_pq_amount_ (amount, - oid_v, - oid_f); - - sz = sizeof(d); - out = GNUNET_malloc (sz); - scratch[0] = out; - GNUNET_memcpy (out, - &d, - sizeof(d)); - } - } - - param_values[0] = scratch[0]; - param_lengths[0] = sz; - param_formats[0] = 1; - - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_amount ( - const struct GNUNET_PQ_Context *db, - const struct TALER_Amount *amount) -{ - struct GNUNET_PQ_QueryParam res = { - .conv_cls = (void *) db, - .conv = &qconv_amount_tuple, - .data = amount, - .size = sizeof (*amount), - .num_params = 1, - }; - - return res; -} - - -/** - * Function called to convert input argument into SQL parameters. - * - * @param cls closure - * @param data pointer to input argument - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_denom_pub (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - const struct TALER_DenominationPublicKey *denom_pub = data; - size_t tlen; - size_t len; - uint32_t be[2]; - char *buf; - void *tbuf; - - (void) cls; - (void) data_len; - GNUNET_assert (1 == param_length); - GNUNET_assert (scratch_length > 0); - GNUNET_break (NULL == cls); - be[0] = htonl ((uint32_t) denom_pub->cipher); - be[1] = htonl (denom_pub->age_mask.bits); - switch (denom_pub->cipher) - { - case TALER_DENOMINATION_RSA: - tlen = GNUNET_CRYPTO_rsa_public_key_encode ( - denom_pub->details.rsa_public_key, - &tbuf); - break; - case TALER_DENOMINATION_CS: - tlen = sizeof (denom_pub->details.cs_public_key); - break; - default: - GNUNET_assert (0); - } - len = tlen + sizeof (be); - buf = GNUNET_malloc (len); - GNUNET_memcpy (buf, - be, - sizeof (be)); - switch (denom_pub->cipher) - { - case TALER_DENOMINATION_RSA: - GNUNET_memcpy (&buf[sizeof (be)], - tbuf, - tlen); - GNUNET_free (tbuf); - break; - case TALER_DENOMINATION_CS: - GNUNET_memcpy (&buf[sizeof (be)], - &denom_pub->details.cs_public_key, - tlen); - break; - default: - GNUNET_assert (0); - } - - scratch[0] = buf; - param_values[0] = (void *) buf; - param_lengths[0] = len; - param_formats[0] = 1; - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_denom_pub ( - const struct TALER_DenominationPublicKey *denom_pub) -{ - struct GNUNET_PQ_QueryParam res = { - .conv = &qconv_denom_pub, - .data = denom_pub, - .num_params = 1 - }; - - return res; -} - - -/** * Function called to convert input argument into SQL parameters. * * @param cls closure @@ -315,105 +37,9 @@ TALER_PQ_query_param_denom_pub ( * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() * @param scratch_length number of entries left in @a scratch * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_denom_sig (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - const struct TALER_DenominationSignature *denom_sig = data; - size_t tlen; - size_t len; - uint32_t be[2]; - char *buf; - void *tbuf; - - (void) cls; - (void) data_len; - GNUNET_assert (1 == param_length); - GNUNET_assert (scratch_length > 0); - GNUNET_break (NULL == cls); - be[0] = htonl ((uint32_t) denom_sig->cipher); - be[1] = htonl (0x00); /* magic marker: unblinded */ - switch (denom_sig->cipher) - { - case TALER_DENOMINATION_RSA: - tlen = GNUNET_CRYPTO_rsa_signature_encode ( - denom_sig->details.rsa_signature, - &tbuf); - break; - case TALER_DENOMINATION_CS: - tlen = sizeof (denom_sig->details.cs_signature); - break; - default: - GNUNET_assert (0); - } - len = tlen + sizeof (be); - buf = GNUNET_malloc (len); - GNUNET_memcpy (buf, - &be, - sizeof (be)); - switch (denom_sig->cipher) - { - case TALER_DENOMINATION_RSA: - GNUNET_memcpy (&buf[sizeof (be)], - tbuf, - tlen); - GNUNET_free (tbuf); - break; - case TALER_DENOMINATION_CS: - GNUNET_memcpy (&buf[sizeof (be)], - &denom_sig->details.cs_signature, - tlen); - break; - default: - GNUNET_assert (0); - } - - scratch[0] = buf; - param_values[0] = (void *) buf; - param_lengths[0] = len; - param_formats[0] = 1; - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_denom_sig ( - const struct TALER_DenominationSignature *denom_sig) -{ - struct GNUNET_PQ_QueryParam res = { - .conv = &qconv_denom_sig, - .data = denom_sig, - .num_params = 1 - }; - - return res; -} - - -/** - * Function called to convert input argument into SQL parameters. * - * @param cls closure - * @param data pointer to input argument - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ static int -qconv_blinded_denom_sig (void *cls, +qconv_donation_unit_pub (void *cls, const void *data, size_t data_len, void *param_values[], @@ -423,7 +49,9 @@ qconv_blinded_denom_sig (void *cls, void *scratch[], unsigned int scratch_length) { - const struct TALER_BlindedDenominationSignature *denom_sig = data; + const struct DONAU_DonationUnitPublicKey *donation_unit_pub = data; + const struct GNUNET_CRYPTO_BlindSignPublicKey *bsp = donation_unit_pub-> + bsign_pub_key; size_t tlen; size_t len; uint32_t be[2]; @@ -435,17 +63,17 @@ qconv_blinded_denom_sig (void *cls, GNUNET_assert (1 == param_length); GNUNET_assert (scratch_length > 0); GNUNET_break (NULL == cls); - be[0] = htonl ((uint32_t) denom_sig->cipher); - be[1] = htonl (0x01); /* magic marker: blinded */ - switch (denom_sig->cipher) + be[0] = htonl ((uint32_t) bsp->cipher); + be[1] = htonl (donation_unit_pub->age_mask.bits); + switch (bsp->cipher) { - case TALER_DENOMINATION_RSA: - tlen = GNUNET_CRYPTO_rsa_signature_encode ( - denom_sig->details.blinded_rsa_signature, + case GNUNET_CRYPTO_BSA_RSA: + tlen = GNUNET_CRYPTO_rsa_public_key_encode ( + bsp->details.rsa_public_key, &tbuf); break; - case TALER_DENOMINATION_CS: - tlen = sizeof (denom_sig->details.blinded_cs_answer); + case GNUNET_CRYPTO_BSA_CS: + tlen = sizeof (bsp->details.cs_public_key); break; default: GNUNET_assert (0); @@ -453,204 +81,25 @@ qconv_blinded_denom_sig (void *cls, len = tlen + sizeof (be); buf = GNUNET_malloc (len); GNUNET_memcpy (buf, - &be, + be, sizeof (be)); - switch (denom_sig->cipher) + switch (bsp->cipher) { - case TALER_DENOMINATION_RSA: + case GNUNET_CRYPTO_BSA_RSA: GNUNET_memcpy (&buf[sizeof (be)], tbuf, tlen); GNUNET_free (tbuf); break; - case TALER_DENOMINATION_CS: - GNUNET_memcpy (&buf[sizeof (be)], - &denom_sig->details.blinded_cs_answer, - tlen); - break; - default: - GNUNET_assert (0); - } - - scratch[0] = buf; - param_values[0] = (void *) buf; - param_lengths[0] = len; - param_formats[0] = 1; - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_blinded_denom_sig ( - const struct TALER_BlindedDenominationSignature *denom_sig) -{ - struct GNUNET_PQ_QueryParam res = { - .conv = &qconv_blinded_denom_sig, - .data = denom_sig, - .num_params = 1 - }; - - return res; -} - - -/** - * Function called to convert input argument into SQL parameters. - * - * @param cls closure - * @param data pointer to input argument - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_blinded_planchet (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - const struct TALER_BlindedPlanchet *bp = data; - size_t tlen; - size_t len; - uint32_t be[2]; - char *buf; - - (void) cls; - (void) data_len; - GNUNET_assert (1 == param_length); - GNUNET_assert (scratch_length > 0); - GNUNET_break (NULL == cls); - be[0] = htonl ((uint32_t) bp->cipher); - be[1] = htonl (0x0100); /* magic marker: blinded */ - switch (bp->cipher) - { - case TALER_DENOMINATION_RSA: - tlen = bp->details.rsa_blinded_planchet.blinded_msg_size; - break; - case TALER_DENOMINATION_CS: - tlen = sizeof (bp->details.cs_blinded_planchet); - break; - default: - GNUNET_assert (0); - } - len = tlen + sizeof (be); - buf = GNUNET_malloc (len); - GNUNET_memcpy (buf, - &be, - sizeof (be)); - switch (bp->cipher) - { - case TALER_DENOMINATION_RSA: + case GNUNET_CRYPTO_BSA_CS: GNUNET_memcpy (&buf[sizeof (be)], - bp->details.rsa_blinded_planchet.blinded_msg, - tlen); - break; - case TALER_DENOMINATION_CS: - GNUNET_memcpy (&buf[sizeof (be)], - &bp->details.cs_blinded_planchet, + &bsp->details.cs_public_key, tlen); break; default: GNUNET_assert (0); } - scratch[0] = buf; - param_values[0] = (void *) buf; - param_lengths[0] = len; - param_formats[0] = 1; - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_blinded_planchet ( - const struct TALER_BlindedPlanchet *bp) -{ - struct GNUNET_PQ_QueryParam res = { - .conv = &qconv_blinded_planchet, - .data = bp, - .num_params = 1 - }; - - return res; -} - - -/** - * Function called to convert input argument into SQL parameters. - * - * @param cls closure - * @param data pointer to input argument - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_exchange_withdraw_values (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - const struct TALER_ExchangeWithdrawValues *alg_values = data; - size_t tlen; - size_t len; - uint32_t be[2]; - char *buf; - (void) cls; - (void) data_len; - GNUNET_assert (1 == param_length); - GNUNET_assert (scratch_length > 0); - GNUNET_break (NULL == cls); - be[0] = htonl ((uint32_t) alg_values->cipher); - be[1] = htonl (0x010000); /* magic marker: EWV */ - switch (alg_values->cipher) - { - case TALER_DENOMINATION_RSA: - tlen = 0; - break; - case TALER_DENOMINATION_CS: - tlen = sizeof (struct TALER_DenominationCSPublicRPairP); - break; - default: - GNUNET_assert (0); - } - len = tlen + sizeof (be); - buf = GNUNET_malloc (len); - GNUNET_memcpy (buf, - &be, - sizeof (be)); - switch (alg_values->cipher) - { - case TALER_DENOMINATION_RSA: - break; - case TALER_DENOMINATION_CS: - GNUNET_memcpy (&buf[sizeof (be)], - &alg_values->details.cs_values, - tlen); - break; - default: - GNUNET_assert (0); - } scratch[0] = buf; param_values[0] = (void *) buf; param_lengths[0] = len; @@ -660,522 +109,17 @@ qconv_exchange_withdraw_values (void *cls, struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_exchange_withdraw_values ( - const struct TALER_ExchangeWithdrawValues *alg_values) -{ - struct GNUNET_PQ_QueryParam res = { - .conv = &qconv_exchange_withdraw_values, - .data = alg_values, - .num_params = 1 - }; - - return res; -} - - -/** - * Function called to convert input argument into SQL parameters. - * - * @param cls closure - * @param data pointer to input argument, here a `json_t *` - * @param data_len number of bytes in @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_json (void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - const json_t *json = data; - char *str; - - (void) cls; - (void) data_len; - GNUNET_assert (1 == param_length); - GNUNET_assert (scratch_length > 0); - str = json_dumps (json, JSON_COMPACT); - if (NULL == str) - return -1; - scratch[0] = str; - param_values[0] = (void *) str; - param_lengths[0] = strlen (str); - param_formats[0] = 1; - return 1; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_json (const json_t *x) +TALER_PQ_query_param_donation_unit_pub ( + const struct DONAU_DonationUnitPublicKey *donation_unit_pub) { struct GNUNET_PQ_QueryParam res = { - .conv = &qconv_json, - .data = x, + .conv = &qconv_donation_unit_pub, + .data = donation_unit_pub, .num_params = 1 }; return res; } - - -/** ------------------- Array support -----------------------------------**/ - -/** - * Closure for the array type handlers. - * - * May contain sizes information for the data, given (and handled) by the - * caller. - */ -struct qconv_array_cls -{ - /** - * If not null, contains the array of sizes (the size of the array is the - * .size field in the ambient GNUNET_PQ_QueryParam struct). We do not free - * this memory. - * - * If not null, this value has precedence over @a sizes, which MUST be NULL */ - const size_t *sizes; - - /** - * If @a size and @a c_sizes are NULL, this field defines the same size - * for each element in the array. - */ - size_t same_size; - - /** - * If true, the array parameter to the data pointer to the qconv_array is a - * continuous byte array of data, either with @a same_size each or sizes - * provided bytes by @a sizes; - */ - bool continuous; - - /** - * Type of the array elements - */ - enum TALER_PQ_ArrayType typ; - - /** - * Oid of the array elements - */ - Oid oid; - - /** - * db context, needed for OID-lookup of basis-types - */ - struct GNUNET_PQ_Context *db; -}; - -/** - * Callback to cleanup a qconv_array_cls to be used during - * GNUNET_PQ_cleanup_query_params_closures - */ -static void -qconv_array_cls_cleanup (void *cls) -{ - GNUNET_free (cls); -} - - -/** - * Function called to convert input argument into SQL parameters for arrays - * - * Note: the format for the encoding of arrays for libpq is not very well - * documented. We peeked into various sources (postgresql and libpqtypes) for - * guidance. - * - * @param cls Closure of type struct qconv_array_cls* - * @param data Pointer to first element in the array - * @param data_len Number of _elements_ in array @a data (if applicable) - * @param[out] param_values SQL data to set - * @param[out] param_lengths SQL length data to set - * @param[out] param_formats SQL format data to set - * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays - * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc() - * @param scratch_length number of entries left in @a scratch - * @return -1 on error, number of offsets used in @a scratch otherwise - */ -static int -qconv_array ( - void *cls, - const void *data, - size_t data_len, - void *param_values[], - int param_lengths[], - int param_formats[], - unsigned int param_length, - void *scratch[], - unsigned int scratch_length) -{ - struct qconv_array_cls *meta = cls; - size_t num = data_len; - size_t total_size; - const size_t *sizes; - bool same_sized; - void *elements = NULL; - bool noerror = true; - /* needed to capture the encoded rsa signatures */ - void **buffers = NULL; - size_t *buffer_lengths = NULL; - - (void) (param_length); - (void) (scratch_length); - - GNUNET_assert (NULL != meta); - GNUNET_assert (num < INT_MAX); - - sizes = meta->sizes; - same_sized = (0 != meta->same_size); - -#define RETURN_UNLESS(cond) \ - do { \ - if (! (cond)) \ - { \ - GNUNET_break ((cond)); \ - noerror = false; \ - goto DONE; \ - } \ - } while (0) - - /* Calculate sizes and check bounds */ - { - /* num * length-field */ - size_t x = sizeof(uint32_t); - size_t y = x * num; - RETURN_UNLESS ((0 == num) || (y / num == x)); - - /* size of header */ - total_size = x = sizeof(struct GNUNET_PQ_ArrayHeader_P); - total_size += y; - RETURN_UNLESS (total_size >= x); - - /* sizes of elements */ - if (same_sized) - { - x = num * meta->same_size; - RETURN_UNLESS ((0 == num) || (x / num == meta->same_size)); - - y = total_size; - total_size += x; - RETURN_UNLESS (total_size >= y); - } - else /* sizes are different per element */ - { - switch (meta->typ) - { - case TALER_PQ_array_of_blinded_denom_sig: - { - const struct TALER_BlindedDenominationSignature *denom_sigs = data; - size_t len; - - buffers = GNUNET_new_array (num, void *); - buffer_lengths = GNUNET_new_array (num, size_t); - - for (size_t i = 0; i<num; i++) - { - switch (denom_sigs[i].cipher) - { - case TALER_DENOMINATION_RSA: - len = GNUNET_CRYPTO_rsa_signature_encode ( - denom_sigs[i].details.blinded_rsa_signature, - &buffers[i]); - RETURN_UNLESS (len != 0); - break; - case TALER_DENOMINATION_CS: - len = sizeof (denom_sigs[i].details.blinded_cs_answer); - break; - default: - GNUNET_assert (0); - } - - /* for the cipher and marker */ - len += 2 * sizeof(uint32_t); - buffer_lengths[i] = len; - - y = total_size; - total_size += len; - RETURN_UNLESS (total_size >= y); - } - sizes = buffer_lengths; - break; - } - default: - GNUNET_assert (0); - } - } - - RETURN_UNLESS (INT_MAX > total_size); - RETURN_UNLESS (0 != total_size); - - elements = GNUNET_malloc (total_size); - } - - /* Write data */ - { - char *out = elements; - struct GNUNET_PQ_ArrayHeader_P h = { - .ndim = htonl (1), /* We only support one-dimensional arrays */ - .has_null = htonl (0), /* We do not support NULL entries in arrays */ - .lbound = htonl (1), /* Default start index value */ - .dim = htonl (num), - .oid = htonl (meta->oid), - }; - - /* Write header */ - GNUNET_memcpy (out, - &h, - sizeof(h)); - out += sizeof(h); - - /* Write elements */ - for (size_t i = 0; i < num; i++) - { - size_t sz = same_sized ? meta->same_size : sizes[i]; - - *(uint32_t *) out = htonl (sz); - out += sizeof(uint32_t); - switch (meta->typ) - { - case TALER_PQ_array_of_amount: - { - const struct TALER_Amount *amounts = data; - Oid oid_v; - Oid oid_f; - - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (meta->db, - "int8", - &oid_v)); - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (meta->db, - "int4", - &oid_f)); - { - struct TALER_PQ_AmountP am - = TALER_PQ_make_taler_pq_amount_ ( - &amounts[i], - oid_v, - oid_f); - - GNUNET_memcpy (out, - &am, - sizeof(am)); - } - break; - } - case TALER_PQ_array_of_blinded_denom_sig: - { - const struct TALER_BlindedDenominationSignature *denom_sigs = data; - uint32_t be[2]; - - be[0] = htonl ((uint32_t) denom_sigs[i].cipher); - be[1] = htonl (0x01); /* magic margker: blinded */ - GNUNET_memcpy (out, - &be, - sizeof(be)); - out += sizeof(be); - sz -= sizeof(be); - - switch (denom_sigs[i].cipher) - { - case TALER_DENOMINATION_RSA: - /* For RSA, 'same_sized' must have been false */ - GNUNET_assert (NULL != buffers); - GNUNET_memcpy (out, - buffers[i], - sz); - break; - case TALER_DENOMINATION_CS: - GNUNET_memcpy (out, - &denom_sigs[i].details.blinded_cs_answer, - sz); - break; - default: - GNUNET_assert (0); - } - break; - } - case TALER_PQ_array_of_blinded_coin_hash: - { - const struct TALER_BlindedCoinHashP *coin_hs = data; - - GNUNET_memcpy (out, - &coin_hs[i], - sizeof(struct TALER_BlindedCoinHashP)); - - break; - } - case TALER_PQ_array_of_denom_hash: - { - const struct TALER_DenominationHashP *denom_hs = data; - - GNUNET_memcpy (out, - &denom_hs[i], - sizeof(struct TALER_DenominationHashP)); - break; - } - default: - { - GNUNET_assert (0); - break; - } - } - out += sz; - } - } - param_values[0] = elements; - param_lengths[0] = total_size; - param_formats[0] = 1; - scratch[0] = elements; - -DONE: - if (NULL != buffers) - { - for (size_t i = 0; i<num; i++) - GNUNET_free (buffers[i]); - GNUNET_free (buffers); - } - GNUNET_free (buffer_lengths); - if (noerror) - return 1; - return -1; -} - - -/** - * Function to generate a typ specific query parameter and corresponding closure - * - * @param num Number of elements in @a elements - * @param continuous If true, @a elements is an continuous array of data - * @param elements Array of @a num elements, either continuous or pointers - * @param sizes Array of @a num sizes, one per element, may be NULL - * @param same_size If not 0, all elements in @a elements have this size - * @param typ Supported internal type of each element in @a elements - * @param oid Oid of the type to be used in Postgres - * @param[in,out] db our database handle for looking up OIDs - * @return Query parameter - */ -static struct GNUNET_PQ_QueryParam -query_param_array_generic ( - unsigned int num, - bool continuous, - const void *elements, - const size_t *sizes, - size_t same_size, - enum TALER_PQ_ArrayType typ, - Oid oid, - struct GNUNET_PQ_Context *db) -{ - struct qconv_array_cls *meta = GNUNET_new (struct qconv_array_cls); - meta->typ = typ; - meta->oid = oid; - meta->sizes = sizes; - meta->same_size = same_size; - meta->continuous = continuous; - meta->db = db; - - struct GNUNET_PQ_QueryParam res = { - .conv = qconv_array, - .conv_cls = meta, - .conv_cls_cleanup = qconv_array_cls_cleanup, - .data = elements, - .size = num, - .num_params = 1, - }; - - return res; -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_array_blinded_denom_sig ( - size_t num, - const struct TALER_BlindedDenominationSignature *denom_sigs, - struct GNUNET_PQ_Context *db) -{ - Oid oid; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, "bytea", &oid)); - return query_param_array_generic (num, - true, - denom_sigs, - NULL, - 0, - TALER_PQ_array_of_blinded_denom_sig, - oid, - NULL); -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_array_blinded_coin_hash ( - size_t num, - const struct TALER_BlindedCoinHashP *coin_hs, - struct GNUNET_PQ_Context *db) -{ - Oid oid; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, "bytea", &oid)); - return query_param_array_generic (num, - true, - coin_hs, - NULL, - sizeof(struct TALER_BlindedCoinHashP), - TALER_PQ_array_of_blinded_coin_hash, - oid, - NULL); -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_array_denom_hash ( - size_t num, - const struct TALER_DenominationHashP *denom_hs, - struct GNUNET_PQ_Context *db) -{ - Oid oid; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, "bytea", &oid)); - return query_param_array_generic (num, - true, - denom_hs, - NULL, - sizeof(struct TALER_DenominationHashP), - TALER_PQ_array_of_denom_hash, - oid, - NULL); -} - - -struct GNUNET_PQ_QueryParam -TALER_PQ_query_param_array_amount ( - size_t num, - const struct TALER_Amount *amounts, - struct GNUNET_PQ_Context *db) -{ - Oid oid; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, "taler_amount", &oid)); - return query_param_array_generic ( - num, - true, - amounts, - NULL, - sizeof(struct TALER_PQ_AmountP), - TALER_PQ_array_of_amount, - oid, - db); -} - +*/ /* end of pq/pq_query_helper.c */ diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c @@ -18,1407 +18,1407 @@ * @brief functions to initialize parameter arrays * @author Christian Grothoff */ -#include "platform.h" +// #include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> -#include "pq_common.h" -#include "taler_pq_lib.h" - - -/** - * Extract an amount from a tuple including the currency from a Postgres - * database @a result at row @a row. - * - * @param cls closure; not used - * @param result where to extract data from - * @param row row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_NO if at least one result was NULL - * #GNUNET_SYSERR if a result was invalid (non-existing field) - */ -static enum GNUNET_GenericReturnValue -extract_amount_currency_tuple (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_Amount *r_amount = dst; - int col; - - (void) cls; - if (sizeof (struct TALER_Amount) != *dst_size) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - - /* Set return value to invalid in case we don't finish */ - memset (r_amount, - 0, - sizeof (struct TALER_Amount)); - col = PQfnumber (result, - fname); - if (col < 0) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Field `%s' does not exist in result\n", - fname); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - col)) - { - return GNUNET_NO; - } - - /* Parse the tuple */ - { - struct TALER_PQ_AmountCurrencyP ap; - const char *in; - size_t size; - - size = PQgetlength (result, - row, - col); - if ( (size >= sizeof (ap)) || - (size <= sizeof (ap) - TALER_CURRENCY_LEN) ) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Incorrect size of binary field `%s' (got %zu, expected (%zu-%zu))\n", - fname, - size, - sizeof (ap) - TALER_CURRENCY_LEN, - sizeof (ap)); - return GNUNET_SYSERR; - } - - in = PQgetvalue (result, - row, - col); - memset (&ap.c, - 0, - TALER_CURRENCY_LEN); - memcpy (&ap, - in, - size); - if (3 != ntohl (ap.cnt)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Incorrect number of elements in tuple-field `%s'\n", - fname); - return GNUNET_SYSERR; - } - /* TODO[oec]: OID-checks? */ - - r_amount->value = GNUNET_ntohll (ap.v); - r_amount->fraction = ntohl (ap.f); - memcpy (r_amount->currency, - ap.c, - TALER_CURRENCY_LEN); - if ('\0' != r_amount->currency[TALER_CURRENCY_LEN - 1]) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Invalid currency (not 0-terminated) in tuple field `%s'\n", - fname); - /* be sure nobody uses this by accident */ - memset (r_amount, - 0, - sizeof (struct TALER_Amount)); - return GNUNET_SYSERR; - } - } - - if (r_amount->value >= TALER_AMOUNT_MAX_VALUE) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Value in field `%s' exceeds legal range\n", - fname); - return GNUNET_SYSERR; - } - if (r_amount->fraction >= TALER_AMOUNT_FRAC_BASE) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Fraction in field `%s' exceeds legal range\n", - fname); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_amount_with_currency (const char *name, - struct TALER_Amount *amount) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_amount_currency_tuple, - .dst = (void *) amount, - .dst_size = sizeof (*amount), - .fname = name - }; - - return res; -} - - -/** - * Extract an amount from a tuple from a Postgres database @a result at row @a row. - * - * @param cls closure, a `const char *` giving the currency - * @param result where to extract data from - * @param row row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_NO if at least one result was NULL - * #GNUNET_SYSERR if a result was invalid (non-existing field) - */ -static enum GNUNET_GenericReturnValue -extract_amount_tuple (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_Amount *r_amount = dst; - const char *currency = cls; - int col; - size_t len; - - if (sizeof (struct TALER_Amount) != *dst_size) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - - /* Set return value to invalid in case we don't finish */ - memset (r_amount, - 0, - sizeof (struct TALER_Amount)); - col = PQfnumber (result, - fname); - if (col < 0) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Field `%s' does not exist in result\n", - fname); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - col)) - { - return GNUNET_NO; - } - - /* Parse the tuple */ - { - struct TALER_PQ_AmountP ap; - const char *in; - size_t size; - - size = PQgetlength (result, - row, - col); - if (sizeof(ap) != size) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Incorrect size of binary field `%s' (got %zu, expected %zu)\n", - fname, - size, - sizeof(ap)); - return GNUNET_SYSERR; - } - - in = PQgetvalue (result, - row, - col); - memcpy (&ap, - in, - size); - if (2 != ntohl (ap.cnt)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Incorrect number of elements in tuple-field `%s'\n", - fname); - return GNUNET_SYSERR; - } - /* TODO[oec]: OID-checks? */ - - r_amount->value = GNUNET_ntohll (ap.v); - r_amount->fraction = ntohl (ap.f); - } - - if (r_amount->value >= TALER_AMOUNT_MAX_VALUE) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Value in field `%s' exceeds legal range\n", - fname); - return GNUNET_SYSERR; - } - if (r_amount->fraction >= TALER_AMOUNT_FRAC_BASE) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Fraction in field `%s' exceeds legal range\n", - fname); - return GNUNET_SYSERR; - } - - len = GNUNET_MIN (TALER_CURRENCY_LEN - 1, - strlen (currency)); - - GNUNET_memcpy (r_amount->currency, - currency, - len); - return GNUNET_OK; -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_amount (const char *name, - const char *currency, - struct TALER_Amount *amount) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_amount_tuple, - .cls = (void *) currency, - .dst = (void *) amount, - .dst_size = sizeof (*amount), - .fname = name - }; - - return res; -} - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param row row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_NO if at least one result was NULL - * #GNUNET_SYSERR if a result was invalid (non-existing field) - */ -static enum GNUNET_GenericReturnValue -extract_json (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - json_t **j_dst = dst; - const char *res; - int fnum; - json_error_t json_error; - size_t slen; - - (void) cls; - (void) dst_size; - fnum = PQfnumber (result, - fname); - if (fnum < 0) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Field `%s' does not exist in result\n", - fname); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - fnum)) - return GNUNET_NO; - slen = PQgetlength (result, - row, - fnum); - res = (const char *) PQgetvalue (result, - row, - fnum); - *j_dst = json_loadb (res, - slen, - JSON_REJECT_DUPLICATES, - &json_error); - if (NULL == *j_dst) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "Failed to parse JSON result for field `%s': %s (%s)\n", - fname, - json_error.text, - json_error.source); - return GNUNET_SYSERR; - } - return GNUNET_OK; -} - - -/** - * Function called to clean up memory allocated - * by a #GNUNET_PQ_ResultConverter. - * - * @param cls closure - * @param rd result data to clean up - */ -static void -clean_json (void *cls, - void *rd) -{ - json_t **dst = rd; - - (void) cls; - if (NULL != *dst) - { - json_decref (*dst); - *dst = NULL; - } -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_json (const char *name, - json_t **jp) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_json, - .cleaner = &clean_json, - .dst = (void *) jp, - .fname = name - }; - - return res; -} - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param row the row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -static enum GNUNET_GenericReturnValue -extract_denom_pub (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_DenominationPublicKey *pk = dst; - size_t len; - const char *res; - int fnum; - uint32_t be[2]; - - (void) cls; - (void) dst_size; - fnum = PQfnumber (result, - fname); - if (fnum < 0) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - fnum)) - return GNUNET_NO; - - /* if a field is null, continue but - * remember that we now return a different result */ - len = PQgetlength (result, - row, - fnum); - res = PQgetvalue (result, - row, - fnum); - if (len < sizeof (be)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (be, - res, - sizeof (be)); - res += sizeof (be); - len -= sizeof (be); - pk->cipher = ntohl (be[0]); - pk->age_mask.bits = ntohl (be[1]); - switch (pk->cipher) - { - case TALER_DENOMINATION_RSA: - pk->details.rsa_public_key - = GNUNET_CRYPTO_rsa_public_key_decode (res, - len); - if (NULL == pk->details.rsa_public_key) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; - case TALER_DENOMINATION_CS: - if (sizeof (pk->details.cs_public_key) != len) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&pk->details.cs_public_key, - res, - len); - return GNUNET_OK; - default: - GNUNET_break (0); - } - return GNUNET_SYSERR; -} - - -/** - * Function called to clean up memory allocated - * by a #GNUNET_PQ_ResultConverter. - * - * @param cls closure - * @param rd result data to clean up - */ -static void -clean_denom_pub (void *cls, - void *rd) -{ - struct TALER_DenominationPublicKey *denom_pub = rd; - - (void) cls; - TALER_denom_pub_free (denom_pub); -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_denom_pub (const char *name, - struct TALER_DenominationPublicKey *denom_pub) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_denom_pub, - .cleaner = &clean_denom_pub, - .dst = (void *) denom_pub, - .fname = name - }; - - return res; -} - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param row the row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -static enum GNUNET_GenericReturnValue -extract_denom_sig (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_DenominationSignature *sig = dst; - size_t len; - const char *res; - int fnum; - uint32_t be[2]; - - (void) cls; - (void) dst_size; - fnum = PQfnumber (result, - fname); - if (fnum < 0) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - fnum)) - return GNUNET_NO; - - /* if a field is null, continue but - * remember that we now return a different result */ - len = PQgetlength (result, - row, - fnum); - res = PQgetvalue (result, - row, - fnum); - if (len < sizeof (be)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&be, - res, - sizeof (be)); - if (0x00 != ntohl (be[1])) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - res += sizeof (be); - len -= sizeof (be); - sig->cipher = ntohl (be[0]); - switch (sig->cipher) - { - case TALER_DENOMINATION_RSA: - sig->details.rsa_signature - = GNUNET_CRYPTO_rsa_signature_decode (res, - len); - if (NULL == sig->details.rsa_signature) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; - case TALER_DENOMINATION_CS: - if (sizeof (sig->details.cs_signature) != len) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&sig->details.cs_signature, - res, - len); - return GNUNET_OK; - default: - GNUNET_break (0); - } - return GNUNET_SYSERR; -} - - -/** - * Function called to clean up memory allocated - * by a #GNUNET_PQ_ResultConverter. - * - * @param cls closure - * @param rd result data to clean up - */ -static void -clean_denom_sig (void *cls, - void *rd) -{ - struct TALER_DenominationSignature *denom_sig = rd; - - (void) cls; - TALER_denom_sig_free (denom_sig); -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_denom_sig (const char *name, - struct TALER_DenominationSignature *denom_sig) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_denom_sig, - .cleaner = &clean_denom_sig, - .dst = (void *) denom_sig, - .fname = name - }; - - return res; -} - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param row the row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -static enum GNUNET_GenericReturnValue -extract_blinded_denom_sig (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_BlindedDenominationSignature *sig = dst; - size_t len; - const char *res; - int fnum; - uint32_t be[2]; - - (void) cls; - (void) dst_size; - fnum = PQfnumber (result, - fname); - if (fnum < 0) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - fnum)) - return GNUNET_NO; - - /* if a field is null, continue but - * remember that we now return a different result */ - len = PQgetlength (result, - row, - fnum); - res = PQgetvalue (result, - row, - fnum); - if (len < sizeof (be)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&be, - res, - sizeof (be)); - if (0x01 != ntohl (be[1])) /* magic marker: blinded */ - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - res += sizeof (be); - len -= sizeof (be); - sig->cipher = ntohl (be[0]); - switch (sig->cipher) - { - case TALER_DENOMINATION_RSA: - sig->details.blinded_rsa_signature - = GNUNET_CRYPTO_rsa_signature_decode (res, - len); - if (NULL == sig->details.blinded_rsa_signature) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; - case TALER_DENOMINATION_CS: - if (sizeof (sig->details.blinded_cs_answer) != len) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&sig->details.blinded_cs_answer, - res, - len); - return GNUNET_OK; - default: - GNUNET_break (0); - } - return GNUNET_SYSERR; -} - - -/** - * Function called to clean up memory allocated - * by a #GNUNET_PQ_ResultConverter. - * - * @param cls closure - * @param rd result data to clean up - */ -static void -clean_blinded_denom_sig (void *cls, - void *rd) -{ - struct TALER_BlindedDenominationSignature *denom_sig = rd; - - (void) cls; - TALER_blinded_denom_sig_free (denom_sig); -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_blinded_denom_sig ( - const char *name, - struct TALER_BlindedDenominationSignature *denom_sig) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_blinded_denom_sig, - .cleaner = &clean_blinded_denom_sig, - .dst = (void *) denom_sig, - .fname = name - }; - - return res; -} - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param row the row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -static enum GNUNET_GenericReturnValue -extract_blinded_planchet (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_BlindedPlanchet *bp = dst; - size_t len; - const char *res; - int fnum; - uint32_t be[2]; - - (void) cls; - (void) dst_size; - fnum = PQfnumber (result, - fname); - if (fnum < 0) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - fnum)) - return GNUNET_NO; - - /* if a field is null, continue but - * remember that we now return a different result */ - len = PQgetlength (result, - row, - fnum); - res = PQgetvalue (result, - row, - fnum); - if (len < sizeof (be)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&be, - res, - sizeof (be)); - if (0x0100 != ntohl (be[1])) /* magic marker: blinded */ - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - res += sizeof (be); - len -= sizeof (be); - bp->cipher = ntohl (be[0]); - switch (bp->cipher) - { - case TALER_DENOMINATION_RSA: - bp->details.rsa_blinded_planchet.blinded_msg_size - = len; - bp->details.rsa_blinded_planchet.blinded_msg - = GNUNET_memdup (res, - len); - return GNUNET_OK; - case TALER_DENOMINATION_CS: - if (sizeof (bp->details.cs_blinded_planchet) != len) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&bp->details.cs_blinded_planchet, - res, - len); - return GNUNET_OK; - default: - GNUNET_break (0); - } - return GNUNET_SYSERR; -} - - -/** - * Function called to clean up memory allocated - * by a #GNUNET_PQ_ResultConverter. - * - * @param cls closure - * @param rd result data to clean up - */ -static void -clean_blinded_planchet (void *cls, - void *rd) -{ - struct TALER_BlindedPlanchet *bp = rd; - - (void) cls; - TALER_blinded_planchet_free (bp); -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_blinded_planchet ( - const char *name, - struct TALER_BlindedPlanchet *bp) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_blinded_planchet, - .cleaner = &clean_blinded_planchet, - .dst = (void *) bp, - .fname = name - }; - - return res; -} - - -/** - * Extract data from a Postgres database @a result at row @a row. - * - * @param cls closure - * @param result where to extract data from - * @param row row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -static enum GNUNET_GenericReturnValue -extract_exchange_withdraw_values (void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - struct TALER_ExchangeWithdrawValues *alg_values = dst; - size_t len; - const char *res; - int fnum; - uint32_t be[2]; - - (void) cls; - (void) dst_size; - fnum = PQfnumber (result, - fname); - if (fnum < 0) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - if (PQgetisnull (result, - row, - fnum)) - return GNUNET_NO; - - /* if a field is null, continue but - * remember that we now return a different result */ - len = PQgetlength (result, - row, - fnum); - res = PQgetvalue (result, - row, - fnum); - if (len < sizeof (be)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&be, - res, - sizeof (be)); - if (0x010000 != ntohl (be[1])) /* magic marker: EWV */ - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - res += sizeof (be); - len -= sizeof (be); - alg_values->cipher = ntohl (be[0]); - switch (alg_values->cipher) - { - case TALER_DENOMINATION_RSA: - if (0 != len) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - return GNUNET_OK; - case TALER_DENOMINATION_CS: - if (sizeof (struct TALER_DenominationCSPublicRPairP) != len) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - GNUNET_memcpy (&alg_values->details.cs_values, - res, - len); - return GNUNET_OK; - default: - GNUNET_break (0); - } - return GNUNET_SYSERR; -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_exchange_withdraw_values ( - const char *name, - struct TALER_ExchangeWithdrawValues *ewv) -{ - struct GNUNET_PQ_ResultSpec res = { - .conv = &extract_exchange_withdraw_values, - .dst = (void *) ewv, - .fname = name - }; - - return res; -} - - -/** - * Closure for the array result specifications. Contains type information - * for the generic parser extract_array_generic and out-pointers for the results. - */ -struct ArrayResultCls -{ - /* Oid of the expected type, must match the oid in the header of the PQResult struct */ - Oid oid; - - /* Target type */ - enum TALER_PQ_ArrayType typ; - - /* If not 0, defines the expected size of each entry */ - size_t same_size; - - /* Out-pointer to write the number of elements in the array */ - size_t *num; - - /* Out-pointer. If @a typ is TALER_PQ_array_of_byte and @a same_size is 0, - * allocate and put the array of @a num sizes here. NULL otherwise */ - size_t **sizes; - - /* DB_connection, needed for OID-lookup for composite types */ - const struct GNUNET_PQ_Context *db; - - /* Currency information for amount composites */ - char currency[TALER_CURRENCY_LEN]; -}; - -/** - * Extract data from a Postgres database @a result as array of a specific type - * from row @a row. The type information and optionally additional - * out-parameters are given in @a cls which is of type array_result_cls. - * - * @param cls closure of type array_result_cls - * @param result where to extract data from - * @param row row to extract data from - * @param fname name (or prefix) of the fields to extract from - * @param[in,out] dst_size where to store size of result, may be NULL - * @param[out] dst where to store the result - * @return - * #GNUNET_YES if all results could be extracted - * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) - */ -static enum GNUNET_GenericReturnValue -extract_array_generic ( - void *cls, - PGresult *result, - int row, - const char *fname, - size_t *dst_size, - void *dst) -{ - const struct ArrayResultCls *info = cls; - int data_sz; - char *data; - void *out = NULL; - struct GNUNET_PQ_ArrayHeader_P header; - int col_num; - - GNUNET_assert (NULL != dst); - *((void **) dst) = NULL; - - #define FAIL_IF(cond) \ - do { \ - if ((cond)) \ - { \ - GNUNET_break (! (cond)); \ - goto FAIL; \ - } \ - } while (0) - - col_num = PQfnumber (result, fname); - FAIL_IF (0 > col_num); - - data_sz = PQgetlength (result, row, col_num); - FAIL_IF (0 > data_sz); - FAIL_IF (sizeof(header) > (size_t) data_sz); - - data = PQgetvalue (result, row, col_num); - FAIL_IF (NULL == data); - - { - struct GNUNET_PQ_ArrayHeader_P *h = - (struct GNUNET_PQ_ArrayHeader_P *) data; - - header.ndim = ntohl (h->ndim); - header.has_null = ntohl (h->has_null); - header.oid = ntohl (h->oid); - header.dim = ntohl (h->dim); - header.lbound = ntohl (h->lbound); - - FAIL_IF (1 != header.ndim); - FAIL_IF (INT_MAX <= header.dim); - FAIL_IF (0 != header.has_null); - FAIL_IF (1 != header.lbound); - FAIL_IF (info->oid != header.oid); - } - - if (NULL != info->num) - *info->num = header.dim; - - { - char *in = data + sizeof(header); - - switch (info->typ) - { - case TALER_PQ_array_of_amount: - { - struct TALER_Amount *amounts; - if (NULL != dst_size) - *dst_size = sizeof(struct TALER_Amount) * (header.dim); - - amounts = GNUNET_new_array (header.dim, struct TALER_Amount); - *((void **) dst) = amounts; - - for (uint32_t i = 0; i < header.dim; i++) - { - struct TALER_PQ_AmountP ap; - struct TALER_Amount *amount = &amounts[i]; - uint32_t val; - size_t sz; - - GNUNET_memcpy (&val, - in, - sizeof(val)); - sz = ntohl (val); - in += sizeof(val); - - /* total size for this array-entry */ - FAIL_IF (sizeof(ap) > sz); - - GNUNET_memcpy (&ap, - in, - sz); - FAIL_IF (2 != ntohl (ap.cnt)); - - amount->value = GNUNET_ntohll (ap.v); - amount->fraction = ntohl (ap.f); - GNUNET_memcpy (amount->currency, - info->currency, - TALER_CURRENCY_LEN); - - in += sizeof(struct TALER_PQ_AmountP); - } - return GNUNET_OK; - } - case TALER_PQ_array_of_denom_hash: - if (NULL != dst_size) - *dst_size = sizeof(struct TALER_DenominationHashP) * (header.dim); - out = GNUNET_new_array (header.dim, struct TALER_DenominationHashP); - *((void **) dst) = out; - for (uint32_t i = 0; i < header.dim; i++) - { - uint32_t val; - size_t sz; - - GNUNET_memcpy (&val, - in, - sizeof(val)); - sz = ntohl (val); - FAIL_IF (sz != sizeof(struct TALER_DenominationHashP)); - in += sizeof(uint32_t); - *(struct TALER_DenominationHashP *) out = - *(struct TALER_DenominationHashP *) in; - in += sz; - out += sz; - } - return GNUNET_OK; - - case TALER_PQ_array_of_blinded_coin_hash: - if (NULL != dst_size) - *dst_size = sizeof(struct TALER_BlindedCoinHashP) * (header.dim); - out = GNUNET_new_array (header.dim, struct TALER_BlindedCoinHashP); - *((void **) dst) = out; - for (uint32_t i = 0; i < header.dim; i++) - { - uint32_t val; - size_t sz; - - GNUNET_memcpy (&val, - in, - sizeof(val)); - sz = ntohl (val); - FAIL_IF (sz != sizeof(struct TALER_BlindedCoinHashP)); - in += sizeof(uint32_t); - *(struct TALER_BlindedCoinHashP *) out = - *(struct TALER_BlindedCoinHashP *) in; - in += sz; - out += sz; - } - return GNUNET_OK; - - case TALER_PQ_array_of_blinded_denom_sig: - { - struct TALER_BlindedDenominationSignature *denom_sigs; - if (0 == header.dim) - { - if (NULL != dst_size) - *dst_size = 0; - break; - } - - denom_sigs = GNUNET_new_array (header.dim, - struct TALER_BlindedDenominationSignature); - *((void **) dst) = denom_sigs; - - /* copy data */ - for (uint32_t i = 0; i < header.dim; i++) - { - struct TALER_BlindedDenominationSignature *denom_sig = &denom_sigs[i]; - uint32_t be[2]; - uint32_t val; - size_t sz; - - GNUNET_memcpy (&val, - in, - sizeof(val)); - sz = ntohl (val); - FAIL_IF (sizeof(be) > sz); - - in += sizeof(val); - GNUNET_memcpy (&be, - in, - sizeof(be)); - FAIL_IF (0x01 != ntohl (be[1])); /* magic marker: blinded */ - - in += sizeof(be); - sz -= sizeof(be); - - denom_sig->cipher = ntohl (be[0]); - switch (denom_sig->cipher) - { - case TALER_DENOMINATION_RSA: - denom_sig->details.blinded_rsa_signature = - GNUNET_CRYPTO_rsa_signature_decode (in, - sz); - FAIL_IF (NULL == denom_sig->details.blinded_rsa_signature); - break; - - case TALER_DENOMINATION_CS: - FAIL_IF (sizeof(denom_sig->details.blinded_cs_answer) != sz); - GNUNET_memcpy (&denom_sig->details.blinded_cs_answer, - in, - sz); - break; - - default: - FAIL_IF (true); - } - - in += sz; - } - return GNUNET_OK; - } - default: - FAIL_IF (true); - } - } - -FAIL: - GNUNET_free (*(void **) dst); - return GNUNET_SYSERR; - #undef FAIL_IF - -} - - -/** - * Cleanup of the data and closure of an array spec. - */ -static void -array_cleanup (void *cls, - void *rd) -{ - - struct ArrayResultCls *info = cls; - void **dst = rd; - - if ((0 == info->same_size) && - (NULL != info->sizes)) - GNUNET_free (*(info->sizes)); - - GNUNET_free (cls); - GNUNET_free (*dst); - *dst = NULL; -} - - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_array_blinded_denom_sig ( - struct GNUNET_PQ_Context *db, - const char *name, - size_t *num, - struct TALER_BlindedDenominationSignature **denom_sigs) -{ - struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); - - info->num = num; - info->typ = TALER_PQ_array_of_blinded_denom_sig; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "bytea", - &info->oid)); - - struct GNUNET_PQ_ResultSpec res = { - .conv = extract_array_generic, - .cleaner = array_cleanup, - .dst = (void *) denom_sigs, - .fname = name, - .cls = info - }; - return res; - -}; - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_array_blinded_coin_hash ( - struct GNUNET_PQ_Context *db, - const char *name, - size_t *num, - struct TALER_BlindedCoinHashP **h_coin_evs) -{ - struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); - - info->num = num; - info->typ = TALER_PQ_array_of_blinded_coin_hash; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "bytea", - &info->oid)); - - struct GNUNET_PQ_ResultSpec res = { - .conv = extract_array_generic, - .cleaner = array_cleanup, - .dst = (void *) h_coin_evs, - .fname = name, - .cls = info - }; - return res; - -}; - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_array_denom_hash ( - struct GNUNET_PQ_Context *db, - const char *name, - size_t *num, - struct TALER_DenominationHashP **denom_hs) -{ - struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); - - info->num = num; - info->typ = TALER_PQ_array_of_denom_hash; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "bytea", - &info->oid)); - - struct GNUNET_PQ_ResultSpec res = { - .conv = extract_array_generic, - .cleaner = array_cleanup, - .dst = (void *) denom_hs, - .fname = name, - .cls = info - }; - return res; - -}; - -struct GNUNET_PQ_ResultSpec -TALER_PQ_result_spec_array_amount ( - struct GNUNET_PQ_Context *db, - const char *name, - const char *currency, - size_t *num, - struct TALER_Amount **amounts) -{ - struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); - - info->num = num; - info->typ = TALER_PQ_array_of_amount; - info->db = db; - GNUNET_assert (GNUNET_OK == - GNUNET_PQ_get_oid_by_name (db, - "taler_amount", - &info->oid)); - - { - size_t clen = GNUNET_MIN (TALER_CURRENCY_LEN - 1, - strlen (currency)); - GNUNET_memcpy (&info->currency, - currency, - clen); - } - - struct GNUNET_PQ_ResultSpec res = { - .conv = extract_array_generic, - .cleaner = array_cleanup, - .dst = (void *) amounts, - .fname = name, - .cls = info, - }; - return res; - - -} +// #include "pq_common.h" +// #include "taler_pq_lib.h" + + +// /** +// * Extract an amount from a tuple including the currency from a Postgres +// * database @a result at row @a row. +// * +// * @param cls closure; not used +// * @param result where to extract data from +// * @param row row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_NO if at least one result was NULL +// * #GNUNET_SYSERR if a result was invalid (non-existing field) +// */ +// static enum GNUNET_GenericReturnValue +// extract_amount_currency_tuple (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_Amount *r_amount = dst; +// int col; + +// (void) cls; +// if (sizeof (struct TALER_Amount) != *dst_size) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } + +// /* Set return value to invalid in case we don't finish */ +// memset (r_amount, +// 0, +// sizeof (struct TALER_Amount)); +// col = PQfnumber (result, +// fname); +// if (col < 0) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Field `%s' does not exist in result\n", +// fname); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// col)) +// { +// return GNUNET_NO; +// } + +// /* Parse the tuple */ +// { +// struct TALER_PQ_AmountCurrencyP ap; +// const char *in; +// size_t size; + +// size = PQgetlength (result, +// row, +// col); +// if ( (size >= sizeof (ap)) || +// (size <= sizeof (ap) - TALER_CURRENCY_LEN) ) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Incorrect size of binary field `%s' (got %zu, expected (%zu-%zu))\n", +// fname, +// size, +// sizeof (ap) - TALER_CURRENCY_LEN, +// sizeof (ap)); +// return GNUNET_SYSERR; +// } + +// in = PQgetvalue (result, +// row, +// col); +// memset (&ap.c, +// 0, +// TALER_CURRENCY_LEN); +// memcpy (&ap, +// in, +// size); +// if (3 != ntohl (ap.cnt)) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Incorrect number of elements in tuple-field `%s'\n", +// fname); +// return GNUNET_SYSERR; +// } +// /* TODO[oec]: OID-checks? */ + +// r_amount->value = GNUNET_ntohll (ap.v); +// r_amount->fraction = ntohl (ap.f); +// memcpy (r_amount->currency, +// ap.c, +// TALER_CURRENCY_LEN); +// if ('\0' != r_amount->currency[TALER_CURRENCY_LEN - 1]) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Invalid currency (not 0-terminated) in tuple field `%s'\n", +// fname); +// /* be sure nobody uses this by accident */ +// memset (r_amount, +// 0, +// sizeof (struct TALER_Amount)); +// return GNUNET_SYSERR; +// } +// } + +// if (r_amount->value >= TALER_AMOUNT_MAX_VALUE) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Value in field `%s' exceeds legal range\n", +// fname); +// return GNUNET_SYSERR; +// } +// if (r_amount->fraction >= TALER_AMOUNT_FRAC_BASE) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Fraction in field `%s' exceeds legal range\n", +// fname); +// return GNUNET_SYSERR; +// } +// return GNUNET_OK; +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_amount_with_currency (const char *name, +// struct TALER_Amount *amount) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_amount_currency_tuple, +// .dst = (void *) amount, +// .dst_size = sizeof (*amount), +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract an amount from a tuple from a Postgres database @a result at row @a row. +// * +// * @param cls closure, a `const char *` giving the currency +// * @param result where to extract data from +// * @param row row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_NO if at least one result was NULL +// * #GNUNET_SYSERR if a result was invalid (non-existing field) +// */ +// static enum GNUNET_GenericReturnValue +// extract_amount_tuple (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_Amount *r_amount = dst; +// const char *currency = cls; +// int col; +// size_t len; + +// if (sizeof (struct TALER_Amount) != *dst_size) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } + +// /* Set return value to invalid in case we don't finish */ +// memset (r_amount, +// 0, +// sizeof (struct TALER_Amount)); +// col = PQfnumber (result, +// fname); +// if (col < 0) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Field `%s' does not exist in result\n", +// fname); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// col)) +// { +// return GNUNET_NO; +// } + +// /* Parse the tuple */ +// { +// struct TALER_PQ_AmountP ap; +// const char *in; +// size_t size; + +// size = PQgetlength (result, +// row, +// col); +// if (sizeof(ap) != size) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Incorrect size of binary field `%s' (got %zu, expected %zu)\n", +// fname, +// size, +// sizeof(ap)); +// return GNUNET_SYSERR; +// } + +// in = PQgetvalue (result, +// row, +// col); +// memcpy (&ap, +// in, +// size); +// if (2 != ntohl (ap.cnt)) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Incorrect number of elements in tuple-field `%s'\n", +// fname); +// return GNUNET_SYSERR; +// } +// /* TODO[oec]: OID-checks? */ + +// r_amount->value = GNUNET_ntohll (ap.v); +// r_amount->fraction = ntohl (ap.f); +// } + +// if (r_amount->value >= TALER_AMOUNT_MAX_VALUE) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Value in field `%s' exceeds legal range\n", +// fname); +// return GNUNET_SYSERR; +// } +// if (r_amount->fraction >= TALER_AMOUNT_FRAC_BASE) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Fraction in field `%s' exceeds legal range\n", +// fname); +// return GNUNET_SYSERR; +// } + +// len = GNUNET_MIN (TALER_CURRENCY_LEN - 1, +// strlen (currency)); + +// GNUNET_memcpy (r_amount->currency, +// currency, +// len); +// return GNUNET_OK; +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_amount (const char *name, +// const char *currency, +// struct TALER_Amount *amount) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_amount_tuple, +// .cls = (void *) currency, +// .dst = (void *) amount, +// .dst_size = sizeof (*amount), +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract data from a Postgres database @a result at row @a row. +// * +// * @param cls closure +// * @param result where to extract data from +// * @param row row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_NO if at least one result was NULL +// * #GNUNET_SYSERR if a result was invalid (non-existing field) +// */ +// static enum GNUNET_GenericReturnValue +// extract_json (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// json_t **j_dst = dst; +// const char *res; +// int fnum; +// json_error_t json_error; +// size_t slen; + +// (void) cls; +// (void) dst_size; +// fnum = PQfnumber (result, +// fname); +// if (fnum < 0) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Field `%s' does not exist in result\n", +// fname); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// fnum)) +// return GNUNET_NO; +// slen = PQgetlength (result, +// row, +// fnum); +// res = (const char *) PQgetvalue (result, +// row, +// fnum); +// *j_dst = json_loadb (res, +// slen, +// JSON_REJECT_DUPLICATES, +// &json_error); +// if (NULL == *j_dst) +// { +// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, +// "Failed to parse JSON result for field `%s': %s (%s)\n", +// fname, +// json_error.text, +// json_error.source); +// return GNUNET_SYSERR; +// } +// return GNUNET_OK; +// } + + +// /** +// * Function called to clean up memory allocated +// * by a #GNUNET_PQ_ResultConverter. +// * +// * @param cls closure +// * @param rd result data to clean up +// */ +// static void +// clean_json (void *cls, +// void *rd) +// { +// json_t **dst = rd; + +// (void) cls; +// if (NULL != *dst) +// { +// json_decref (*dst); +// *dst = NULL; +// } +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_json (const char *name, +// json_t **jp) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_json, +// .cleaner = &clean_json, +// .dst = (void *) jp, +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract data from a Postgres database @a result at row @a row. +// * +// * @param cls closure +// * @param result where to extract data from +// * @param row the row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) +// */ +// static enum GNUNET_GenericReturnValue +// extract_denom_pub (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_DenominationPublicKey *pk = dst; +// size_t len; +// const char *res; +// int fnum; +// uint32_t be[2]; + +// (void) cls; +// (void) dst_size; +// fnum = PQfnumber (result, +// fname); +// if (fnum < 0) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// fnum)) +// return GNUNET_NO; + +// /* if a field is null, continue but +// * remember that we now return a different result */ +// len = PQgetlength (result, +// row, +// fnum); +// res = PQgetvalue (result, +// row, +// fnum); +// if (len < sizeof (be)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (be, +// res, +// sizeof (be)); +// res += sizeof (be); +// len -= sizeof (be); +// pk->cipher = ntohl (be[0]); +// pk->age_mask.bits = ntohl (be[1]); +// switch (pk->cipher) +// { +// case TALER_DENOMINATION_RSA: +// pk->details.rsa_public_key +// = GNUNET_CRYPTO_rsa_public_key_decode (res, +// len); +// if (NULL == pk->details.rsa_public_key) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// return GNUNET_OK; +// case TALER_DENOMINATION_CS: +// if (sizeof (pk->details.cs_public_key) != len) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&pk->details.cs_public_key, +// res, +// len); +// return GNUNET_OK; +// default: +// GNUNET_break (0); +// } +// return GNUNET_SYSERR; +// } + + +// /** +// * Function called to clean up memory allocated +// * by a #GNUNET_PQ_ResultConverter. +// * +// * @param cls closure +// * @param rd result data to clean up +// */ +// static void +// clean_denom_pub (void *cls, +// void *rd) +// { +// struct TALER_DenominationPublicKey *denom_pub = rd; + +// (void) cls; +// TALER_denom_pub_free (denom_pub); +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_denom_pub (const char *name, +// struct TALER_DenominationPublicKey *denom_pub) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_denom_pub, +// .cleaner = &clean_denom_pub, +// .dst = (void *) denom_pub, +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract data from a Postgres database @a result at row @a row. +// * +// * @param cls closure +// * @param result where to extract data from +// * @param row the row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) +// */ +// static enum GNUNET_GenericReturnValue +// extract_denom_sig (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_DenominationSignature *sig = dst; +// size_t len; +// const char *res; +// int fnum; +// uint32_t be[2]; + +// (void) cls; +// (void) dst_size; +// fnum = PQfnumber (result, +// fname); +// if (fnum < 0) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// fnum)) +// return GNUNET_NO; + +// /* if a field is null, continue but +// * remember that we now return a different result */ +// len = PQgetlength (result, +// row, +// fnum); +// res = PQgetvalue (result, +// row, +// fnum); +// if (len < sizeof (be)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&be, +// res, +// sizeof (be)); +// if (0x00 != ntohl (be[1])) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// res += sizeof (be); +// len -= sizeof (be); +// sig->cipher = ntohl (be[0]); +// switch (sig->cipher) +// { +// case TALER_DENOMINATION_RSA: +// sig->details.rsa_signature +// = GNUNET_CRYPTO_rsa_signature_decode (res, +// len); +// if (NULL == sig->details.rsa_signature) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// return GNUNET_OK; +// case TALER_DENOMINATION_CS: +// if (sizeof (sig->details.cs_signature) != len) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&sig->details.cs_signature, +// res, +// len); +// return GNUNET_OK; +// default: +// GNUNET_break (0); +// } +// return GNUNET_SYSERR; +// } + + +// /** +// * Function called to clean up memory allocated +// * by a #GNUNET_PQ_ResultConverter. +// * +// * @param cls closure +// * @param rd result data to clean up +// */ +// static void +// clean_denom_sig (void *cls, +// void *rd) +// { +// struct TALER_DenominationSignature *denom_sig = rd; + +// (void) cls; +// TALER_denom_sig_free (denom_sig); +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_denom_sig (const char *name, +// struct TALER_DenominationSignature *denom_sig) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_denom_sig, +// .cleaner = &clean_denom_sig, +// .dst = (void *) denom_sig, +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract data from a Postgres database @a result at row @a row. +// * +// * @param cls closure +// * @param result where to extract data from +// * @param row the row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) +// */ +// static enum GNUNET_GenericReturnValue +// extract_blinded_denom_sig (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_BlindedDenominationSignature *sig = dst; +// size_t len; +// const char *res; +// int fnum; +// uint32_t be[2]; + +// (void) cls; +// (void) dst_size; +// fnum = PQfnumber (result, +// fname); +// if (fnum < 0) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// fnum)) +// return GNUNET_NO; + +// /* if a field is null, continue but +// * remember that we now return a different result */ +// len = PQgetlength (result, +// row, +// fnum); +// res = PQgetvalue (result, +// row, +// fnum); +// if (len < sizeof (be)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&be, +// res, +// sizeof (be)); +// if (0x01 != ntohl (be[1])) /* magic marker: blinded */ +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// res += sizeof (be); +// len -= sizeof (be); +// sig->cipher = ntohl (be[0]); +// switch (sig->cipher) +// { +// case TALER_DENOMINATION_RSA: +// sig->details.blinded_rsa_signature +// = GNUNET_CRYPTO_rsa_signature_decode (res, +// len); +// if (NULL == sig->details.blinded_rsa_signature) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// return GNUNET_OK; +// case TALER_DENOMINATION_CS: +// if (sizeof (sig->details.blinded_cs_answer) != len) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&sig->details.blinded_cs_answer, +// res, +// len); +// return GNUNET_OK; +// default: +// GNUNET_break (0); +// } +// return GNUNET_SYSERR; +// } + + +// /** +// * Function called to clean up memory allocated +// * by a #GNUNET_PQ_ResultConverter. +// * +// * @param cls closure +// * @param rd result data to clean up +// */ +// static void +// clean_blinded_denom_sig (void *cls, +// void *rd) +// { +// struct TALER_BlindedDenominationSignature *denom_sig = rd; + +// (void) cls; +// TALER_blinded_denom_sig_free (denom_sig); +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_blinded_denom_sig ( +// const char *name, +// struct TALER_BlindedDenominationSignature *denom_sig) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_blinded_denom_sig, +// .cleaner = &clean_blinded_denom_sig, +// .dst = (void *) denom_sig, +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract data from a Postgres database @a result at row @a row. +// * +// * @param cls closure +// * @param result where to extract data from +// * @param row the row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) +// */ +// static enum GNUNET_GenericReturnValue +// extract_blinded_planchet (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_BlindedPlanchet *bp = dst; +// size_t len; +// const char *res; +// int fnum; +// uint32_t be[2]; + +// (void) cls; +// (void) dst_size; +// fnum = PQfnumber (result, +// fname); +// if (fnum < 0) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// fnum)) +// return GNUNET_NO; + +// /* if a field is null, continue but +// * remember that we now return a different result */ +// len = PQgetlength (result, +// row, +// fnum); +// res = PQgetvalue (result, +// row, +// fnum); +// if (len < sizeof (be)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&be, +// res, +// sizeof (be)); +// if (0x0100 != ntohl (be[1])) /* magic marker: blinded */ +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// res += sizeof (be); +// len -= sizeof (be); +// bp->cipher = ntohl (be[0]); +// switch (bp->cipher) +// { +// case TALER_DENOMINATION_RSA: +// bp->details.rsa_blinded_planchet.blinded_msg_size +// = len; +// bp->details.rsa_blinded_planchet.blinded_msg +// = GNUNET_memdup (res, +// len); +// return GNUNET_OK; +// case TALER_DENOMINATION_CS: +// if (sizeof (bp->details.cs_blinded_planchet) != len) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&bp->details.cs_blinded_planchet, +// res, +// len); +// return GNUNET_OK; +// default: +// GNUNET_break (0); +// } +// return GNUNET_SYSERR; +// } + + +// /** +// * Function called to clean up memory allocated +// * by a #GNUNET_PQ_ResultConverter. +// * +// * @param cls closure +// * @param rd result data to clean up +// */ +// static void +// clean_blinded_planchet (void *cls, +// void *rd) +// { +// struct TALER_BlindedPlanchet *bp = rd; + +// (void) cls; +// TALER_blinded_planchet_free (bp); +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_blinded_planchet ( +// const char *name, +// struct TALER_BlindedPlanchet *bp) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_blinded_planchet, +// .cleaner = &clean_blinded_planchet, +// .dst = (void *) bp, +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Extract data from a Postgres database @a result at row @a row. +// * +// * @param cls closure +// * @param result where to extract data from +// * @param row row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) +// */ +// static enum GNUNET_GenericReturnValue +// extract_exchange_withdraw_values (void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// struct TALER_ExchangeWithdrawValues *alg_values = dst; +// size_t len; +// const char *res; +// int fnum; +// uint32_t be[2]; + +// (void) cls; +// (void) dst_size; +// fnum = PQfnumber (result, +// fname); +// if (fnum < 0) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// if (PQgetisnull (result, +// row, +// fnum)) +// return GNUNET_NO; + +// /* if a field is null, continue but +// * remember that we now return a different result */ +// len = PQgetlength (result, +// row, +// fnum); +// res = PQgetvalue (result, +// row, +// fnum); +// if (len < sizeof (be)) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&be, +// res, +// sizeof (be)); +// if (0x010000 != ntohl (be[1])) /* magic marker: EWV */ +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// res += sizeof (be); +// len -= sizeof (be); +// alg_values->cipher = ntohl (be[0]); +// switch (alg_values->cipher) +// { +// case TALER_DENOMINATION_RSA: +// if (0 != len) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// return GNUNET_OK; +// case TALER_DENOMINATION_CS: +// if (sizeof (struct TALER_DenominationCSPublicRPairP) != len) +// { +// GNUNET_break (0); +// return GNUNET_SYSERR; +// } +// GNUNET_memcpy (&alg_values->details.cs_values, +// res, +// len); +// return GNUNET_OK; +// default: +// GNUNET_break (0); +// } +// return GNUNET_SYSERR; +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_exchange_withdraw_values ( +// const char *name, +// struct TALER_ExchangeWithdrawValues *ewv) +// { +// struct GNUNET_PQ_ResultSpec res = { +// .conv = &extract_exchange_withdraw_values, +// .dst = (void *) ewv, +// .fname = name +// }; + +// return res; +// } + + +// /** +// * Closure for the array result specifications. Contains type information +// * for the generic parser extract_array_generic and out-pointers for the results. +// */ +// struct ArrayResultCls +// { +// /* Oid of the expected type, must match the oid in the header of the PQResult struct */ +// Oid oid; + +// /* Target type */ +// enum TALER_PQ_ArrayType typ; + +// /* If not 0, defines the expected size of each entry */ +// size_t same_size; + +// /* Out-pointer to write the number of elements in the array */ +// size_t *num; + +// /* Out-pointer. If @a typ is TALER_PQ_array_of_byte and @a same_size is 0, +// * allocate and put the array of @a num sizes here. NULL otherwise */ +// size_t **sizes; + +// /* DB_connection, needed for OID-lookup for composite types */ +// const struct GNUNET_PQ_Context *db; + +// /* Currency information for amount composites */ +// char currency[TALER_CURRENCY_LEN]; +// }; + +// /** +// * Extract data from a Postgres database @a result as array of a specific type +// * from row @a row. The type information and optionally additional +// * out-parameters are given in @a cls which is of type array_result_cls. +// * +// * @param cls closure of type array_result_cls +// * @param result where to extract data from +// * @param row row to extract data from +// * @param fname name (or prefix) of the fields to extract from +// * @param[in,out] dst_size where to store size of result, may be NULL +// * @param[out] dst where to store the result +// * @return +// * #GNUNET_YES if all results could be extracted +// * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) +// */ +// static enum GNUNET_GenericReturnValue +// extract_array_generic ( +// void *cls, +// PGresult *result, +// int row, +// const char *fname, +// size_t *dst_size, +// void *dst) +// { +// const struct ArrayResultCls *info = cls; +// int data_sz; +// char *data; +// void *out = NULL; +// struct GNUNET_PQ_ArrayHeader_P header; +// int col_num; + +// GNUNET_assert (NULL != dst); +// *((void **) dst) = NULL; + +// #define FAIL_IF(cond) \ +// do { \ +// if ((cond)) \ +// { \ +// GNUNET_break (! (cond)); \ +// goto FAIL; \ +// } \ +// } while (0) + +// col_num = PQfnumber (result, fname); +// FAIL_IF (0 > col_num); + +// data_sz = PQgetlength (result, row, col_num); +// FAIL_IF (0 > data_sz); +// FAIL_IF (sizeof(header) > (size_t) data_sz); + +// data = PQgetvalue (result, row, col_num); +// FAIL_IF (NULL == data); + +// { +// struct GNUNET_PQ_ArrayHeader_P *h = +// (struct GNUNET_PQ_ArrayHeader_P *) data; + +// header.ndim = ntohl (h->ndim); +// header.has_null = ntohl (h->has_null); +// header.oid = ntohl (h->oid); +// header.dim = ntohl (h->dim); +// header.lbound = ntohl (h->lbound); + +// FAIL_IF (1 != header.ndim); +// FAIL_IF (INT_MAX <= header.dim); +// FAIL_IF (0 != header.has_null); +// FAIL_IF (1 != header.lbound); +// FAIL_IF (info->oid != header.oid); +// } + +// if (NULL != info->num) +// *info->num = header.dim; + +// { +// char *in = data + sizeof(header); + +// switch (info->typ) +// { +// case TALER_PQ_array_of_amount: +// { +// struct TALER_Amount *amounts; +// if (NULL != dst_size) +// *dst_size = sizeof(struct TALER_Amount) * (header.dim); + +// amounts = GNUNET_new_array (header.dim, struct TALER_Amount); +// *((void **) dst) = amounts; + +// for (uint32_t i = 0; i < header.dim; i++) +// { +// struct TALER_PQ_AmountP ap; +// struct TALER_Amount *amount = &amounts[i]; +// uint32_t val; +// size_t sz; + +// GNUNET_memcpy (&val, +// in, +// sizeof(val)); +// sz = ntohl (val); +// in += sizeof(val); + +// /* total size for this array-entry */ +// FAIL_IF (sizeof(ap) > sz); + +// GNUNET_memcpy (&ap, +// in, +// sz); +// FAIL_IF (2 != ntohl (ap.cnt)); + +// amount->value = GNUNET_ntohll (ap.v); +// amount->fraction = ntohl (ap.f); +// GNUNET_memcpy (amount->currency, +// info->currency, +// TALER_CURRENCY_LEN); + +// in += sizeof(struct TALER_PQ_AmountP); +// } +// return GNUNET_OK; +// } +// case TALER_PQ_array_of_denom_hash: +// if (NULL != dst_size) +// *dst_size = sizeof(struct TALER_DenominationHashP) * (header.dim); +// out = GNUNET_new_array (header.dim, struct TALER_DenominationHashP); +// *((void **) dst) = out; +// for (uint32_t i = 0; i < header.dim; i++) +// { +// uint32_t val; +// size_t sz; + +// GNUNET_memcpy (&val, +// in, +// sizeof(val)); +// sz = ntohl (val); +// FAIL_IF (sz != sizeof(struct TALER_DenominationHashP)); +// in += sizeof(uint32_t); +// *(struct TALER_DenominationHashP *) out = +// *(struct TALER_DenominationHashP *) in; +// in += sz; +// out += sz; +// } +// return GNUNET_OK; + +// case TALER_PQ_array_of_blinded_coin_hash: +// if (NULL != dst_size) +// *dst_size = sizeof(struct TALER_BlindedCoinHashP) * (header.dim); +// out = GNUNET_new_array (header.dim, struct TALER_BlindedCoinHashP); +// *((void **) dst) = out; +// for (uint32_t i = 0; i < header.dim; i++) +// { +// uint32_t val; +// size_t sz; + +// GNUNET_memcpy (&val, +// in, +// sizeof(val)); +// sz = ntohl (val); +// FAIL_IF (sz != sizeof(struct TALER_BlindedCoinHashP)); +// in += sizeof(uint32_t); +// *(struct TALER_BlindedCoinHashP *) out = +// *(struct TALER_BlindedCoinHashP *) in; +// in += sz; +// out += sz; +// } +// return GNUNET_OK; + +// case TALER_PQ_array_of_blinded_denom_sig: +// { +// struct TALER_BlindedDenominationSignature *denom_sigs; +// if (0 == header.dim) +// { +// if (NULL != dst_size) +// *dst_size = 0; +// break; +// } + +// denom_sigs = GNUNET_new_array (header.dim, +// struct TALER_BlindedDenominationSignature); +// *((void **) dst) = denom_sigs; + +// /* copy data */ +// for (uint32_t i = 0; i < header.dim; i++) +// { +// struct TALER_BlindedDenominationSignature *denom_sig = &denom_sigs[i]; +// uint32_t be[2]; +// uint32_t val; +// size_t sz; + +// GNUNET_memcpy (&val, +// in, +// sizeof(val)); +// sz = ntohl (val); +// FAIL_IF (sizeof(be) > sz); + +// in += sizeof(val); +// GNUNET_memcpy (&be, +// in, +// sizeof(be)); +// FAIL_IF (0x01 != ntohl (be[1])); /* magic marker: blinded */ + +// in += sizeof(be); +// sz -= sizeof(be); + +// denom_sig->cipher = ntohl (be[0]); +// switch (denom_sig->cipher) +// { +// case TALER_DENOMINATION_RSA: +// denom_sig->details.blinded_rsa_signature = +// GNUNET_CRYPTO_rsa_signature_decode (in, +// sz); +// FAIL_IF (NULL == denom_sig->details.blinded_rsa_signature); +// break; + +// case TALER_DENOMINATION_CS: +// FAIL_IF (sizeof(denom_sig->details.blinded_cs_answer) != sz); +// GNUNET_memcpy (&denom_sig->details.blinded_cs_answer, +// in, +// sz); +// break; + +// default: +// FAIL_IF (true); +// } + +// in += sz; +// } +// return GNUNET_OK; +// } +// default: +// FAIL_IF (true); +// } +// } + +// FAIL: +// GNUNET_free (*(void **) dst); +// return GNUNET_SYSERR; +// #undef FAIL_IF + +// } + + +// /** +// * Cleanup of the data and closure of an array spec. +// */ +// static void +// array_cleanup (void *cls, +// void *rd) +// { + +// struct ArrayResultCls *info = cls; +// void **dst = rd; + +// if ((0 == info->same_size) && +// (NULL != info->sizes)) +// GNUNET_free (*(info->sizes)); + +// GNUNET_free (cls); +// GNUNET_free (*dst); +// *dst = NULL; +// } + + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_array_blinded_denom_sig ( +// struct GNUNET_PQ_Context *db, +// const char *name, +// size_t *num, +// struct TALER_BlindedDenominationSignature **denom_sigs) +// { +// struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); + +// info->num = num; +// info->typ = TALER_PQ_array_of_blinded_denom_sig; +// GNUNET_assert (GNUNET_OK == +// GNUNET_PQ_get_oid_by_name (db, +// "bytea", +// &info->oid)); + +// struct GNUNET_PQ_ResultSpec res = { +// .conv = extract_array_generic, +// .cleaner = array_cleanup, +// .dst = (void *) denom_sigs, +// .fname = name, +// .cls = info +// }; +// return res; + +// }; + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_array_blinded_coin_hash ( +// struct GNUNET_PQ_Context *db, +// const char *name, +// size_t *num, +// struct TALER_BlindedCoinHashP **h_coin_evs) +// { +// struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); + +// info->num = num; +// info->typ = TALER_PQ_array_of_blinded_coin_hash; +// GNUNET_assert (GNUNET_OK == +// GNUNET_PQ_get_oid_by_name (db, +// "bytea", +// &info->oid)); + +// struct GNUNET_PQ_ResultSpec res = { +// .conv = extract_array_generic, +// .cleaner = array_cleanup, +// .dst = (void *) h_coin_evs, +// .fname = name, +// .cls = info +// }; +// return res; + +// }; + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_array_denom_hash ( +// struct GNUNET_PQ_Context *db, +// const char *name, +// size_t *num, +// struct TALER_DenominationHashP **denom_hs) +// { +// struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); + +// info->num = num; +// info->typ = TALER_PQ_array_of_denom_hash; +// GNUNET_assert (GNUNET_OK == +// GNUNET_PQ_get_oid_by_name (db, +// "bytea", +// &info->oid)); + +// struct GNUNET_PQ_ResultSpec res = { +// .conv = extract_array_generic, +// .cleaner = array_cleanup, +// .dst = (void *) denom_hs, +// .fname = name, +// .cls = info +// }; +// return res; + +// }; + +// struct GNUNET_PQ_ResultSpec +// TALER_PQ_result_spec_array_amount ( +// struct GNUNET_PQ_Context *db, +// const char *name, +// const char *currency, +// size_t *num, +// struct TALER_Amount **amounts) +// { +// struct ArrayResultCls *info = GNUNET_new (struct ArrayResultCls); + +// info->num = num; +// info->typ = TALER_PQ_array_of_amount; +// info->db = db; +// GNUNET_assert (GNUNET_OK == +// GNUNET_PQ_get_oid_by_name (db, +// "taler_amount", +// &info->oid)); + +// { +// size_t clen = GNUNET_MIN (TALER_CURRENCY_LEN - 1, +// strlen (currency)); +// GNUNET_memcpy (&info->currency, +// currency, +// clen); +// } + +// struct GNUNET_PQ_ResultSpec res = { +// .conv = extract_array_generic, +// .cleaner = array_cleanup, +// .dst = (void *) amounts, +// .fname = name, +// .cls = info, +// }; +// return res; + + +// } /* end of pq_result_helper.c */ diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c @@ -18,7 +18,7 @@ * @brief Tests for Postgres convenience API * @author Christian Grothoff <christian@grothoff.org> */ -#include "platform.h" +#include "taler/platform.h" #include "taler_util.h" #include "taler_pq_lib.h" diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c @@ -23,18 +23,18 @@ * @author Christian Grothoff * @author Marcello Stanisci */ -#include "platform.h" +#include "taler/platform.h" #include "taler_util.h" #include "taler_signatures.h" #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_testing_lib.h> #include <microhttpd.h> #include "taler_bank_service.h" #include "taler_fakebank_lib.h" #include "taler_testing_lib.h" -#include "taler_extensions.h" +#include "taler/taler_extensions.h" /** * Configuration file we use. One (big) configuration is used @@ -114,7 +114,7 @@ run (void *cls, * Move money to the donau's bank account. */ CMD_TRANSFER_TO_DONAU ("create-reserve-1", - "EUR:6.02"), + "EUR:6.02"), TALER_TESTING_cmd_reserve_poll ("poll-reserve-1", "create-reserve-1", "EUR:6.02", @@ -259,7 +259,7 @@ run (void *cls, /* Fill reserve with EUR:5, 1ct is for fees. */ CMD_TRANSFER_TO_DONAU ("refresh-create-reserve-1", - "EUR:5.01"), + "EUR:5.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("ck-refresh-create-reserve-1", "EUR:5.01", cred.user42_payto, @@ -367,7 +367,7 @@ run (void *cls, * Move money to the donau's bank account. */ CMD_TRANSFER_TO_DONAU ("create-reserve-age", - "EUR:6.01"), + "EUR:6.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-age", "EUR:6.01", cred.user42_payto, @@ -519,7 +519,7 @@ run (void *cls, struct TALER_TESTING_Command unaggregation[] = { TALER_TESTING_cmd_check_bank_empty ("far-future-aggregation-a"), CMD_TRANSFER_TO_DONAU ("create-reserve-unaggregated", - "EUR:5.01"), + "EUR:5.01"), /* "consume" reserve creation transfer. */ TALER_TESTING_cmd_check_bank_admin_transfer ( "check-create-reserve-unaggregated", @@ -554,7 +554,7 @@ run (void *cls, struct TALER_TESTING_Command refresh_age[] = { /* Fill reserve with EUR:5, 1ct is for fees. */ CMD_TRANSFER_TO_DONAU ("refresh-create-reserve-age-1", - "EUR:6.01"), + "EUR:6.01"), TALER_TESTING_cmd_check_bank_admin_transfer ( "ck-refresh-create-reserve-age-1", "EUR:6.01", @@ -654,7 +654,7 @@ run (void *cls, */ struct TALER_TESTING_Command aggregation[] = { CMD_TRANSFER_TO_DONAU ("create-reserve-aggtest", - "EUR:5.01"), + "EUR:5.01"), /* "consume" reserve creation transfer. */ TALER_TESTING_cmd_check_bank_admin_transfer ( "check-create-reserve-aggtest", @@ -701,7 +701,7 @@ run (void *cls, * config. */ CMD_TRANSFER_TO_DONAU ("create-reserve-r1", - "EUR:5.01"), + "EUR:5.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-r1", "EUR:5.01", cred.user42_payto, @@ -806,7 +806,7 @@ run (void *cls, * refund deadline */ CMD_TRANSFER_TO_DONAU ("create-reserve-rb", - "EUR:5.01"), + "EUR:5.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-create-reserve-rb", "EUR:5.01", cred.user42_payto, @@ -851,7 +851,7 @@ run (void *cls, * config. */ CMD_TRANSFER_TO_DONAU ("recoup-create-reserve-1", - "EUR:15.02"), + "EUR:15.02"), TALER_TESTING_cmd_check_bank_admin_transfer ( "recoup-create-reserve-1-check", "EUR:15.02", @@ -982,7 +982,7 @@ run (void *cls, * the aggregator is given a config file that overrides * the reserve expiration time (making it now-ish) */ CMD_TRANSFER_TO_DONAU ("short-lived-reserve", - "EUR:5.01"), + "EUR:5.01"), TALER_TESTING_cmd_check_bank_admin_transfer ("check-short-lived-reserve", "EUR:5.01", cred.user42_payto, @@ -1019,7 +1019,7 @@ run (void *cls, * fails. Do not use EUR:5 here as the EUR:5 coin was * revoked and we did not bother to create a new one... */ CMD_TRANSFER_TO_DONAU ("recoup-create-reserve-2", - "EUR:2.02"), + "EUR:2.02"), TALER_TESTING_cmd_check_bank_admin_transfer ("ck-recoup-create-reserve-2", "EUR:2.02", cred.user42_payto, @@ -1089,7 +1089,7 @@ run (void *cls, MHD_HTTP_GONE), /* Test that revoked coins cannot be withdrawn */ CMD_TRANSFER_TO_DONAU ("recoup-create-reserve-3", - "EUR:1.01"), + "EUR:1.01"), TALER_TESTING_cmd_check_bank_admin_transfer ( "check-recoup-create-reserve-3", "EUR:1.01", @@ -1116,7 +1116,7 @@ run (void *cls, * Move money to the donau's bank account. */ CMD_TRANSFER_TO_DONAU ("create-batch-reserve-1", - "EUR:6.03"), + "EUR:6.03"), TALER_TESTING_cmd_reserve_poll ("poll-batch-reserve-1", "create-batch-reserve-1", "EUR:6.03", @@ -1191,7 +1191,7 @@ run (void *cls, { reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 0] = CMD_TRANSFER_TO_DONAU ("reserve-open-close-key", - "EUR:20"); + "EUR:20"); reserve_open_close[(i * RESERVE_OPEN_CLOSE_CHUNK) + 1] = TALER_TESTING_cmd_exec_wirewatch2 ("reserve-open-close-wirewatch", config_file_expire_reserve_now, @@ -1221,10 +1221,10 @@ run (void *cls, "-e", NULL), TALER_TESTING_cmd_get_donau ("get-donau", - cred.cfg, - NULL, - true, - true), + cred.cfg, + NULL, + true, + true), TALER_TESTING_cmd_batch ("withdraw", withdraw), TALER_TESTING_cmd_batch ("spend", diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c @@ -21,8 +21,8 @@ * @brief Implement batch-execution of CMDs. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" diff --git a/src/testing/testing_api_cmd_batch_deposit.c b/src/testing/testing_api_cmd_batch_deposit.c @@ -22,8 +22,8 @@ * @author Marcello Stanisci * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" #include "taler_signatures.h" @@ -111,7 +111,7 @@ struct BatchDepositState * Signing key used by the donau to sign the * deposit confirmation. */ - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; /** * Set (by the interpreter) to a fresh private key. This @@ -122,7 +122,7 @@ struct BatchDepositState /** * Deposit handle while operation is running. */ - struct TALER_DONAU_BatchDepositHandle *dh; + struct DONAU_BatchDepositHandle *dh; /** * Array of coins to batch-deposit. @@ -191,7 +191,7 @@ struct BatchDepositState */ static void batch_deposit_cb (void *cls, - const struct TALER_DONAU_BatchDepositResult *dr) + const struct DONAU_BatchDepositResult *dr) { struct BatchDepositState *ds = cls; @@ -215,9 +215,9 @@ batch_deposit_cb (void *cls, ds->donau_timestamp = dr->details.ok.deposit_timestamp; ds->donau_pub = *dr->details.ok.donau_pub; ds->donau_sigs = GNUNET_memdup (dr->details.ok.donau_sigs, - dr->details.ok.num_signatures - * sizeof (struct - TALER_DonauSignatureP)); + dr->details.ok.num_signatures + * sizeof (struct + TALER_DonauSignatureP)); } TALER_TESTING_interpreter_next (ds->is); } @@ -236,15 +236,15 @@ batch_deposit_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct BatchDepositState *ds = cls; - const struct TALER_DONAU_DenomPublicKey *denom_pub; + const struct DONAU_DenomPublicKey *denom_pub; const struct TALER_DenominationSignature *denom_pub_sig; - struct TALER_CharityPublicKeyP charity_pub; + struct DONAU_CharityPublicKeyP charity_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; struct TALER_WireSaltP wire_salt; struct TALER_CharityWireHashP h_wire; const char *payto_uri; - struct TALER_DONAU_CoinDepositDetail cdds[ds->num_coins]; + struct DONAU_CoinDepositDetail cdds[ds->num_coins]; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_string ("payto_uri", &payto_uri), @@ -288,7 +288,7 @@ batch_deposit_run (void *cls, } GNUNET_assert (GNUNET_OK == TALER_JSON_charity_wire_signature_hash (ds->wire_details, - &h_wire)); + &h_wire)); if (! GNUNET_TIME_absolute_is_zero (ds->refund_deadline.abs_time)) { struct GNUNET_TIME_Relative refund_deadline; @@ -312,7 +312,7 @@ batch_deposit_run (void *cls, for (unsigned int i = 0; i<ds->num_coins; i++) { struct Coin *coin = &ds->coins[i]; - struct TALER_DONAU_CoinDepositDetail *cdd = &cdds[i]; + struct DONAU_CoinDepositDetail *cdd = &cdds[i]; const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_AgeCommitmentProof *age_commitment_proof = NULL; @@ -377,7 +377,7 @@ batch_deposit_run (void *cls, GNUNET_assert (NULL == ds->dh); { - struct TALER_DONAU_DepositContractDetail dcd = { + struct DONAU_DepositContractDetail dcd = { .wire_deadline = ds->wire_deadline, .charity_payto_uri = payto_uri, .wire_salt = wire_salt, @@ -388,7 +388,7 @@ batch_deposit_run (void *cls, .refund_deadline = ds->refund_deadline }; - ds->dh = TALER_DONAU_batch_deposit ( + ds->dh = DONAU_batch_deposit ( TALER_TESTING_interpreter_get_context (is), donau_url, TALER_TESTING_get_keys (is), @@ -428,7 +428,7 @@ batch_deposit_cleanup (void *cls, { TALER_TESTING_command_incomplete (ds->is, cmd->label); - TALER_DONAU_batch_deposit_cancel (ds->dh); + DONAU_batch_deposit_cancel (ds->dh); ds->dh = NULL; } if (NULL != ds->retry_task) @@ -496,9 +496,9 @@ batch_deposit_traits (void *cls, /* First two traits are only available if ds->traits is #GNUNET_YES */ TALER_TESTING_make_trait_donau_pub (index, - &ds->donau_pub), + &ds->donau_pub), TALER_TESTING_make_trait_donau_sig (index, - &ds->donau_sigs[index]), + &ds->donau_sigs[index]), /* These traits are always available */ TALER_TESTING_make_trait_wire_details (ds->wire_details), TALER_TESTING_make_trait_contract_terms (ds->contract_terms), diff --git a/src/testing/testing_api_cmd_batch_withdraw.c b/src/testing/testing_api_cmd_batch_withdraw.c @@ -22,13 +22,13 @@ * @author Christian Grothoff * @author Marcello Stanisci */ -#include "platform.h" +#include "taler/platform.h" #include "taler_donau_service.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include <microhttpd.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" -#include "taler_extensions.h" +#include "taler/taler_extensions.h" #include "taler_testing_lib.h" /** @@ -49,7 +49,7 @@ struct CoinState * use. Otherwise, this will be set (by the interpreter) to the * denomination PK matching @e amount. */ - struct TALER_DONAU_DenomPublicKey *pk; + struct DONAU_DenomPublicKey *pk; /** * Private key of the coin. @@ -87,9 +87,9 @@ struct CoinState /** * Reserve history entry that corresponds to this coin. - * Will be of type #TALER_DONAU_RTT_WITHDRAWAL. + * Will be of type #DONAU_RTT_WITHDRAWAL. */ - struct TALER_DONAU_ReserveHistoryEntry reserve_history; + struct DONAU_ReserveHistoryEntry reserve_history; }; @@ -134,7 +134,7 @@ struct BatchWithdrawState /** * Withdraw handle (while operation is running). */ - struct TALER_DONAU_BatchWithdrawHandle *wsh; + struct DONAU_BatchWithdrawHandle *wsh; /** * Array of coin states. @@ -182,7 +182,7 @@ struct BatchWithdrawState static void reserve_batch_withdraw_cb (void *cls, const struct - TALER_DONAU_BatchWithdrawResponse *wr) + DONAU_BatchWithdrawResponse *wr) { struct BatchWithdrawState *ws = cls; struct TALER_TESTING_Interpreter *is = ws->is; @@ -201,7 +201,7 @@ reserve_batch_withdraw_cb (void *cls, for (unsigned int i = 0; i<ws->num_coins; i++) { struct CoinState *cs = &ws->coins[i]; - const struct TALER_DONAU_PrivateCoinDetails *pcd + const struct DONAU_PrivateCoinDetails *pcd = &wr->details.ok.coins[i]; TALER_denom_sig_deep_copy (&cs->sig, @@ -251,11 +251,11 @@ batch_withdraw_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct BatchWithdrawState *ws = cls; - const struct TALER_DONAU_Keys *keys = TALER_TESTING_get_keys (is); + const struct DONAU_Keys *keys = TALER_TESTING_get_keys (is); const struct TALER_ReservePrivateKeyP *rp; const struct TALER_TESTING_Command *create_reserve; - const struct TALER_DONAU_DenomPublicKey *dpk; - struct TALER_DONAU_WithdrawCoinInput wcis[ws->num_coins]; + const struct DONAU_DenomPublicKey *dpk; + struct DONAU_WithdrawCoinInput wcis[ws->num_coins]; (void) cmd; ws->is = is; @@ -291,7 +291,7 @@ batch_withdraw_run (void *cls, for (unsigned int i = 0; i<ws->num_coins; i++) { struct CoinState *cs = &ws->coins[i]; - struct TALER_DONAU_WithdrawCoinInput *wci = &wcis[i]; + struct DONAU_WithdrawCoinInput *wci = &wcis[i]; TALER_planchet_master_setup_random (&cs->ps); dpk = TALER_TESTING_find_pk (keys, @@ -308,8 +308,8 @@ batch_withdraw_run (void *cls, } /* We copy the denomination key, as re-querying /keys * would free the old one. */ - cs->pk = TALER_DONAU_copy_denomination_key (dpk); - cs->reserve_history.type = TALER_DONAU_RTT_WITHDRAWAL; + cs->pk = DONAU_copy_denomination_key (dpk); + cs->reserve_history.type = DONAU_RTT_WITHDRAWAL; GNUNET_assert (0 <= TALER_amount_add (&cs->reserve_history.amount, &cs->amount, @@ -320,7 +320,7 @@ batch_withdraw_run (void *cls, wci->ps = &cs->ps; wci->ach = &cs->h_age_commitment; } - ws->wsh = TALER_DONAU_batch_withdraw ( + ws->wsh = DONAU_batch_withdraw ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), keys, @@ -355,7 +355,7 @@ batch_withdraw_cleanup (void *cls, { TALER_TESTING_command_incomplete (ws->is, cmd->label); - TALER_DONAU_batch_withdraw_cancel (ws->wsh); + DONAU_batch_withdraw_cancel (ws->wsh); ws->wsh = NULL; } for (unsigned int i = 0; i<ws->num_coins; i++) @@ -365,7 +365,7 @@ batch_withdraw_cleanup (void *cls, TALER_denom_sig_free (&cs->sig); if (NULL != cs->pk) { - TALER_DONAU_destroy_denomination_key (cs->pk); + DONAU_destroy_denomination_key (cs->pk); cs->pk = NULL; } if (0 < ws->age) @@ -407,7 +407,7 @@ batch_withdraw_traits (void *cls, TALER_TESTING_make_trait_blinding_key (index, &cs->bks), TALER_TESTING_make_trait_donau_wd_value (index, - &cs->donau_vals), + &cs->donau_vals), TALER_TESTING_make_trait_denom_pub (index, cs->pk), TALER_TESTING_make_trait_denom_sig (index, diff --git a/src/testing/testing_api_cmd_common.c b/src/testing/testing_api_cmd_common.c @@ -21,20 +21,20 @@ * @brief common functions for commands * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include "taler_testing_lib.h" int TALER_TESTING_history_entry_cmp ( - const struct TALER_DONAU_ReserveHistoryEntry *h1, - const struct TALER_DONAU_ReserveHistoryEntry *h2) + const struct DONAU_ReserveHistoryEntry *h1, + const struct DONAU_ReserveHistoryEntry *h2) { if (h1->type != h2->type) return 1; switch (h1->type) { - case TALER_DONAU_RTT_CREDIT: + case DONAU_RTT_CREDIT: if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && @@ -47,7 +47,7 @@ TALER_TESTING_history_entry_cmp ( h2->details.in_details.timestamp)) ) return 0; return 1; - case TALER_DONAU_RTT_WITHDRAWAL: + case DONAU_RTT_WITHDRAWAL: if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && @@ -59,7 +59,7 @@ TALER_TESTING_history_entry_cmp ( that should be good enough. */ return 0; return 1; - case TALER_DONAU_RTT_AGEWITHDRAWAL: + case DONAU_RTT_AGEWITHDRAWAL: /* testing_api_cmd_age_withdraw doesn't set the out_authorization_sig, so we cannot test for it here. but if the amount matches, that should be good enough. */ @@ -73,7 +73,7 @@ TALER_TESTING_history_entry_cmp ( h2->details.age_withdraw.max_age)) return 0; return 1; - case TALER_DONAU_RTT_RECOUP: + case DONAU_RTT_RECOUP: /* donau_sig, donau_pub and timestamp are NOT available from the original recoup response, hence here NOT check(able/ed) */ if ( (0 == @@ -84,7 +84,7 @@ TALER_TESTING_history_entry_cmp ( &h2->details.recoup_details.coin_pub)) ) return 0; return 1; - case TALER_DONAU_RTT_CLOSING: + case DONAU_RTT_CLOSING: /* testing_api_cmd_exec_closer doesn't set the receiver_account_details, donau_sig, donau_pub or wtid or timestamp so we cannot test for it here. but if the amount matches, @@ -97,7 +97,7 @@ TALER_TESTING_history_entry_cmp ( &h2->details.close_details.fee)) ) return 0; return 1; - case TALER_DONAU_RTT_HISTORY: + case DONAU_RTT_HISTORY: if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && @@ -110,7 +110,7 @@ TALER_TESTING_history_entry_cmp ( &h2->details.history_details.reserve_sig)) ) return 0; return 1; - case TALER_DONAU_RTT_MERGE: + case DONAU_RTT_MERGE: if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && @@ -143,7 +143,7 @@ TALER_TESTING_history_entry_cmp ( h2->details.merge_details.flags) ) return 0; return 1; - case TALER_DONAU_RTT_OPEN: + case DONAU_RTT_OPEN: if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && @@ -165,7 +165,7 @@ TALER_TESTING_history_entry_cmp ( &h2->details.open_request.reserve_sig)) ) return 0; return 1; - case TALER_DONAU_RTT_CLOSE: + case DONAU_RTT_CLOSE: if ( (0 == TALER_amount_cmp (&h1->amount, &h2->amount)) && diff --git a/src/testing/testing_api_cmd_deposit.c b/src/testing/testing_api_cmd_deposit.c @@ -21,8 +21,8 @@ * @brief command for testing /deposit. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" #include "taler_signatures.h" @@ -98,7 +98,7 @@ struct DepositState /** * Deposit handle while operation is running. */ - struct TALER_DONAU_BatchDepositHandle *dh; + struct DONAU_BatchDepositHandle *dh; /** * Timestamp of the /deposit operation in the wallet (contract signing time). @@ -145,7 +145,7 @@ struct DepositState * Signing key used by the donau to sign the * deposit confirmation. */ - struct TALER_DonauPublicKeyP donau_pub; + struct DONAU_DonauPublicKeyP donau_pub; /** * Signature from the donau on the @@ -215,7 +215,7 @@ do_retry (void *cls) */ static void deposit_cb (void *cls, - const struct TALER_DONAU_BatchDepositResult *dr) + const struct DONAU_BatchDepositResult *dr) { struct DepositState *ds = cls; @@ -285,10 +285,10 @@ deposit_run (void *cls, const struct TALER_CoinSpendPrivateKeyP *coin_priv; struct TALER_CoinSpendPublicKeyP coin_pub; const struct TALER_AgeCommitmentHash *phac; - const struct TALER_DONAU_DenomPublicKey *denom_pub; + const struct DONAU_DenomPublicKey *denom_pub; const struct TALER_DenominationSignature *denom_pub_sig; struct TALER_CoinSpendSignatureP coin_sig; - struct TALER_CharityPublicKeyP charity_pub; + struct DONAU_CharityPublicKeyP charity_pub; struct TALER_PrivateContractHashP h_contract_terms; enum TALER_ErrorCode ec; struct TALER_WireSaltP wire_salt; @@ -352,7 +352,7 @@ deposit_run (void *cls, } if ( (GNUNET_OK != TALER_TESTING_get_trait_charity_priv (cmd, - &charity_priv)) ) + &charity_priv)) ) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -436,7 +436,7 @@ deposit_run (void *cls, GNUNET_assert (GNUNET_OK == TALER_JSON_charity_wire_signature_hash (ds->wire_details, - &h_wire)); + &h_wire)); TALER_wallet_deposit_sign (&ds->amount, &denom_pub->fees.deposit, &h_wire, @@ -453,7 +453,7 @@ deposit_run (void *cls, } GNUNET_assert (NULL == ds->dh); { - struct TALER_DONAU_CoinDepositDetail cdd = { + struct DONAU_CoinDepositDetail cdd = { .amount = ds->amount, .coin_pub = coin_pub, .coin_sig = coin_sig, @@ -461,7 +461,7 @@ deposit_run (void *cls, .h_denom_pub = denom_pub->h_key, .h_age_commitment = {{{0}}}, }; - struct TALER_DONAU_DepositContractDetail dcd = { + struct DONAU_DepositContractDetail dcd = { .wire_deadline = ds->wire_deadline, .charity_payto_uri = payto_uri, .wire_salt = wire_salt, @@ -474,7 +474,7 @@ deposit_run (void *cls, if (NULL != phac) cdd.h_age_commitment = *phac; - ds->dh = TALER_DONAU_batch_deposit ( + ds->dh = DONAU_batch_deposit ( TALER_TESTING_interpreter_get_context (is), donau_url, TALER_TESTING_get_keys (is), @@ -514,7 +514,7 @@ deposit_cleanup (void *cls, { TALER_TESTING_command_incomplete (ds->is, cmd->label); - TALER_DONAU_batch_deposit_cancel (ds->dh); + DONAU_batch_deposit_cancel (ds->dh); ds->dh = NULL; } if (NULL != ds->retry_task) @@ -589,9 +589,9 @@ deposit_traits (void *cls, /* First two traits are only available if ds->traits is #GNUNET_YES */ TALER_TESTING_make_trait_donau_pub (0, - &ds->donau_pub), + &ds->donau_pub), TALER_TESTING_make_trait_donau_sig (0, - &ds->donau_sig), + &ds->donau_sig), /* These traits are always available */ TALER_TESTING_make_trait_coin_priv (0, coin_spent_priv), diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c @@ -22,8 +22,8 @@ * @brief Implement the testing CMDs for the /deposits/ GET operations. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -88,7 +88,7 @@ struct TrackTransactionState /** * Handle to the "track transaction" pending operation. */ - struct TALER_DONAU_DepositGetHandle *tth; + struct DONAU_DepositGetHandle *tth; /** * Interpreter state. @@ -108,7 +108,7 @@ struct TrackTransactionState */ static void deposit_wtid_cb (void *cls, - const struct TALER_DONAU_GetDepositResponse *dr) + const struct DONAU_GetDepositResponse *dr) { struct TrackTransactionState *tts = cls; struct TALER_TESTING_Interpreter *is = tts->is; @@ -258,21 +258,21 @@ track_transaction_run (void *cls, GNUNET_assert ( (GNUNET_OK == TALER_JSON_charity_wire_signature_hash (wire_details, - &h_wire_details)) && + &h_wire_details)) && (GNUNET_OK == TALER_JSON_contract_hash (contract_terms, &h_contract_terms)) ); if (GNUNET_OK != TALER_TESTING_get_trait_charity_priv (transaction_cmd, - &charity_priv)) + &charity_priv)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (tts->is); return; } - tts->tth = TALER_DONAU_deposits_get ( + tts->tth = DONAU_deposits_get ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), TALER_TESTING_get_keys (is), @@ -304,7 +304,7 @@ track_transaction_cleanup (void *cls, { TALER_TESTING_command_incomplete (tts->is, cmd->label); - TALER_DONAU_deposits_get_cancel (tts->tth); + DONAU_deposits_get_cancel (tts->tth); tts->tth = NULL; } GNUNET_free (tts->charity_payto_uri); diff --git a/src/testing/testing_api_cmd_get_donau.c b/src/testing/testing_api_cmd_get_donau.c @@ -21,8 +21,8 @@ * @brief Command to get an donau handle * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -46,12 +46,12 @@ struct GetDonauState /** * Donau handle we produced. */ - struct TALER_DONAU_GetKeysHandle *donau; + struct DONAU_GetKeysHandle *donau; /** * Keys of the donau. */ - struct TALER_DONAU_Keys *keys; + struct DONAU_Keys *keys; /** * URL of the donau. @@ -91,11 +91,11 @@ struct GetDonauState */ static void cert_cb (void *cls, - const struct TALER_DONAU_KeysResponse *kr, - struct TALER_DONAU_Keys *keys) + const struct DONAU_KeysResponse *kr, + struct DONAU_Keys *keys) { struct GetDonauState *ges = cls; - const struct TALER_DONAU_HttpResponse *hr = &kr->hr; + const struct DONAU_HttpResponse *hr = &kr->hr; struct TALER_TESTING_Interpreter *is = ges->is; ges->donau = NULL; @@ -136,11 +136,11 @@ cert_cb (void *cls, */ static void get_donau_run (void *cls, - const struct TALER_TESTING_Command *cmd, - struct TALER_TESTING_Interpreter *is) + const struct TALER_TESTING_Command *cmd, + struct TALER_TESTING_Interpreter *is) { struct GetDonauState *ges = cls; - struct TALER_DONAU_Keys *xkeys = NULL; + struct DONAU_Keys *xkeys = NULL; (void) cmd; if (NULL == ges->donau_url) @@ -152,7 +152,7 @@ get_donau_run (void *cls, if (NULL != ges->last_keys_ref) { const struct TALER_TESTING_Command *state_cmd; - struct TALER_DONAU_Keys *old_keys; + struct DONAU_Keys *old_keys; const char *donau_url; json_t *s_keys; @@ -182,7 +182,7 @@ get_donau_run (void *cls, } if (GNUNET_OK != TALER_TESTING_get_trait_donau_url (state_cmd, - &donau_url)) + &donau_url)) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); @@ -195,14 +195,14 @@ get_donau_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - s_keys = TALER_DONAU_keys_to_json (old_keys); + s_keys = DONAU_keys_to_json (old_keys); if (NULL == s_keys) { GNUNET_break (0); TALER_TESTING_interpreter_fail (is); return; } - xkeys = TALER_DONAU_keys_from_json (s_keys); + xkeys = DONAU_keys_from_json (s_keys); if (NULL == xkeys) { GNUNET_break (0); @@ -223,19 +223,19 @@ get_donau_run (void *cls, &ges->master_priv.eddsa_priv)) { GNUNET_break (0); - TALER_DONAU_keys_decref (xkeys); + DONAU_keys_decref (xkeys); TALER_TESTING_interpreter_fail (is); return; } } ges->is = is; ges->donau - = TALER_DONAU_get_keys (TALER_TESTING_interpreter_get_context (is), - ges->donau_url, - xkeys, - &cert_cb, - ges); - TALER_DONAU_keys_decref (xkeys); + = DONAU_get_keys (TALER_TESTING_interpreter_get_context (is), + ges->donau_url, + xkeys, + &cert_cb, + ges); + DONAU_keys_decref (xkeys); if (NULL == ges->donau) { GNUNET_break (0); @@ -255,16 +255,16 @@ get_donau_run (void *cls, */ static void get_donau_cleanup (void *cls, - const struct TALER_TESTING_Command *cmd) + const struct TALER_TESTING_Command *cmd) { struct GetDonauState *ges = cls; if (NULL != ges->donau) { - TALER_DONAU_get_keys_cancel (ges->donau); + DONAU_get_keys_cancel (ges->donau); ges->donau = NULL; } - TALER_DONAU_keys_decref (ges->keys); + DONAU_keys_decref (ges->keys); ges->keys = NULL; GNUNET_free (ges->master_priv_file); GNUNET_free (ges->donau_url); @@ -283,9 +283,9 @@ get_donau_cleanup (void *cls, */ static enum GNUNET_GenericReturnValue get_donau_traits (void *cls, - const void **ret, - const char *trait, - unsigned int index) + const void **ret, + const char *trait, + unsigned int index) { struct GetDonauState *ges = cls; unsigned int off = (NULL == ges->master_priv_file) ? 1 : 0; diff --git a/src/testing/testing_api_cmd_insert_deposit.c b/src/testing/testing_api_cmd_insert_deposit.c @@ -22,13 +22,13 @@ * @author Marcello Stanisci * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include "taler_util.h" -#include "taler_json_lib.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" #include "taler_testing_lib.h" -#include "taler_donaudb_plugin.h" +#include "donaudb_plugin.h" #include "taler_donaudb_lib.h" @@ -40,7 +40,7 @@ struct InsertDepositState /** * Database connection we use. */ - struct TALER_DONAUDB_Plugin *plugin; + struct DONAUDB_Plugin *plugin; /** * Human-readable name of the shop. @@ -85,7 +85,7 @@ struct InsertDepositState * @param[out] issue information to initialize with "valid" data */ static void -fake_issue (struct TALER_DONAUDB_DenominationKeyInformation *issue) +fake_issue (struct DONAUDB_DenominationKeyInformation *issue) { struct GNUNET_TIME_Timestamp now; @@ -132,10 +132,10 @@ insert_deposit_run (void *cls, struct TALER_TESTING_Interpreter *is) { struct InsertDepositState *ids = cls; - struct TALER_DONAUDB_CoinDepositInformation deposit; - struct TALER_DONAUDB_BatchDeposit bd; + struct DONAUDB_CoinDepositInformation deposit; + struct DONAUDB_BatchDeposit bd; struct TALER_CharityPrivateKeyP charity_priv; - struct TALER_DONAUDB_DenominationKeyInformation issue; + struct DONAUDB_DenominationKeyInformation issue; struct TALER_DenominationPublicKey dpk; struct TALER_DenominationPrivateKey denom_priv; char *receiver_wire_account; @@ -331,7 +331,7 @@ insert_deposit_cleanup (void *cls, { // FIXME: historically, we also did: // ids->plugin->drop_tables (ids->plugin->cls); - TALER_DONAUDB_plugin_unload (ids->plugin); + DONAUDB_plugin_unload (ids->plugin); ids->plugin = NULL; } GNUNET_free (ids); @@ -349,7 +349,7 @@ TALER_TESTING_cmd_insert_deposit ( const char *amount_with_fee, const char *deposit_fee) { - static struct TALER_DONAUDB_Plugin *pluginc; + static struct DONAUDB_Plugin *pluginc; static const struct GNUNET_CONFIGURATION_Handle *db_cfgc; struct InsertDepositState *ids; @@ -361,7 +361,7 @@ TALER_TESTING_cmd_insert_deposit ( } else { - ids->plugin = TALER_DONAUDB_plugin_load (db_cfg); + ids->plugin = DONAUDB_plugin_load (db_cfg); pluginc = ids->plugin; db_cfgc = db_cfg; } diff --git a/src/testing/testing_api_cmd_offline_sign_extensions.c b/src/testing/testing_api_cmd_offline_sign_extensions.c @@ -22,8 +22,8 @@ * @brief run the taler-donau-offline command to sign extensions (and therefore activate them) * @author Özgür Kesim */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" #include "taler_testing_lib.h" diff --git a/src/testing/testing_api_cmd_offline_sign_global_fees.c b/src/testing/testing_api_cmd_offline_sign_global_fees.c @@ -23,8 +23,8 @@ * @author Marcello Stanisci * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" #include "taler_testing_lib.h" diff --git a/src/testing/testing_api_cmd_offline_sign_keys.c b/src/testing/testing_api_cmd_offline_sign_keys.c @@ -23,8 +23,8 @@ * @author Marcello Stanisci * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" #include "taler_testing_lib.h" diff --git a/src/testing/testing_api_cmd_reserve_close.c b/src/testing/testing_api_cmd_reserve_close.c @@ -21,8 +21,8 @@ * @brief Implement the /reserve/$RID/close test command. * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -41,7 +41,7 @@ struct CloseState /** * Handle to the "reserve close" operation. */ - struct TALER_DONAU_ReservesCloseHandle *rsh; + struct DONAU_ReservesCloseHandle *rsh; /** * payto://-URI where to wire the funds. @@ -91,7 +91,7 @@ struct CloseState */ static void reserve_close_cb (void *cls, - const struct TALER_DONAU_ReserveCloseResult *rs) + const struct DONAU_ReserveCloseResult *rs) { struct CloseState *ss = cls; struct TALER_TESTING_Interpreter *is = ss->is; @@ -165,7 +165,7 @@ close_run (void *cls, } GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv, &ss->reserve_pub.eddsa_pub); - ss->rsh = TALER_DONAU_reserves_close ( + ss->rsh = DONAU_reserves_close ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), ss->reserve_priv, @@ -192,7 +192,7 @@ close_cleanup (void *cls, { TALER_TESTING_command_incomplete (ss->is, cmd->label); - TALER_DONAU_reserves_close_cancel (ss->rsh); + DONAU_reserves_close_cancel (ss->rsh); ss->rsh = NULL; } GNUNET_free (ss); diff --git a/src/testing/testing_api_cmd_reserve_get.c b/src/testing/testing_api_cmd_reserve_get.c @@ -21,8 +21,8 @@ * @brief Implement the GET /reserve/$RID test command. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -81,7 +81,7 @@ struct StatusState /** * Handle to the "reserve status" operation. */ - struct TALER_DONAU_ReservesGetHandle *rsh; + struct DONAU_ReservesGetHandle *rsh; /** * Expected reserve balance. @@ -115,7 +115,7 @@ struct StatusState */ static void reserve_status_cb (void *cls, - const struct TALER_DONAU_ReserveSummary *rs) + const struct DONAU_ReserveSummary *rs) { struct StatusState *ss = cls; struct TALER_TESTING_Interpreter *is = ss->is; @@ -200,7 +200,7 @@ status_run (void *cls, TALER_TESTING_interpreter_fail (is); return; } - ss->rsh = TALER_DONAU_reserves_get ( + ss->rsh = DONAU_reserves_get ( TALER_TESTING_interpreter_get_context (is), donau_url, ss->reserve_pubp, @@ -232,7 +232,7 @@ status_cleanup (void *cls, { TALER_TESTING_command_incomplete (ss->is, cmd->label); - TALER_DONAU_reserves_get_cancel (ss->rsh); + DONAU_reserves_get_cancel (ss->rsh); ss->rsh = NULL; } GNUNET_free (ss); diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c @@ -21,8 +21,8 @@ * @brief Implement the /reserve/history test command. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -47,7 +47,7 @@ struct HistoryState /** * Handle to the "reserve history" operation. */ - struct TALER_DONAU_ReservesHistoryHandle *rsh; + struct DONAU_ReservesHistoryHandle *rsh; /** * Expected reserve balance. @@ -66,9 +66,9 @@ struct HistoryState /** * Reserve history entry that corresponds to this operation. - * Will be of type #TALER_DONAU_RTT_HISTORY. + * Will be of type #DONAU_RTT_HISTORY. */ - struct TALER_DONAU_ReserveHistoryEntry reserve_history; + struct DONAU_ReserveHistoryEntry reserve_history; /** * Expected HTTP response code. @@ -96,7 +96,7 @@ struct AnalysisContext /** * Array of history items to match. */ - const struct TALER_DONAU_ReserveHistoryEntry *history; + const struct DONAU_ReserveHistoryEntry *history; /** * Array of @e history_length of matched entries. @@ -124,7 +124,7 @@ analyze_command (void *cls, { struct AnalysisContext *ac = cls; const struct TALER_ReservePublicKeyP *reserve_pub = ac->reserve_pub; - const struct TALER_DONAU_ReserveHistoryEntry *history = ac->history; + const struct DONAU_ReserveHistoryEntry *history = ac->history; unsigned int history_length = ac->history_length; bool *found = ac->found; @@ -174,7 +174,7 @@ analyze_command (void *cls, return; /* command affects some _other_ reserve */ for (unsigned int j = 0; true; j++) { - const struct TALER_DONAU_ReserveHistoryEntry *he; + const struct DONAU_ReserveHistoryEntry *he; bool matched = false; if (GNUNET_OK != @@ -225,7 +225,7 @@ analyze_command (void *cls, */ static void reserve_history_cb (void *cls, - const struct TALER_DONAU_ReserveHistory *rs) + const struct DONAU_ReserveHistory *rs) { struct HistoryState *ss = cls; struct TALER_TESTING_Interpreter *is = ss->is; @@ -234,14 +234,14 @@ reserve_history_cb (void *cls, ss->rsh = NULL; if (MHD_HTTP_OK == rs->hr.http_status) { - struct TALER_DONAU_Keys *keys; - const struct TALER_DONAU_GlobalFee *gf; + struct DONAU_Keys *keys; + const struct DONAU_GlobalFee *gf; - ss->reserve_history.type = TALER_DONAU_RTT_HISTORY; + ss->reserve_history.type = DONAU_RTT_HISTORY; keys = TALER_TESTING_get_keys (is); GNUNET_assert (NULL != keys); - gf = TALER_DONAU_get_global_fee (keys, - rs->ts); + gf = DONAU_get_global_fee (keys, + rs->ts); GNUNET_assert (NULL != gf); ss->reserve_history.amount = gf->fees.history; ss->reserve_history.details.history_details.request_timestamp = rs->ts; @@ -361,7 +361,7 @@ history_run (void *cls, } GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv, &ss->reserve_pub.eddsa_pub); - ss->rsh = TALER_DONAU_reserves_history ( + ss->rsh = DONAU_reserves_history ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), TALER_TESTING_get_keys (is), @@ -421,7 +421,7 @@ history_cleanup (void *cls, { TALER_TESTING_command_incomplete (ss->is, cmd->label); - TALER_DONAU_reserves_history_cancel (ss->rsh); + DONAU_reserves_history_cancel (ss->rsh); ss->rsh = NULL; } GNUNET_free (ss); diff --git a/src/testing/testing_api_cmd_reserve_open.c b/src/testing/testing_api_cmd_reserve_open.c @@ -21,8 +21,8 @@ * @brief Implement the /reserve/$RID/open test command. * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -74,7 +74,7 @@ struct OpenState /** * Handle to the "reserve open" operation. */ - struct TALER_DONAU_ReservesOpenHandle *rsh; + struct DONAU_ReservesOpenHandle *rsh; /** * Expected reserve balance. @@ -122,7 +122,7 @@ struct OpenState */ static void reserve_open_cb (void *cls, - const struct TALER_DONAU_ReserveOpenResult *rs) + const struct DONAU_ReserveOpenResult *rs) { struct OpenState *ss = cls; struct TALER_TESTING_Interpreter *is = ss->is; @@ -164,7 +164,7 @@ open_run (void *cls, { struct OpenState *ss = cls; const struct TALER_TESTING_Command *create_reserve; - struct TALER_DONAU_PurseDeposit cp[GNUNET_NZL (ss->cpl)]; + struct DONAU_PurseDeposit cp[GNUNET_NZL (ss->cpl)]; ss->is = is; create_reserve @@ -190,12 +190,12 @@ open_run (void *cls, &ss->reserve_pub.eddsa_pub); for (unsigned int i = 0; i<ss->cpl; i++) { - struct TALER_DONAU_PurseDeposit *cpi = &cp[i]; + struct DONAU_PurseDeposit *cpi = &cp[i]; const struct TALER_TESTING_Command *cmdi; const struct TALER_AgeCommitmentProof *age_commitment_proof; const struct TALER_CoinSpendPrivateKeyP *coin_priv; const struct TALER_DenominationSignature *denom_sig; - const struct TALER_DONAU_DenomPublicKey *denom_pub; + const struct DONAU_DenomPublicKey *denom_pub; char *cref; unsigned int cidx; @@ -251,7 +251,7 @@ open_run (void *cls, cpi->amount = ss->cd[i].amount; cpi->h_denom_pub = denom_pub->h_key; } - ss->rsh = TALER_DONAU_reserves_open ( + ss->rsh = DONAU_reserves_open ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), TALER_TESTING_get_keys (is), @@ -283,7 +283,7 @@ open_cleanup (void *cls, { TALER_TESTING_command_incomplete (ss->is, cmd->label); - TALER_DONAU_reserves_open_cancel (ss->rsh); + DONAU_reserves_open_cancel (ss->rsh); ss->rsh = NULL; } GNUNET_free (ss); diff --git a/src/testing/testing_api_cmd_reserve_status.c b/src/testing/testing_api_cmd_reserve_status.c @@ -21,8 +21,8 @@ * @brief Implement the /reserve/$RID/status test command. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -41,7 +41,7 @@ struct StatusState /** * Handle to the "reserve status" operation. */ - struct TALER_DONAU_ReservesStatusHandle *rsh; + struct DONAU_ReservesStatusHandle *rsh; /** * Expected reserve balance. @@ -87,7 +87,7 @@ struct AnalysisContext /** * Array of history items to match. */ - const struct TALER_DONAU_ReserveHistoryEntry *history; + const struct DONAU_ReserveHistoryEntry *history; /** * Array of @e history_length of matched entries. @@ -115,7 +115,7 @@ analyze_command (void *cls, { struct AnalysisContext *ac = cls; const struct TALER_ReservePublicKeyP *reserve_pub = ac->reserve_pub; - const struct TALER_DONAU_ReserveHistoryEntry *history = ac->history; + const struct DONAU_ReserveHistoryEntry *history = ac->history; unsigned int history_length = ac->history_length; bool *found = ac->found; @@ -165,7 +165,7 @@ analyze_command (void *cls, return; /* command affects some _other_ reserve */ for (unsigned int j = 0; true; j++) { - const struct TALER_DONAU_ReserveHistoryEntry *he; + const struct DONAU_ReserveHistoryEntry *he; bool matched = false; if (GNUNET_OK != @@ -215,7 +215,7 @@ analyze_command (void *cls, */ static void reserve_status_cb (void *cls, - const struct TALER_DONAU_ReserveStatus *rs) + const struct DONAU_ReserveStatus *rs) { struct StatusState *ss = cls; struct TALER_TESTING_Interpreter *is = ss->is; @@ -337,7 +337,7 @@ status_run (void *cls, } GNUNET_CRYPTO_eddsa_key_get_public (&ss->reserve_priv->eddsa_priv, &ss->reserve_pub.eddsa_pub); - ss->rsh = TALER_DONAU_reserves_status ( + ss->rsh = DONAU_reserves_status ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), TALER_TESTING_get_keys (is), @@ -364,7 +364,7 @@ status_cleanup (void *cls, { TALER_TESTING_command_incomplete (ss->is, cmd->label); - TALER_DONAU_reserves_status_cancel (ss->rsh); + DONAU_reserves_status_cancel (ss->rsh); ss->rsh = NULL; } GNUNET_free (ss); diff --git a/src/testing/testing_api_cmd_revoke.c b/src/testing/testing_api_cmd_revoke.c @@ -21,8 +21,8 @@ * @brief Implement the revoke test command. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -135,7 +135,7 @@ revoke_run (void *cls, { struct RevokeState *rs = cls; const struct TALER_TESTING_Command *coin_cmd; - const struct TALER_DONAU_DenomPublicKey *denom_pub; + const struct DONAU_DenomPublicKey *denom_pub; rs->is = is; /* Get denom pub from trait */ diff --git a/src/testing/testing_api_cmd_revoke_denom_key.c b/src/testing/testing_api_cmd_revoke_denom_key.c @@ -21,8 +21,8 @@ * @brief Implement the revoke test command. * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" #include "taler_testing_lib.h" @@ -51,7 +51,7 @@ struct RevokeState /** * Handle for the operation. */ - struct TALER_DONAU_ManagementRevokeDenominationKeyHandle *kh; + struct DONAU_ManagementRevokeDenominationKeyHandle *kh; /** * Should we use a bogus signature? @@ -70,10 +70,10 @@ struct RevokeState static void success_cb ( void *cls, - const struct TALER_DONAU_ManagementRevokeDenominationResponse *rdr) + const struct DONAU_ManagementRevokeDenominationResponse *rdr) { struct RevokeState *rs = cls; - const struct TALER_DONAU_HttpResponse *hr = &rdr->hr; + const struct DONAU_HttpResponse *hr = &rdr->hr; rs->kh = NULL; if (rs->expected_response_code != hr->http_status) @@ -101,7 +101,7 @@ revoke_cleanup (void *cls, if (NULL != rs->kh) { - TALER_DONAU_management_revoke_denomination_key_cancel (rs->kh); + DONAU_management_revoke_denomination_key_cancel (rs->kh); rs->kh = NULL; } GNUNET_free (rs); @@ -150,7 +150,7 @@ revoke_run (void *cls, { struct RevokeState *rs = cls; const struct TALER_TESTING_Command *coin_cmd; - const struct TALER_DONAU_DenomPublicKey *denom_pub; + const struct DONAU_DenomPublicKey *denom_pub; struct TALER_MasterSignatureP master_sig; const char *donau_url; @@ -158,7 +158,7 @@ revoke_run (void *cls, const struct TALER_TESTING_Command *donau_cmd; donau_cmd = TALER_TESTING_interpreter_get_command (is, - "donau"); + "donau"); if (NULL == donau_cmd) { GNUNET_break (0); @@ -167,7 +167,7 @@ revoke_run (void *cls, } GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_donau_url (donau_cmd, - &donau_url)); + &donau_url)); } rs->is = is; /* Get denom pub from trait */ @@ -199,7 +199,7 @@ revoke_run (void *cls, const struct TALER_MasterPrivateKeyP *master_priv; donau_cmd = TALER_TESTING_interpreter_get_command (is, - "donau"); + "donau"); if (NULL == donau_cmd) { GNUNET_break (0); @@ -210,10 +210,10 @@ revoke_run (void *cls, TALER_TESTING_get_trait_master_priv (donau_cmd, &master_priv)); TALER_donau_offline_denomination_revoke_sign (&denom_pub->h_key, - master_priv, - &master_sig); + master_priv, + &master_sig); } - rs->kh = TALER_DONAU_management_revoke_denomination_key ( + rs->kh = DONAU_management_revoke_denomination_key ( TALER_TESTING_interpreter_get_context (is), donau_url, &denom_pub->h_key, diff --git a/src/testing/testing_api_cmd_revoke_sign_key.c b/src/testing/testing_api_cmd_revoke_sign_key.c @@ -21,8 +21,8 @@ * @brief Implement the revoke test command. * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" #include "taler_testing_lib.h" @@ -51,7 +51,7 @@ struct RevokeState /** * Handle for the operation. */ - struct TALER_DONAU_ManagementRevokeSigningKeyHandle *kh; + struct DONAU_ManagementRevokeSigningKeyHandle *kh; /** * Should we use a bogus signature? @@ -70,10 +70,10 @@ struct RevokeState static void success_cb ( void *cls, - const struct TALER_DONAU_ManagementRevokeSigningKeyResponse *rsr) + const struct DONAU_ManagementRevokeSigningKeyResponse *rsr) { struct RevokeState *rs = cls; - const struct TALER_DONAU_HttpResponse *hr = &rsr->hr; + const struct DONAU_HttpResponse *hr = &rsr->hr; rs->kh = NULL; if (rs->expected_response_code != hr->http_status) @@ -101,7 +101,7 @@ revoke_cleanup (void *cls, if (NULL != rs->kh) { - TALER_DONAU_management_revoke_signing_key_cancel (rs->kh); + DONAU_management_revoke_signing_key_cancel (rs->kh); rs->kh = NULL; } GNUNET_free (rs); @@ -150,7 +150,7 @@ revoke_run (void *cls, { struct RevokeState *rs = cls; const struct TALER_TESTING_Command *coin_cmd; - const struct TALER_DonauPublicKeyP *donau_pub; + const struct DONAU_DonauPublicKeyP *donau_pub; struct TALER_MasterSignatureP master_sig; const char *donau_url; @@ -158,7 +158,7 @@ revoke_run (void *cls, const struct TALER_TESTING_Command *donau_cmd; donau_cmd = TALER_TESTING_interpreter_get_command (is, - "donau"); + "donau"); if (NULL == donau_cmd) { GNUNET_break (0); @@ -167,7 +167,7 @@ revoke_run (void *cls, } GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_donau_url (donau_cmd, - &donau_url)); + &donau_url)); } rs->is = is; /* Get sign pub from trait */ @@ -182,8 +182,8 @@ revoke_run (void *cls, } GNUNET_assert (GNUNET_OK == TALER_TESTING_get_trait_donau_pub (coin_cmd, - 0, - &donau_pub)); + 0, + &donau_pub)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Trying to revoke sign '%s..'\n", TALER_B2S (donau_pub)); @@ -199,7 +199,7 @@ revoke_run (void *cls, const struct TALER_MasterPrivateKeyP *master_priv; donau_cmd = TALER_TESTING_interpreter_get_command (is, - "donau"); + "donau"); if (NULL == donau_cmd) { GNUNET_break (0); @@ -210,10 +210,10 @@ revoke_run (void *cls, TALER_TESTING_get_trait_master_priv (donau_cmd, &master_priv)); TALER_donau_offline_signkey_revoke_sign (donau_pub, - master_priv, - &master_sig); + master_priv, + &master_sig); } - rs->kh = TALER_DONAU_management_revoke_signing_key ( + rs->kh = DONAU_management_revoke_signing_key ( TALER_TESTING_interpreter_get_context (is), donau_url, donau_pub, diff --git a/src/testing/testing_api_cmd_stat.c b/src/testing/testing_api_cmd_stat.c @@ -21,8 +21,8 @@ * @brief command(s) to get performance statistics on other commands * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" diff --git a/src/testing/testing_api_cmd_transfer_get.c b/src/testing/testing_api_cmd_transfer_get.c @@ -22,8 +22,8 @@ * @brief Implement the testing CMDs for the /transfer GET operation. * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" @@ -72,7 +72,7 @@ struct TrackTransferState /** * Handle to a pending "track transfer" operation. */ - struct TALER_DONAU_TransfersGetHandle *tth; + struct DONAU_TransfersGetHandle *tth; /** * Interpreter state. @@ -105,7 +105,7 @@ track_transfer_cleanup (void *cls, { TALER_TESTING_command_incomplete (tts->is, cmd->label); - TALER_DONAU_transfers_get_cancel (tts->tth); + DONAU_transfers_get_cancel (tts->tth); tts->tth = NULL; } GNUNET_free (tts); @@ -122,10 +122,10 @@ track_transfer_cleanup (void *cls, */ static void track_transfer_cb (void *cls, - const struct TALER_DONAU_TransfersGetResponse *tgr) + const struct DONAU_TransfersGetResponse *tgr) { struct TrackTransferState *tts = cls; - const struct TALER_DONAU_HttpResponse *hr = &tgr->hr; + const struct DONAU_HttpResponse *hr = &tgr->hr; struct TALER_TESTING_Interpreter *is = tts->is; struct TALER_Amount expected_amount; @@ -142,7 +142,7 @@ track_transfer_cb (void *cls, { case MHD_HTTP_OK: { - const struct TALER_DONAU_TransferData *ta + const struct DONAU_TransferData *ta = &tgr->details.ok.td; if (NULL == tts->expected_total_amount) @@ -342,7 +342,7 @@ track_transfer_run (void *cls, } GNUNET_assert (NULL != wtid_ptr); } - tts->tth = TALER_DONAU_transfers_get ( + tts->tth = DONAU_transfers_get ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), TALER_TESTING_get_keys (is), diff --git a/src/testing/testing_api_cmd_wait.c b/src/testing/testing_api_cmd_wait.c @@ -21,8 +21,8 @@ * @brief command(s) to wait on some process * @author Christian Grothoff */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <gnunet/gnunet_curl_lib.h> #include "taler_testing_lib.h" diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c @@ -22,12 +22,12 @@ * @author Christian Grothoff * @author Marcello Stanisci */ -#include "platform.h" -#include "taler_json_lib.h" +#include "taler/platform.h" +#include "taler/taler_json_lib.h" #include <microhttpd.h> #include <gnunet/gnunet_curl_lib.h> #include "taler_signatures.h" -#include "taler_extensions.h" +#include "taler/taler_extensions.h" #include "taler_testing_lib.h" #include "backoff.h" @@ -83,7 +83,7 @@ struct WithdrawState * use. Otherwise, this will be set (by the interpreter) to the * denomination PK matching @e amount. */ - struct TALER_DONAU_DenomPublicKey *pk; + struct DONAU_DenomPublicKey *pk; /** * Donau base URL. Only used as offered trait. @@ -151,14 +151,14 @@ struct WithdrawState /** * Reserve history entry that corresponds to this operation. - * Will be of type #TALER_DONAU_RTT_WITHDRAWAL. + * Will be of type #DONAU_RTT_WITHDRAWAL. */ - struct TALER_DONAU_ReserveHistoryEntry reserve_history; + struct DONAU_ReserveHistoryEntry reserve_history; /** * Withdraw handle (while operation is running). */ - struct TALER_DONAU_WithdrawHandle *wsh; + struct DONAU_WithdrawHandle *wsh; /** * Task scheduled to try later. @@ -242,7 +242,7 @@ do_retry (void *cls) */ static void reserve_withdraw_cb (void *cls, - const struct TALER_DONAU_WithdrawResponse *wr) + const struct DONAU_WithdrawResponse *wr) { struct WithdrawState *ws = cls; struct TALER_TESTING_Interpreter *is = ws->is; @@ -348,7 +348,7 @@ withdraw_run (void *cls, struct WithdrawState *ws = cls; const struct TALER_ReservePrivateKeyP *rp; const struct TALER_TESTING_Command *create_reserve; - const struct TALER_DONAU_DenomPublicKey *dpk; + const struct DONAU_DenomPublicKey *dpk; if (NULL != cmd) ws->cmd = cmd; @@ -423,26 +423,26 @@ withdraw_run (void *cls, } /* We copy the denomination key, as re-querying /keys * would free the old one. */ - ws->pk = TALER_DONAU_copy_denomination_key (dpk); + ws->pk = DONAU_copy_denomination_key (dpk); } else { ws->amount = ws->pk->value; } - ws->reserve_history.type = TALER_DONAU_RTT_WITHDRAWAL; + ws->reserve_history.type = DONAU_RTT_WITHDRAWAL; GNUNET_assert (0 <= TALER_amount_add (&ws->reserve_history.amount, &ws->amount, &ws->pk->fees.withdraw)); ws->reserve_history.details.withdraw.fee = ws->pk->fees.withdraw; { - struct TALER_DONAU_WithdrawCoinInput wci = { + struct DONAU_WithdrawCoinInput wci = { .pk = ws->pk, .ps = &ws->ps, .ach = 0 < ws->age ? &ws->h_age_commitment : NULL }; - ws->wsh = TALER_DONAU_withdraw ( + ws->wsh = DONAU_withdraw ( TALER_TESTING_interpreter_get_context (is), TALER_TESTING_get_donau_url (is), TALER_TESTING_get_keys (is), @@ -477,7 +477,7 @@ withdraw_cleanup (void *cls, { TALER_TESTING_command_incomplete (ws->is, cmd->label); - TALER_DONAU_withdraw_cancel (ws->wsh); + DONAU_withdraw_cancel (ws->wsh); ws->wsh = NULL; } if (NULL != ws->retry_task) @@ -488,7 +488,7 @@ withdraw_cleanup (void *cls, TALER_denom_sig_free (&ws->sig); if (NULL != ws->pk) { - TALER_DONAU_destroy_denomination_key (ws->pk); + DONAU_destroy_denomination_key (ws->pk); ws->pk = NULL; } if (ws->age > 0) @@ -526,7 +526,7 @@ withdraw_traits (void *cls, TALER_TESTING_make_trait_blinding_key (0 /* only one coin */, &ws->bks), TALER_TESTING_make_trait_donau_wd_value (0 /* only one coin */, - &ws->donau_vals), + &ws->donau_vals), TALER_TESTING_make_trait_denom_pub (0 /* only one coin */, ws->pk), TALER_TESTING_make_trait_denom_sig (0 /* only one coin */, @@ -651,7 +651,7 @@ struct TALER_TESTING_Command TALER_TESTING_cmd_withdraw_denomination ( const char *label, const char *reserve_reference, - const struct TALER_DONAU_DenomPublicKey *dk, + const struct DONAU_DenomPublicKey *dk, unsigned int expected_response_code) { struct WithdrawState *ws; @@ -665,7 +665,7 @@ TALER_TESTING_cmd_withdraw_denomination ( } ws = GNUNET_new (struct WithdrawState); ws->reserve_reference = reserve_reference; - ws->pk = TALER_DONAU_copy_denomination_key (dk); + ws->pk = DONAU_copy_denomination_key (dk); ws->expected_response_code = expected_response_code; { struct TALER_TESTING_Command cmd = { diff --git a/src/testing/testing_api_misc.c b/src/testing/testing_api_misc.c @@ -21,7 +21,7 @@ * @brief non-command functions useful for writing tests * @author Christian Grothoff */ -#include "platform.h" +#include "taler/platform.h" #include <gnunet/gnunet_util_lib.h> #include "taler_testing_lib.h" #include "taler_fakebank_lib.h" @@ -259,14 +259,14 @@ TALER_TESTING_cleanup_files_cfg ( } -const struct TALER_DONAU_DenomPublicKey * +const struct DONAU_DenomPublicKey * TALER_TESTING_find_pk ( - const struct TALER_DONAU_Keys *keys, + const struct DONAU_Keys *keys, const struct TALER_Amount *amount, bool age_restricted) { struct GNUNET_TIME_Timestamp now; - struct TALER_DONAU_DenomPublicKey *pk; + struct DONAU_DenomPublicKey *pk; char *str; now = GNUNET_TIME_timestamp_get (); diff --git a/src/util/donau_signatures.c b/src/util/donau_signatures.c @@ -35,7 +35,7 @@ struct DONAU_DonationStatementConfirmationPS { /** * Purpose must be #DONAU_SIGNATURE_DONAU_DONATION_STATEMENT. Signed - * by a `struct TALER_DONAU_EddsaPublicKeyP` using EdDSA. + * by a `struct DONAU_EddsaPublicKeyP` using EdDSA. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;