diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-01-27 15:06:01 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-01-27 15:06:01 +0100 |
commit | d64edbd2352dee0b6cf2733b92e86068c827b0c4 (patch) | |
tree | a9dd74453df4ac7654d82260259ccf773ec72ecd /src/backend/taler-merchant-httpd_contract.c | |
parent | 165ed03d36bdf9bc945f27f48e12d8ffdaad6a67 (diff) |
implement #4159
Diffstat (limited to 'src/backend/taler-merchant-httpd_contract.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_contract.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c index d606afb5..a6c3fe7d 100644 --- a/src/backend/taler-merchant-httpd_contract.c +++ b/src/backend/taler-merchant-httpd_contract.c @@ -56,6 +56,15 @@ MH_handler_contract (struct TMH_RequestHandler *rh, int res; struct TALER_ContractPS contract; struct GNUNET_CRYPTO_EddsaSignature contract_sig; + struct TALER_Amount total; + struct TALER_Amount max_fee; + uint64_t transaction_id; + struct TMH_PARSE_FieldSpecification spec[] = { + TMH_PARSE_member_amount ("amount", &total), + TMH_PARSE_member_amount ("max_fee", &total), + TMH_PARSE_member_uint64 ("transaction_id", &transaction_id), + TMH_PARSE_MEMBER_END + }; res = TMH_PARSE_post_json (connection, connection_cls, @@ -75,6 +84,15 @@ MH_handler_contract (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_internal_error (connection, "contract request malformed"); } + /* extract fields we need to sign separately */ + res = TMH_PARSE_json_data (connection, + jcontract, + spec); + if (GNUNET_NO == res) + return MHD_YES; + if (GNUNET_SYSERR == res) + return TMH_RESPONSE_reply_internal_error (connection, + "contract request malformed"); /* add fields to the contract that the backend should provide */ json_object_set (jcontract, @@ -91,12 +109,18 @@ MH_handler_contract (struct TMH_RequestHandler *rh, "merchant_pub", TALER_json_from_data (&pubkey, sizeof (pubkey))); + /* create contract signature */ GNUNET_assert (GNUNET_OK == TALER_hash_json (jcontract, &contract.h_contract)); contract.purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_CONTRACT); contract.purpose.size = htonl (sizeof (contract)); + contract.transaction_id = GNUNET_htonll (transaction_id); + TALER_amount_hton (&contract.total_amount, + &total); + TALER_amount_hton (&contract.max_fee, + &max_fee); GNUNET_CRYPTO_eddsa_sign (privkey, &contract.purpose, &contract_sig); |