diff options
-rw-r--r-- | RENAMING_NOTES.txt | 1 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 20 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 38 | ||||
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 1 |
4 files changed, 18 insertions, 42 deletions
diff --git a/RENAMING_NOTES.txt b/RENAMING_NOTES.txt index 3bb1b695..b7eb0887 100644 --- a/RENAMING_NOTES.txt +++ b/RENAMING_NOTES.txt @@ -5,6 +5,5 @@ Files to be cleaned from the 'h/H_contract' presence. - postgres plugin - db testcase - merchant service include -- db plugin include - pay lib - lib testcase diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 06af5a34..feb61135 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -174,7 +174,6 @@ postgres_initialize (void *cls) " transaction_id VARCHAR NOT NULL" ",exchange_uri VARCHAR NOT NULL" ",merchant_pub BYTEA NOT NULL CHECK (LENGTH(merchant_pub)=32)" - ",h_contract BYTEA NOT NULL CHECK (LENGTH(h_contract)=64)" ",h_wire BYTEA NOT NULL CHECK (LENGTH(h_wire)=64)" ",timestamp INT8 NOT NULL" ",refund_deadline INT8 NOT NULL" @@ -232,7 +231,6 @@ postgres_initialize (void *cls) "(transaction_id" ",exchange_uri" ",merchant_pub" - ",h_contract" ",h_wire" ",timestamp" ",refund_deadline" @@ -240,8 +238,8 @@ postgres_initialize (void *cls) ",total_amount_frac" ",total_amount_curr" ") VALUES " - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", - 10); + "($1, $2, $3, $4, $5, $6, $7, $8, $9)", + 9); PG_PREPARE (pg, "insert_deposit", "INSERT INTO merchant_deposits" @@ -299,7 +297,6 @@ postgres_initialize (void *cls) " transaction_id" ",merchant_pub" ",exchange_uri" - ",h_contract" ",h_wire" ",timestamp" ",refund_deadline" @@ -315,7 +312,6 @@ postgres_initialize (void *cls) "find_transaction", "SELECT" " exchange_uri" - ",h_contract" ",h_wire" ",timestamp" ",refund_deadline" @@ -511,7 +507,6 @@ postgres_insert_proposal_data (void *cls, * @param transaction_id of the proposal * @param merchant_pub merchant's public key * @param exchange_uri URI of the exchange - * @param h_contract hash of the contract * @param h_wire hash of our wire details * @param timestamp time of the confirmation * @param refund refund deadline @@ -523,7 +518,6 @@ postgres_store_transaction (void *cls, const char *transaction_id, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_wire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, @@ -533,11 +527,12 @@ postgres_store_transaction (void *cls, PGresult *result; int ret; + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "dbtc: %s\n", total_amount->currency); + struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (transaction_id), GNUNET_PQ_query_param_string (exchange_uri), GNUNET_PQ_query_param_auto_from_type (merchant_pub), - GNUNET_PQ_query_param_auto_from_type (h_contract), GNUNET_PQ_query_param_auto_from_type (h_wire), GNUNET_PQ_query_param_absolute_time (×tamp), GNUNET_PQ_query_param_absolute_time (&refund), @@ -545,6 +540,7 @@ postgres_store_transaction (void *cls, GNUNET_PQ_query_param_end }; + result = GNUNET_PQ_exec_prepared (pg->conn, "insert_transaction", params); @@ -753,7 +749,6 @@ postgres_find_transactions_by_date (void *cls, { struct TALER_MerchantPublicKeyP merchant_pub; char *exchange_uri; - struct GNUNET_HashCode h_contract; struct GNUNET_HashCode h_wire; struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute refund_deadline; @@ -766,8 +761,6 @@ postgres_find_transactions_by_date (void *cls, &transaction_id), GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", &merchant_pub), - GNUNET_PQ_result_spec_auto_from_type ("h_contract", - &h_contract), GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), GNUNET_PQ_result_spec_absolute_time ("timestamp", @@ -852,7 +845,6 @@ postgres_find_transaction (void *cls, { char *exchange_uri; - struct GNUNET_HashCode h_contract; struct GNUNET_HashCode h_wire; struct GNUNET_TIME_Absolute timestamp; struct GNUNET_TIME_Absolute refund_deadline; @@ -860,8 +852,6 @@ postgres_find_transaction (void *cls, struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_string ("exchange_uri", &exchange_uri), - GNUNET_PQ_result_spec_auto_from_type ("h_contract", - &h_contract), GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), GNUNET_PQ_result_spec_absolute_time ("timestamp", diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index ddda177e..add1e81d 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -60,17 +60,10 @@ static int result; static struct TALER_MERCHANTDB_Plugin *plugin; /** - * Hash of the contract. Set to some random value. - */ -static struct GNUNET_HashCode h_contract; - -/** * Hash of the (fictitious) transaction id. Set to some random value. */ static struct GNUNET_HashCode h_transaction_id; - - /** * Hash of the wire transfer address. Set to some random value. */ @@ -79,7 +72,7 @@ static struct GNUNET_HashCode h_wire; /** * Transaction ID. */ -static uint64_t transaction_id; +char *transaction_id; /** * Time of the transaction. @@ -156,7 +149,6 @@ static json_t *proposal_data; * @param transaction_id of the contract * @param merchant_pub public key of the merchant * @param exchange_uri URI of the exchange - * @param h_contract hash of the contract * @param h_wire hash of our wire details * @param timestamp time of the confirmation * @param refund_deadline refund deadline @@ -164,25 +156,22 @@ static json_t *proposal_data; */ static void transaction_cb (void *cls, - uint64_t atransaction_id, const struct TALER_MerchantPublicKeyP *amerchant_pub, const char *aexchange_uri, - const struct GNUNET_HashCode *ah_contract, + const char *atransaction_id, const struct GNUNET_HashCode *ah_wire, struct GNUNET_TIME_Absolute atimestamp, struct GNUNET_TIME_Absolute arefund_deadline, const struct TALER_Amount *atotal_amount) { #define CHECK(a) do { if (! (a)) { GNUNET_break (0); result = 3; } } while (0) - CHECK (atransaction_id == transaction_id); CHECK (0 == memcmp (amerchant_pub, &merchant_pub, sizeof (struct TALER_MerchantPublicKeyP))); + CHECK (0 == strcmp (atransaction_id, + transaction_id)); CHECK (0 == strcmp (aexchange_uri, EXCHANGE_URI)); - CHECK (0 == memcmp (ah_contract, - &h_contract, - sizeof (struct GNUNET_HashCode))); CHECK (0 == memcmp (ah_wire, &h_wire, sizeof (struct GNUNET_HashCode))); @@ -201,7 +190,6 @@ transaction_cb (void *cls, * @param transaction_id of the contract * @param merchant_pub merchant's public key * @param exchange_uri URI of the exchange - * @param h_contract hash of the contract * @param h_wire hash of our wire details * @param timestamp time of the confirmation * @param refund refund deadline @@ -210,10 +198,9 @@ transaction_cb (void *cls, static void history_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, @@ -235,13 +222,14 @@ history_cb (void *cls, */ static void deposit_cb (void *cls, - uint64_t atransaction_id, + const char *atransaction_id, const struct TALER_CoinSpendPublicKeyP *acoin_pub, const struct TALER_Amount *aamount_with_fee, const struct TALER_Amount *adeposit_fee, const json_t *aexchange_proof) { - CHECK (atransaction_id == transaction_id); + CHECK ((0 == strcmp (atransaction_id, + transaction_id))); CHECK (0 == memcmp (acoin_pub, &coin_pub, sizeof (struct TALER_CoinSpendPublicKeyP))); @@ -273,7 +261,7 @@ deposit_cb (void *cls, */ static void transfer_cb (void *cls, - uint64_t atransaction_id, + const char *atransaction_id, const struct TALER_CoinSpendPublicKeyP *acoin_pub, const struct TALER_WireTransferIdentifierRawP *awtid, struct GNUNET_TIME_Absolute execution_time, @@ -336,10 +324,11 @@ run (void *cls) } /* Prepare data for 'store_payment()' */ - RND_BLK (&h_contract); - RND_BLK (&h_transaction_id); RND_BLK (&h_wire); - RND_BLK (&transaction_id); + transaction_id = "test_ID"; + GNUNET_CRYPTO_hash (transaction_id, + strlen (transaction_id), + &h_transaction_id); RND_BLK (&signkey_pub); RND_BLK (&merchant_pub); RND_BLK (&wtid); @@ -386,7 +375,6 @@ run (void *cls) transaction_id, &merchant_pub, EXCHANGE_URI, - &h_contract, &h_wire, timestamp, refund_deadline, diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 2fe1c5e9..1abddc35 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -198,7 +198,6 @@ struct TALER_MERCHANTDB_Plugin const char *transaction_id, const struct TALER_MerchantPublicKeyP *merchant_pub, const char *exchange_uri, - const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_wire, struct GNUNET_TIME_Absolute timestamp, struct GNUNET_TIME_Absolute refund, |