diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bank-lib/fakebank.c | 36 | ||||
-rw-r--r-- | src/include/taler_fakebank_lib.h | 4 |
2 files changed, 35 insertions, 5 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index 267201358..5b03648f6 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -28,7 +28,7 @@ #include "taler_mhd_lib.h" /** - * Maximum POST request size (for /admin/add/incoming) + * Maximum POST request size (for /admin/add-incoming) */ #define REQUEST_BUFFER_MAX (4 * 1024) @@ -64,6 +64,11 @@ struct Transaction char *credit_account; /** + * Random unique identifier for the request. + */ + struct GNUNET_HashCode request_uid; + + /** * What does the @e subject contain? */ enum @@ -346,6 +351,7 @@ TALER_FAKEBANK_check_credit (struct TALER_FAKEBANK_Handle *h, * @param amount amount to transfer * @param subject wire transfer subject to use * @param exchange_base_url exchange URL + * @param request_uid unique number to make the request unique, or NULL to create one * @return row_id of the transfer */ uint64_t @@ -355,10 +361,27 @@ TALER_FAKEBANK_make_transfer (struct TALER_FAKEBANK_Handle *h, const struct TALER_Amount *amount, const struct TALER_WireTransferIdentifierRawP *subject, - const char *exchange_base_url) + const char *exchange_base_url, + const struct GNUNET_HashCode *request_uid) { struct Transaction *t; + if (NULL != request_uid) + { + for (struct Transaction *t = h->transactions_head; NULL != t; t = t->next) + if ( (0 == GNUNET_memcmp (request_uid, + &t->request_uid)) && + (0 == strcasecmp (debit_account, + t->debit_account)) && + (0 == strcasecmp (credit_account, + t->credit_account)) && + (0 == TALER_amount_cmp (amount, + &t->amount)) && + (T_DEBIT == t->type) && + (0 == GNUNET_memcmp (subject, + &t->subject.debit.wtid)) ) + return t->row_id; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Making transfer from %s to %s over %s and subject %s; for exchange: %s\n", debit_account, @@ -375,6 +398,11 @@ TALER_FAKEBANK_make_transfer (struct TALER_FAKEBANK_Handle *h, t->type = T_DEBIT; t->subject.debit.exchange_base_url = GNUNET_strdup (exchange_base_url); t->subject.debit.wtid = *subject; + if (NULL == request_uid) + GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_NONCE, + &t->request_uid); + else + t->request_uid = *request_uid; GNUNET_TIME_round_abs (&t->date); GNUNET_CONTAINER_DLL_insert_tail (h->transactions_head, h->transactions_tail, @@ -690,13 +718,13 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h, return MHD_NO; } { - // FIXME: use uuid here!!! row_id = TALER_FAKEBANK_make_transfer (h, account, credit_account, &amount, &wtid, - base_url); + base_url, + &uuid); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s, from %s\n", account, diff --git a/src/include/taler_fakebank_lib.h b/src/include/taler_fakebank_lib.h index 25e04187c..017ffd454 100644 --- a/src/include/taler_fakebank_lib.h +++ b/src/include/taler_fakebank_lib.h @@ -70,6 +70,7 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h); * @param amount amount to transfer * @param subject wire transfer subject to use * @param exchange_base_url exchange URL + * @param request_uid unique number to make the request unique, or NULL to create one * @return serial_id of the transfer */ uint64_t @@ -79,7 +80,8 @@ TALER_FAKEBANK_make_transfer (struct TALER_FAKEBANK_Handle *h, const struct TALER_Amount *amount, const struct TALER_WireTransferIdentifierRawP *subject, - const char *exchange_base_url); + const char *exchange_base_url, + const struct GNUNET_HashCode *request_uid); /** |