exchange

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

commit 8c915fd5e3f54c86ebb6249f627d43e1a855d5c4
parent 36ceb50a187d0dbd97bfc1b7ac66388968383adb
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Thu,  5 Mar 2026 15:16:17 +0100

adapt to latest wire gateway specification

Diffstat:
Msrc/bank-lib/bank_api_registration.c | 77+++++++++++++++++++++++++++++++----------------------------------------------
Msrc/include/taler/taler_bank_service.h | 9++++++---
2 files changed, 37 insertions(+), 49 deletions(-)

diff --git a/src/bank-lib/bank_api_registration.c b/src/bank-lib/bank_api_registration.c @@ -61,30 +61,6 @@ struct TALER_BANK_RegistrationHandle /** - * Convert a #TALER_BANK_SubjectFormat enum value to its JSON string - * representation as used by the wire gateway API. - * - * @param fmt the format enum value - * @return corresponding string, or NULL for unknown values - */ -static const char * -format_to_string (enum TALER_BANK_SubjectFormat fmt) -{ - switch (fmt) - { - case TALER_BANK_SUBJECT_FORMAT_SIMPLE: - return "SIMPLE"; - case TALER_BANK_SUBJECT_FORMAT_URI: - return "URI"; - case TALER_BANK_SUBJECT_FORMAT_CH_QR_BILL: - return "CH_QR_BILL"; - } - GNUNET_break (0); - return NULL; -} - - -/** * Parse the "subject" field of a successful /registration response. * The field is a JSON object discriminated by "type". * @@ -213,10 +189,10 @@ handle_registration_finished (void *cls, break; case MHD_HTTP_OK: { - const json_t *subject_json; + const json_t *subjects; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_object_const ("subject", - &subject_json), + GNUNET_JSON_spec_array_const ("subjects", + &subjects), GNUNET_JSON_spec_timestamp ("expiration", &rr.details.ok.expiration), GNUNET_JSON_spec_end () @@ -232,14 +208,34 @@ handle_registration_finished (void *cls, rr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; break; } - if (GNUNET_OK != - parse_transfer_subject (subject_json, - &rr.details.ok.subject)) + { - GNUNET_break_op (0); - rr.http_status = 0; - rr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; - break; + size_t n = json_array_size (subjects); + struct TALER_BANK_TransferSubject ts[GNUNET_NZL (n)]; + size_t i; + const json_t *subject; + + json_array_foreach ((json_t *) subjects, i, subject) + { + if (GNUNET_OK != + parse_transfer_subject (subject, + &ts[i])) + { + GNUNET_break_op (0); + rr.http_status = 0; + rr.ec = TALER_EC_GENERIC_INVALID_RESPONSE; + break; + } + } + if (MHD_HTTP_OK == rr.http_status) + { + rr.details.ok.num_subjects = n; + rr.details.ok.subjects = ts; + rh->cb (rh->cb_cls, + &rr); + TALER_BANK_registration_cancel (rh); + return; + } } } break; @@ -279,7 +275,6 @@ struct TALER_BANK_RegistrationHandle * TALER_BANK_registration ( struct GNUNET_CURL_Context *ctx, const char *base_url, - enum TALER_BANK_SubjectFormat format, const struct TALER_Amount *credit_amount, enum TALER_BANK_RegistrationType type, const union TALER_AccountPublicKeyP *account_pub, @@ -291,7 +286,6 @@ TALER_BANK_registration ( struct TALER_ReserveMapAuthorizationPublicKeyP authorization_pub; struct TALER_ReserveMapAuthorizationSignatureP authorization_sig; struct TALER_BANK_RegistrationHandle *rh; - const char *format_str; const char *type_str; json_t *reg_obj; CURL *eh; @@ -301,12 +295,6 @@ TALER_BANK_registration ( &authorization_sig); GNUNET_CRYPTO_eddsa_key_get_public (&authorization_priv->eddsa_priv, &authorization_pub.eddsa_pub); - format_str = format_to_string (format); - if (NULL == format_str) - { - GNUNET_break (0); - return NULL; - } switch (type) { @@ -322,8 +310,6 @@ TALER_BANK_registration ( } reg_obj = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("format", - format_str), TALER_JSON_pack_amount ("credit_amount", credit_amount), GNUNET_JSON_pack_string ("type", @@ -334,7 +320,7 @@ TALER_BANK_registration ( account_pub), GNUNET_JSON_pack_data_auto ("authorization_pub", &authorization_pub), - GNUNET_JSON_pack_data_auto ("authorization_signature", + GNUNET_JSON_pack_data_auto ("authorization_sig", &authorization_sig), GNUNET_JSON_pack_bool ("recurrent", recurrent)); @@ -372,7 +358,6 @@ TALER_BANK_registration ( return NULL; } json_decref (reg_obj); - rh->job = GNUNET_CURL_job_add2 (ctx, eh, rh->post_ctx.headers, diff --git a/src/include/taler/taler_bank_service.h b/src/include/taler/taler_bank_service.h @@ -1196,7 +1196,12 @@ struct TALER_BANK_RegistrationResponse /** * The wire transfer subject to communicate to the user. */ - struct TALER_BANK_TransferSubject subject; + const struct TALER_BANK_TransferSubject *subjects; + + /** + * Length of the @e subjects array. + */ + size_t num_subjects; /** * Expiration time of this registration. The registration is @@ -1234,7 +1239,6 @@ typedef void * * @param ctx curl context for the event loop * @param base_url base URL for the registration API - * @param format the wire transfer subject format to request * @param credit_amount amount to be credited in the wire transfer * @param type transfer type, either reserve withdrawal or KYC authentication * @param account_pub account public key to associate with the registration @@ -1252,7 +1256,6 @@ struct TALER_BANK_RegistrationHandle * TALER_BANK_registration ( struct GNUNET_CURL_Context *ctx, const char *base_url, - enum TALER_BANK_SubjectFormat format, const struct TALER_Amount *credit_amount, enum TALER_BANK_RegistrationType type, const union TALER_AccountPublicKeyP *account_pub,