aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/taler_mintdb_plugin.h15
-rw-r--r--src/include/taler_signatures.h16
-rw-r--r--src/mint/taler-mint-httpd_db.c40
-rw-r--r--src/mint/taler-mint-httpd_responses.c59
-rw-r--r--src/mint/taler-mint-httpd_responses.h14
-rw-r--r--src/mintdb/plugin_mintdb_postgres.c8
6 files changed, 120 insertions, 32 deletions
diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h
index 90319b964..9e4f891c5 100644
--- a/src/include/taler_mintdb_plugin.h
+++ b/src/include/taler_mintdb_plugin.h
@@ -573,8 +573,11 @@ typedef void
* wire transfer identifier information.
*
* @param cls closure
- * @param wtid base32-encoded wire transfer identifier, NULL
+ * @param wtid wire transfer identifier, NULL
* if the transaction was not yet done
+ * @param coin_contribution how much did the coin we asked about
+ * contribute to the total transfer value? (deposit value minus fee)
+ * @param total_amount how much was the total wire transfer?
* @param execution_time when was the transaction done, or
* when we expect it to be done (if @a wtid was NULL);
* #GNUNET_TIME_UNIT_FOREVER_ABS if the /deposit is unknown
@@ -582,7 +585,9 @@ typedef void
*/
typedef void
(*TALER_MINTDB_DepositWtidCallback)(void *cls,
- const char *wtid,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *coin_contribution,
+ const struct TALER_Amount *total_amount,
struct GNUNET_TIME_Absolute execution_time);
@@ -1224,16 +1229,14 @@ struct TALER_MINTDB_Plugin
* into a wire transfer by the respective @a raw_wtid.
*
* @param cls the @e cls of this struct with the plugin-specific state
- * @param raw_wtid the raw wire transfer identifier we used
- * @param raw_len number of bytes in @a raw_wtid (right now always 32)
+ * @param wtid the raw wire transfer identifier we used
* @param cb function to call on each transaction found
* @param cb_cls closure for @a cb
* @return #GNUNET_OK on success, #GNUNET_SYSERR on database errors
*/
int
(*lookup_wire_transactions) (void *cls,
- const void *raw_wtid,
- size_t raw_len,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_MINTDB_TransactionDataCallback cb,
void *cb_cls);
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 62e602a01..29008fc9a 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -893,7 +893,7 @@ struct TALER_ConfirmWirePS
/**
* Raw value (binary encoding) of the wire transfer subject.
*/
- struct TALER_WireTransferIdentifierRawP raw;
+ struct TALER_WireTransferIdentifierRawP wtid;
/**
* The coin's public key. This is the value that must have been
@@ -903,13 +903,13 @@ struct TALER_ConfirmWirePS
/**
* Merchant-generated transaction ID to detect duplicate
- * transactions. The merchant must communicate a merchant-unique ID
- * to the customer for each transaction. Note that different coins
- * that are part of the same transaction can use the same
- * transaction ID. The transaction ID is useful for later disputes,
- * and the merchant's contract offer (@e h_contract) with the
- * customer should include the offer's term and transaction ID
- * signed with a key from the merchant.
+ * transactions, in big endian. The merchant must communicate a
+ * merchant-unique ID to the customer for each transaction. Note
+ * that different coins that are part of the same transaction can
+ * use the same transaction ID. The transaction ID is useful for
+ * later disputes, and the merchant's contract offer (@e h_contract)
+ * with the customer should include the offer's term and transaction
+ * ID signed with a key from the merchant.
*/
uint64_t transaction_id GNUNET_PACKED;
diff --git a/src/mint/taler-mint-httpd_db.c b/src/mint/taler-mint-httpd_db.c
index 14e03dfd2..d31dcd2ba 100644
--- a/src/mint/taler-mint-httpd_db.c
+++ b/src/mint/taler-mint-httpd_db.c
@@ -1702,7 +1702,6 @@ TMH_DB_execute_wire_deposits (struct MHD_Connection *connection,
ctx.deposits = json_array ();
ret = TMH_plugin->lookup_wire_transactions (TMH_plugin->cls,
&wtid->raw,
- sizeof (wtid->raw),
&handle_transaction_data,
&ctx);
if (GNUNET_SYSERR == ret)
@@ -1743,6 +1742,26 @@ struct DepositWtidContext
struct MHD_Connection *connection;
/**
+ * Hash of the contract we are looking up.
+ */
+ struct GNUNET_HashCode h_contract;
+
+ /**
+ * Hash of the wire transfer details we are looking up.
+ */
+ struct GNUNET_HashCode h_wire;
+
+ /**
+ * Public key we are looking up.
+ */
+ struct TALER_CoinSpendPublicKeyP coin_pub;
+
+ /**
+ * Transaction ID we are looking up.
+ */
+ uint64_t transaction_id;
+
+ /**
* MHD result code to return.
*/
int res;
@@ -1754,8 +1773,11 @@ struct DepositWtidContext
* wire transfer identifier information.
*
* @param cls our context for transmission
- * @param wtid base32-encoded wire transfer identifier, NULL
+ * @param wtid raw wire transfer identifier, NULL
* if the transaction was not yet done
+ * @param coin_contribution how much did the coin we asked about
+ * contribute to the total transfer value? (deposit value minus fee)
+ * @param total_amount how much was the total wire transfer?
* @param execution_time when was the transaction done, or
* when we expect it to be done (if @a wtid was NULL);
* #GNUNET_TIME_UNIT_FOREVER_ABS if the /deposit is unknown
@@ -1763,7 +1785,9 @@ struct DepositWtidContext
*/
static void
handle_wtid_data (void *cls,
- const char *wtid,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *coin_contribution,
+ const struct TALER_Amount *total_amount,
struct GNUNET_TIME_Absolute execution_time)
{
struct DepositWtidContext *ctx = cls;
@@ -1780,6 +1804,12 @@ handle_wtid_data (void *cls,
else
{
ctx->res = TMH_RESPONSE_reply_deposit_wtid (ctx->connection,
+ &ctx->h_contract,
+ &ctx->h_wire,
+ &ctx->coin_pub,
+ coin_contribution,
+ total_amount,
+ ctx->transaction_id,
wtid,
execution_time);
}
@@ -1810,6 +1840,10 @@ TMH_DB_execute_deposit_wtid (struct MHD_Connection *connection,
struct DepositWtidContext ctx;
ctx.connection = connection;
+ ctx.h_contract = *h_contract;
+ ctx.h_wire = *h_wire;
+ ctx.coin_pub = *coin_pub;
+ ctx.transaction_id = transaction_id;
ctx.res = MHD_NO; /* this value should never be read... */
ret = TMH_plugin->wire_lookup_deposit_wtid (TMH_plugin->cls,
h_contract,
diff --git a/src/mint/taler-mint-httpd_responses.c b/src/mint/taler-mint-httpd_responses.c
index 9a55d5aab..d89b74c8f 100644
--- a/src/mint/taler-mint-httpd_responses.c
+++ b/src/mint/taler-mint-httpd_responses.c
@@ -1092,34 +1092,69 @@ TMH_RESPONSE_reply_deposit_pending (struct MHD_Connection *connection,
* them. Generates the 200 reply.
*
* @param connection connection to the client
- * @param wtid wire transfer identifier (as 0-terminated string)
+ * @param h_contract hash of the contract
+ * @param h_wire hash of wire account details
+ * @param coin_pub public key of the coin
+ * @param coin_contribution how much did the coin we asked about
+ * contribute to the total transfer value? (deposit value minus fee)
+ * @param total_amount how much was the total wire transfer?
+ * @param transaction_id merchant transaction identifier
+ * @param wtid raw wire transfer identifier
* @param exec_time execution time of the wire transfer
* @return MHD result code
*/
int
TMH_RESPONSE_reply_deposit_wtid (struct MHD_Connection *connection,
- const char *wtid,
+ const struct GNUNET_HashCode *h_contract,
+ const struct GNUNET_HashCode *h_wire,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_Amount *coin_contribution,
+ const struct TALER_Amount *total_amount,
+ uint64_t transaction_id,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute exec_time)
{
struct TALER_ConfirmWirePS cw;
struct TALER_MintPublicKeyP pub;
struct TALER_MintSignatureP sig;
+ struct TALER_WireTransferIdentifierP wtid_crc;
+ char *wtid_s;
+ int ret;
+ /* Create signature for the reply */
cw.purpose.purpose = htonl (TALER_SIGNATURE_MINT_CONFIRM_WIRE);
cw.purpose.size = htonl (sizeof (struct TALER_ConfirmWirePS));
- // FIXME: fill in rest of 'cw'!
+ cw.h_wire = *h_wire;
+ cw.h_contract = *h_contract;
+ cw.wtid = *wtid;
+ cw.coin_pub = *coin_pub;
+ cw.transaction_id = GNUNET_htonll (transaction_id);
+ cw.execution_time = GNUNET_TIME_absolute_hton (exec_time);
+ TALER_amount_hton (&cw.coin_contribution,
+ coin_contribution);
+ TALER_amount_hton (&cw.total_amount,
+ total_amount);
TMH_KS_sign (&cw.purpose,
&pub,
&sig);
- return TMH_RESPONSE_reply_json_pack (connection,
- MHD_HTTP_FOUND,
+ /* Compute checksum and crockford encoding if wire transfer subject */
+ wtid_crc.raw = *wtid;
+ wtid_crc.crc8 = GNUNET_CRYPTO_crc8_n (wtid,
+ sizeof (struct TALER_WireTransferIdentifierRawP));
+
+ wtid_s = GNUNET_STRINGS_data_to_string_alloc (&wtid_crc,
+ sizeof (wtid_crc));
+ ret = TMH_RESPONSE_reply_json_pack (connection,
+ MHD_HTTP_OK,
"{s:s, s:o, s:o, s:o}",
- "wtid", wtid,
+ "wtid", wtid_s,
"execution_time", TALER_json_from_abs (exec_time),
"mint_sig", TALER_json_from_data (&sig,
sizeof (sig)),
"mint_pub", TALER_json_from_data (&pub,
sizeof (pub)));
+ GNUNET_free (wtid_s);
+ return ret;
}
@@ -1141,8 +1176,16 @@ TMH_RESPONSE_reply_wire_deposit_details (struct MHD_Connection *connection,
const struct GNUNET_HashCode *h_wire,
json_t *deposits)
{
- GNUNET_break (0); // FIXME: not implemented
- return MHD_NO;
+ /* FIXME: #4135: signing not implemented here */
+ return TMH_RESPONSE_reply_json_pack (connection,
+ MHD_HTTP_OK,
+ "{s:o, s:o, s:o, s:o}",
+ "total", TALER_json_from_amount (total),
+ "merchant_pub", TALER_json_from_data (merchant_pub,
+ sizeof (struct TALER_MerchantPublicKeyP)),
+ "h_wire", TALER_json_from_data (h_wire,
+ sizeof (struct GNUNET_HashCode)),
+ "deposits", deposits);
}
diff --git a/src/mint/taler-mint-httpd_responses.h b/src/mint/taler-mint-httpd_responses.h
index 6debbc935..caad29047 100644
--- a/src/mint/taler-mint-httpd_responses.h
+++ b/src/mint/taler-mint-httpd_responses.h
@@ -277,13 +277,23 @@ TMH_RESPONSE_reply_deposit_pending (struct MHD_Connection *connection,
* them. Generates the 200 reply.
*
* @param connection connection to the client
- * @param wtid wire transfer identifier (as 0-terminated string)
+ * @param h_contract hash of the contract
+ * @param h_wire hash of wire account details
+ * @param coin_pub public key of the coin
+ * @param transaction_id merchant transaction identifier
+ * @param wtid raw wire transfer identifier
* @param exec_time execution time of the wire transfer
* @return MHD result code
*/
int
TMH_RESPONSE_reply_deposit_wtid (struct MHD_Connection *connection,
- const char *wtid,
+ const struct GNUNET_HashCode *h_contract,
+ const struct GNUNET_HashCode *h_wire,
+ const struct TALER_CoinSpendPublicKeyP *coin_pub,
+ const struct TALER_Amount *coin_contribution,
+ const struct TALER_Amount *total_amount,
+ uint64_t transaction_id,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
struct GNUNET_TIME_Absolute exec_time);
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c
index 057ea9fe8..ad0c91150 100644
--- a/src/mintdb/plugin_mintdb_postgres.c
+++ b/src/mintdb/plugin_mintdb_postgres.c
@@ -3366,19 +3366,17 @@ postgres_get_coin_transactions (void *cls,
/**
* Lookup the list of Taler transactions that was aggregated
- * into a wire transfer by the respective @a raw_wtid.
+ * into a wire transfer by the respective @a wtid.
*
* @param cls closure
- * @param raw_wtid the raw wire transfer identifier we used
- * @param raw_len number of bytes in @a raw_wtid (right now always 32)
+ * @param wtid the raw wire transfer identifier we used
* @param cb function to call on each transaction found
* @param cb_cls closure for @a cb
* @return #GNUNET_OK on success, #GNUNET_SYSERR on database errors
*/
static int
postgres_lookup_wire_transactions (void *cls,
- const void *raw_wtid,
- size_t raw_len,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
TALER_MINTDB_TransactionDataCallback cb,
void *cb_cls)
{