Merge branch 'master' into auction_brandt
This commit is contained in:
commit
0ad6a8cbfb
@ -102,6 +102,12 @@ struct ReserveOpenContext
|
||||
* Desired minimum purse limit.
|
||||
*/
|
||||
uint32_t purse_limit;
|
||||
|
||||
/**
|
||||
* Set to true if the reserve balance is too low
|
||||
* for the operation.
|
||||
*/
|
||||
bool no_funds;
|
||||
};
|
||||
|
||||
|
||||
@ -109,7 +115,7 @@ struct ReserveOpenContext
|
||||
* Send reserve open to client.
|
||||
*
|
||||
* @param connection connection to the client
|
||||
* @param rhc reserve open to return
|
||||
* @param rsc reserve open data to return
|
||||
* @return MHD result code
|
||||
*/
|
||||
static MHD_RESULT
|
||||
@ -223,12 +229,14 @@ reserve_open_transaction (void *cls,
|
||||
/* inputs */
|
||||
rsc->reserve_pub,
|
||||
&rsc->total,
|
||||
&rsc->reserve_payment,
|
||||
rsc->purse_limit,
|
||||
&rsc->reserve_sig,
|
||||
rsc->desired_expiration,
|
||||
rsc->timestamp,
|
||||
&rsc->gf->fees.account,
|
||||
/* outputs */
|
||||
&rsc->no_funds,
|
||||
&rsc->open_cost,
|
||||
&rsc->reserve_expiration);
|
||||
switch (qs)
|
||||
@ -253,6 +261,15 @@ reserve_open_transaction (void *cls,
|
||||
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
|
||||
break;
|
||||
}
|
||||
if (rsc->no_funds)
|
||||
{
|
||||
*mhd_ret
|
||||
= TEH_RESPONSE_reply_reserve_insufficient_balance (
|
||||
connection,
|
||||
&rsc->reserve_payment,
|
||||
rsc->reserve_pub);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
return qs;
|
||||
}
|
||||
|
||||
@ -342,13 +359,10 @@ TEH_handler_reserves_open (struct TEH_RequestContext *rc,
|
||||
cleanup_rsc (&rsc);
|
||||
return MHD_YES; /* failure */
|
||||
}
|
||||
/* FIXME-DOLD: Alternatively, we could here add coin->amount_minus_fee and
|
||||
thereby charge the deposit fee even when paying the reserve-open fee.
|
||||
To be decided... */
|
||||
if (0 >
|
||||
TALER_amount_add (&rsc.total,
|
||||
&rsc.total,
|
||||
&coin->amount))
|
||||
&coin->amount_minus_fee))
|
||||
{
|
||||
GNUNET_break (0);
|
||||
cleanup_rsc (&rsc);
|
||||
|
@ -31,11 +31,13 @@ TEH_PG_do_reserve_open (
|
||||
void *cls,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_Amount *total_paid,
|
||||
const struct TALER_Amount *reserve_payment,
|
||||
uint32_t min_purse_limit,
|
||||
const struct TALER_ReserveSignatureP *reserve_sig,
|
||||
struct GNUNET_TIME_Timestamp desired_expiration,
|
||||
struct GNUNET_TIME_Timestamp now,
|
||||
const struct TALER_Amount *open_fee,
|
||||
bool *no_funds,
|
||||
struct TALER_Amount *open_cost,
|
||||
struct GNUNET_TIME_Timestamp *final_expiration)
|
||||
{
|
||||
@ -43,6 +45,7 @@ TEH_PG_do_reserve_open (
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||
TALER_PQ_query_param_amount (total_paid),
|
||||
TALER_PQ_query_param_amount (reserve_payment),
|
||||
GNUNET_PQ_query_param_uint32 (&min_purse_limit),
|
||||
GNUNET_PQ_query_param_auto_from_type (reserve_sig),
|
||||
GNUNET_PQ_query_param_timestamp (&desired_expiration),
|
||||
@ -51,9 +54,11 @@ TEH_PG_do_reserve_open (
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("open_cost",
|
||||
GNUNET_PQ_result_spec_bool ("out_no_funds",
|
||||
no_funds),
|
||||
TALER_PQ_RESULT_SPEC_AMOUNT ("out_open_cost",
|
||||
open_cost),
|
||||
GNUNET_PQ_result_spec_timestamp ("final_expiration",
|
||||
GNUNET_PQ_result_spec_timestamp ("out_final_expiration",
|
||||
final_expiration),
|
||||
GNUNET_PQ_result_spec_end
|
||||
};
|
||||
@ -61,11 +66,12 @@ TEH_PG_do_reserve_open (
|
||||
PREPARE (pg,
|
||||
"do_reserve_open",
|
||||
"SELECT "
|
||||
" open_cost_val"
|
||||
",open_cost_frac"
|
||||
",final_expiration"
|
||||
" out_open_cost_val"
|
||||
",out_open_cost_frac"
|
||||
",out_final_expiration"
|
||||
",out_no_funds"
|
||||
" FROM exchange_do_reserve_open"
|
||||
" ($1,$2,$3,$4,$5,$6,$7,$8,$9);");
|
||||
" ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11);");
|
||||
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
|
||||
"do_reserve_open",
|
||||
params,
|
||||
|
@ -27,15 +27,20 @@
|
||||
|
||||
|
||||
/**
|
||||
* Insert reserve close operation into database.
|
||||
* Perform reserve open operation on database.
|
||||
*
|
||||
* @param cls closure
|
||||
* @param reserve_pub which reserve is this about?
|
||||
* @param execution_date when did we perform the transfer?
|
||||
* @param receiver_account to which account do we transfer, in payto://-format
|
||||
* @param wtid identifier for the wire transfer
|
||||
* @param amount_with_fee amount we charged to the reserve
|
||||
* @param closing_fee how high is the closing fee
|
||||
* @param total_paid total amount paid (coins and reserve)
|
||||
* @param reserve_payment amount to be paid from the reserve
|
||||
* @param min_purse_limit minimum number of purses we should be able to open
|
||||
* @param reserve_sig signature by the reserve for the operation
|
||||
* @param desired_expiration when should the reserve expire (earliest time)
|
||||
* @param now when did we the client initiate the action
|
||||
* @param open_fee annual fee to be charged for the open operation by the exchange
|
||||
* @param[out] no_funds set to true if reserve balance is insufficient
|
||||
* @param[out] open_cost set to the actual cost
|
||||
* @param[out] final_expiration when will the reserve expire now
|
||||
* @return transaction status code
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
@ -43,11 +48,13 @@ TEH_PG_do_reserve_open (
|
||||
void *cls,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_Amount *total_paid,
|
||||
const struct TALER_Amount *reserve_payment,
|
||||
uint32_t min_purse_limit,
|
||||
const struct TALER_ReserveSignatureP *reserve_sig,
|
||||
struct GNUNET_TIME_Timestamp desired_expiration,
|
||||
struct GNUNET_TIME_Timestamp now,
|
||||
const struct TALER_Amount *open_fee,
|
||||
bool *no_funds,
|
||||
struct TALER_Amount *open_cost,
|
||||
struct GNUNET_TIME_Timestamp *final_expiration);
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
*
|
||||
* @param cls closure
|
||||
* @param h_payto which target account is this about?
|
||||
* @param h_payto account identifier
|
||||
* @param time_limit oldest transaction that could be relevant
|
||||
* @param kac function to call for each applicable amount, in reverse chronological order (or until @a kac aborts by returning anything except #GNUNET_OK).
|
||||
* @param kac_cls closure for @a kac
|
||||
|
@ -17296,6 +17296,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
|
||||
plugin->select_merge_amounts_for_kyc_check
|
||||
= &postgres_select_merge_amounts_for_kyc_check;
|
||||
/* NEW style, sort alphabetically! */
|
||||
plugin->insert_reserve_open_deposit
|
||||
= &TEH_PG_insert_reserve_open_deposit;
|
||||
plugin->insert_close_request
|
||||
= &TEH_PG_insert_close_request;
|
||||
plugin->iterate_reserve_close_info
|
||||
|
@ -2175,4 +2175,30 @@ out_insufficient_funds=FALSE;
|
||||
|
||||
END $$;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION exchange_do_reserve_open(
|
||||
IN in_reserve_pub BYTEA,
|
||||
IN in_total_paid_val INT8,
|
||||
IN in_total_paid_frac INT4,
|
||||
IN in_reserve_payment_val INT8,
|
||||
IN in_reserve_payment_frac INT4,
|
||||
IN in_min_purse_limit INT4,
|
||||
IN in_reserve_sig BYTEA,
|
||||
IN in_desired_expiration INT8,
|
||||
IN in_now INT8,
|
||||
IN in_open_fee_val INT8,
|
||||
IN in_open_fee_frac INT4,
|
||||
OUT out_open_cost_val INT8,
|
||||
OUT out_open_cost_frac INT4,
|
||||
OUT out_final_expiration INT8,
|
||||
OUT out_no_funds BOOLEAN)
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
BEGIN
|
||||
|
||||
-- FIXME: implement!
|
||||
|
||||
END $$
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
@ -4093,22 +4093,29 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
*
|
||||
* @param cls closure
|
||||
* @param reserve_pub which reserve is this about?
|
||||
* @param execution_date when did we perform the transfer?
|
||||
* @param receiver_account to which account do we transfer, in payto://-format
|
||||
* @param wtid identifier for the wire transfer
|
||||
* @param amount_with_fee amount we charged to the reserve
|
||||
* @param closing_fee how high is the closing fee
|
||||
* @param total_paid total amount paid (coins and reserve)
|
||||
* @param reserve_payment amount to be paid from the reserve
|
||||
* @param min_purse_limit minimum number of purses we should be able to open
|
||||
* @param reserve_sig signature by the reserve for the operation
|
||||
* @param desired_expiration when should the reserve expire (earliest time)
|
||||
* @param now when did we the client initiate the action
|
||||
* @param open_fee annual fee to be charged for the open operation by the exchange
|
||||
* @param[out] no_funds set to true if reserve balance is insufficient
|
||||
* @param[out] open_cost set to the actual cost
|
||||
* @param[out] final_expiration when will the reserve expire now
|
||||
* @return transaction status code
|
||||
*/
|
||||
enum GNUNET_DB_QueryStatus
|
||||
(*do_reserve_open)(void *cls,
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
const struct TALER_Amount *total_paid,
|
||||
const struct TALER_Amount *reserve_payment,
|
||||
uint32_t min_purse_limit,
|
||||
const struct TALER_ReserveSignatureP *reserve_sig,
|
||||
struct GNUNET_TIME_Timestamp desired_expiration,
|
||||
struct GNUNET_TIME_Timestamp now,
|
||||
const struct TALER_Amount *open_fee,
|
||||
bool *no_funds,
|
||||
struct TALER_Amount *open_cost,
|
||||
struct GNUNET_TIME_Timestamp *final_expiration);
|
||||
|
||||
|
@ -312,7 +312,7 @@ TALER_KYCLOGIC_requirements_to_logic (const char *requirements,
|
||||
*
|
||||
* @param provider_section configuration section of a
|
||||
* provider that triggered KYC process for a user
|
||||
* @param provider_user user ID of the user at the provider
|
||||
* @param provider_user_id user ID of the user at the provider
|
||||
* @param legitimization_id legitimizatin ID of a process
|
||||
* of that user at the provider
|
||||
* @param[out] attr_expiration set to when the @a attrs expire
|
||||
|
Loading…
Reference in New Issue
Block a user