diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-02-20 17:44:06 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-02-20 17:44:06 +0100 |
commit | 2a52426a7cdc55f49f726f24ddc735d6c01decaa (patch) | |
tree | 877fdbd77d028f6650f8cdc1e80b6482d0d30d54 /src/backenddb | |
parent | 8ffaa360d505a40c74071a6cd3f534dfb4776c9f (diff) | |
download | merchant-2a52426a7cdc55f49f726f24ddc735d6c01decaa.tar.gz merchant-2a52426a7cdc55f49f726f24ddc735d6c01decaa.tar.bz2 merchant-2a52426a7cdc55f49f726f24ddc735d6c01decaa.zip |
preparations to store AML decision if any is returned by the exchange, incomplete, not really used
Diffstat (limited to 'src/backenddb')
-rw-r--r-- | src/backenddb/merchant-0004.sql | 7 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 30 | ||||
-rw-r--r-- | src/backenddb/test_merchantdb.c | 39 |
3 files changed, 51 insertions, 25 deletions
diff --git a/src/backenddb/merchant-0004.sql b/src/backenddb/merchant-0004.sql index 55cfa2fc..b63594ee 100644 --- a/src/backenddb/merchant-0004.sql +++ b/src/backenddb/merchant-0004.sql @@ -106,6 +106,13 @@ COMMENT ON COLUMN merchant_pending_webhooks.body IS 'Body of the webhook'; +ALTER TABLE merchant_kyc + ADD COLUMN aml_decision INT4 NOT NULL DEFAULT (0); + +COMMENT ON COLUMN merchant_kyc.aml_decision + IS 'current AML decision for our account at the exchange'; + + COMMIT; diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 5afe7f0a..9f07d3aa 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -907,7 +907,8 @@ kyc_status_cb (void *cls, char *exchange_url; char *payto_uri; struct GNUNET_TIME_Timestamp last_check; - uint8_t kyc_ok; + bool kyc_ok; + uint32_t aml_decision; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_auto_from_type ("h_wire", &h_wire), @@ -919,8 +920,10 @@ kyc_status_cb (void *cls, &exchange_url), GNUNET_PQ_result_spec_timestamp ("kyc_timestamp", &last_check), - GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", - &kyc_ok), + GNUNET_PQ_result_spec_bool ("kyc_ok", + &kyc_ok), + GNUNET_PQ_result_spec_uint32 ("aml_decision", + &aml_decision), GNUNET_PQ_result_spec_end }; @@ -954,7 +957,8 @@ kyc_status_cb (void *cls, payto_uri, exchange_url, last_check, - 0 != kyc_ok); + kyc_ok, + (enum TALER_AmlDecisionState) aml_decision); GNUNET_PQ_cleanup_result (rs); } } @@ -1023,6 +1027,7 @@ postgres_account_kyc_get_status (void *cls, * @param exchange_pub public key of the exchange, or NULL for none * @param timestamp timestamp to store * @param kyc_ok current KYC status (true for satisfied) + * @param aml_decision current AML decision state at the exchange * @return database result code */ static enum GNUNET_DB_QueryStatus @@ -1035,23 +1040,25 @@ postgres_account_kyc_set_status ( const struct TALER_ExchangeSignatureP *exchange_sig, const struct TALER_ExchangePublicKeyP *exchange_pub, struct GNUNET_TIME_Timestamp timestamp, - bool kyc_ok) + bool kyc_ok, + enum TALER_AmlDecisionState aml_decision) { struct PostgresClosure *pg = cls; - uint8_t ok = kyc_ok; + uint32_t aml32 = (uint32_t) aml_decision; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (merchant_id), GNUNET_PQ_query_param_auto_from_type (h_wire), GNUNET_PQ_query_param_string (exchange_url), GNUNET_PQ_query_param_uint64 (&exchange_kyc_serial), GNUNET_PQ_query_param_timestamp (×tamp), - GNUNET_PQ_query_param_auto_from_type (&ok), + GNUNET_PQ_query_param_bool (kyc_ok), exchange_pub ? GNUNET_PQ_query_param_auto_from_type (exchange_pub) : GNUNET_PQ_query_param_null (), exchange_sig ? GNUNET_PQ_query_param_auto_from_type (exchange_sig) : GNUNET_PQ_query_param_null (), + GNUNET_PQ_query_param_uint32 (&aml32), GNUNET_PQ_query_param_end }; @@ -7923,8 +7930,9 @@ postgres_connect (void *cls) ",account_serial" ",exchange_url" ",exchange_pub" - ",exchange_sig)" - " SELECT $5, $6, $4, account_serial, $3, $7, $8" + ",exchange_sig" + ",aml_decision)" + " SELECT $5, $6, $4, account_serial, $3, $7, $8, $9" " FROM merchant_instances" " JOIN merchant_accounts USING (merchant_serial)" " WHERE merchant_id=$1" @@ -7935,7 +7943,8 @@ postgres_connect (void *cls) " ,kyc_timestamp=$5" " ,kyc_ok=$6" " ,exchange_pub=$7" - " ,exchange_sig=$8"), + " ,exchange_sig=$8" + " ,aml_decision=$9"), /* for postgres_account_kyc_get_status */ GNUNET_PQ_make_prepare ("lookup_kyc_status", "SELECT" @@ -7945,6 +7954,7 @@ postgres_connect (void *cls) ",exchange_url" ",kyc_timestamp" ",kyc_ok" + ",aml_decision" " FROM merchant_instances" " JOIN merchant_accounts" " USING (merchant_serial)" diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 3dbf9cbb..346a5427 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -6722,7 +6722,8 @@ kyc_status_ok (void *cls, const char *payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok) + bool kyc_ok, + enum TALER_AmlDecisionState ades) { bool *fail = cls; @@ -6738,7 +6739,8 @@ kyc_status_fail (void *cls, const char *payto_uri, const char *exchange_url, struct GNUNET_TIME_Timestamp last_check, - bool kyc_ok) + bool kyc_ok, + enum TALER_AmlDecisionState ades) { bool *fail = cls; @@ -6778,7 +6780,8 @@ test_kyc (void) NULL, NULL, now, - false)); + false, + TALER_AML_NORMAL)); TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->account_kyc_set_status (plugin->cls, instance.instance.id, @@ -6788,7 +6791,8 @@ test_kyc (void) NULL, NULL, now, - false)); + false, + TALER_AML_NORMAL)); TEST_RET_ON_FAIL (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->account_kyc_set_status (plugin->cls, instance.instance.id, @@ -6798,7 +6802,8 @@ test_kyc (void) NULL, NULL, now, - true)); + true, + TALER_AML_NORMAL)); fail = true; TEST_RET_ON_FAIL (1 != plugin->account_kyc_get_status (plugin->cls, @@ -7855,7 +7860,8 @@ test_insert_pending_webhook (const struct InstanceData *instance, TEST_COND_RET_ON_FAIL (expected_result == plugin->insert_pending_webhook (plugin->cls, instance->instance.id, - pwebhook->webhook_serial, + pwebhook-> + webhook_serial, pwebhook->pwebhook.url, pwebhook->pwebhook. http_method, @@ -7885,8 +7891,10 @@ test_update_pending_webhook (const struct InstanceData *instance, pwebhook->pwebhook.retries++; TEST_COND_RET_ON_FAIL (expected_result == plugin->update_pending_webhook (plugin->cls, - pwebhook->webhook_serial, - pwebhook->pwebhook.next_attempt), + pwebhook-> + webhook_serial, + pwebhook->pwebhook. + next_attempt), "Update pending webhook failed\n"); return 0; } @@ -7936,9 +7944,9 @@ get_pending_serial_cb (void *cls, header)) && (0 == strcmp (lpw->pwebhook->pwebhook.body, body)) ) - { - lpw->webhook_pending_serial = webhook_pending_serial; - } + { + lpw->webhook_pending_serial = webhook_pending_serial; + } /* else { fprintf(stdout, "next_attempt: %lu vs %lu\n", lpw->pwebhook->pwebhook.next_attempt.abs_value_us, next_attempt.abs_value_us); @@ -8037,9 +8045,9 @@ lookup_pending_webhooks_cb (void *cls, header)) && (0 == strcmp (cmp->webhooks_to_cmp[i].pwebhook.body, body)) ) - { - cmp->results_matching[i]++; - } + { + cmp->results_matching[i]++; + } } } @@ -8194,6 +8202,7 @@ test_lookup_all_webhooks (const struct InstanceData *instance, return 0; } + /** * Tests deleting a pending webhook. * @@ -8307,7 +8316,7 @@ run_test_pending_webhooks (struct TestPendingWebhooks_Closure *cls) &cls->pwebhooks[1])); TEST_RET_ON_FAIL (test_update_pending_webhook (&cls->instance, &cls->pwebhooks[1], - GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); //??? + GNUNET_DB_STATUS_SUCCESS_NO_RESULTS)); // ??? TEST_RET_ON_FAIL (test_lookup_all_webhooks (&cls->instance, 2, cls->pwebhooks)); |