diff options
Diffstat (limited to 'src/bank-lib')
-rw-r--r-- | src/bank-lib/bank_api_admin.c | 12 | ||||
-rw-r--r-- | src/bank-lib/fakebank.c | 34 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_with_fakebank.c | 4 | ||||
-rw-r--r-- | src/bank-lib/test_bank_interpreter.c | 12 | ||||
-rw-r--r-- | src/bank-lib/test_bank_interpreter.h | 7 |
5 files changed, 49 insertions, 20 deletions
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index 338ddce92..0b6386ad4 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -162,8 +162,9 @@ handle_admin_add_incoming_finished (void *cls, * to the operators of the bank. * * @param ctx curl context for the event loop - * @param bank_base_url URL of the bank - * @param reserve_pub public key of the reserve + * @param bank_base_url URL of the bank (used to execute this request) + * @param exchange_base_url base URL of the exchange (for tracking) + * @param wtid wire transfer identifier for the transfer * @param amount amount that was deposited * @param execution_date when did we receive the amount * @param debit_account_no account number to withdraw from (53 bits at most) @@ -177,6 +178,7 @@ handle_admin_add_incoming_finished (void *cls, struct TALER_BANK_AdminAddIncomingHandle * TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, const char *bank_base_url, + const char *exchange_base_url, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount, uint64_t debit_account_no, @@ -188,9 +190,9 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, json_t *admin_obj; CURL *eh; - admin_obj = json_pack ("{s:o, s:o," - " s:I, s:I}", - "wtid", GNUNET_JSON_from_data_auto (wtid), /* #4340 */ + admin_obj = json_pack ("{s:s, s:o, s:o, s:I, s:I}", + "exchange_url", exchange_base_url, + "wtid", GNUNET_JSON_from_data_auto (wtid), "amount", TALER_JSON_from_amount (amount), "debit_account", (json_int_t) debit_account_no, "credit_account", (json_int_t) credit_account_no); diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index 83ea79770..d99332bdb 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2016 Inria and GNUnet e.V. + (C) 2016, 2017 Inria and GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -65,6 +65,11 @@ struct Transaction * Subject of the transfer. */ struct TALER_WireTransferIdentifierRawP wtid; + + /** + * Base URL of the exchange. + */ + char *exchange_base_url; }; @@ -105,6 +110,8 @@ struct TALER_FAKEBANK_Handle * @param want_amount transfer amount desired * @param want_debit account that should have been debited * @param want_debit account that should have been credited + * @param exchange_base_url expected base URL of the exchange + * i.e. "https://example.com/"; may include a port * @param[out] wtid set to the wire transfer identifier * @return #GNUNET_OK on success */ @@ -113,6 +120,7 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, const struct TALER_Amount *want_amount, uint64_t want_debit, uint64_t want_credit, + const char *exchange_base_url, struct TALER_WireTransferIdentifierRawP *wtid) { struct Transaction *t; @@ -122,12 +130,15 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, if ( (want_debit == t->debit_account) && (want_credit == t->credit_account) && (0 == TALER_amount_cmp (want_amount, - &t->amount)) ) + &t->amount)) && + (0 == strcasecmp (exchange_base_url, + t->exchange_base_url)) ) { GNUNET_CONTAINER_DLL_remove (h->transactions_head, h->transactions_tail, t); *wtid = t->wtid; + GNUNET_free (t->exchange_base_url); GNUNET_free (t); return GNUNET_OK; } @@ -140,10 +151,11 @@ TALER_FAKEBANK_check (struct TALER_FAKEBANK_Handle *h, s = TALER_amount_to_string (&t->amount); fprintf (stderr, - "%llu -> %llu (%s)\n", + "%llu -> %llu (%s) from %s\n", (unsigned long long) t->debit_account, (unsigned long long) t->credit_account, - s); + s, + t->exchange_base_url); GNUNET_free (s); } return GNUNET_SYSERR; @@ -174,10 +186,11 @@ TALER_FAKEBANK_check_empty (struct TALER_FAKEBANK_Handle *h) s = TALER_amount_to_string (&t->amount); fprintf (stderr, - "%llu -> %llu (%s)\n", + "%llu -> %llu (%s) from %s\n", (unsigned long long) t->debit_account, (unsigned long long) t->credit_account, - s); + s, + t->exchange_base_url); GNUNET_free (s); } return GNUNET_SYSERR; @@ -199,6 +212,7 @@ TALER_FAKEBANK_stop (struct TALER_FAKEBANK_Handle *h) GNUNET_CONTAINER_DLL_remove (h->transactions_head, h->transactions_tail, t); + GNUNET_free (t->exchange_base_url); GNUNET_free (t); } if (NULL != h->mhd_task) @@ -303,11 +317,13 @@ handle_mhd_request (void *cls, } t = GNUNET_new (struct Transaction); { + const char *base_url; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("wtid", &t->wtid), GNUNET_JSON_spec_uint64 ("debit_account", &t->debit_account), GNUNET_JSON_spec_uint64 ("credit_account", &t->credit_account), TALER_JSON_spec_amount ("amount", &t->amount), + GNUNET_JSON_spec_string ("exchange_url", &base_url), GNUNET_JSON_spec_end () }; if (GNUNET_OK != @@ -319,14 +335,16 @@ handle_mhd_request (void *cls, json_decref (json); return MHD_NO; } + t->exchange_base_url = GNUNET_strdup (base_url); GNUNET_CONTAINER_DLL_insert (h->transactions_head, h->transactions_tail, t); } GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "Receiving incoming wire transfer: %llu->%llu\n", + "Receiving incoming wire transfer: %llu->%llu from %s\n", (unsigned long long) t->debit_account, - (unsigned long long) t->credit_account); + (unsigned long long) t->credit_account, + t->exchange_base_url); json_decref (json); resp = MHD_create_response_from_buffer (0, "", MHD_RESPMEM_PERSISTENT); ret = MHD_queue_response (connection, diff --git a/src/bank-lib/test_bank_api_with_fakebank.c b/src/bank-lib/test_bank_api_with_fakebank.c index 8e0ac6d15..3c726a749 100644 --- a/src/bank-lib/test_bank_api_with_fakebank.c +++ b/src/bank-lib/test_bank_api_with_fakebank.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2016 GNUnet e.V. + Copyright (C) 2016, 2017 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -45,6 +45,7 @@ run (void *cls) .details.admin_add_incoming.expected_response_code = MHD_HTTP_OK, .details.admin_add_incoming.credit_account_no = 1, .details.admin_add_incoming.debit_account_no = 2, + .details.admin_add_incoming.exchange_base_url = "https://exchange.net/", .details.admin_add_incoming.amount = "PUDOS:5.01" }, /* Add EUR:3.21 to account 3 */ { .oc = TBI_OC_ADMIN_ADD_INCOMING, @@ -52,6 +53,7 @@ run (void *cls) .details.admin_add_incoming.expected_response_code = MHD_HTTP_OK, .details.admin_add_incoming.credit_account_no = 3, .details.admin_add_incoming.debit_account_no = 2, + .details.admin_add_incoming.exchange_base_url = "https://exchange.org/", .details.admin_add_incoming.amount = "PUDOS:3.21" }, /* check transfers arrived at fakebank */ { .oc = TBI_OC_EXPECT_TRANSFER, diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index 03648786c..f088cfc40 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2016 GNUnet e.V. + Copyright (C) 2016, 2017 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -222,6 +222,7 @@ interpreter_run (void *cls) cmd->details.admin_add_incoming.aih = TALER_BANK_admin_add_incoming (is->ctx, "http://localhost:8081", + cmd->details.admin_add_incoming.exchange_base_url, &cmd->details.admin_add_incoming.wtid, &amount, cmd->details.admin_add_incoming.debit_account_no, @@ -243,10 +244,11 @@ interpreter_run (void *cls) &amount)); if (GNUNET_OK != TALER_FAKEBANK_check (is->fakebank, - &amount, - ref->details.admin_add_incoming.debit_account_no, - ref->details.admin_add_incoming.credit_account_no, - &wtid)) + &amount, + ref->details.admin_add_incoming.debit_account_no, + ref->details.admin_add_incoming.credit_account_no, + ref->details.admin_add_incoming.exchange_base_url, + &wtid)) { GNUNET_break (0); fail (is); diff --git a/src/bank-lib/test_bank_interpreter.h b/src/bank-lib/test_bank_interpreter.h index 0093b0db3..1f2772ca7 100644 --- a/src/bank-lib/test_bank_interpreter.h +++ b/src/bank-lib/test_bank_interpreter.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2016 GNUnet e.V. + Copyright (C) 2016, 2017 GNUnet e.V. TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -100,6 +100,11 @@ struct TBI_Command uint64_t debit_account_no; /** + * Exchange base URL to use. + */ + const char *exchange_base_url; + + /** * Wire transfer identifier to use. Initialized to * a random value. */ |