diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-12-25 13:56:33 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-12-25 13:56:40 +0100 |
commit | 87376e02eba3f5c2cf83a493446dee0c300565a4 (patch) | |
tree | 18103edb2bdf2b29a773cce2de596b06d8265abb /src/lib/exchange_api_melt.c | |
parent | 2c14d338704f4574055c4b5c51d8a79dd2e22345 (diff) | |
download | exchange-87376e02eba3f5c2cf83a493446dee0c300565a4.tar.xz |
protocol v12 changes (/recoup split, signature changes) plus database sharding plus O(n^2)=>O(n) worst-case complexity reduction on coin balance checks
Diffstat (limited to 'src/lib/exchange_api_melt.c')
-rw-r--r-- | src/lib/exchange_api_melt.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c index ab20e6fc1..f375171b9 100644 --- a/src/lib/exchange_api_melt.c +++ b/src/lib/exchange_api_melt.c @@ -213,15 +213,10 @@ verify_melt_signature_spend_conflict (struct TALER_EXCHANGE_MeltHandle *mh, const json_t *json) { json_t *history; - struct TALER_Amount original_value; - struct TALER_Amount melt_value_with_fee; struct TALER_Amount total; - struct TALER_CoinSpendPublicKeyP coin_pub; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("history", &history), - GNUNET_JSON_spec_fixed_auto ("coin_pub", &coin_pub), - TALER_JSON_spec_amount_any ("original_value", &original_value), - TALER_JSON_spec_amount_any ("requested_value", &melt_value_with_fee), + GNUNET_JSON_spec_json ("history", + &history), GNUNET_JSON_spec_end () }; const struct MeltedCoin *mc; @@ -240,25 +235,6 @@ verify_melt_signature_spend_conflict (struct TALER_EXCHANGE_MeltHandle *mh, /* Find out which coin was deemed problematic by the exchange */ mc = &mh->md->melted_coin; - - /* check basic coin properties */ - if (0 != TALER_amount_cmp (&original_value, - &mc->original_value)) - { - /* We disagree on the value of the coin */ - GNUNET_break_op (0); - json_decref (history); - return GNUNET_SYSERR; - } - if (0 != TALER_amount_cmp (&melt_value_with_fee, - &mc->melt_amount_with_fee)) - { - /* We disagree on the value of the coin */ - GNUNET_break_op (0); - json_decref (history); - return GNUNET_SYSERR; - } - /* verify coin history */ memset (&h_denom_pub, 0, @@ -267,8 +243,8 @@ verify_melt_signature_spend_conflict (struct TALER_EXCHANGE_MeltHandle *mh, "history"); if (GNUNET_OK != TALER_EXCHANGE_verify_coin_history (&mh->dki, - original_value.currency, - &coin_pub, + mc->original_value.currency, + &mh->coin_pub, history, &h_denom_pub, &total)) @@ -287,7 +263,7 @@ verify_melt_signature_spend_conflict (struct TALER_EXCHANGE_MeltHandle *mh, if (0 > TALER_amount_add (&total, &total, - &melt_value_with_fee)) + &mc->melt_amount_with_fee)) { /* clearly not OK if our transaction would have caused the overflow... */ @@ -295,7 +271,7 @@ verify_melt_signature_spend_conflict (struct TALER_EXCHANGE_MeltHandle *mh, } if (0 >= TALER_amount_cmp (&total, - &original_value)) + &mc->original_value)) { /* transaction should have still fit */ GNUNET_break (0); @@ -488,7 +464,7 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, &coin_pub.eddsa_pub); melt_obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_data_auto ("denom_pub_hash", - &melt.h_denom_pub), + &h_denom_pub), TALER_JSON_pack_denom_sig ("denom_sig", &md->melted_coin.sig), GNUNET_JSON_pack_data_auto ("confirm_sig", @@ -496,13 +472,13 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, TALER_JSON_pack_amount ("value_with_fee", &md->melted_coin.melt_amount_with_fee), GNUNET_JSON_pack_data_auto ("rc", - &melt.rc)); + &md->rc)); { char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; char *end; end = GNUNET_STRINGS_data_to_string ( - &melt.coin_pub, + &coin_pub, sizeof (struct TALER_CoinSpendPublicKeyP), pub_str, sizeof (pub_str)); @@ -520,7 +496,7 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, /* and now we can at last begin the actual request handling */ mh = GNUNET_new (struct TALER_EXCHANGE_MeltHandle); mh->exchange = exchange; - mh->coin_pub = melt.coin_pub; + mh->coin_pub = coin_pub; mh->dki = *dki; memset (&mh->dki.key, 0, |