allow merge into non-existent reserve if KYC is disabled
This commit is contained in:
parent
94fa05ec2a
commit
68d2df88f2
@ -1,5 +1,14 @@
|
||||
SUBDIRS = .
|
||||
|
||||
tmplpkgdatadir = $(prefix)/share/taler/exchange/templates/
|
||||
|
||||
dist_tmplpkgdata_DATA = \
|
||||
test.en.must
|
||||
|
||||
# %%.must: merchant-backoffice/%.html
|
||||
# WTF: cp $< $@
|
||||
|
||||
|
||||
# English (en)
|
||||
tosendir=$(datadir)/taler/exchange/tos/en
|
||||
|
||||
|
0
contrib/test.en.must
Normal file
0
contrib/test.en.must
Normal file
@ -177,6 +177,7 @@ taler_exchange_httpd_LDADD = \
|
||||
$(top_builddir)/src/mhd/libtalermhd.la \
|
||||
$(top_builddir)/src/json/libtalerjson.la \
|
||||
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
|
||||
$(top_builddir)/src/templating/libtalertemplating.la \
|
||||
$(top_builddir)/src/kyclogic/libtalerkyclogic.la \
|
||||
$(top_builddir)/src/util/libtalerutil.la \
|
||||
$(top_builddir)/src/extensions/libtalerextensions.la \
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <sys/resource.h>
|
||||
#include <limits.h>
|
||||
#include "taler_kyclogic_lib.h"
|
||||
#include "taler_templating_lib.h"
|
||||
#include "taler_mhd_lib.h"
|
||||
#include "taler-exchange-httpd_auditors.h"
|
||||
#include "taler-exchange-httpd_batch-deposit.h"
|
||||
@ -2125,6 +2126,7 @@ do_shutdown (void *cls)
|
||||
GNUNET_CURL_gnunet_rc_destroy (exchange_curl_rc);
|
||||
exchange_curl_rc = NULL;
|
||||
}
|
||||
TALER_TEMPLATING_done ();
|
||||
}
|
||||
|
||||
|
||||
@ -2162,6 +2164,13 @@ run (void *cls,
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return;
|
||||
}
|
||||
if (GNUNET_OK !=
|
||||
TALER_TEMPLATING_init ("exchange"))
|
||||
{
|
||||
global_ret = EXIT_FAILURE;
|
||||
GNUNET_SCHEDULER_shutdown ();
|
||||
return;
|
||||
}
|
||||
if (GNUNET_SYSERR ==
|
||||
TEH_plugin->preflight (TEH_plugin->cls))
|
||||
{
|
||||
|
@ -275,7 +275,6 @@ merge_transaction (void *cls,
|
||||
bool in_conflict = true;
|
||||
bool no_balance = true;
|
||||
bool no_partner = true;
|
||||
bool no_reserve = true;
|
||||
const char *required;
|
||||
|
||||
required = TALER_KYCLOGIC_kyc_test_required (
|
||||
@ -305,7 +304,6 @@ merge_transaction (void *cls,
|
||||
&pcc->reserve_pub,
|
||||
&no_partner,
|
||||
&no_balance,
|
||||
&no_reserve,
|
||||
&in_conflict);
|
||||
if (qs < 0)
|
||||
{
|
||||
@ -329,15 +327,6 @@ merge_transaction (void *cls,
|
||||
pcc->provider_url);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
if (no_reserve)
|
||||
{
|
||||
*mhd_ret =
|
||||
TALER_MHD_reply_with_error (connection,
|
||||
MHD_HTTP_NOT_FOUND,
|
||||
TALER_EC_EXCHANGE_GENERIC_RESERVE_UNKNOWN,
|
||||
NULL);
|
||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||
}
|
||||
if (no_balance)
|
||||
{
|
||||
*mhd_ret =
|
||||
|
@ -4450,10 +4450,9 @@ prepare_statements (struct PostgresClosure *pg)
|
||||
"SELECT"
|
||||
" out_no_partner AS no_partner"
|
||||
",out_no_balance AS no_balance"
|
||||
",out_no_reserve AS no_reserve"
|
||||
",out_conflict AS conflict"
|
||||
" FROM exchange_do_purse_merge"
|
||||
" ($1, $2, $3, $4, $5, $6, $7);",
|
||||
" ($1, $2, $3, $4, $5, $6, $7, $8);",
|
||||
7),
|
||||
/* Used in #postgres_do_reserve_purse() */
|
||||
GNUNET_PQ_make_prepare (
|
||||
@ -16007,7 +16006,6 @@ postgres_get_purse_deposit (
|
||||
* @param reserve_pub public key of the reserve to credit
|
||||
* @param[out] no_partner set to true if @a partner_url is unknown
|
||||
* @param[out] no_balance set to true if the @a purse_pub is not paid up yet
|
||||
* @param[out] no_reserve set to true if the @a reserve_pub is not known
|
||||
* @param[out] in_conflict set to true if @a purse_pub was merged into a different reserve already
|
||||
* @return transaction status code
|
||||
*/
|
||||
@ -16022,11 +16020,12 @@ postgres_do_purse_merge (
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
bool *no_partner,
|
||||
bool *no_balance,
|
||||
bool *no_reserve,
|
||||
bool *in_conflict)
|
||||
{
|
||||
struct PostgresClosure *pg = cls;
|
||||
struct TALER_PaytoHashP h_payto;
|
||||
struct GNUNET_TIME_Timestamp expiration
|
||||
= GNUNET_TIME_relative_to_timestamp (GNUNET_TIME_UNIT_YEARS); /* FIXME: make this configurable? */
|
||||
struct GNUNET_PQ_QueryParam params[] = {
|
||||
GNUNET_PQ_query_param_auto_from_type (purse_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (merge_sig),
|
||||
@ -16037,6 +16036,7 @@ postgres_do_purse_merge (
|
||||
: GNUNET_PQ_query_param_string (partner_url),
|
||||
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
|
||||
GNUNET_PQ_query_param_auto_from_type (&h_payto),
|
||||
GNUNET_PQ_query_param_timestamp (&expiration),
|
||||
GNUNET_PQ_query_param_end
|
||||
};
|
||||
struct GNUNET_PQ_ResultSpec rs[] = {
|
||||
@ -16044,8 +16044,6 @@ postgres_do_purse_merge (
|
||||
no_partner),
|
||||
GNUNET_PQ_result_spec_bool ("no_balance",
|
||||
no_balance),
|
||||
GNUNET_PQ_result_spec_bool ("no_reserve",
|
||||
no_reserve),
|
||||
GNUNET_PQ_result_spec_bool ("conflict",
|
||||
in_conflict),
|
||||
GNUNET_PQ_result_spec_end
|
||||
|
@ -1606,9 +1606,9 @@ CREATE OR REPLACE FUNCTION exchange_do_purse_merge(
|
||||
IN in_partner_url VARCHAR,
|
||||
IN in_reserve_pub BYTEA,
|
||||
IN in_wallet_h_payto BYTEA,
|
||||
IN in_expiration_date INT8,
|
||||
OUT out_no_partner BOOLEAN,
|
||||
OUT out_no_balance BOOLEAN,
|
||||
OUT out_no_reserve BOOLEAN,
|
||||
OUT out_conflict BOOLEAN)
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
@ -1642,7 +1642,6 @@ ELSE
|
||||
THEN
|
||||
out_no_partner=TRUE;
|
||||
out_conflict=FALSE;
|
||||
out_no_reserve=FALSE;
|
||||
RETURN;
|
||||
END IF;
|
||||
END IF;
|
||||
@ -1670,7 +1669,6 @@ IF NOT FOUND
|
||||
THEN
|
||||
out_no_balance=TRUE;
|
||||
out_conflict=FALSE;
|
||||
out_no_reserve=FALSE;
|
||||
RETURN;
|
||||
END IF;
|
||||
out_no_balance=FALSE;
|
||||
@ -1703,29 +1701,30 @@ THEN
|
||||
THEN
|
||||
-- Purse was merged, but to some other reserve. Not allowed.
|
||||
out_conflict=TRUE;
|
||||
out_no_reserve=FALSE;
|
||||
RETURN;
|
||||
END IF;
|
||||
|
||||
-- "success"
|
||||
out_conflict=FALSE;
|
||||
out_no_reserve=FALSE;
|
||||
RETURN;
|
||||
END IF;
|
||||
out_conflict=FALSE;
|
||||
|
||||
ASSERT NOT my_finished, 'internal invariant failed';
|
||||
|
||||
PERFORM
|
||||
FROM exchange.reserves
|
||||
WHERE reserve_pub=in_reserve_pub;
|
||||
|
||||
IF NOT FOUND
|
||||
THEN
|
||||
out_no_reserve=TRUE;
|
||||
RETURN;
|
||||
END IF;
|
||||
out_no_reserve=FALSE;
|
||||
-- Initialize reserve, if not yet exists.
|
||||
INSERT INTO reserves
|
||||
(reserve_pub
|
||||
,expiration_date
|
||||
,gc_date)
|
||||
VALUES
|
||||
(in_reserve_pub
|
||||
,in_expiration_date
|
||||
,in_expiration_date)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
|
||||
|
||||
|
||||
-- Store account merge signature.
|
||||
@ -1785,7 +1784,7 @@ RETURN;
|
||||
|
||||
END $$;
|
||||
|
||||
COMMENT ON FUNCTION exchange_do_purse_merge(BYTEA, BYTEA, INT8, BYTEA, VARCHAR, BYTEA, BYTEA)
|
||||
COMMENT ON FUNCTION exchange_do_purse_merge(BYTEA, BYTEA, INT8, BYTEA, VARCHAR, BYTEA, BYTEA, INT8)
|
||||
IS 'Checks that the partner exists, the purse has not been merged with a different reserve and that the purse is full. If so, persists the merge data and either merges the purse with the reserve or marks it as ready for the taler-exchange-router. Caller MUST abort the transaction on failures so as to not persist data by accident.';
|
||||
|
||||
|
||||
|
@ -5394,7 +5394,6 @@ struct TALER_EXCHANGEDB_Plugin
|
||||
const struct TALER_ReservePublicKeyP *reserve_pub,
|
||||
bool *no_partner,
|
||||
bool *no_balance,
|
||||
bool *no_reserve,
|
||||
bool *in_conflict);
|
||||
|
||||
|
||||
|
@ -414,8 +414,8 @@ TALER_TEMPLATING_init (const char *subsystem)
|
||||
}
|
||||
GNUNET_asprintf (&dn,
|
||||
"%s/%s/templates/",
|
||||
subsystem,
|
||||
path);
|
||||
path,
|
||||
subsystem);
|
||||
GNUNET_free (path);
|
||||
}
|
||||
ret = GNUNET_DISK_directory_scan (dn,
|
||||
|
Loading…
Reference in New Issue
Block a user