diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-05-15 15:53:21 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-05-16 11:05:00 +0200 |
commit | 7c28823cafa0692849deae506e81efdbc07f2ed3 (patch) | |
tree | ae955b26766f21370e1da7d7c367c25bc9dec422 | |
parent | be3b891dbd9b1532b9dca91629d478cc3933dfdc (diff) |
handle base32-wire transfer subject being followed by space+exchange base url in wire plugin and fakebank
-rw-r--r-- | src/bank-lib/fakebank.c | 13 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api.c | 4 | ||||
-rw-r--r-- | src/bank-lib/test_bank_api_with_fakebank.c | 6 | ||||
-rw-r--r-- | src/bank-lib/test_bank_interpreter.c | 14 | ||||
-rw-r--r-- | src/include/taler_bank_service.h | 3 | ||||
-rw-r--r-- | src/wire/plugin_wire_test.c | 18 |
6 files changed, 45 insertions, 13 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index fb5121687..8d16567fb 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c @@ -512,8 +512,17 @@ handle_history (struct TALER_FAKEBANK_Handle *h, continue; } - subject = GNUNET_STRINGS_data_to_string_alloc (&pos->wtid, - sizeof (pos->wtid)); + { + char *ws; + + ws = GNUNET_STRINGS_data_to_string_alloc (&pos->wtid, + sizeof (pos->wtid)); + GNUNET_asprintf (&subject, + "%s %s", + ws, + pos->exchange_base_url); + GNUNET_free (ws); + } trans = json_pack ("{s:I, s:o, s:o, s:s, s:I, s:s}", "row_id", (json_int_t) pos->serial_id, "date", GNUNET_JSON_from_time_abs (pos->date), diff --git a/src/bank-lib/test_bank_api.c b/src/bank-lib/test_bank_api.c index 800dc56a0..9904f3718 100644 --- a/src/bank-lib/test_bank_api.c +++ b/src/bank-lib/test_bank_api.c @@ -53,7 +53,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, /* Ignored */ - .details.admin_add_incoming.amount = "PUDOS:5.01" }, + .details.admin_add_incoming.amount = "KUDOS:5.01" }, /* Move money from Exchange to Bank */ { .oc = TBI_OC_ADMIN_ADD_INCOMING, .label = "deposit-2", @@ -61,7 +61,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, /* Ignored */ - .details.admin_add_incoming.amount = "PUDOS:5.01" }, + .details.admin_add_incoming.amount = "KUDOS:5.01" }, #if 0 /* Ask Exchange's incoming history */ { .oc = TBI_OC_HISTORY, diff --git a/src/bank-lib/test_bank_api_with_fakebank.c b/src/bank-lib/test_bank_api_with_fakebank.c index 01ab30cd9..e16c3a915 100644 --- a/src/bank-lib/test_bank_api_with_fakebank.c +++ b/src/bank-lib/test_bank_api_with_fakebank.c @@ -52,7 +52,7 @@ run (void *cls) .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" }, + .details.admin_add_incoming.amount = "KUDOS:5.01" }, /* Add EUR:3.21 to account 3 */ { .oc = TBI_OC_HISTORY, .label = "history-1c", @@ -72,14 +72,14 @@ run (void *cls) .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" }, + .details.admin_add_incoming.amount = "KUDOS:3.21" }, { .oc = TBI_OC_ADMIN_ADD_INCOMING, .label = "credit-2", .details.admin_add_incoming.expected_response_code = MHD_HTTP_OK, .details.admin_add_incoming.credit_account_no = 2, .details.admin_add_incoming.debit_account_no = 3, .details.admin_add_incoming.exchange_base_url = "https://exchange.org/", - .details.admin_add_incoming.amount = "PUDOS:3.22" }, + .details.admin_add_incoming.amount = "KUDOS:3.22" }, { .oc = TBI_OC_HISTORY, .label = "history-2b", .details.history.account_number = 2, diff --git a/src/bank-lib/test_bank_interpreter.c b/src/bank-lib/test_bank_interpreter.c index bfd744a0b..94b3b0e51 100644 --- a/src/bank-lib/test_bank_interpreter.c +++ b/src/bank-lib/test_bank_interpreter.c @@ -323,9 +323,17 @@ build_history (struct InterpreterState *is, /* h[total].execution_date; // unknown here */ h[total].serial_id = pos->details.admin_add_incoming.serial_id; - h[total].details.wire_transfer_subject - = GNUNET_STRINGS_data_to_string_alloc (&pos->details.admin_add_incoming.wtid, - sizeof (struct TALER_WireTransferIdentifierRawP)); + { + char *ws; + + ws = GNUNET_STRINGS_data_to_string_alloc (&pos->details.admin_add_incoming.wtid, + sizeof (struct TALER_WireTransferIdentifierRawP)); + GNUNET_asprintf (&h[total].details.wire_transfer_subject, + "%s %s", + ws, + pos->details.admin_add_incoming.exchange_base_url); + GNUNET_free (ws); + } total++; } } diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h index 803250d56..246174df9 100644 --- a/src/include/taler_bank_service.h +++ b/src/include/taler_bank_service.h @@ -200,7 +200,8 @@ struct TALER_BANK_TransferDetails struct GNUNET_TIME_Absolute execution_date; /** - * Wire transfer subject + * Wire transfer subject. Usually a reserve public key + * followed by the BASE URI of the exchange. */ char *wire_transfer_subject; diff --git a/src/wire/plugin_wire_test.c b/src/wire/plugin_wire_test.c index de3a6aba6..8d625ce6b 100644 --- a/src/wire/plugin_wire_test.c +++ b/src/wire/plugin_wire_test.c @@ -822,16 +822,29 @@ bhist_cb (void *cls, if (MHD_HTTP_OK == http_status) { + char *subject; + char *space; + wd.amount = details->amount; wd.execution_date = details->execution_date; + subject = GNUNET_strdup (details->wire_transfer_subject); + space = strchr (subject, (int) ' '); + if (NULL != space) + { + /* Space separates the actual wire transfer subject from the + exchange base URL (if present, expected only for outgoing + transactions). So we cut the string off at the space. */ + *space = '\0'; + } /* NOTE: For a real bank, the subject should include a checksum! */ if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (details->wire_transfer_subject, - strlen (details->wire_transfer_subject), + GNUNET_STRINGS_string_to_data (subject, + strlen (subject), &wd.reserve_pub, sizeof (wd.reserve_pub))) { GNUNET_break (0); + GNUNET_free (subject); /* NOTE: for a "real" bank, we would want to trigger logic to undo the wire transfer. However, for the "demo" bank, it should currently be "impossible" to do wire transfers with invalid subjects, and @@ -839,6 +852,7 @@ bhist_cb (void *cls, that nicely either right now). So we don't handle this case for now. */ return; } + GNUNET_free (subject); wd.account_details = details->account_details; if ( (NULL != whh->hres_cb) && |