diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 02:39:36 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 02:39:36 +0100 |
commit | f5f15e6531bb7072a02cb976771a43803bd044f6 (patch) | |
tree | 80cc93a627533fe4768bd5aded76c77c3d37660d /src/exchange/taler-exchange-httpd_withdraw.c | |
parent | b560527ee3d5605310f3793dbcbf86a9b4844c91 (diff) | |
download | exchange-f5f15e6531bb7072a02cb976771a43803bd044f6.tar.gz exchange-f5f15e6531bb7072a02cb976771a43803bd044f6.tar.bz2 exchange-f5f15e6531bb7072a02cb976771a43803bd044f6.zip |
first rough-cut implementation of POST /reserves//status
Diffstat (limited to 'src/exchange/taler-exchange-httpd_withdraw.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index fcf596e06..5765181b2 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -52,32 +52,19 @@ reply_withdraw_insufficient_funds ( const struct TALER_EXCHANGEDB_ReserveHistory *rh) { json_t *json_history; - struct TALER_Amount balance; - json_history = TEH_RESPONSE_compile_reserve_history (rh, - &balance); + json_history = TEH_RESPONSE_compile_reserve_history (rh); if (NULL == json_history) return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_EXCHANGE_WITHDRAW_HISTORY_ERROR_INSUFFICIENT_FUNDS, NULL); - if (0 != - TALER_amount_cmp (&balance, - ebalance)) - { - GNUNET_break (0); - json_decref (json_history); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_INVARIANT_FAILURE, - "reserve balance corrupt"); - } return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_CONFLICT, TALER_JSON_pack_ec (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS), TALER_JSON_pack_amount ("balance", - &balance), + ebalance), TALER_JSON_pack_amount ("requested_amount", withdraw_amount), GNUNET_JSON_pack_array_steal ("history", @@ -105,7 +92,6 @@ struct WithdrawContext */ struct TALER_Amount amount_with_fee; - /** * Blinded planchet. */ @@ -329,8 +315,8 @@ check_request_idempotent (struct TEH_RequestContext *rc, MHD_RESULT TEH_handler_withdraw (struct TEH_RequestContext *rc, - const json_t *root, - const char *const args[2]) + const struct TALER_ReservePublicKeyP *reserve_pub, + const json_t *root) { struct WithdrawContext wc; struct GNUNET_JSON_Specification spec[] = { @@ -348,18 +334,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc, memset (&wc, 0, sizeof (wc)); - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (args[0], - strlen (args[0]), - &wc.collectable.reserve_pub, - sizeof (wc.collectable.reserve_pub))) - { - GNUNET_break_op (0); - return TALER_MHD_reply_with_error (rc->connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_MERCHANT_GENERIC_RESERVE_PUB_MALFORMED, - args[0]); - } + wc.collectable.reserve_pub = *reserve_pub; { enum GNUNET_GenericReturnValue res; |