diff options
author | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-02-06 15:12:12 +0100 |
---|---|---|
committer | Marcello Stanisci <marcello.stanisci@inria.fr> | 2017-02-06 15:12:12 +0100 |
commit | 3051f7f06358f5f25dcd35588f663672b266e0a5 (patch) | |
tree | 8926c0eb0e2967193b77bbc0e8928f338c632636 /src | |
parent | dfdaec21180a4b692f7a380ba2bc34c38809ad9a (diff) | |
download | merchant-3051f7f06358f5f25dcd35588f663672b266e0a5.tar.gz merchant-3051f7f06358f5f25dcd35588f663672b266e0a5.tar.bz2 merchant-3051f7f06358f5f25dcd35588f663672b266e0a5.zip |
Renaming /track/transaction handler to the point
where it depends on a few exchange-lib's renamings.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 23 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 39 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 4 | ||||
-rw-r--r-- | src/lib/merchant_api_proposal.c | 12 | ||||
-rw-r--r-- | src/lib/test_merchant_api.c | 8 |
6 files changed, 35 insertions, 55 deletions
diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 026479d4..8406ee98 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -159,7 +159,7 @@ struct PayContext /** * Transaction ID given in @e root. */ - uint64_t transaction_id; + const char *transaction_id; /** * Maximum fee the merchant is willing to pay, from @e root. @@ -432,7 +432,7 @@ deposit_cb (void *cls, TMH_RESPONSE_make_json_pack ("{s:s, s:o}", "merchant_sig", json_string_value (GNUNET_JSON_from_data_auto (&sig)), - "h_proposal_data", + "hash", GNUNET_JSON_from_data (&pc->h_proposal_data, sizeof (struct GNUNET_HashCode)))); } @@ -773,7 +773,7 @@ handle_pay_timeout (void *cls) */ static void check_coin_paid (void *cls, - uint64_t transaction_id, + const char *transaction_id, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, @@ -782,7 +782,8 @@ check_coin_paid (void *cls, struct PayContext *pc = cls; unsigned int i; - if (pc->transaction_id != transaction_id) + if (0 != strcmp (pc->transaction_id, + transaction_id)) { GNUNET_break (0); return; @@ -811,7 +812,6 @@ check_coin_paid (void *cls, * @param transaction_id of the contract * @param merchant_pub merchant's public key * @param exchange_uri URI of the exchange - * @param h_proposal_data hash of the contract * @param h_xwire hash of our wire details * @param timestamp time of the confirmation * @param refund refund deadline @@ -819,10 +819,9 @@ check_coin_paid (void *cls, */ static void check_transaction_exists (void *cls, - uint64_t transaction_id, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const struct GNUNET_HashCode *h_proposal_data, + const char *transaction_id, const struct GNUNET_HashCode *h_xwire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, @@ -830,9 +829,8 @@ check_transaction_exists (void *cls, { struct PayContext *pc = cls; - if ( (0 == memcmp (h_proposal_data, - &pc->h_proposal_data, - sizeof (struct GNUNET_HashCode))) && + if ( (0 == strcmp (transaction_id, + pc->transaction_id)) && (0 == memcmp (h_xwire, &pc->mi->h_wire, sizeof (struct GNUNET_HashCode))) && @@ -953,7 +951,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, GNUNET_JSON_spec_absolute_time ("refund_deadline", &pc->refund_deadline), GNUNET_JSON_spec_absolute_time ("pay_deadline", &pc->pay_deadline), GNUNET_JSON_spec_absolute_time ("timestamp", &pc->timestamp), - GNUNET_JSON_spec_uint64 ("transaction_id", &pc->transaction_id), + GNUNET_JSON_spec_string ("transaction_id", &pc->transaction_id), GNUNET_JSON_spec_end() }; @@ -990,7 +988,7 @@ MH_handler_pay (struct TMH_RequestHandler *rh, "Parsed JSON for /pay.\n"); pdps.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT); pdps.purpose.size = htonl (sizeof (pdps)); - pdps.h_proposal_data = pc->h_proposal_data; + pdps.hash = pc->h_proposal_data; if (GNUNET_OK != GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_CONTRACT, &pdps.purpose, @@ -1182,7 +1180,6 @@ MH_handler_pay (struct TMH_RequestHandler *rh, pc->transaction_id, &pc->mi->pubkey, pc->chosen_exchange, - &pc->h_proposal_data, &pc->mi->h_wire, pc->timestamp, pc->refund_deadline, diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index 2a59ae5e..7fb2abc6 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -258,7 +258,7 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, pdps.purpose.size = htonl (sizeof (pdps)); GNUNET_assert (GNUNET_OK == TALER_JSON_hash (order, - &pdps.h_proposal_data)); + &pdps.hash)); GNUNET_CRYPTO_eddsa_sign (&mi->privkey.eddsa_priv, &pdps.purpose, &merchant_sig); @@ -281,7 +281,7 @@ MH_handler_proposal_put (struct TMH_RequestHandler *rh, "{s:O, s:o s:o}", "data", order, "merchant_sig", GNUNET_JSON_from_data_auto (&merchant_sig), - "hash", GNUNET_JSON_from_data_auto (&pdps.h_proposal_data)); + "hash", GNUNET_JSON_from_data_auto (&pdps.hash)); GNUNET_JSON_parse_free (spec); json_decref (root); return res; diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c index edf323f3..976cbb58 100644 --- a/src/backend/taler-merchant-httpd_track-transaction.c +++ b/src/backend/taler-merchant-httpd_track-transaction.c @@ -185,11 +185,6 @@ struct TrackTransactionContext struct GNUNET_HashCode h_wire; /** - * Hash of the contract. - */ - struct GNUNET_HashCode h_contract; - - /** * Timestamp of the transaction. */ struct GNUNET_TIME_Absolute timestamp; @@ -207,7 +202,7 @@ struct TrackTransactionContext /** * Transaction this request is about. */ - uint64_t transaction_id; + const char *transaction_id; /** * Response code to return upon resume. @@ -568,7 +563,6 @@ trace_coins (struct TrackTransactionContext *tctx) tcc->dwh = TALER_EXCHANGE_track_transaction (tctx->eh, &tctx->mi->privkey, &tctx->h_wire, - &tctx->h_contract, &tcc->coin_pub, tctx->transaction_id, &wtid_cb, @@ -734,10 +728,9 @@ handle_track_transaction_timeout (void *cls) */ static void transaction_cb (void *cls, - uint64_t transaction_id, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const struct GNUNET_HashCode *h_contract, + const char *transaction_id, const struct GNUNET_HashCode *h_wire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, @@ -745,9 +738,8 @@ transaction_cb (void *cls, { struct TrackTransactionContext *tctx = cls; - tctx->transaction_id = transaction_id; + tctx->transaction_id = GNUNET_strdup (transaction_id); tctx->exchange_uri = GNUNET_strdup (exchange_uri); - tctx->h_contract = *h_contract; tctx->h_wire = *h_wire; tctx->timestamp = timestamp; tctx->refund_deadline = refund; @@ -774,7 +766,7 @@ transaction_cb (void *cls, */ static void transfer_cb (void *cls, - uint64_t transaction_id, + const char *transaction_id, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_WireTransferIdentifierRawP *wtid, struct GNUNET_TIME_Absolute execution_time, @@ -804,7 +796,7 @@ transfer_cb (void *cls, */ static void coin_cb (void *cls, - uint64_t transaction_id, + const char *transaction_id, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *deposit_fee, @@ -846,8 +838,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, size_t *upload_data_size) { struct TrackTransactionContext *tctx; - unsigned long long transaction_id; - const char *str; + const char *transaction_id; const char *instance; int ret; struct GNUNET_HashCode h_instance; @@ -895,10 +886,10 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, "Not sure why we are here, should be suspended\n"); return MHD_YES; /* still work in progress */ } - str = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - "id"); - if (NULL == str) + transaction_id = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "id"); + if (NULL == transaction_id) return TMH_RESPONSE_reply_arg_missing (connection, TALER_EC_PARAMETER_MISSING, "id"); @@ -916,14 +907,6 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_not_found (connection, TALER_EC_TRACK_TRANSACTION_INSTANCE_UNKNOWN, "unknown instance"); - if (1 != - sscanf (str, - "%llu", - &transaction_id)) - return TMH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - "id"); - ret = db->find_transaction (db->cls, transaction_id, &tctx->mi->pubkey, @@ -936,7 +919,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, "id"); } if ( (GNUNET_SYSERR == ret) || - (tctx->transaction_id != (uint64_t) transaction_id) || + (0 != strcmp (tctx->transaction_id, transaction_id)) || (NULL == tctx->exchange_uri) ) { GNUNET_break (0); diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 8c0d8dff..441a1f54 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -54,7 +54,7 @@ struct TALER_MERCHANT_ProposalLookupOperation; * @param obj raw JSON reply, or error details if the request failed * @param proposal_data completed contract, NULL on error * @param sig merchant's signature over the contract, NULL on error - * @param h_proposal_data proposal data's hashcode, NULL on error + * @param hash proposal data's hashcode, NULL on error */ typedef void (*TALER_MERCHANT_ProposalCallback) (void *cls, @@ -63,7 +63,7 @@ typedef void const json_t *obj, const json_t *proposal_data, const struct TALER_MerchantSignatureP *sig, - const struct GNUNET_HashCode *h_proposal_data); + const struct GNUNET_HashCode *hash); /** diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c index bdcdbd4d..8a951b9f 100644 --- a/src/lib/merchant_api_proposal.c +++ b/src/lib/merchant_api_proposal.c @@ -117,14 +117,14 @@ handle_proposal_finished (void *cls, struct TALER_MERCHANT_ProposalOperation *po = cls; json_t *proposal_data; const struct TALER_MerchantSignatureP *sigp; - const struct GNUNET_HashCode *h_proposal_datap; + const struct GNUNET_HashCode *hashp; struct TALER_MerchantSignatureP sig; - struct GNUNET_HashCode h_proposal_data; + struct GNUNET_HashCode hash; po->job = NULL; proposal_data = NULL; sigp = NULL; - h_proposal_datap = NULL; + hashp = NULL; switch (response_code) { case 0: @@ -134,7 +134,7 @@ handle_proposal_finished (void *cls, struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_json ("proposal_data", &proposal_data), GNUNET_JSON_spec_fixed_auto ("merchant_sig", &sig), - GNUNET_JSON_spec_fixed_auto ("h_proposal_data", &h_proposal_data), + GNUNET_JSON_spec_fixed_auto ("hash", &hash), GNUNET_JSON_spec_end() }; @@ -147,7 +147,7 @@ handle_proposal_finished (void *cls, response_code = 0; break; } - h_proposal_datap = &h_proposal_data; + hashp = &hash; sigp = &sig; } break; @@ -184,7 +184,7 @@ handle_proposal_finished (void *cls, json, proposal_data, sigp, - h_proposal_datap); + hashp); if (NULL != proposal_data) json_decref (proposal_data); } diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c index 0e2ea5c7..1397bd44 100644 --- a/src/lib/test_merchant_api.c +++ b/src/lib/test_merchant_api.c @@ -431,7 +431,7 @@ struct Command /** * Proposal data's hashcode. */ - struct GNUNET_HashCode h_proposal_data; + struct GNUNET_HashCode hash; } proposal; @@ -1031,7 +1031,7 @@ proposal_cb (void *cls, const json_t *obj, const json_t *proposal_data, const struct TALER_MerchantSignatureP *sig, - const struct GNUNET_HashCode *h_proposal_data) + const struct GNUNET_HashCode *hash) { struct InterpreterState *is = cls; struct Command *cmd = &is->commands[is->ip]; @@ -1042,7 +1042,7 @@ proposal_cb (void *cls, case MHD_HTTP_OK: cmd->details.proposal.proposal_data = json_incref ((json_t *) proposal_data); cmd->details.proposal.merchant_sig = *sig; - cmd->details.proposal.h_proposal_data = *h_proposal_data; + cmd->details.proposal.hash = *hash; break; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -1815,7 +1815,7 @@ interpreter_run (void *cls) = TALER_MERCHANT_pay_wallet (ctx, MERCHANT_URI, instance, - &ref->details.proposal.h_proposal_data, + &ref->details.proposal.hash, transaction_id, &total_amount, &max_fee, |