diff options
author | Lucien Heuzeveldt <lucien.heuzeveldt@gmail.com> | 2021-12-23 22:49:57 +0100 |
---|---|---|
committer | Gian Demarmels <gian@demarmels.org> | 2022-02-04 15:33:07 +0100 |
commit | 3225566c93eceb52078fbe13fc301722f349b2c0 (patch) | |
tree | f011f29c49103aaf2a573b4711a97d642944037e /src/include | |
parent | db9b84970dbd5aacc9eca1f19bb03d27a06e3452 (diff) | |
download | exchange-3225566c93eceb52078fbe13fc301722f349b2c0.tar.xz |
implement exchange_api_csr
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_exchange_service.h | 79 | ||||
-rw-r--r-- | src/include/taler_json_lib.h | 12 |
2 files changed, 91 insertions, 0 deletions
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index caa61c5f1..2dd220293 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1033,6 +1033,85 @@ void TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund); +/* ********************* POST /csr *********************** */ + + +/** + * @brief A /csr Handle + */ +struct TALER_EXCHANGE_CsRHandle; + + +/** + * Details about a response for a CS R request. + */ +struct TALER_EXCHANGE_CsRResponse +{ + /** + * HTTP response data. + */ + struct TALER_EXCHANGE_HttpResponse hr; + + /** + * Details about the response. + */ + union + { + /** + * Details if the status is #MHD_HTTP_OK. + */ + struct + { + /** + * Signature over the coin. + */ + struct TALER_DenominationCsPublicR r_pubs; + } success; + + /** + * Details if the status is #MHD_HTTP_GONE. + */ + struct + { + /* TODO: returning full details is not implemented */ + } gone; + + } details; +}; + + +/** + * Callbacks of this type are used to serve the result of submitting a + * CS R request to a exchange. + * + * @param cls closure + * @param csrr response details + */ +typedef void +(*TALER_EXCHANGE_CsRCallback) (void *cls, + const struct TALER_EXCHANGE_CsRResponse *csrr); + + +/** + * Get a CS R using a /csr request. + * + * @param exchange the exchange handle; the exchange must be ready to operate + * @param pk denomination of coin the R's will be used for + * @param nonce public nonce for CS R request + * @param res_cb the callback to call when the final result for this request is available + * @param res_cb_cls closure for the above callback + * @return handle for the operation on success, NULL on error, i.e. + * if the inputs are invalid (i.e. denomination key not with this exchange). + * In this case, the callback is not called. + */ +struct TALER_EXCHANGE_CsRHandle * +TALER_EXCHANGE_csr (struct TALER_EXCHANGE_Handle *exchange, + const struct TALER_EXCHANGE_DenomPublicKey *pk, + const struct TALER_WithdrawNonce *nonce, + TALER_EXCHANGE_CsRCallback res_cb, + void *res_cb_cls); + + /* ********************* GET /reserves/$RESERVE_PUB *********************** */ diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 51ebe6d90..d243dd723 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -300,6 +300,18 @@ TALER_JSON_spec_i18n_str (const char *name, /** + * Generate line in parser specification for a CS R. + * + * @param field name of the field + * @param r_pub where the r_pub has to be written + * @return corresponding field spec + */ +struct GNUNET_JSON_Specification +TALER_JSON_spec_csr (const char *field, + struct GNUNET_CRYPTO_CsRPublic *r_pub); + + +/** * Hash a JSON for binary signing. * * See https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-15 |