aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-06-04 21:59:55 +0200
committerChristian Grothoff <christian@grothoff.org>2022-06-04 22:00:02 +0200
commita17781ba8d5f875b5150e524174c5f144aa6c0ba (patch)
treec01f11a3810428471e6399b4961942732a21a1f1 /src/exchangedb
parent6512456dc2559577867fdce1f7fe7f1b5a12291f (diff)
-more work on p2p payments and tests thereof
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/exchange-0001-part.sql15
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c16
2 files changed, 24 insertions, 7 deletions
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql
index 0b99e25f9..c79fdf840 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -3090,6 +3090,7 @@ CREATE OR REPLACE FUNCTION exchange_do_purse_merge(
IN in_reserve_sig BYTEA,
IN in_partner_url VARCHAR,
IN in_reserve_pub BYTEA,
+ IN in_require_kyc BOOLEAN,
OUT out_no_partner BOOLEAN,
OUT out_no_balance BOOLEAN,
OUT out_no_kyc BOOLEAN,
@@ -3197,7 +3198,8 @@ out_conflict=FALSE;
ASSERT NOT my_finished, 'internal invariant failed';
-IF in_partner_url IS NULL
+IF ( (in_partner_url IS NULL) AND
+ (in_require_kyc) )
THEN
-- Need to do KYC check.
SELECT NOT kyc_passed
@@ -3272,7 +3274,7 @@ RETURN;
END $$;
-COMMENT ON FUNCTION exchange_do_purse_merge(BYTEA, BYTEA, INT8, BYTEA, VARCHAR, BYTEA)
+COMMENT ON FUNCTION exchange_do_purse_merge(BYTEA, BYTEA, INT8, BYTEA, VARCHAR, BYTEA, BOOLEAN)
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.';
@@ -3285,6 +3287,7 @@ CREATE OR REPLACE FUNCTION exchange_do_reserve_purse(
IN in_purse_fee_val INT8,
IN in_purse_fee_frac INT4,
IN in_reserve_pub BYTEA,
+ IN in_require_kyc BOOLEAN,
OUT out_no_funds BOOLEAN,
OUT out_no_kyc BOOLEAN,
OUT out_no_reserve BOOLEAN,
@@ -3350,7 +3353,7 @@ THEN
END IF;
out_no_reserve=FALSE;
-IF (out_no_kyc)
+IF (out_no_kyc AND in_require_kyc)
THEN
out_no_funds=FALSE;
RETURN;
@@ -3412,6 +3415,12 @@ INSERT INTO account_merges
END $$;
+COMMENT ON FUNCTION exchange_do_reserve_purse(BYTEA, BYTEA, INT8, BYTEA, BOOLEAN, INT8, INT4, BYTEA, BOOLEAN)
+ IS 'Create a purse for a reserve.';
+
+
+
+
CREATE OR REPLACE FUNCTION exchange_do_account_merge(
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index 01869d592..9fcd6203a 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3977,8 +3977,8 @@ prepare_statements (struct PostgresClosure *pg)
",out_no_reserve AS no_reserve"
",out_conflict AS conflict"
" FROM exchange_do_purse_merge"
- " ($1, $2, $3, $4, $5, $6);",
- 6),
+ " ($1, $2, $3, $4, $5, $6, $7);",
+ 7),
/* Used in #postgres_do_reserve_purse() */
GNUNET_PQ_make_prepare (
"call_reserve_purse",
@@ -3988,8 +3988,8 @@ prepare_statements (struct PostgresClosure *pg)
",out_no_kyc AS no_kyc"
",out_conflict AS conflict"
" FROM exchange_do_reserve_purse"
- " ($1, $2, $3, $4, $5, $6, $7, $8);",
- 8),
+ " ($1, $2, $3, $4, $5, $6, $7, $8, $9);",
+ 9),
/* Used in #postgres_select_purse_merge */
GNUNET_PQ_make_prepare (
"select_purse_merge",
@@ -14492,6 +14492,7 @@ postgres_get_purse_deposit (
* @param reserve_sig signature of the reserve affirming the merge
* @param partner_url URL of the partner exchange, can be NULL if the reserves lives with us
* @param reserve_pub public key of the reserve to credit
+ * @param require_kyc true if we should check for KYC
* @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
@@ -14508,6 +14509,7 @@ postgres_do_purse_merge (
const struct TALER_ReserveSignatureP *reserve_sig,
const char *partner_url,
const struct TALER_ReservePublicKeyP *reserve_pub,
+ bool require_kyc,
bool *no_partner,
bool *no_balance,
bool *no_reserve,
@@ -14524,6 +14526,7 @@ postgres_do_purse_merge (
? GNUNET_PQ_query_param_null ()
: GNUNET_PQ_query_param_string (partner_url),
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
+ GNUNET_PQ_query_param_bool (require_kyc),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {
@@ -14559,7 +14562,10 @@ postgres_do_purse_merge (
* @param reserve_sig signature of the reserve affirming the merge
* @param purse_fee amount to charge the reserve for the purse creation, NULL to use the quota
* @param reserve_pub public key of the reserve to credit
+ * @param require_kyc true if we should check for KYC
* @param[out] in_conflict set to true if @a purse_pub was merged into a different reserve already
+ * @param[out] no_reserve set to true if @a reserve_pub is not a known reserve
+ * @param[out] no_kyc set to true if @a reserve_pub has not passed KYC checks
* @param[out] insufficient_funds set to true if @a reserve_pub has insufficient capacity to create another purse
* @return transaction status code
*/
@@ -14572,6 +14578,7 @@ postgres_do_reserve_purse (
const struct TALER_ReserveSignatureP *reserve_sig,
const struct TALER_Amount *purse_fee,
const struct TALER_ReservePublicKeyP *reserve_pub,
+ bool require_kyc,
bool *in_conflict,
bool *no_reserve,
bool *no_kyc,
@@ -14589,6 +14596,7 @@ postgres_do_reserve_purse (
? &zero_fee
: purse_fee),
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
+ GNUNET_PQ_query_param_bool (require_kyc),
GNUNET_PQ_query_param_end
};
struct GNUNET_PQ_ResultSpec rs[] = {