From 7bd9e5fb6fbf5ca4bb4dda457b2be53f94781656 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 5 May 2016 09:16:48 +0200 Subject: remove unused args from API, towards supporting /contract in testcase --- src/backend/taler-merchant-httpd_util.c | 5 +--- src/include/taler_merchant_service.h | 11 ++------- src/lib/merchant_api_contract.c | 8 +++--- src/lib/merchant_api_pay.c | 20 +++++++++------ src/lib/test_merchant_api.c | 43 ++++++++++++++++++++++++++++++++- 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/src/backend/taler-merchant-httpd_util.c b/src/backend/taler-merchant-httpd_util.c index 97d1db67..800e41ab 100644 --- a/src/backend/taler-merchant-httpd_util.c +++ b/src/backend/taler-merchant-httpd_util.c @@ -29,7 +29,6 @@ #include "taler-merchant-httpd_responses.h" - /** * Hashes a plain JSON contract sending the result to the other end of * HTTP communication @@ -48,7 +47,6 @@ MH_handler_hash_contract (struct TMH_RequestHandler *rh, const char *upload_data, size_t *upload_data_size) { - json_t *root; json_t *jcontract; int res; @@ -102,8 +100,7 @@ MH_handler_hash_contract (struct TMH_RequestHandler *rh, MHD_HTTP_OK, "{s:O}", "hash", GNUNET_JSON_from_data (&hc, - sizeof (hc))); + sizeof (hc))); json_decref (root); return res; - } diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index fc98f09b..3d0ee8ee 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -108,14 +108,11 @@ struct TALER_MERCHANT_Pay; * can indicate success, depending on whether the interaction * was with a merchant frontend or backend; * 0 if the merchant's reply is bogus (fails to follow the protocol) - * @param redirect_uri URI for the redirect, if the request was successful and we were talking to a frontend; - * NULL if the request failed or if were were talking to a backend * @param obj the received JSON reply, with error details if the request failed */ typedef void (*TALER_MERCHANT_PayCallback) (void *cls, unsigned int http_status, - const char *redirect_uri, const json_t *obj); @@ -179,7 +176,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, const char *merchant_uri, const struct GNUNET_HashCode *h_contract, uint64_t transaction_id, - const struct TALER_Amount *amount, + const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantSignatureP *merchant_sig, @@ -244,12 +241,10 @@ struct TALER_MERCHANT_PaidCoin * @param amount total value of the contract to be paid to the merchant * @param max_fee maximum fee covered by the merchant (according to the contract) * @param transaction_id transaction id for the transaction between merchant and customer - * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) * @param merchant_sig the signature of the merchant over the original contract * @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed) * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant - * @param execution_deadline date by which the merchant would like the exchange to execute the transaction (can be zero if there is no specific date desired by the frontend) - * @param h_wire hash of the merchant’s account details + * @param execution_deadline date by which the merchant would like the exchange to execute the transaction (can be zero if there is no specific date desired by the frontend). If non-zero, must be larger than @a refund_deadline. * @param exchange_uri URI of the exchange that the coins belong to * @param num_coins number of coins used to pay * @param coins array of coins we use to pay @@ -265,12 +260,10 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, uint64_t transaction_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantSignatureP *merchant_sig, struct GNUNET_TIME_Absolute refund_deadline, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute execution_deadline, - const struct GNUNET_HashCode *h_wire, const char *exchange_uri, unsigned int num_coins, const struct TALER_MERCHANT_PaidCoin *coins, diff --git a/src/lib/merchant_api_contract.c b/src/lib/merchant_api_contract.c index fa327a5d..073d4463 100644 --- a/src/lib/merchant_api_contract.c +++ b/src/lib/merchant_api_contract.c @@ -112,12 +112,10 @@ handle_contract_finished (void *cls, { GNUNET_break_op (0); response_code = 0; + break; } - else - { - h_contractp = &h_contract; - sigp = &sig; - } + h_contractp = &h_contract; + sigp = &sig; } break; case MHD_HTTP_BAD_REQUEST: diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c index 17c44910..ba287aca 100644 --- a/src/lib/merchant_api_pay.c +++ b/src/lib/merchant_api_pay.c @@ -121,7 +121,6 @@ handle_pay_finished (void *cls, } ph->cb (ph->cb_cls, response_code, - "FIXME-redirect-URI", json); TALER_MERCHANT_pay_cancel (ph); } @@ -134,6 +133,11 @@ handle_pay_finished (void *cls, * @param exchange_uri URI of the exchange that the coins belong to * @param h_wire hash of the merchant’s account details * @param h_contract hash of the contact of the merchant with the customer + * @param transaction_id transaction id for the transaction between merchant and customer + * @param amount total value of the contract to be paid to the merchant + * @param max_fee maximum fee covered by the merchant (according to the contract) + * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) + * @param merchant_sig signature from the merchant over the original contract * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant * @param transaction_id transaction id for the transaction between merchant and customer * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) @@ -215,12 +219,10 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, amount, max_fee, transaction_id, - merchant_pub, merchant_sig, refund_deadline, timestamp, GNUNET_TIME_UNIT_ZERO_ABS, - h_wire, exchange_uri, num_coins, pc, @@ -237,13 +239,11 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx, * * @param ctx the execution loop context * @param exchange_uri URI of the exchange that the coins belong to - * @param h_wire hash of the merchant’s account details * @param h_contract hash of the contact of the merchant with the customer * @param timestamp timestamp when the contract was finalized, must match approximately the current time of the merchant * @param transaction_id transaction id for the transaction between merchant and customer - * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) * @param refund_deadline date until which the merchant can issue a refund to the customer via the merchant (can be zero if refunds are not allowed) - * @param execution_deadline date by which the merchant would like the exchange to execute the transaction (can be zero if there is no specific date desired by the frontend) + * @param execution_deadline date by which the merchant would like the exchange to execute the transaction (can be zero if there is no specific date desired by the frontend). If non-zero, must be larger than @a refund_deadline. * @param num_coins number of coins used to pay * @param coins array of coins we use to pay * @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT made by the customer with the coin’s private key. @@ -260,12 +260,10 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, const struct TALER_Amount *amount, const struct TALER_Amount *max_fee, uint64_t transaction_id, - const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantSignatureP *merchant_sig, struct GNUNET_TIME_Absolute refund_deadline, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute execution_deadline, - const struct GNUNET_HashCode *h_wire, const char *exchange_uri, unsigned int num_coins, const struct TALER_MERCHANT_PaidCoin *coins, @@ -280,6 +278,12 @@ TALER_MERCHANT_pay_frontend (struct GNUNET_CURL_Context *ctx, struct TALER_Amount total_amount; unsigned int i; + if ( (0 != execution_deadline.abs_value_us) && + (execution_deadline.abs_value_us < refund_deadline.abs_value_us) ) + { + GNUNET_break (0); + return NULL; + } if (0 == num_coins) { GNUNET_break (0); diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index 77450b72..87bf51ee 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -95,6 +95,11 @@ enum OpCode */ OC_WITHDRAW_SIGN, + /** + * Get backend to sign a contract. + */ + OC_CONTRACT, + /** * Pay with coins. */ @@ -286,6 +291,39 @@ struct Command } reserve_withdraw; + /** + * Information for an #OC_CONTRACT command. + */ + struct + { + + /** + * Contract proposal (without merchant_pub, exchanges or H_wire). + */ + const char *proposal; + + /** + * Handle to the active /contract operation, or NULL. + */ + struct TALER_MERCHANT_ContractOperation *co; + + /** + * Full contract in JSON, set by the /contract operation. + */ + json_t *contract; + + /** + * Signature, set by the /contract operation. + */ + struct TALER_MerchantSignatureP merchant_sig; + + /** + * Hash of the full contract, set by the /contract operation. + */ + struct GNUNET_HashCode h_contract; + + } contract; + /** * Information for a #OC_PAY command. * FIXME: support tests where we pay with multiple coins at once. @@ -727,7 +765,6 @@ reserve_withdraw_cb (void *cls, static void pay_cb (void *cls, unsigned int http_status, - const char *redirect_uri, const json_t *obj) { struct InterpreterState *is = cls; @@ -977,6 +1014,10 @@ interpreter_run (void *cls) return; } return; + case OC_CONTRACT: + { + + } case OC_PAY: { struct TALER_MERCHANT_PayCoin pc; -- cgit v1.2.3