diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-07-05 12:07:27 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-07-05 12:07:27 +0200 |
commit | 3ff92b9bbcf072d0b9840ad1c6af0a2bc1b1ef21 (patch) | |
tree | b995a39b55d287e7d91887a6350a52bfcc5137d4 /src/exchange/taler-exchange-httpd_responses.c | |
parent | 9e5dc2a5423992023123a3f2afe1c41343145422 (diff) | |
download | exchange-3ff92b9bbcf072d0b9840ad1c6af0a2bc1b1ef21.tar.gz exchange-3ff92b9bbcf072d0b9840ad1c6af0a2bc1b1ef21.tar.bz2 exchange-3ff92b9bbcf072d0b9840ad1c6af0a2bc1b1ef21.zip |
-deduplicate purse creation confirmation logic
Diffstat (limited to 'src/exchange/taler-exchange-httpd_responses.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index c33cdfc19..bcdc14ece 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -937,4 +937,46 @@ TEH_RESPONSE_reply_reserve_insufficient_balance ( } +MHD_RESULT +TEH_RESPONSE_reply_purse_created ( + struct MHD_Connection *connection, + struct GNUNET_TIME_Timestamp exchange_timestamp, + const struct TALER_Amount *purse_balance, + const struct TEH_PurseDetails *pd) +{ + struct TALER_ExchangePublicKeyP pub; + struct TALER_ExchangeSignatureP sig; + enum TALER_ErrorCode ec; + + if (TALER_EC_NONE != + (ec = TALER_exchange_online_purse_created_sign ( + &TEH_keys_exchange_sign_, + exchange_timestamp, + pd->purse_expiration, + &pd->target_amount, + purse_balance, + &pd->purse_pub, + &pd->h_contract_terms, + &pub, + &sig))) + { + GNUNET_break (0); + return TALER_MHD_reply_with_ec (connection, + ec, + NULL); + } + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + TALER_JSON_pack_amount ("total_deposited", + purse_balance), + GNUNET_JSON_pack_timestamp ("exchange_timestamp", + exchange_timestamp), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub)); +} + + /* end of taler-exchange-httpd_responses.c */ |