check reserve balance after p2p merges
This commit is contained in:
parent
06bfbd9150
commit
99a844e52e
@ -174,19 +174,15 @@ struct ReserveHistoryContext
|
|||||||
*/
|
*/
|
||||||
struct TALER_ReservePublicKeyP reserve_pub;
|
struct TALER_ReservePublicKeyP reserve_pub;
|
||||||
|
|
||||||
#ifndef MBOSS_DONE
|
|
||||||
/**
|
|
||||||
* History of the reserve, set in the callback.
|
|
||||||
* FIXME: get rid of this once benchmarking is done!
|
|
||||||
*/
|
|
||||||
struct TALER_EXCHANGEDB_ReserveHistory *rh;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Balance of the reserve, set in the callback.
|
* Balance of the reserve, set in the callback.
|
||||||
*/
|
*/
|
||||||
struct TALER_Amount balance;
|
struct TALER_Amount balance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true if we did not find the reserve.
|
||||||
|
*/
|
||||||
|
bool not_found;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -214,16 +210,9 @@ reserve_balance_transaction (void *cls,
|
|||||||
struct ReserveHistoryContext *rsc = cls;
|
struct ReserveHistoryContext *rsc = cls;
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
#ifdef MBOSS_DONE
|
|
||||||
qs = TEH_plugin->get_reserve_balance (TEH_plugin->cls,
|
qs = TEH_plugin->get_reserve_balance (TEH_plugin->cls,
|
||||||
&rsc->reserve_pub,
|
&rsc->reserve_pub,
|
||||||
&rsc->balance);
|
&rsc->balance);
|
||||||
#else
|
|
||||||
qs = TEH_plugin->get_reserve_history (TEH_plugin->cls,
|
|
||||||
&rsc->reserve_pub,
|
|
||||||
&rsc->balance,
|
|
||||||
&rsc->rh);
|
|
||||||
#endif
|
|
||||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -233,6 +222,10 @@ reserve_balance_transaction (void *cls,
|
|||||||
TALER_EC_GENERIC_DB_FETCH_FAILED,
|
TALER_EC_GENERIC_DB_FETCH_FAILED,
|
||||||
"get_reserve_balance");
|
"get_reserve_balance");
|
||||||
}
|
}
|
||||||
|
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
|
||||||
|
rsc->not_found = true;
|
||||||
|
if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT == qs)
|
||||||
|
rsc->not_found = false;
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +235,6 @@ TEH_handler_reserves_get (struct TEH_RequestContext *rc,
|
|||||||
const char *const args[1])
|
const char *const args[1])
|
||||||
{
|
{
|
||||||
struct ReserveHistoryContext rsc;
|
struct ReserveHistoryContext rsc;
|
||||||
MHD_RESULT mhd_ret;
|
|
||||||
struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_ZERO;
|
struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_ZERO;
|
||||||
struct GNUNET_DB_EventHandler *eh = NULL;
|
struct GNUNET_DB_EventHandler *eh = NULL;
|
||||||
|
|
||||||
@ -302,22 +294,25 @@ TEH_handler_reserves_get (struct TEH_RequestContext *rc,
|
|||||||
&db_event_cb,
|
&db_event_cb,
|
||||||
rc);
|
rc);
|
||||||
}
|
}
|
||||||
rsc.rh = NULL;
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
TEH_DB_run_transaction (rc->connection,
|
|
||||||
"get reserve balance",
|
|
||||||
TEH_MT_REQUEST_OTHER,
|
|
||||||
&mhd_ret,
|
|
||||||
&reserve_balance_transaction,
|
|
||||||
&rsc))
|
|
||||||
{
|
{
|
||||||
if (NULL != eh)
|
MHD_RESULT mhd_ret;
|
||||||
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
|
|
||||||
eh);
|
if (GNUNET_OK !=
|
||||||
return mhd_ret;
|
TEH_DB_run_transaction (rc->connection,
|
||||||
|
"get reserve balance",
|
||||||
|
TEH_MT_REQUEST_OTHER,
|
||||||
|
&mhd_ret,
|
||||||
|
&reserve_balance_transaction,
|
||||||
|
&rsc))
|
||||||
|
{
|
||||||
|
if (NULL != eh)
|
||||||
|
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
|
||||||
|
eh);
|
||||||
|
return mhd_ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* generate proper response */
|
/* generate proper response */
|
||||||
if (NULL == rsc.rh)
|
if (rsc.not_found)
|
||||||
{
|
{
|
||||||
struct ReservePoller *rp = rc->rh_ctx;
|
struct ReservePoller *rp = rc->rh_ctx;
|
||||||
|
|
||||||
@ -349,16 +344,11 @@ TEH_handler_reserves_get (struct TEH_RequestContext *rc,
|
|||||||
if (NULL != eh)
|
if (NULL != eh)
|
||||||
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
|
TEH_plugin->event_listen_cancel (TEH_plugin->cls,
|
||||||
eh);
|
eh);
|
||||||
mhd_ret = TALER_MHD_REPLY_JSON_PACK (
|
return TALER_MHD_REPLY_JSON_PACK (
|
||||||
rc->connection,
|
rc->connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
TALER_JSON_pack_amount ("balance",
|
TALER_JSON_pack_amount ("balance",
|
||||||
&rsc.balance));
|
&rsc.balance));
|
||||||
#ifndef MBOSS_DONE
|
|
||||||
TEH_plugin->free_reserve_history (TEH_plugin->cls,
|
|
||||||
rsc.rh);
|
|
||||||
#endif
|
|
||||||
return mhd_ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ DROP TABLE IF EXISTS wad_out_entries CASCADE;
|
|||||||
DROP TABLE IF EXISTS wads_in CASCADE;
|
DROP TABLE IF EXISTS wads_in CASCADE;
|
||||||
DROP TABLE IF EXISTS wad_in_entries CASCADE;
|
DROP TABLE IF EXISTS wad_in_entries CASCADE;
|
||||||
DROP TABLE IF EXISTS partner_accounts CASCADE;
|
DROP TABLE IF EXISTS partner_accounts CASCADE;
|
||||||
|
DROP TABLE IF EXISTS purse_actions CASCADE;
|
||||||
|
|
||||||
DROP FUNCTION IF EXISTS exchange_do_withdraw;
|
DROP FUNCTION IF EXISTS exchange_do_withdraw;
|
||||||
DROP FUNCTION IF EXISTS exchange_do_withdraw_limit_check;
|
DROP FUNCTION IF EXISTS exchange_do_withdraw_limit_check;
|
||||||
|
@ -3136,8 +3136,8 @@ THEN
|
|||||||
-- The taler-exchange-router will take care of this.
|
-- The taler-exchange-router will take care of this.
|
||||||
UPDATE purse_actions
|
UPDATE purse_actions
|
||||||
SET action_date=0 --- "immediately"
|
SET action_date=0 --- "immediately"
|
||||||
,partner_serial_id=NEW.partner_serial_id
|
,partner_serial_id=my_partner_serial_id
|
||||||
WHERE purse_pub=NEW.purse_pub;
|
WHERE purse_pub=in_purse_pub;
|
||||||
ELSE
|
ELSE
|
||||||
-- This is a local reserve, update balance immediately.
|
-- This is a local reserve, update balance immediately.
|
||||||
UPDATE reserves
|
UPDATE reserves
|
||||||
|
@ -318,10 +318,11 @@ TALER_EXCHANGE_reserves_status (
|
|||||||
json_decref (status_obj);
|
json_decref (status_obj);
|
||||||
}
|
}
|
||||||
ctx = TEAH_handle_to_context (exchange);
|
ctx = TEAH_handle_to_context (exchange);
|
||||||
rsh->job = GNUNET_CURL_job_add (ctx,
|
rsh->job = GNUNET_CURL_job_add2 (ctx,
|
||||||
eh,
|
eh,
|
||||||
&handle_reserves_status_finished,
|
rsh->post_ctx.headers,
|
||||||
rsh);
|
&handle_reserves_status_finished,
|
||||||
|
rsh);
|
||||||
return rsh;
|
return rsh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ run (void *cls,
|
|||||||
"EUR:1.01",
|
"EUR:1.01",
|
||||||
NULL),
|
NULL),
|
||||||
TALER_TESTING_cmd_purse_poll (
|
TALER_TESTING_cmd_purse_poll (
|
||||||
"poll-purse-before-merge",
|
"push-poll-purse-before-merge",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"purse-with-deposit",
|
"purse-with-deposit",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -175,13 +175,24 @@ run (void *cls,
|
|||||||
"push-get-contract",
|
"push-get-contract",
|
||||||
"create-reserve-1"),
|
"create-reserve-1"),
|
||||||
TALER_TESTING_cmd_purse_poll_finish (
|
TALER_TESTING_cmd_purse_poll_finish (
|
||||||
"merge-purse-poll-finish",
|
"push-merge-purse-poll-finish",
|
||||||
GNUNET_TIME_relative_multiply (
|
GNUNET_TIME_relative_multiply (
|
||||||
GNUNET_TIME_UNIT_SECONDS,
|
GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
"poll-purse-before-merge"),
|
"push-poll-purse-before-merge"),
|
||||||
// FIXME: trigger p2p job
|
TALER_TESTING_cmd_status (
|
||||||
// FIXME: check reserve history!
|
"push-check-post-merge-reserve-balance-get",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:1",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
#if FIXME
|
||||||
|
/* POST history doesn't yet support P2P transfers */
|
||||||
|
TALER_TESTING_cmd_reserves_status (
|
||||||
|
"push-check-post-merge-reserve-balance-post",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:1",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
#endif
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
struct TALER_TESTING_Command pull[] = {
|
struct TALER_TESTING_Command pull[] = {
|
||||||
@ -198,7 +209,7 @@ run (void *cls,
|
|||||||
false, /* for deposit */
|
false, /* for deposit */
|
||||||
"purse-create-with-reserve"),
|
"purse-create-with-reserve"),
|
||||||
TALER_TESTING_cmd_purse_poll (
|
TALER_TESTING_cmd_purse_poll (
|
||||||
"poll-purse-before-deposit",
|
"pull-poll-purse-before-deposit",
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"purse-create-with-reserve",
|
"purse-create-with-reserve",
|
||||||
"EUR:1",
|
"EUR:1",
|
||||||
@ -213,13 +224,24 @@ run (void *cls,
|
|||||||
"EUR:1.01",
|
"EUR:1.01",
|
||||||
NULL),
|
NULL),
|
||||||
TALER_TESTING_cmd_purse_poll_finish (
|
TALER_TESTING_cmd_purse_poll_finish (
|
||||||
"deposit-purse-poll-finish",
|
"pull-deposit-purse-poll-finish",
|
||||||
GNUNET_TIME_relative_multiply (
|
GNUNET_TIME_relative_multiply (
|
||||||
GNUNET_TIME_UNIT_SECONDS,
|
GNUNET_TIME_UNIT_SECONDS,
|
||||||
5),
|
5),
|
||||||
"poll-purse-before-deposit"),
|
"pull-poll-purse-before-deposit"),
|
||||||
// FIXME: trigger p2p job
|
TALER_TESTING_cmd_status (
|
||||||
// FIXME: check reserve history!
|
"pull-check-post-merge-reserve-balance-get",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:2",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
#if FIXME
|
||||||
|
/* POST history doesn't yet support P2P transfers */
|
||||||
|
TALER_TESTING_cmd_reserves_status (
|
||||||
|
"push-check-post-merge-reserve-balance-post",
|
||||||
|
"create-reserve-1",
|
||||||
|
"EUR:2",
|
||||||
|
MHD_HTTP_OK),
|
||||||
|
#endif
|
||||||
TALER_TESTING_cmd_end ()
|
TALER_TESTING_cmd_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,7 +141,6 @@ purse_status_cb (void *cls,
|
|||||||
}
|
}
|
||||||
if (MHD_HTTP_OK == ss->expected_response_code)
|
if (MHD_HTTP_OK == ss->expected_response_code)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
struct TALER_Amount eb;
|
struct TALER_Amount eb;
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
@ -152,11 +151,10 @@ purse_status_cb (void *cls,
|
|||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected amount in purse: %s\n",
|
"Unexpected amount in purse: %s\n",
|
||||||
TALER_amount_to_string (&rs->details.ok.balance));
|
TALER_amount_to_string (&rs->details.success.balance));
|
||||||
TALER_TESTING_interpreter_fail (ss->is);
|
TALER_TESTING_interpreter_fail (ss->is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (NULL != ss->ps)
|
if (NULL != ss->ps)
|
||||||
{
|
{
|
||||||
|
@ -144,8 +144,9 @@ reserve_status_cb (void *cls,
|
|||||||
&rs->details.ok.balance))
|
&rs->details.ok.balance))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Unexpected amount in reserve: %s\n",
|
"Unexpected amount %s in reserve, wanted %s\n",
|
||||||
TALER_amount_to_string (&rs->details.ok.balance));
|
TALER_amount_to_string (&rs->details.ok.balance),
|
||||||
|
ss->expected_balance);
|
||||||
TALER_TESTING_interpreter_fail (ss->is);
|
TALER_TESTING_interpreter_fail (ss->is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ TALER_payto_validate (const char *payto_uri)
|
|||||||
/* This is more strict than RFC 8905, alas we do not need to support messages/instructions/etc.,
|
/* This is more strict than RFC 8905, alas we do not need to support messages/instructions/etc.,
|
||||||
and it is generally better to start with a narrow whitelist; we can be more permissive later ...*/
|
and it is generally better to start with a narrow whitelist; we can be more permissive later ...*/
|
||||||
#define ALLOWED_CHARACTERS \
|
#define ALLOWED_CHARACTERS \
|
||||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/:&?-.,="
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/:&?-.,=+"
|
||||||
if (NULL == strchr (ALLOWED_CHARACTERS,
|
if (NULL == strchr (ALLOWED_CHARACTERS,
|
||||||
(int) payto_uri[i]))
|
(int) payto_uri[i]))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user