prepare API to enable verification of fees in coin history check
This commit is contained in:
parent
33bd1ca2bb
commit
11c5283711
@ -1685,6 +1685,7 @@ TALER_EXCHANGE_track_transaction_cancel (struct
|
||||
* Convenience function. Verifies a coin's transaction history as
|
||||
* returned by the exchange.
|
||||
*
|
||||
* @param dk fee structure for the coin, NULL to skip verifying fees
|
||||
* @param currency expected currency for the coin
|
||||
* @param coin_pub public key of the coin
|
||||
* @param history history of the coin in json encoding
|
||||
@ -1692,7 +1693,9 @@ TALER_EXCHANGE_track_transaction_cancel (struct
|
||||
* @return #GNUNET_OK if @a history is valid, #GNUNET_SYSERR if not
|
||||
*/
|
||||
int
|
||||
TALER_EXCHANGE_verify_coin_history (const char *currency,
|
||||
TALER_EXCHANGE_verify_coin_history (const struct
|
||||
TALER_EXCHANGE_DenomPublicKey *dk,
|
||||
const char *currency,
|
||||
const struct
|
||||
TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
json_t *history,
|
||||
|
@ -29,6 +29,7 @@
|
||||
/**
|
||||
* Verify a coins transaction history as returned by the exchange.
|
||||
*
|
||||
* @param dk fee structure for the coin, NULL to skip verifying fees
|
||||
* @param currency expected currency for the coin
|
||||
* @param coin_pub public key of the coin
|
||||
* @param history history of the coin in json encoding
|
||||
@ -36,7 +37,9 @@
|
||||
* @return #GNUNET_OK if @a history is valid, #GNUNET_SYSERR if not
|
||||
*/
|
||||
int
|
||||
TALER_EXCHANGE_verify_coin_history (const char *currency,
|
||||
TALER_EXCHANGE_verify_coin_history (const struct
|
||||
TALER_EXCHANGE_DenomPublicKey *dk,
|
||||
const char *currency,
|
||||
const struct
|
||||
TALER_CoinSpendPublicKeyP *coin_pub,
|
||||
json_t *history,
|
||||
|
@ -101,9 +101,10 @@ struct TALER_EXCHANGE_DepositHandle
|
||||
struct TALER_Amount amount_with_fee;
|
||||
|
||||
/**
|
||||
* Total value of the coin being transacted with.
|
||||
* @brief Public information about the coin's denomination key.
|
||||
* Note that the "key" field itself has been zero'ed out.
|
||||
*/
|
||||
struct TALER_Amount coin_value;
|
||||
struct TALER_EXCHANGE_DenomPublicKey dki;
|
||||
|
||||
/**
|
||||
* Chance that we will inform the auditor about the deposit
|
||||
@ -250,7 +251,8 @@ verify_deposit_signature_forbidden (const struct
|
||||
history = json_object_get (json,
|
||||
"history");
|
||||
if (GNUNET_OK !=
|
||||
TALER_EXCHANGE_verify_coin_history (dh->coin_value.currency,
|
||||
TALER_EXCHANGE_verify_coin_history (&dh->dki,
|
||||
dh->dki.value.currency,
|
||||
&dh->depconf.coin_pub,
|
||||
history,
|
||||
&total))
|
||||
@ -269,7 +271,7 @@ verify_deposit_signature_forbidden (const struct
|
||||
}
|
||||
|
||||
if (0 >= TALER_amount_cmp (&total,
|
||||
&dh->coin_value))
|
||||
&dh->dki.value))
|
||||
{
|
||||
/* transaction should have still fit */
|
||||
GNUNET_break (0);
|
||||
@ -604,7 +606,9 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange,
|
||||
dh->depconf.coin_pub = *coin_pub;
|
||||
dh->depconf.merchant = *merchant_pub;
|
||||
dh->amount_with_fee = *amount;
|
||||
dh->coin_value = dki->value;
|
||||
dh->dki = *dki;
|
||||
dh->dki.key.rsa_public_key = NULL; /* lifetime not warranted, so better
|
||||
not copy the pointer */
|
||||
|
||||
eh = TEL_curl_easy_get (dh->url);
|
||||
if (GNUNET_OK !=
|
||||
|
@ -237,7 +237,8 @@ handle_payback_finished (void *cls,
|
||||
history = json_object_get (j,
|
||||
"history");
|
||||
if (GNUNET_OK !=
|
||||
TALER_EXCHANGE_verify_coin_history (dki->fee_deposit.currency,
|
||||
TALER_EXCHANGE_verify_coin_history (dki,
|
||||
dki->fee_deposit.currency,
|
||||
&ph->coin_pub,
|
||||
history,
|
||||
&total))
|
||||
@ -366,8 +367,7 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange,
|
||||
ph->coin_pub = pr.coin_pub;
|
||||
ph->exchange = exchange;
|
||||
ph->pk = *pk;
|
||||
ph->pk.key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (
|
||||
pk->key.rsa_public_key);
|
||||
ph->pk.key.rsa_public_key = NULL; /* zero out, as lifetime cannot be warranted */
|
||||
ph->cb = payback_cb;
|
||||
ph->cb_cls = payback_cb_cls;
|
||||
ph->url = TEAH_path_to_url (exchange, "/payback");
|
||||
@ -382,7 +382,6 @@ TALER_EXCHANGE_payback (struct TALER_EXCHANGE_Handle *exchange,
|
||||
curl_easy_cleanup (eh);
|
||||
json_decref (payback_obj);
|
||||
GNUNET_free (ph->url);
|
||||
GNUNET_CRYPTO_rsa_public_key_free (ph->pk.key.rsa_public_key);
|
||||
GNUNET_free (ph);
|
||||
return NULL;
|
||||
}
|
||||
@ -416,7 +415,6 @@ TALER_EXCHANGE_payback_cancel (struct TALER_EXCHANGE_PaybackHandle *ph)
|
||||
}
|
||||
GNUNET_free (ph->url);
|
||||
TALER_curl_easy_post_finished (&ph->ctx);
|
||||
GNUNET_CRYPTO_rsa_public_key_free (ph->pk.key.rsa_public_key);
|
||||
GNUNET_free (ph);
|
||||
}
|
||||
|
||||
|
@ -864,6 +864,11 @@ struct TALER_EXCHANGE_RefreshMeltHandle
|
||||
* Actual information about the melt operation.
|
||||
*/
|
||||
struct MeltData *md;
|
||||
|
||||
/**
|
||||
* @brief Public information about the coin's denomination key
|
||||
*/
|
||||
struct TALER_EXCHANGE_DenomPublicKey dki;
|
||||
};
|
||||
|
||||
|
||||
@ -1000,7 +1005,8 @@ verify_refresh_melt_signature_conflict (struct
|
||||
history = json_object_get (json,
|
||||
"history");
|
||||
if (GNUNET_OK !=
|
||||
TALER_EXCHANGE_verify_coin_history (original_value.currency,
|
||||
TALER_EXCHANGE_verify_coin_history (&rmh->dki,
|
||||
original_value.currency,
|
||||
&coin_pub,
|
||||
history,
|
||||
&total))
|
||||
@ -1153,6 +1159,8 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
|
||||
TALER_EXCHANGE_RefreshMeltCallback melt_cb,
|
||||
void *melt_cb_cls)
|
||||
{
|
||||
const struct TALER_EXCHANGE_Keys *key_state;
|
||||
const struct TALER_EXCHANGE_DenomPublicKey *dki;
|
||||
json_t *melt_obj;
|
||||
struct TALER_EXCHANGE_RefreshMeltHandle *rmh;
|
||||
CURL *eh;
|
||||
@ -1208,10 +1216,16 @@ TALER_EXCHANGE_refresh_melt (struct TALER_EXCHANGE_Handle *exchange,
|
||||
free_melt_data (md);
|
||||
return NULL;
|
||||
}
|
||||
key_state = TALER_EXCHANGE_get_keys (exchange);
|
||||
dki = TALER_EXCHANGE_get_denomination_key (key_state,
|
||||
&md->melted_coin.pub_key);
|
||||
|
||||
/* and now we can at last begin the actual request handling */
|
||||
rmh = GNUNET_new (struct TALER_EXCHANGE_RefreshMeltHandle);
|
||||
rmh->exchange = exchange;
|
||||
rmh->dki = *dki;
|
||||
rmh->dki.key.rsa_public_key = NULL; /* lifetime not warranted, so better
|
||||
not copy the pointer */
|
||||
rmh->melt_cb = melt_cb;
|
||||
rmh->melt_cb_cls = melt_cb_cls;
|
||||
rmh->md = md;
|
||||
|
Loading…
Reference in New Issue
Block a user