-some FIXMEs from API review

This commit is contained in:
Christian Grothoff 2022-06-02 12:59:06 +02:00
parent 65ce2eede6
commit 5dd03fe359
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 43 additions and 22 deletions

View File

@ -225,17 +225,18 @@ create_transaction (void *cls,
TALER_amount_set_zero (pcc->amount.currency, TALER_amount_set_zero (pcc->amount.currency,
&purse_fee); &purse_fee);
/* 1) create purse */ /* 1) create purse */
qs = TEH_plugin->insert_purse_request (TEH_plugin->cls, qs = TEH_plugin->insert_purse_request (
pcc->purse_pub, TEH_plugin->cls,
&pcc->merge_pub, pcc->purse_pub,
pcc->purse_expiration, &pcc->merge_pub,
&pcc->h_contract_terms, pcc->purse_expiration,
pcc->min_age, &pcc->h_contract_terms,
TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE, pcc->min_age,
&purse_fee, TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
&pcc->amount, &purse_fee,
&pcc->purse_sig, &pcc->amount,
&in_conflict); &pcc->purse_sig,
&in_conflict);
if (qs < 0) if (qs < 0)
{ {
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@ -409,12 +410,13 @@ create_transaction (void *cls,
void *econtract; void *econtract;
struct GNUNET_HashCode h_econtract; struct GNUNET_HashCode h_econtract;
qs = TEH_plugin->select_contract_by_purse (TEH_plugin->cls, qs = TEH_plugin->select_contract_by_purse (
pcc->purse_pub, TEH_plugin->cls,
&pub_ckey, pcc->purse_pub,
&econtract_sig, &pub_ckey,
&econtract_size, &econtract_sig,
&econtract); &econtract_size,
&econtract);
if (qs <= 0) if (qs <= 0)
{ {
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@ -478,6 +480,7 @@ parse_coin (struct MHD_Connection *connection,
GNUNET_JSON_spec_fixed_auto ("h_age_commitment", GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
&coin->cpi.h_age_commitment), &coin->cpi.h_age_commitment),
&coin->cpi.no_age_commitment), &coin->cpi.no_age_commitment),
// FIXME-Oec: proof of age is missing.
GNUNET_JSON_spec_fixed_auto ("coin_sig", GNUNET_JSON_spec_fixed_auto ("coin_sig",
&coin->coin_sig), &coin->coin_sig),
GNUNET_JSON_spec_fixed_auto ("coin_pub", GNUNET_JSON_spec_fixed_auto ("coin_pub",

View File

@ -310,6 +310,7 @@ parse_coin (struct MHD_Connection *connection,
GNUNET_JSON_spec_fixed_auto ("h_age_commitment", GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
&coin->cpi.h_age_commitment), &coin->cpi.h_age_commitment),
&coin->cpi.no_age_commitment), &coin->cpi.no_age_commitment),
// FIXME-Oec: proof of age is missing!
GNUNET_JSON_spec_fixed_auto ("coin_sig", GNUNET_JSON_spec_fixed_auto ("coin_sig",
&coin->coin_sig), &coin->coin_sig),
GNUNET_JSON_spec_fixed_auto ("coin_pub", GNUNET_JSON_spec_fixed_auto ("coin_pub",

View File

@ -139,11 +139,14 @@ reply_merge_success (struct MHD_Connection *connection,
TALER_amount_cmp (&pcc->balance, TALER_amount_cmp (&pcc->balance,
&pcc->target_amount)) &pcc->target_amount))
{ {
GNUNET_break (0);
return TALER_MHD_REPLY_JSON_PACK ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_ACCEPTED, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_JSON_pack_amount ("balance", TALER_JSON_pack_amount ("balance",
&pcc->balance)); &pcc->balance),
TALER_JSON_pack_amount ("target_amount",
&pcc->target_amount));
} }
if ( (NULL == pcc->provider_url) || if ( (NULL == pcc->provider_url) ||
(0 == strcmp (pcc->provider_url, (0 == strcmp (pcc->provider_url,
@ -221,6 +224,7 @@ merge_transaction (void *cls,
bool no_balance = true; bool no_balance = true;
bool no_partner = true; bool no_partner = true;
// FIXME: add KYC-check logic!
qs = TEH_plugin->do_purse_merge (TEH_plugin->cls, qs = TEH_plugin->do_purse_merge (TEH_plugin->cls,
pcc->purse_pub, pcc->purse_pub,
&pcc->merge_sig, &pcc->merge_sig,
@ -248,7 +252,7 @@ merge_transaction (void *cls,
{ {
*mhd_ret = *mhd_ret =
TALER_MHD_reply_with_error (connection, TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_NOT_FOUND,
TALER_EC_EXCHANGE_MERGE_PURSE_PARTNER_UNKNOWN, TALER_EC_EXCHANGE_MERGE_PURSE_PARTNER_UNKNOWN,
pcc->provider_url); pcc->provider_url);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
@ -303,6 +307,7 @@ merge_transaction (void *cls,
GNUNET_free (partner_url); GNUNET_free (partner_url);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
// FIXME: if ! kyc check, return 451!
return qs; return qs;
} }
@ -488,7 +493,7 @@ TEH_handler_purses_merge (
GNUNET_free (pcc.provider_url); GNUNET_free (pcc.provider_url);
return TALER_MHD_reply_with_error ( return TALER_MHD_reply_with_error (
connection, connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_FORBIDDEN,
TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_MERGE_SIGNATURE, TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_MERGE_SIGNATURE,
NULL); NULL);
} }
@ -514,12 +519,17 @@ TEH_handler_purses_merge (
GNUNET_free (pcc.provider_url); GNUNET_free (pcc.provider_url);
return TALER_MHD_reply_with_error ( return TALER_MHD_reply_with_error (
connection, connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_FORBIDDEN,
TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE, TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE,
NULL); NULL);
} }
} }
if (GNUNET_TIME_absolute_is_past (pcc.purse_expiration.abs_time))
{
// FIXME: idempotency check, otherwise generate 410!
}
/* execute transaction */ /* execute transaction */
{ {
MHD_RESULT mhd_ret; MHD_RESULT mhd_ret;

View File

@ -174,6 +174,7 @@ reply_purse_success (struct MHD_Connection *connection,
ec, ec,
NULL); NULL);
} }
// FIXME: share logic with /purses/$PID/create API!
return TALER_MHD_REPLY_JSON_PACK ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_OK, MHD_HTTP_OK,
@ -211,6 +212,9 @@ purse_transaction (void *cls,
{ {
bool in_conflict = true; bool in_conflict = true;
// FIXME: also check KYC state of the account
// FIXME: distinguish reserve-not-found!
/* 1) store purse */ /* 1) store purse */
qs = TEH_plugin->insert_purse_request (TEH_plugin->cls, qs = TEH_plugin->insert_purse_request (TEH_plugin->cls,
&rpc->purse_pub, &rpc->purse_pub,
@ -289,6 +293,9 @@ purse_transaction (void *cls,
&merge_pub)); &merge_pub));
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
// FIXME: return 404 if reserve-not-found!
// FIXME: if KYC check failed, generate 451 response!
} }
/* 2) create purse with reserve (and debit reserve for purse creation!) */ /* 2) create purse with reserve (and debit reserve for purse creation!) */