summaryrefslogtreecommitdiff
path: root/src/backend-lib/taler-merchant-httpd_contract.c
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2015-09-24 10:13:31 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2015-09-24 10:13:31 +0200
commitd8b70e33e6300a168fa35606c5de9723fcd979c4 (patch)
treef63af4b36829119f850e2d2cab7ccf3300dcf08d /src/backend-lib/taler-merchant-httpd_contract.c
parent1e04bb2610bd142aebeb0fd040e649045ec785df (diff)
downloadmerchant-d8b70e33e6300a168fa35606c5de9723fcd979c4.tar.gz
merchant-d8b70e33e6300a168fa35606c5de9723fcd979c4.tar.bz2
merchant-d8b70e33e6300a168fa35606c5de9723fcd979c4.zip
DB query to retrieve the nounce,edate pair based on the
contract hash: tested
Diffstat (limited to 'src/backend-lib/taler-merchant-httpd_contract.c')
-rw-r--r--src/backend-lib/taler-merchant-httpd_contract.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/backend-lib/taler-merchant-httpd_contract.c b/src/backend-lib/taler-merchant-httpd_contract.c
index 7cfda21c..f746343b 100644
--- a/src/backend-lib/taler-merchant-httpd_contract.c
+++ b/src/backend-lib/taler-merchant-httpd_contract.c
@@ -99,27 +99,27 @@ MERCHANT_get_wire_json (const struct MERCHANT_WIREFORMAT_Sepa *wire,
* @param edate when the merchant wants to receive the wire transfer corresponding
* to this deal (this value is also a field inside the 'wire' JSON format)
* @param nounce the nounce used to hash the wire details
-* @param contract_str where to store the (stringified) contract
-* @return GNUNET_OK on success; GNUNET_SYSERR upon errors
+* @param contract_str where to store
+* @return pointer to the (stringified) contract; NULL upon errors
*/
/**
* TODO: inspect reference counting and, accordingly, free those json_t*(s)
* still allocated */
-uint32_t
+char *
MERCHANT_handle_contract (const json_t *j_contract,
PGconn *db_conn,
struct Contract *contract,
struct GNUNET_TIME_Absolute timestamp,
struct GNUNET_TIME_Absolute expiry,
struct GNUNET_TIME_Absolute edate,
- uint64_t nounce,
- const char *contract_str)
+ uint64_t nounce)
{
json_t *j_amount;
json_int_t j_product_id;
json_int_t j_trans_id;
+ char *contract_str;
struct TALER_Amount amount;
@@ -134,12 +134,11 @@ MERCHANT_handle_contract (const json_t *j_contract,
"product_id", &j_product_id))
{
printf ("no unpacking\n");
- return GNUNET_SYSERR;
+ return NULL;
}
- /* needed for DB work */
- TALER_json_to_amount (j_amount, &amount); // produces a WARNING..
-
+ /* DB will store the amount */
+ TALER_json_to_amount (j_amount, &amount);
contract_str = json_dumps (j_contract, JSON_COMPACT | JSON_PRESERVE_ORDER);
GNUNET_CRYPTO_hash (contract_str, strlen (contract_str) + 1,
&contract->h_contract_details);
@@ -157,7 +156,8 @@ MERCHANT_handle_contract (const json_t *j_contract,
contract_str,
nounce,
(uint64_t) j_product_id))
- return GNUNET_SYSERR;
-
- return GNUNET_OK;
+ return NULL;
+ return contract_str;
}
+
+