From cde71b7fe74c2a5abb32bf07d40a112e9d7b1135 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:07:49 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later) --- src/testing/testing_api_cmd_deposits_get.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index fd02e75b..6f014011 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -81,29 +81,17 @@ struct TrackTransactionState * * @param cls closure. * @param hr HTTP response details - * @param exchange_pub public key of the exchange - * @param wtid wire transfer identifier, NULL if exchange did not - * execute the transaction yet. - * @param execution_time actual or planned execution time for the - * wire transfer. - * @param coin_contribution contribution to the total amount of - * the deposited coin (can be NULL). + * @param dd data about the wire transfer associated with the deposit */ static void deposit_wtid_cb (void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, - const struct TALER_ExchangePublicKeyP *exchange_pub, - const struct TALER_WireTransferIdentifierRawP *wtid, - struct GNUNET_TIME_Absolute execution_time, - const struct TALER_Amount *coin_contribution) + const struct TALER_EXCHANGE_DepositData *dd) { struct TrackTransactionState *tts = cls; struct TALER_TESTING_Interpreter *is = tts->is; struct TALER_TESTING_Command *cmd = &is->commands[is->ip]; - (void) coin_contribution; - (void) exchange_pub; - (void) execution_time; tts->tth = NULL; if (tts->expected_response_code != hr->http_status) { @@ -123,7 +111,8 @@ deposit_wtid_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - tts->wtid = *wtid; + GNUNET_assert (NULL != dd->wtid); + tts->wtid = *dd->wtid; if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; @@ -151,7 +140,7 @@ deposit_wtid_cb (void *cls, } /* Compare that expected and gotten subjects match. */ - if (0 != GNUNET_memcmp (wtid, + if (0 != GNUNET_memcmp (dd->wtid, wtid_want)) { GNUNET_break (0); -- cgit v1.2.3 From 4844023f6904d2281cc90fe23d372978a9d9c137 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:12:18 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies --- src/include/taler_exchange_service.h | 16 +++++++-------- src/lib/exchange_api_deposits_get.c | 31 +++++++++++------------------- src/testing/testing_api_cmd_deposits_get.c | 5 ++--- 3 files changed, 21 insertions(+), 31 deletions(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 32012304..f94b8253 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1691,22 +1691,22 @@ struct TALER_EXCHANGE_DepositData { /** - * exchange key used to sign, NULL if exchange did not + * exchange key used to sign, all zeros if exchange did not * yet execute the transaction */ - const struct TALER_ExchangePublicKeyP *exchange_pub; + struct TALER_ExchangePublicKeyP exchange_pub; /** - * signature from the exchange over the deposit data, NULL if exchange did not + * signature from the exchange over the deposit data, all zeros if exchange did not * yet execute the transaction */ - const struct TALER_ExchangeSignatureP *exchange_sig; + struct TALER_ExchangeSignatureP exchange_sig; /** - * wire transfer identifier used by the exchange, NULL if exchange did not + * wire transfer identifier used by the exchange, all zeros if exchange did not * yet execute the transaction */ - const struct TALER_WireTransferIdentifierRawP *wtid; + struct TALER_WireTransferIdentifierRawP wtid; /** * actual or planned execution time for the wire transfer @@ -1714,10 +1714,10 @@ struct TALER_EXCHANGE_DepositData struct GNUNET_TIME_Absolute execution_time; /** - * contribution to the total amount by this coin, NULL if exchange did not + * contribution to the total amount by this coin, all zeros if exchange did not * yet execute the transaction */ - const struct TALER_Amount *coin_contribution; + struct TALER_Amount coin_contribution; }; diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c index 6a2ad5c3..004a24d4 100644 --- a/src/lib/exchange_api_deposits_get.c +++ b/src/lib/exchange_api_deposits_get.c @@ -146,16 +146,13 @@ handle_deposit_wtid_finished (void *cls, break; case MHD_HTTP_OK: { - struct GNUNET_TIME_Absolute execution_time; - struct TALER_Amount coin_contribution; - struct TALER_ExchangePublicKeyP exchange_pub; - struct TALER_ExchangeSignatureP exchange_sig; + struct TALER_EXCHANGE_DepositData dd; struct GNUNET_JSON_Specification spec[] = { GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid), - GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), - TALER_JSON_spec_amount ("coin_contribution", &coin_contribution), - GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), - GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub), + GNUNET_JSON_spec_absolute_time ("execution_time", &dd.execution_time), + TALER_JSON_spec_amount ("coin_contribution", &dd.coin_contribution), + GNUNET_JSON_spec_fixed_auto ("exchange_sig", &dd.exchange_sig), + GNUNET_JSON_spec_fixed_auto ("exchange_pub", &dd.exchange_pub), GNUNET_JSON_spec_end () }; @@ -169,14 +166,15 @@ handle_deposit_wtid_finished (void *cls, hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE; break; } - dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (execution_time); + dwh->depconf.execution_time = GNUNET_TIME_absolute_hton ( + dd.execution_time); TALER_amount_hton (&dwh->depconf.coin_contribution, - &coin_contribution); + &dd.coin_contribution); if (GNUNET_OK != verify_deposit_wtid_signature_ok (dwh, j, - &exchange_pub, - &exchange_sig)) + &dd.exchange_pub, + &dd.exchange_sig)) { GNUNET_break_op (0); hr.http_status = 0; @@ -184,14 +182,7 @@ handle_deposit_wtid_finished (void *cls, } else { - struct TALER_EXCHANGE_DepositData dd = { - .exchange_pub = &exchange_pub, - .exchange_sig = &exchange_sig, - .wtid = &dwh->depconf.wtid, - .execution_time = execution_time, - .coin_contribution = &coin_contribution - }; - + dd.wtid = dwh->depconf.wtid; dwh->cb (dwh->cb_cls, &hr, &dd); diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 6f014011..33987e16 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -111,8 +111,7 @@ deposit_wtid_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - GNUNET_assert (NULL != dd->wtid); - tts->wtid = *dd->wtid; + tts->wtid = dd->wtid; if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; @@ -140,7 +139,7 @@ deposit_wtid_cb (void *cls, } /* Compare that expected and gotten subjects match. */ - if (0 != GNUNET_memcmp (dd->wtid, + if (0 != GNUNET_memcmp (&dd->wtid, wtid_want)) { GNUNET_break (0); -- cgit v1.2.3 From 035c505c71610a693d3d253a3eee02d9cb9a2cbf Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:07:49 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later) --- src/include/taler_exchange_service.h | 1 + src/testing/testing_api_cmd_deposits_get.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 38928dc1..ea185f09 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1722,6 +1722,7 @@ struct TALER_EXCHANGE_DepositData * yet execute the transaction */ struct TALER_Amount coin_contribution; + }; diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 33987e16..640ab6e3 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -112,6 +112,7 @@ deposit_wtid_cb (void *cls, { case MHD_HTTP_OK: tts->wtid = dd->wtid; + if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; -- cgit v1.2.3 From 556085ac80df6148a1c0523ada516f843390ce6d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:12:18 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies --- src/testing/testing_api_cmd_deposits_get.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 640ab6e3..33987e16 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -112,7 +112,6 @@ deposit_wtid_cb (void *cls, { case MHD_HTTP_OK: tts->wtid = dd->wtid; - if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; -- cgit v1.2.3 From cdbf3a05ae3c92122b8ec15073c6fadfa0793315 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:07:49 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later) --- src/include/taler_exchange_service.h | 4 ---- src/testing/testing_api_cmd_deposits_get.c | 11 ++++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 2fb15db1..ea185f09 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1611,11 +1611,7 @@ struct TALER_EXCHANGE_TransferData struct GNUNET_TIME_Absolute execution_time; /** -<<<<<<< HEAD - * amount of the wire transfer; FIXME: total wired (without fee), or including @a wire_fee? -======= * amount of the wire transfer ->>>>>>> update exchange API to return struct instead of lots of individual args for TALER_EXCHANGE_transfers_get() -- simplifies merchant later */ struct TALER_Amount total_amount; diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 33987e16..700b0edf 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -111,7 +111,14 @@ deposit_wtid_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - tts->wtid = dd->wtid; + << << << < HEAD + tts->wtid = dd->wtid; + ====== = + GNUNET_assert (NULL != dd->wtid); + tts->wtid = *dd->wtid; + >> >> >> > modify + TALER_EXCHANGE_deposits_get () API to combine returned arguments into + a struct (simplifies merchant later) if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; @@ -147,6 +154,8 @@ deposit_wtid_cb (void *cls, return; } } + + break; case MHD_HTTP_ACCEPTED: /* allowed, nothing to check here */ -- cgit v1.2.3 From 099102dc573293656988adf6b9783255ae4fc643 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:12:18 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies --- src/include/taler_exchange_service.h | 1 - src/testing/testing_api_cmd_deposits_get.c | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index ea185f09..38928dc1 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1722,7 +1722,6 @@ struct TALER_EXCHANGE_DepositData * yet execute the transaction */ struct TALER_Amount coin_contribution; - }; diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 700b0edf..d5617ec2 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -111,14 +111,7 @@ deposit_wtid_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - << << << < HEAD - tts->wtid = dd->wtid; - ====== = - GNUNET_assert (NULL != dd->wtid); - tts->wtid = *dd->wtid; - >> >> >> > modify - TALER_EXCHANGE_deposits_get () API to combine returned arguments into - a struct (simplifies merchant later) + tts->wtid = dd->wtid; if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; -- cgit v1.2.3 From d63cf1e40eb78348302eb187adf576f73a51e01a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:07:49 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later) --- src/testing/testing_api_cmd_deposits_get.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index d5617ec2..9b65822b 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -111,7 +111,8 @@ deposit_wtid_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - tts->wtid = dd->wtid; + GNUNET_assert (NULL != dd->wtid); + tts->wtid = *dd->wtid; if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; @@ -139,7 +140,11 @@ deposit_wtid_cb (void *cls, } /* Compare that expected and gotten subjects match. */ +<<<<<<< HEAD if (0 != GNUNET_memcmp (&dd->wtid, +======= + if (0 != GNUNET_memcmp (dd->wtid, +>>>>>>> modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later) wtid_want)) { GNUNET_break (0); -- cgit v1.2.3 From 532440acf829f794fec93952da889ca015559bb4 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 May 2020 20:12:18 +0200 Subject: modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies --- src/testing/testing_api_cmd_deposits_get.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/testing/testing_api_cmd_deposits_get.c') diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c index 9b65822b..d5617ec2 100644 --- a/src/testing/testing_api_cmd_deposits_get.c +++ b/src/testing/testing_api_cmd_deposits_get.c @@ -111,8 +111,7 @@ deposit_wtid_cb (void *cls, switch (hr->http_status) { case MHD_HTTP_OK: - GNUNET_assert (NULL != dd->wtid); - tts->wtid = *dd->wtid; + tts->wtid = dd->wtid; if (NULL != tts->bank_transfer_reference) { const struct TALER_TESTING_Command *bank_transfer_cmd; @@ -140,11 +139,7 @@ deposit_wtid_cb (void *cls, } /* Compare that expected and gotten subjects match. */ -<<<<<<< HEAD if (0 != GNUNET_memcmp (&dd->wtid, -======= - if (0 != GNUNET_memcmp (dd->wtid, ->>>>>>> modify TALER_EXCHANGE_deposits_get() API to combine returned arguments into a struct (simplifies merchant later) wtid_want)) { GNUNET_break (0); -- cgit v1.2.3