exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit ed40ad727b032e923dab174fc6e393cf44143955
parent 6c9a0ce92cdf301d045ec48b50149c023a959ed9
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed,  4 Jun 2025 22:51:54 +0200

get #10044 test to pass, fix exchange_do_lookup_kyc_requirement_by_row regression

Diffstat:
Msrc/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql | 23+++++++++++++++++++----
Msrc/exchangedb/pg_lookup_kyc_requirement_by_row.c | 4++++
2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql b/src/exchangedb/exchange_do_lookup_kyc_requirement_by_row.sql @@ -47,7 +47,10 @@ SELECT access_token IF NOT FOUND THEN --- RAISE WARNING 'kyc_target % not found', in_h_normalized_payto; + -- RAISE WARNING 'kyc_target % not found', in_h_normalized_payto; + -- Given that we don't recognize the normalized payto, there is no + -- chance that we can match the incoming public key against anything, + -- so this is a 404-case. out_not_found = TRUE; out_kyc_required = FALSE; RETURN; @@ -59,9 +62,11 @@ my_ok = (in_account_pub IS NOT NULL) AND IF ( (NOT my_ok) AND (in_account_pub IS NOT NULL) ) THEN --- RAISE WARNING 'target_pub % does not match', in_account_pub; + -- RAISE WARNING 'target_pub % does not match', in_account_pub; + -- We were given an in_account_pub, but it did not match the + -- target pub. -- Try to see if the in_account_pub appears in ANY reserve_in - -- for this account. + -- for this account instead. PERFORM FROM reserves_in WHERE reserve_pub=in_account_pub @@ -76,12 +81,22 @@ THEN END IF; END IF; -IF (NOT my_ok) +IF (NOT my_ok AND + ( (in_account_pub IS NOT NULL) OR + (my_wtrec.target_pub IS NULL) ) ) THEN + -- We failed to find a matching public key for in_account_pub, and + -- either the client provided a specific one to match OR + -- we could not return any one that could even work, which means + -- we are lacking the KYC auth or any even a triggered requirement. out_not_found = TRUE; out_kyc_required = FALSE; RETURN; END IF; + +-- We have found "something", which may or may not match the input +-- public key (if there was one), but at least some KYC requirement +-- exists. out_not_found = FALSE; out_is_wallet = my_wtrec.is_wallet; diff --git a/src/exchangedb/pg_lookup_kyc_requirement_by_row.c b/src/exchangedb/pg_lookup_kyc_requirement_by_row.c @@ -93,6 +93,10 @@ TEH_PG_lookup_kyc_requirement_by_row ( *aml_review = false; *is_wallet = false; *rule_gen = 0; + if (! have_pub) + memset (account_pub, + 0, + sizeof (*account_pub)); memset (reserve_pub, 0, sizeof (*reserve_pub));