use 32 byte hash for hpayto, use that for joins on queries to better align queries with partitions

This commit is contained in:
Christian Grothoff 2022-03-03 23:52:08 +01:00
parent f951cdef8c
commit 1643b745af
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
15 changed files with 224 additions and 187 deletions

View File

@ -81,6 +81,11 @@ struct AggregationUnit
/** /**
* Selected wire target for the aggregation. * Selected wire target for the aggregation.
*/ */
struct TALER_PaytoHashP h_payto;
/**
* Serial number of the wire target.
*/
uint64_t wire_target; uint64_t wire_target;
/** /**
@ -426,6 +431,8 @@ deposit_cb (void *cls,
GNUNET_assert (NULL == au->payto_uri); GNUNET_assert (NULL == au->payto_uri);
au->payto_uri = GNUNET_strdup (payto_uri); au->payto_uri = GNUNET_strdup (payto_uri);
TALER_payto_hash (payto_uri,
&au->h_payto);
au->wire_target = wire_target; au->wire_target = wire_target;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
&au->wtid, &au->wtid,
@ -775,7 +782,7 @@ run_aggregation (void *cls)
TALER_B2S (&au_active.merchant_pub), TALER_B2S (&au_active.merchant_pub),
(unsigned long long) au_active.wire_target); (unsigned long long) au_active.wire_target);
qs = db_plugin->iterate_matching_deposits (db_plugin->cls, qs = db_plugin->iterate_matching_deposits (db_plugin->cls,
au_active.wire_target, &au_active.h_payto,
&au_active.merchant_pub, &au_active.merchant_pub,
&aggregate_cb, &aggregate_cb,
&au_active, &au_active,
@ -918,7 +925,7 @@ run_aggregation (void *cls)
qs = db_plugin->store_wire_transfer_out (db_plugin->cls, qs = db_plugin->store_wire_transfer_out (db_plugin->cls,
au_active.execution_time, au_active.execution_time,
&au_active.wtid, &au_active.wtid,
au_active.wire_target, &au_active.h_payto,
au_active.wa->section_name, au_active.wa->section_name,
&au_active.final_amount); &au_active.final_amount);
cleanup_au (&au_active); cleanup_au (&au_active);

View File

@ -60,10 +60,15 @@ struct KycPoller
struct GNUNET_DB_EventHandler *eh; struct GNUNET_DB_EventHandler *eh;
/** /**
* UUID being checked. * UUID found based on @e h_payto.
*/ */
uint64_t payment_target_uuid; uint64_t payment_target_uuid;
/**
* UUID being checked.
*/
uint64_t auth_payment_target_uuid;
/** /**
* Current KYC status. * Current KYC status.
*/ */
@ -75,11 +80,6 @@ struct KycPoller
*/ */
struct TALER_PaytoHashP h_payto; struct TALER_PaytoHashP h_payto;
/**
* Hash of the payto:// URI that was given to us for auth.
*/
struct TALER_PaytoHashP auth_h_payto;
/** /**
* When will this request time out? * When will this request time out?
*/ */
@ -170,7 +170,6 @@ kyc_check (void *cls,
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
qs = TEH_plugin->select_kyc_status (TEH_plugin->cls, qs = TEH_plugin->select_kyc_status (TEH_plugin->cls,
kyp->payment_target_uuid,
&kyp->h_payto, &kyp->h_payto,
&kyp->kyc); &kyp->kyc);
if (qs < 0) if (qs < 0)
@ -184,6 +183,9 @@ kyc_check (void *cls,
"inselect_wallet_status"); "inselect_wallet_status");
return qs; return qs;
} }
// FIXME: avoid duplicating this...
kyp->payment_target_uuid = kyp->kyc.payment_target_uuid;
return qs; return qs;
} }
@ -261,7 +263,7 @@ TEH_handler_kyc_check (
TALER_EC_GENERIC_PARAMETER_MALFORMED, TALER_EC_GENERIC_PARAMETER_MALFORMED,
"payment_target_uuid"); "payment_target_uuid");
} }
kyp->payment_target_uuid = (uint64_t) payment_target_uuid; kyp->auth_payment_target_uuid = (uint64_t) payment_target_uuid;
} }
{ {
const char *ts; const char *ts;
@ -308,8 +310,8 @@ TEH_handler_kyc_check (
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (hps, GNUNET_STRINGS_string_to_data (hps,
strlen (hps), strlen (hps),
&kyp->auth_h_payto, &kyp->h_payto,
sizeof (kyp->auth_h_payto))) sizeof (kyp->h_payto)))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection, return TALER_MHD_reply_with_error (rc->connection,
@ -334,7 +336,7 @@ TEH_handler_kyc_check (
struct TALER_KycCompletedEventP rep = { struct TALER_KycCompletedEventP rep = {
.header.size = htons (sizeof (rep)), .header.size = htons (sizeof (rep)),
.header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED), .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED),
.h_payto = kyp->auth_h_payto .h_payto = kyp->h_payto
}; };
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@ -356,9 +358,9 @@ TEH_handler_kyc_check (
kyp); kyp);
if (GNUNET_SYSERR == ret) if (GNUNET_SYSERR == ret)
return res; return res;
if (0 !=
GNUNET_memcmp (&kyp->h_payto, if (kyp->auth_payment_target_uuid !=
&kyp->auth_h_payto)) kyp->payment_target_uuid)
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection, return TALER_MHD_reply_with_error (rc->connection,

View File

@ -78,9 +78,9 @@ struct KycProofContext
char *id; char *id;
/** /**
* Payment target this is about. * Hash of payment target URI this is about.
*/ */
unsigned long long payment_target_uuid; struct TALER_PaytoHashP h_payto;
/** /**
* HTTP response to return. * HTTP response to return.
@ -171,7 +171,7 @@ persist_kyc_ok (void *cls,
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
qs = TEH_plugin->set_kyc_ok (TEH_plugin->cls, qs = TEH_plugin->set_kyc_ok (TEH_plugin->cls,
kpc->payment_target_uuid, &kpc->h_payto,
kpc->id); kpc->id);
if (GNUNET_DB_STATUS_HARD_ERROR == qs) if (GNUNET_DB_STATUS_HARD_ERROR == qs)
{ {
@ -530,24 +530,21 @@ TEH_handler_kyc_proof (
if (NULL == kpc) if (NULL == kpc)
{ /* first time */ { /* first time */
char dummy;
kpc = GNUNET_new (struct KycProofContext); kpc = GNUNET_new (struct KycProofContext);
kpc->rc = rc; kpc->rc = rc;
rc->rh_ctx = kpc; rc->rh_ctx = kpc;
rc->rh_cleaner = &clean_kpc; rc->rh_cleaner = &clean_kpc;
if (GNUNET_OK !=
if (1 != GNUNET_STRINGS_string_to_data (args[0],
sscanf (args[0], strlen (args[0]),
"%llu%c", &kpc->h_payto,
&kpc->payment_target_uuid, sizeof (kpc->h_payto)))
&dummy))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
return TALER_MHD_reply_with_error (rc->connection, return TALER_MHD_reply_with_error (rc->connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_GENERIC_PARAMETER_MALFORMED, TALER_EC_GENERIC_PARAMETER_MALFORMED,
"payment_target_uuid"); "h_payto");
} }
kpc->authorization_code kpc->authorization_code
= MHD_lookup_connection_value (rc->connection, = MHD_lookup_connection_value (rc->connection,

View File

@ -68,17 +68,17 @@ COMMENT ON TABLE denomination_revocations
CREATE TABLE IF NOT EXISTS wire_targets CREATE TABLE IF NOT EXISTS wire_targets
(wire_target_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY -- UNIQUE (wire_target_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY -- UNIQUE
,h_payto BYTEA PRIMARY KEY CHECK (LENGTH(h_payto)=64) ,wire_target_h_payto BYTEA PRIMARY KEY CHECK (LENGTH(wire_target_h_payto)=32)
,payto_uri VARCHAR NOT NULL ,payto_uri VARCHAR NOT NULL
,kyc_ok BOOLEAN NOT NULL DEFAULT (FALSE) ,kyc_ok BOOLEAN NOT NULL DEFAULT (FALSE)
,external_id VARCHAR ,external_id VARCHAR
) )
PARTITION BY HASH (h_payto); PARTITION BY HASH (wire_target_h_payto);
COMMENT ON TABLE wire_targets COMMENT ON TABLE wire_targets
IS 'All senders and recipients of money via the exchange'; IS 'All senders and recipients of money via the exchange';
COMMENT ON COLUMN wire_targets.payto_uri COMMENT ON COLUMN wire_targets.payto_uri
IS 'Can be a regular bank account, or also be a URI identifying a reserve-account (for P2P payments)'; IS 'Can be a regular bank account, or also be a URI identifying a reserve-account (for P2P payments)';
COMMENT ON COLUMN wire_targets.h_payto COMMENT ON COLUMN wire_targets.wire_target_h_payto
IS 'Unsalted hash of payto_uri'; IS 'Unsalted hash of payto_uri';
COMMENT ON COLUMN wire_targets.kyc_ok COMMENT ON COLUMN wire_targets.kyc_ok
IS 'true if the KYC check was passed successfully'; IS 'true if the KYC check was passed successfully';
@ -160,14 +160,14 @@ CREATE TABLE IF NOT EXISTS reserves_in
,wire_reference INT8 NOT NULL ,wire_reference INT8 NOT NULL
,credit_val INT8 NOT NULL ,credit_val INT8 NOT NULL
,credit_frac INT4 NOT NULL ,credit_frac INT4 NOT NULL
,wire_source_serial_id INT8 NOT NULL -- REFERENCES wire_targets (wire_target_serial_id) ,wire_source_h_payto BYTEA CHECK (LENGTH(wire_source_h_payto)=32)
,exchange_account_section TEXT NOT NULL ,exchange_account_section TEXT NOT NULL
,execution_date INT8 NOT NULL ,execution_date INT8 NOT NULL
) )
PARTITION BY HASH (reserve_pub); PARTITION BY HASH (reserve_pub);
COMMENT ON TABLE reserves_in COMMENT ON TABLE reserves_in
IS 'list of transfers of funds into the reserves, one per incoming wire transfer'; IS 'list of transfers of funds into the reserves, one per incoming wire transfer';
COMMENT ON COLUMN reserves_in.wire_source_serial_id COMMENT ON COLUMN reserves_in.wire_source_h_payto
IS 'Identifies the debited bank account and KYC status'; IS 'Identifies the debited bank account and KYC status';
COMMENT ON COLUMN reserves_in.reserve_pub COMMENT ON COLUMN reserves_in.reserve_pub
IS 'Public key of the reserve. Private key signifies ownership of the remaining balance.'; IS 'Public key of the reserve. Private key signifies ownership of the remaining balance.';
@ -215,7 +215,7 @@ CREATE TABLE IF NOT EXISTS reserves_close
,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE ,reserve_pub BYTEA NOT NULL REFERENCES reserves (reserve_pub) ON DELETE CASCADE
,execution_date INT8 NOT NULL ,execution_date INT8 NOT NULL
,wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32) ,wtid BYTEA NOT NULL CHECK (LENGTH(wtid)=32)
,wire_target_serial_id INT8 NOT NULL -- REFERENCES wire_targets (wire_target_serial_id) ,wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)
,amount_val INT8 NOT NULL ,amount_val INT8 NOT NULL
,amount_frac INT4 NOT NULL ,amount_frac INT4 NOT NULL
,closing_fee_val INT8 NOT NULL ,closing_fee_val INT8 NOT NULL
@ -223,7 +223,7 @@ CREATE TABLE IF NOT EXISTS reserves_close
PARTITION BY HASH (reserve_pub); PARTITION BY HASH (reserve_pub);
COMMENT ON TABLE reserves_close COMMENT ON TABLE reserves_close
IS 'wire transfers executed by the reserve to close reserves'; IS 'wire transfers executed by the reserve to close reserves';
COMMENT ON COLUMN reserves_close.wire_target_serial_id COMMENT ON COLUMN reserves_close.wire_target_h_payto
IS 'Identifies the credited bank account (and KYC status). Note that closing does not depend on KYC.'; IS 'Identifies the credited bank account (and KYC status). Note that closing does not depend on KYC.';
CREATE TABLE IF NOT EXISTS reserves_close_default CREATE TABLE IF NOT EXISTS reserves_close_default
@ -618,7 +618,7 @@ CREATE TABLE IF NOT EXISTS deposits
,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64) ,h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)
,coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64) ,coin_sig BYTEA NOT NULL CHECK (LENGTH(coin_sig)=64)
,wire_salt BYTEA NOT NULL CHECK (LENGTH(wire_salt)=16) ,wire_salt BYTEA NOT NULL CHECK (LENGTH(wire_salt)=16)
,wire_target_serial_id INT8 NOT NULL -- REFERENCES wire_targets (wire_target_serial_id) ,wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)
,tiny BOOLEAN NOT NULL DEFAULT FALSE ,tiny BOOLEAN NOT NULL DEFAULT FALSE
,done BOOLEAN NOT NULL DEFAULT FALSE ,done BOOLEAN NOT NULL DEFAULT FALSE
,extension_blocked BOOLEAN NOT NULL DEFAULT FALSE ,extension_blocked BOOLEAN NOT NULL DEFAULT FALSE
@ -652,7 +652,7 @@ COMMENT ON TABLE deposits
IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).'; IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).';
COMMENT ON COLUMN deposits.shard COMMENT ON COLUMN deposits.shard
IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. 64-bit value because we need an *unsigned* 32-bit value.'; IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. 64-bit value because we need an *unsigned* 32-bit value.';
COMMENT ON COLUMN deposits.wire_target_serial_id COMMENT ON COLUMN deposits.wire_target_h_payto
IS 'Identifies the target bank account and KYC status'; IS 'Identifies the target bank account and KYC status';
COMMENT ON COLUMN deposits.wire_salt COMMENT ON COLUMN deposits.wire_salt
IS 'Salt used when hashing the payto://-URI to get the h_wire'; IS 'Salt used when hashing the payto://-URI to get the h_wire';
@ -685,7 +685,7 @@ COMMENT ON INDEX deposits_for_get_ready_index
CREATE INDEX IF NOT EXISTS deposits_for_iterate_matching_index CREATE INDEX IF NOT EXISTS deposits_for_iterate_matching_index
ON deposits ON deposits
(merchant_pub (merchant_pub
,wire_target_serial_id ,wire_target_h_payto
,done ,done
,extension_blocked ,extension_blocked
,refund_deadline ASC ,refund_deadline ASC
@ -742,7 +742,7 @@ CREATE TABLE IF NOT EXISTS wire_out
(wireout_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY -- PRIMARY KEY (wireout_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY -- PRIMARY KEY
,execution_date INT8 NOT NULL ,execution_date INT8 NOT NULL
,wtid_raw BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid_raw)=32) ,wtid_raw BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid_raw)=32)
,wire_target_serial_id INT8 NOT NULL -- REFERENCES wire_targets (wire_target_serial_id) ,wire_target_h_payto BYTEA CHECK (LENGTH(wire_target_h_payto)=32)
,exchange_account_section TEXT NOT NULL ,exchange_account_section TEXT NOT NULL
,amount_val INT8 NOT NULL ,amount_val INT8 NOT NULL
,amount_frac INT4 NOT NULL ,amount_frac INT4 NOT NULL
@ -752,7 +752,7 @@ COMMENT ON TABLE wire_out
IS 'wire transfers the exchange has executed'; IS 'wire transfers the exchange has executed';
COMMENT ON COLUMN wire_out.exchange_account_section COMMENT ON COLUMN wire_out.exchange_account_section
IS 'identifies the configuration section with the debit account of this payment'; IS 'identifies the configuration section with the debit account of this payment';
COMMENT ON COLUMN wire_out.wire_target_serial_id COMMENT ON COLUMN wire_out.wire_target_h_payto
IS 'Identifies the credited bank account and KYC status'; IS 'Identifies the credited bank account and KYC status';
CREATE TABLE IF NOT EXISTS wire_out_default CREATE TABLE IF NOT EXISTS wire_out_default
@ -779,9 +779,9 @@ SELECT add_constraints_to_wire_out_partition('default');
CREATE INDEX IF NOT EXISTS wire_out_by_wireout_uuid_index CREATE INDEX IF NOT EXISTS wire_out_by_wireout_uuid_index
ON wire_out ON wire_out
(wireout_uuid); (wireout_uuid);
CREATE INDEX IF NOT EXISTS wire_out_by_wire_target_serial_id_index CREATE INDEX IF NOT EXISTS wire_out_by_wire_target_h_payto_index
ON wire_out ON wire_out
(wire_target_serial_id); (wire_target_h_payto);
CREATE TABLE IF NOT EXISTS aggregation_tracking CREATE TABLE IF NOT EXISTS aggregation_tracking
@ -1143,7 +1143,7 @@ BEGIN
-- reserves_out (INSERT, with CONFLICT detection) by wih -- reserves_out (INSERT, with CONFLICT detection) by wih
-- reserves by reserve_pub (UPDATE) -- reserves by reserve_pub (UPDATE)
-- reserves_in by reserve_pub (SELECT) -- reserves_in by reserve_pub (SELECT)
-- wire_targets by wire_target_serial_id -- wire_targets by wire_target_h_payto
SELECT denominations_serial SELECT denominations_serial
INTO denom_serial INTO denom_serial
@ -1300,12 +1300,12 @@ END IF;
-- this reserve. FIXME: likely not adequate for reserves that got P2P transfers! -- this reserve. FIXME: likely not adequate for reserves that got P2P transfers!
SELECT SELECT
kyc_ok kyc_ok
,wire_source_serial_id ,wire_target_serial_id
INTO INTO
kycok kycok
,account_uuid ,account_uuid
FROM reserves_in FROM reserves_in
JOIN wire_targets ON (wire_source_serial_id = wire_target_serial_id) JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
WHERE reserve_pub=rpub WHERE reserve_pub=rpub
LIMIT 1; -- limit 1 should not be required (without p2p transfers) LIMIT 1; -- limit 1 should not be required (without p2p transfers)
@ -1424,12 +1424,12 @@ END IF;
INSERT INTO wire_targets INSERT INTO wire_targets
(h_payto (wire_target_h_payto
,payto_uri) ,payto_uri)
VALUES VALUES
(in_h_payto (in_h_payto
,in_receiver_wire_account) ,in_receiver_wire_account)
ON CONFLICT DO NOTHING -- for CONFLICT ON (h_payto) ON CONFLICT DO NOTHING -- for CONFLICT ON (wire_target_h_payto)
RETURNING wire_target_serial_id INTO wtsi; RETURNING wire_target_serial_id INTO wtsi;
IF NOT FOUND IF NOT FOUND
@ -1437,7 +1437,7 @@ THEN
SELECT wire_target_serial_id SELECT wire_target_serial_id
INTO wtsi INTO wtsi
FROM wire_targets FROM wire_targets
WHERE h_payto=in_h_payto; WHERE wire_target_h_payto=in_h_payto;
END IF; END IF;
@ -1454,7 +1454,7 @@ INSERT INTO deposits
,h_contract_terms ,h_contract_terms
,coin_sig ,coin_sig
,wire_salt ,wire_salt
,wire_target_serial_id ,wire_target_h_payto
,extension_blocked ,extension_blocked
,extension_details_serial_id ,extension_details_serial_id
) )
@ -1471,7 +1471,7 @@ INSERT INTO deposits
,in_h_contract_terms ,in_h_contract_terms
,in_coin_sig ,in_coin_sig
,in_wire_salt ,in_wire_salt
,wtsi ,in_h_payto
,in_extension_blocked ,in_extension_blocked
,xdi) ,xdi)
ON CONFLICT DO NOTHING; ON CONFLICT DO NOTHING;

View File

@ -176,7 +176,8 @@ irbt_cb_table_reserves_in (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference), GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference),
TALER_PQ_query_param_amount (&td->details.reserves_in.credit), TALER_PQ_query_param_amount (&td->details.reserves_in.credit),
GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.sender_account), GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_in.sender_account_h_payto),
GNUNET_PQ_query_param_string ( GNUNET_PQ_query_param_string (
td->details.reserves_in.exchange_account_section), td->details.reserves_in.exchange_account_section),
GNUNET_PQ_query_param_timestamp ( GNUNET_PQ_query_param_timestamp (
@ -207,8 +208,8 @@ irbt_cb_table_reserves_close (struct PostgresClosure *pg,
&td->details.reserves_close.execution_date), &td->details.reserves_close.execution_date),
GNUNET_PQ_query_param_auto_from_type ( GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_close.wtid), &td->details.reserves_close.wtid),
GNUNET_PQ_query_param_uint64 ( GNUNET_PQ_query_param_auto_from_type (
&td->details.reserves_close.wire_target_serial_id), &td->details.reserves_close.sender_account_h_payto),
TALER_PQ_query_param_amount (&td->details.reserves_close.amount), TALER_PQ_query_param_amount (&td->details.reserves_close.amount),
TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee), TALER_PQ_query_param_amount (&td->details.reserves_close.closing_fee),
GNUNET_PQ_query_param_auto_from_type ( GNUNET_PQ_query_param_auto_from_type (
@ -523,7 +524,8 @@ irbt_cb_table_deposits (struct PostgresClosure *pg,
&td->details.deposits.h_contract_terms), &td->details.deposits.h_contract_terms),
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.coin_sig), GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.coin_sig),
GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.wire_salt), GNUNET_PQ_query_param_auto_from_type (&td->details.deposits.wire_salt),
GNUNET_PQ_query_param_uint64 (&td->details.deposits.wire_target_serial_id), GNUNET_PQ_query_param_auto_from_type (
&td->details.deposits.wire_target_h_payto),
GNUNET_PQ_query_param_bool (td->details.deposits.tiny), GNUNET_PQ_query_param_bool (td->details.deposits.tiny),
GNUNET_PQ_query_param_bool (td->details.deposits.done), GNUNET_PQ_query_param_bool (td->details.deposits.done),
GNUNET_PQ_query_param_bool (td->details.deposits.extension_blocked), GNUNET_PQ_query_param_bool (td->details.deposits.extension_blocked),
@ -579,7 +581,8 @@ irbt_cb_table_wire_out (struct PostgresClosure *pg,
GNUNET_PQ_query_param_uint64 (&td->serial), GNUNET_PQ_query_param_uint64 (&td->serial),
GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date), GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date),
GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw), GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw),
GNUNET_PQ_query_param_uint64 (&td->details.wire_out.wire_target_serial_id), GNUNET_PQ_query_param_auto_from_type (
&td->details.wire_out.wire_target_h_payto),
GNUNET_PQ_query_param_string ( GNUNET_PQ_query_param_string (
td->details.wire_out.exchange_account_section), td->details.wire_out.exchange_account_section),
TALER_PQ_query_param_amount (&td->details.wire_out.amount), TALER_PQ_query_param_amount (&td->details.wire_out.amount),

View File

@ -289,9 +289,9 @@ lrbt_cb_table_reserves_in (void *cls,
TALER_PQ_RESULT_SPEC_AMOUNT ( TALER_PQ_RESULT_SPEC_AMOUNT (
"credit", "credit",
&td.details.reserves_in.credit), &td.details.reserves_in.credit),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_auto_from_type (
"wire_source_serial_id", "wire_source_h_payto",
&td.details.reserves_in.sender_account), &td.details.reserves_in.sender_account_h_payto),
GNUNET_PQ_result_spec_string ( GNUNET_PQ_result_spec_string (
"exchange_account_section", "exchange_account_section",
&td.details.reserves_in.exchange_account_section), &td.details.reserves_in.exchange_account_section),
@ -350,9 +350,9 @@ lrbt_cb_table_reserves_close (void *cls,
GNUNET_PQ_result_spec_auto_from_type ( GNUNET_PQ_result_spec_auto_from_type (
"wtid", "wtid",
&td.details.reserves_close.wtid), &td.details.reserves_close.wtid),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_auto_from_type (
"wire_target_serial_id", "wire_target_h_payto",
&td.details.reserves_close.wire_target_serial_id), &td.details.reserves_close.sender_account_h_payto),
TALER_PQ_RESULT_SPEC_AMOUNT ( TALER_PQ_RESULT_SPEC_AMOUNT (
"amount", "amount",
&td.details.reserves_close.amount), &td.details.reserves_close.amount),
@ -947,9 +947,9 @@ lrbt_cb_table_deposits (void *cls,
GNUNET_PQ_result_spec_auto_from_type ( GNUNET_PQ_result_spec_auto_from_type (
"wire_salt", "wire_salt",
&td.details.deposits.wire_salt), &td.details.deposits.wire_salt),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_auto_from_type (
"wire_target_serial_id", "wire_target_h_payto",
&td.details.deposits.wire_target_serial_id), &td.details.deposits.wire_target_h_payto),
GNUNET_PQ_result_spec_bool ( GNUNET_PQ_result_spec_bool (
"tiny", "tiny",
&td.details.deposits.tiny), &td.details.deposits.tiny),
@ -1067,9 +1067,9 @@ lrbt_cb_table_wire_out (void *cls,
GNUNET_PQ_result_spec_auto_from_type ( GNUNET_PQ_result_spec_auto_from_type (
"wtid_raw", "wtid_raw",
&td.details.wire_out.wtid_raw), &td.details.wire_out.wtid_raw),
GNUNET_PQ_result_spec_uint64 ( GNUNET_PQ_result_spec_auto_from_type (
"wire_target_serial_id", "wire_target_h_payto",
&td.details.wire_out.wire_target_serial_id), &td.details.wire_out.wire_target_h_payto),
GNUNET_PQ_result_spec_string ( GNUNET_PQ_result_spec_string (
"exchange_account_section", "exchange_account_section",
&td.details.wire_out.exchange_account_section), &td.details.wire_out.exchange_account_section),

View File

@ -429,7 +429,7 @@ prepare_statements (struct PostgresClosure *pg)
" FROM reserves" " FROM reserves"
" JOIN reserves_in ri USING (reserve_pub)" " JOIN reserves_in ri USING (reserve_pub)"
" JOIN wire_targets wt " " JOIN wire_targets wt "
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)" " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)"
" WHERE reserve_pub=$1" " WHERE reserve_pub=$1"
" LIMIT 1;", " LIMIT 1;",
1), 1),
@ -439,31 +439,21 @@ prepare_statements (struct PostgresClosure *pg)
"UPDATE wire_targets" "UPDATE wire_targets"
" SET kyc_ok=TRUE" " SET kyc_ok=TRUE"
",external_id=$2" ",external_id=$2"
" WHERE wire_target_serial_id=$1", " WHERE wire_target_h_payto=$1",
2), 2),
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"get_kyc_h_payto", "get_kyc_h_payto",
"SELECT" "SELECT"
" h_payto" " wire_target_h_payto"
" FROM wire_targets" " FROM wire_targets"
" WHERE wire_target_serial_id=$1" " WHERE wire_target_h_payto=$1"
" LIMIT 1;", " LIMIT 1;",
1), 1),
/* Used in #postgres_select_kyc_status() */
GNUNET_PQ_make_prepare (
"select_kyc_status",
"SELECT"
" kyc_ok"
",h_payto"
" FROM wire_targets"
" WHERE"
" wire_target_serial_id=$1",
1),
/* Used in #postgres_inselect_wallet_kyc_status() */ /* Used in #postgres_inselect_wallet_kyc_status() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"insert_kyc_status", "insert_kyc_status",
"INSERT INTO wire_targets" "INSERT INTO wire_targets"
" (h_payto" " (wire_target_h_payto"
" ,payto_uri" " ,payto_uri"
" ) VALUES " " ) VALUES "
" ($1, $2)" " ($1, $2)"
@ -475,7 +465,7 @@ prepare_statements (struct PostgresClosure *pg)
" kyc_ok" " kyc_ok"
",wire_target_serial_id" ",wire_target_serial_id"
" FROM wire_targets" " FROM wire_targets"
" WHERE h_payto=$1;", " WHERE wire_target_h_payto=$1;",
1), 1),
/* Used in #reserves_get() */ /* Used in #reserves_get() */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
@ -509,7 +499,7 @@ prepare_statements (struct PostgresClosure *pg)
"(reserve_pub" "(reserve_pub"
",execution_date" ",execution_date"
",wtid" ",wtid"
",wire_target_serial_id" ",wire_target_h_payto"
",amount_val" ",amount_val"
",amount_frac" ",amount_frac"
",closing_fee_val" ",closing_fee_val"
@ -536,11 +526,12 @@ prepare_statements (struct PostgresClosure *pg)
",credit_val" ",credit_val"
",credit_frac" ",credit_frac"
",exchange_account_section" ",exchange_account_section"
",wire_source_serial_id" ",wire_source_h_payto"
",execution_date" ",execution_date"
") VALUES ($1, $2, $3, $4, $5, $6, $7)" ") VALUES ($1, $2, $3, $4, $5, $6, $7)"
" ON CONFLICT DO NOTHING;", " ON CONFLICT DO NOTHING;",
7), 7),
#if FIXME_DEAD
/* Used in #postgres_reserves_in_insert() to store transaction details */ /* Used in #postgres_reserves_in_insert() to store transaction details */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
"reserves_in_add_by_pub", "reserves_in_add_by_pub",
@ -550,11 +541,12 @@ prepare_statements (struct PostgresClosure *pg)
",credit_val" ",credit_val"
",credit_frac" ",credit_frac"
",exchange_account_section" ",exchange_account_section"
",wire_source_serial_id" ",wire_source_h_payto"
",execution_date" ",execution_date"
") VALUES ($1, $2, $3, $4, $5, $6, $7)" ") VALUES ($1, $2, $3, $4, $5, $6, $7)"
" ON CONFLICT DO NOTHING;", " ON CONFLICT DO NOTHING;",
7), 7),
#endif
/* Used in postgres_select_reserves_in_above_serial_id() to obtain inbound /* Used in postgres_select_reserves_in_above_serial_id() to obtain inbound
transactions for reserves with serial id '\geq' the given parameter */ transactions for reserves with serial id '\geq' the given parameter */
GNUNET_PQ_make_prepare ( GNUNET_PQ_make_prepare (
@ -571,7 +563,7 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN reserves" " JOIN reserves"
" USING (reserve_pub)" " USING (reserve_pub)"
" JOIN wire_targets" " JOIN wire_targets"
" ON (wire_source_serial_id = wire_target_serial_id)" " ON (wire_source_h_payto = wire_target_h_payto)"
" WHERE reserve_in_serial_id>=$1" " WHERE reserve_in_serial_id>=$1"
" ORDER BY reserve_in_serial_id;", " ORDER BY reserve_in_serial_id;",
1), 1),
@ -591,7 +583,7 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN reserves " " JOIN reserves "
" USING (reserve_pub)" " USING (reserve_pub)"
" JOIN wire_targets" " JOIN wire_targets"
" ON (wire_source_serial_id = wire_target_serial_id)" " ON (wire_source_h_payto = wire_target_h_payto)"
" WHERE reserve_in_serial_id>=$1 AND exchange_account_section=$2" " WHERE reserve_in_serial_id>=$1 AND exchange_account_section=$2"
" ORDER BY reserve_in_serial_id;", " ORDER BY reserve_in_serial_id;",
2), 2),
@ -607,7 +599,7 @@ prepare_statements (struct PostgresClosure *pg)
",payto_uri AS sender_account_details" ",payto_uri AS sender_account_details"
" FROM reserves_in" " FROM reserves_in"
" JOIN wire_targets" " JOIN wire_targets"
" ON (wire_source_serial_id = wire_target_serial_id)" " ON (wire_source_h_payto = wire_target_h_payto)"
" WHERE reserve_pub=$1;", " WHERE reserve_pub=$1;",
1), 1),
/* Used in #postgres_do_withdraw() to store /* Used in #postgres_do_withdraw() to store
@ -1067,7 +1059,7 @@ prepare_statements (struct PostgresClosure *pg)
",merchant_pub" ",merchant_pub"
",h_contract_terms" ",h_contract_terms"
",wire_salt" ",wire_salt"
",wire_target_serial_id" ",wire_target_h_payto"
",coin_sig" ",coin_sig"
",exchange_timestamp" ",exchange_timestamp"
",shard" ",shard"
@ -1096,7 +1088,7 @@ prepare_statements (struct PostgresClosure *pg)
" FROM deposits" " FROM deposits"
" JOIN known_coins USING (known_coin_id)" " JOIN known_coins USING (known_coin_id)"
" JOIN denominations USING (denominations_serial)" " JOIN denominations USING (denominations_serial)"
" JOIN wire_targets USING (wire_target_serial_id)" " JOIN wire_targets USING (wire_target_h_payto)"
" WHERE ((coin_pub=$1)" " WHERE ((coin_pub=$1)"
" AND (merchant_pub=$3)" " AND (merchant_pub=$3)"
" AND (h_contract_terms=$2));", " AND (h_contract_terms=$2));",
@ -1122,7 +1114,7 @@ prepare_statements (struct PostgresClosure *pg)
",done" ",done"
",deposit_serial_id" ",deposit_serial_id"
" FROM deposits" " FROM deposits"
" JOIN wire_targets USING (wire_target_serial_id)" " JOIN wire_targets USING (wire_target_h_payto)"
" JOIN known_coins kc USING (known_coin_id)" " JOIN known_coins kc USING (known_coin_id)"
" JOIN denominations denom USING (denominations_serial)" " JOIN denominations denom USING (denominations_serial)"
" WHERE (" " WHERE ("
@ -1145,7 +1137,7 @@ prepare_statements (struct PostgresClosure *pg)
",denom.fee_deposit_frac" ",denom.fee_deposit_frac"
",wire_deadline" ",wire_deadline"
" FROM deposits" " FROM deposits"
" JOIN wire_targets USING (wire_target_serial_id)" " JOIN wire_targets USING (wire_target_h_payto)"
" JOIN known_coins USING (known_coin_id)" " JOIN known_coins USING (known_coin_id)"
" JOIN denominations denom USING (denominations_serial)" " JOIN denominations denom USING (denominations_serial)"
" WHERE ((coin_pub=$1)" " WHERE ((coin_pub=$1)"
@ -1169,7 +1161,7 @@ prepare_statements (struct PostgresClosure *pg)
",kc.coin_pub" ",kc.coin_pub"
" FROM deposits" " FROM deposits"
" JOIN wire_targets " " JOIN wire_targets "
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" JOIN known_coins kc" " JOIN known_coins kc"
" USING (known_coin_id)" " USING (known_coin_id)"
" JOIN denominations denom" " JOIN denominations denom"
@ -1203,7 +1195,7 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN denominations denom USING (denominations_serial)" " JOIN denominations denom USING (denominations_serial)"
" WHERE" " WHERE"
" merchant_pub=$1" " merchant_pub=$1"
" AND wire_target_serial_id=$2" " AND wire_target_h_payto=$2"
" AND done=FALSE" " AND done=FALSE"
" AND extension_blocked=FALSE" " AND extension_blocked=FALSE"
" AND refund_deadline<$3" " AND refund_deadline<$3"
@ -1251,7 +1243,7 @@ prepare_statements (struct PostgresClosure *pg)
",done" ",done"
" FROM deposits" " FROM deposits"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" JOIN known_coins kc" " JOIN known_coins kc"
" USING (known_coin_id)" " USING (known_coin_id)"
" JOIN denominations denoms" " JOIN denominations denoms"
@ -1287,7 +1279,7 @@ prepare_statements (struct PostgresClosure *pg)
" aggregation_serial_id" " aggregation_serial_id"
",deposits.h_contract_terms" ",deposits.h_contract_terms"
",payto_uri" ",payto_uri"
",h_payto" ",wire_targets.wire_target_h_payto"
",kc.coin_pub" ",kc.coin_pub"
",deposits.merchant_pub" ",deposits.merchant_pub"
",wire_out.execution_date" ",wire_out.execution_date"
@ -1300,7 +1292,7 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN deposits" " JOIN deposits"
" USING (deposit_serial_id)" " USING (deposit_serial_id)"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" JOIN known_coins kc" " JOIN known_coins kc"
" USING (known_coin_id)" " USING (known_coin_id)"
" JOIN denominations denom" " JOIN denominations denom"
@ -1323,7 +1315,7 @@ prepare_statements (struct PostgresClosure *pg)
",denom.fee_deposit_frac" ",denom.fee_deposit_frac"
" FROM deposits" " FROM deposits"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" JOIN aggregation_tracking" " JOIN aggregation_tracking"
" USING (deposit_serial_id)" " USING (deposit_serial_id)"
" JOIN known_coins" " JOIN known_coins"
@ -1382,7 +1374,7 @@ prepare_statements (struct PostgresClosure *pg)
"INSERT INTO wire_out " "INSERT INTO wire_out "
"(execution_date" "(execution_date"
",wtid_raw" ",wtid_raw"
",wire_target_serial_id" ",wire_target_h_payto"
",exchange_account_section" ",exchange_account_section"
",amount_val" ",amount_val"
",amount_frac" ",amount_frac"
@ -1395,7 +1387,7 @@ prepare_statements (struct PostgresClosure *pg)
"(wireout_uuid" "(wireout_uuid"
",execution_date" ",execution_date"
",wtid_raw" ",wtid_raw"
",wire_target_serial_id" ",wire_target_h_payto"
",exchange_account_section" ",exchange_account_section"
",amount_val" ",amount_val"
",amount_frac" ",amount_frac"
@ -1456,7 +1448,7 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN known_coins" " JOIN known_coins"
" USING (known_coin_id)" " USING (known_coin_id)"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" WHERE wire_deadline >= $1" " WHERE wire_deadline >= $1"
" AND wire_deadline < $2" " AND wire_deadline < $2"
" AND NOT (EXISTS (SELECT 1" " AND NOT (EXISTS (SELECT 1"
@ -1480,7 +1472,7 @@ prepare_statements (struct PostgresClosure *pg)
",amount_frac" ",amount_frac"
" FROM wire_out" " FROM wire_out"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" WHERE wireout_uuid>=$1" " WHERE wireout_uuid>=$1"
" ORDER BY wireout_uuid ASC;", " ORDER BY wireout_uuid ASC;",
1), 1),
@ -1496,7 +1488,7 @@ prepare_statements (struct PostgresClosure *pg)
",amount_frac" ",amount_frac"
" FROM wire_out" " FROM wire_out"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" WHERE " " WHERE "
" wireout_uuid>=$1 " " wireout_uuid>=$1 "
" AND exchange_account_section=$2" " AND exchange_account_section=$2"
@ -1580,7 +1572,7 @@ prepare_statements (struct PostgresClosure *pg)
",closing_fee_frac" ",closing_fee_frac"
" FROM reserves_close" " FROM reserves_close"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" JOIN reserves" " JOIN reserves"
" USING (reserve_pub)" " USING (reserve_pub)"
" WHERE close_uuid>=$1" " WHERE close_uuid>=$1"
@ -1649,7 +1641,7 @@ prepare_statements (struct PostgresClosure *pg)
",wtid" ",wtid"
" FROM reserves_close" " FROM reserves_close"
" JOIN wire_targets" " JOIN wire_targets"
" USING (wire_target_serial_id)" " USING (wire_target_h_payto)"
" WHERE reserve_pub=$1;", " WHERE reserve_pub=$1;",
1), 1),
/* Used in #postgres_get_expired_reserves() */ /* Used in #postgres_get_expired_reserves() */
@ -1665,7 +1657,7 @@ prepare_statements (struct PostgresClosure *pg)
" JOIN reserves_in ri" " JOIN reserves_in ri"
" USING (reserve_pub)" " USING (reserve_pub)"
" JOIN wire_targets wt" " JOIN wire_targets wt"
" ON (ri.wire_source_serial_id = wt.wire_target_serial_id)" " ON (ri.wire_source_h_payto = wt.wire_target_h_payto)"
" WHERE expiration_date<=$1" " WHERE expiration_date<=$1"
" AND (current_balance_val != 0 " " AND (current_balance_val != 0 "
" OR current_balance_frac != 0)" " OR current_balance_frac != 0)"
@ -2198,7 +2190,7 @@ prepare_statements (struct PostgresClosure *pg)
",wire_reference" ",wire_reference"
",credit_val" ",credit_val"
",credit_frac" ",credit_frac"
",wire_source_serial_id" ",wire_source_h_payto"
",exchange_account_section" ",exchange_account_section"
",execution_date" ",execution_date"
" FROM reserves_in" " FROM reserves_in"
@ -2212,7 +2204,7 @@ prepare_statements (struct PostgresClosure *pg)
",reserve_pub" ",reserve_pub"
",execution_date" ",execution_date"
",wtid" ",wtid"
",wire_target_serial_id" ",wire_target_h_payto"
",amount_val" ",amount_val"
",amount_frac" ",amount_frac"
",closing_fee_val" ",closing_fee_val"
@ -2354,7 +2346,7 @@ prepare_statements (struct PostgresClosure *pg)
",h_contract_terms" ",h_contract_terms"
",coin_sig" ",coin_sig"
",wire_salt" ",wire_salt"
",wire_target_serial_id" ",wire_target_h_payto"
",tiny" ",tiny"
",done" ",done"
",extension_blocked" ",extension_blocked"
@ -2382,7 +2374,7 @@ prepare_statements (struct PostgresClosure *pg)
" wireout_uuid AS serial" " wireout_uuid AS serial"
",execution_date" ",execution_date"
",wtid_raw" ",wtid_raw"
",wire_target_serial_id" ",wire_target_h_payto"
",exchange_account_section" ",exchange_account_section"
",amount_val" ",amount_val"
",amount_frac" ",amount_frac"
@ -2487,7 +2479,7 @@ prepare_statements (struct PostgresClosure *pg)
"insert_into_table_wire_targets", "insert_into_table_wire_targets",
"INSERT INTO wire_targets" "INSERT INTO wire_targets"
"(wire_target_serial_id" "(wire_target_serial_id"
",h_payto" ",wire_target_h_payto"
",payto_uri" ",payto_uri"
",kyc_ok" ",kyc_ok"
",external_id" ",external_id"
@ -2513,7 +2505,7 @@ prepare_statements (struct PostgresClosure *pg)
",wire_reference" ",wire_reference"
",credit_val" ",credit_val"
",credit_frac" ",credit_frac"
",wire_source_serial_id" ",wire_source_h_payto"
",exchange_account_section" ",exchange_account_section"
",execution_date" ",execution_date"
",reserve_pub" ",reserve_pub"
@ -2526,7 +2518,7 @@ prepare_statements (struct PostgresClosure *pg)
"(close_uuid" "(close_uuid"
",execution_date" ",execution_date"
",wtid" ",wtid"
",wire_target_serial_id" ",wire_target_h_payto"
",amount_val" ",amount_val"
",amount_frac" ",amount_frac"
",closing_fee_val" ",closing_fee_val"
@ -2660,7 +2652,7 @@ prepare_statements (struct PostgresClosure *pg)
",h_contract_terms" ",h_contract_terms"
",coin_sig" ",coin_sig"
",wire_salt" ",wire_salt"
",wire_target_serial_id" ",wire_target_h_payto"
",tiny" ",tiny"
",done" ",done"
",extension_blocked" ",extension_blocked"
@ -3914,22 +3906,22 @@ postgres_reserves_get (void *cls,
* Set the KYC status to "OK" for a bank account. * Set the KYC status to "OK" for a bank account.
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param payment_target_uuid which account has been checked * @param h_payto which account has been checked
* @param id external ID to persist * @param id external ID to persist
* @return transaction status * @return transaction status
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
postgres_set_kyc_ok (void *cls, postgres_set_kyc_ok (void *cls,
uint64_t payment_target_uuid, const struct TALER_PaytoHashP *h_payto,
const char *id) const char *id)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&payment_target_uuid), GNUNET_PQ_query_param_auto_from_type (h_payto),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_QueryParam params2[] = { struct GNUNET_PQ_QueryParam params2[] = {
GNUNET_PQ_query_param_uint64 (&payment_target_uuid), GNUNET_PQ_query_param_auto_from_type (h_payto),
GNUNET_PQ_query_param_string (id), GNUNET_PQ_query_param_string (id),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -3938,7 +3930,7 @@ postgres_set_kyc_ok (void *cls,
.header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED) .header.type = htons (TALER_DBEVENT_EXCHANGE_KYC_COMPLETED)
}; };
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_payto", GNUNET_PQ_result_spec_auto_from_type ("wire_target_h_payto",
&rep.h_payto), &rep.h_payto),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
@ -3967,34 +3959,31 @@ postgres_set_kyc_ok (void *cls,
* Get the @a kyc status and @a h_payto by UUID. * Get the @a kyc status and @a h_payto by UUID.
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param payment_target_uuid which account to get the KYC status for * @param h_payto set to the hash of the account's payto URI (unsalted)
* @param[out] h_payto set to the hash of the account's payto URI (unsalted)
* @param[out] kyc set to the KYC status of the account * @param[out] kyc set to the KYC status of the account
* @return transaction status * @return transaction status
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
postgres_select_kyc_status (void *cls, postgres_select_kyc_status (void *cls,
uint64_t payment_target_uuid, const struct TALER_PaytoHashP *h_payto,
struct TALER_PaytoHashP *h_payto,
struct TALER_EXCHANGEDB_KycStatus *kyc) struct TALER_EXCHANGEDB_KycStatus *kyc)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_uint64 (&payment_target_uuid), GNUNET_PQ_query_param_auto_from_type (&h_payto),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_payto", GNUNET_PQ_result_spec_uint64 ("wire_target_serial_id",
h_payto), &kyc->payment_target_uuid),
GNUNET_PQ_result_spec_auto_from_type ("kyc_ok", GNUNET_PQ_result_spec_bool ("kyc_ok",
&kyc->ok), &kyc->ok),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };
kyc->type = TALER_EXCHANGEDB_KYC_UNKNOWN; kyc->type = TALER_EXCHANGEDB_KYC_UNKNOWN;
kyc->payment_target_uuid = payment_target_uuid;
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn, return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"select_kyc_status", "select_kyc_status_by_payto",
params, params,
rs); rs);
} }
@ -4015,7 +4004,6 @@ inselect_account_kyc_status (
const char *payto_uri, const char *payto_uri,
struct TALER_EXCHANGEDB_KycStatus *kyc) struct TALER_EXCHANGEDB_KycStatus *kyc)
{ {
struct TALER_PaytoHashP h_payto; struct TALER_PaytoHashP h_payto;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
@ -4267,10 +4255,14 @@ postgres_reserves_in_insert (void *cls,
enum GNUNET_DB_QueryStatus qs2; enum GNUNET_DB_QueryStatus qs2;
struct TALER_EXCHANGEDB_KycStatus kyc; struct TALER_EXCHANGEDB_KycStatus kyc;
enum GNUNET_DB_QueryStatus qs3; enum GNUNET_DB_QueryStatus qs3;
struct TALER_PaytoHashP h_payto;
TALER_payto_hash (sender_account_details,
&h_payto);
memset (&kyc, memset (&kyc,
0, 0,
sizeof (kyc)); sizeof (kyc));
/* FIXME: inselect re-computes h_payto... */
qs3 = inselect_account_kyc_status (pg, qs3 = inselect_account_kyc_status (pg,
sender_account_details, sender_account_details,
&kyc); &kyc);
@ -4286,7 +4278,7 @@ postgres_reserves_in_insert (void *cls,
GNUNET_PQ_query_param_uint64 (&wire_ref), GNUNET_PQ_query_param_uint64 (&wire_ref),
TALER_PQ_query_param_amount (balance), TALER_PQ_query_param_amount (balance),
GNUNET_PQ_query_param_string (exchange_account_section), GNUNET_PQ_query_param_string (exchange_account_section),
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid), GNUNET_PQ_query_param_auto_from_type (&h_payto),
GNUNET_PQ_query_param_timestamp (&execution_time), GNUNET_PQ_query_param_timestamp (&execution_time),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -5686,7 +5678,7 @@ match_deposit_cb (void *cls,
* destination. Those deposits must not already be "done". * destination. Those deposits must not already be "done".
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param wire_target destination of the wire transfer * @param h_payto destination of the wire transfer
* @param merchant_pub public key of the merchant * @param merchant_pub public key of the merchant
* @param deposit_cb function to call for each deposit * @param deposit_cb function to call for each deposit
* @param deposit_cb_cls closure for @a deposit_cb * @param deposit_cb_cls closure for @a deposit_cb
@ -5697,7 +5689,7 @@ match_deposit_cb (void *cls,
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
postgres_iterate_matching_deposits ( postgres_iterate_matching_deposits (
void *cls, void *cls,
uint64_t wire_target, const struct TALER_PaytoHashP *h_payto,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb, TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
void *deposit_cb_cls, void *deposit_cb_cls,
@ -5707,7 +5699,7 @@ postgres_iterate_matching_deposits (
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (merchant_pub), GNUNET_PQ_query_param_auto_from_type (merchant_pub),
GNUNET_PQ_query_param_uint64 (&wire_target), GNUNET_PQ_query_param_auto_from_type (h_payto),
GNUNET_PQ_query_param_absolute_time (&now), GNUNET_PQ_query_param_absolute_time (&now),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
}; };
@ -5955,7 +5947,11 @@ postgres_insert_deposit (void *cls,
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct TALER_EXCHANGEDB_KycStatus kyc; struct TALER_EXCHANGEDB_KycStatus kyc;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
struct TALER_PaytoHashP h_payto;
TALER_payto_hash (deposit->receiver_wire_account,
&h_payto);
/* FIXME: inselect re-computes h_payto... */
qs = inselect_account_kyc_status (pg, qs = inselect_account_kyc_status (pg,
deposit->receiver_wire_account, deposit->receiver_wire_account,
&kyc); &kyc);
@ -5975,7 +5971,7 @@ postgres_insert_deposit (void *cls,
GNUNET_PQ_query_param_auto_from_type (&deposit->merchant_pub), GNUNET_PQ_query_param_auto_from_type (&deposit->merchant_pub),
GNUNET_PQ_query_param_auto_from_type (&deposit->h_contract_terms), GNUNET_PQ_query_param_auto_from_type (&deposit->h_contract_terms),
GNUNET_PQ_query_param_auto_from_type (&deposit->wire_salt), GNUNET_PQ_query_param_auto_from_type (&deposit->wire_salt),
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid), GNUNET_PQ_query_param_auto_from_type (&h_payto),
GNUNET_PQ_query_param_auto_from_type (&deposit->csig), GNUNET_PQ_query_param_auto_from_type (&deposit->csig),
GNUNET_PQ_query_param_timestamp (&exchange_timestamp), GNUNET_PQ_query_param_timestamp (&exchange_timestamp),
GNUNET_PQ_query_param_uint64 (&shard), GNUNET_PQ_query_param_uint64 (&shard),
@ -7264,7 +7260,7 @@ handle_wt_result (void *cls,
&h_contract_terms), &h_contract_terms),
GNUNET_PQ_result_spec_string ("payto_uri", GNUNET_PQ_result_spec_string ("payto_uri",
&payto_uri), &payto_uri),
GNUNET_PQ_result_spec_auto_from_type ("h_payto", GNUNET_PQ_result_spec_auto_from_type ("wire_target_h_payto",
&h_payto), &h_payto),
TALER_PQ_result_spec_denom_pub ("denom_pub", TALER_PQ_result_spec_denom_pub ("denom_pub",
&denom_pub), &denom_pub),
@ -7798,7 +7794,11 @@ postgres_insert_reserve_closed (
struct TALER_EXCHANGEDB_Reserve reserve; struct TALER_EXCHANGEDB_Reserve reserve;
struct TALER_EXCHANGEDB_KycStatus kyc; struct TALER_EXCHANGEDB_KycStatus kyc;
enum GNUNET_DB_QueryStatus qs; enum GNUNET_DB_QueryStatus qs;
struct TALER_PaytoHashP h_payto;
TALER_payto_hash (receiver_account,
&h_payto);
/* FIXME: inselect re-computes h_payto... */
qs = inselect_account_kyc_status (pg, qs = inselect_account_kyc_status (pg,
receiver_account, receiver_account,
&kyc); &kyc);
@ -7813,7 +7813,7 @@ postgres_insert_reserve_closed (
GNUNET_PQ_query_param_auto_from_type (reserve_pub), GNUNET_PQ_query_param_auto_from_type (reserve_pub),
GNUNET_PQ_query_param_timestamp (&execution_date), GNUNET_PQ_query_param_timestamp (&execution_date),
GNUNET_PQ_query_param_auto_from_type (wtid), GNUNET_PQ_query_param_auto_from_type (wtid),
GNUNET_PQ_query_param_uint64 (&kyc.payment_target_uuid), GNUNET_PQ_query_param_auto_from_type (&h_payto),
TALER_PQ_query_param_amount (amount_with_fee), TALER_PQ_query_param_amount (amount_with_fee),
TALER_PQ_query_param_amount (closing_fee), TALER_PQ_query_param_amount (closing_fee),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
@ -8094,7 +8094,7 @@ postgres_start_deferred_wire_out (void *cls)
* @param cls closure * @param cls closure
* @param date time of the wire transfer * @param date time of the wire transfer
* @param wtid subject of the wire transfer * @param wtid subject of the wire transfer
* @param wire_target identifies the receiver account of the wire transfer * @param h_payto identifies the receiver account of the wire transfer
* @param exchange_account_section configuration section of the exchange specifying the * @param exchange_account_section configuration section of the exchange specifying the
* exchange's bank account being used * exchange's bank account being used
* @param amount amount that was transmitted * @param amount amount that was transmitted
@ -8105,7 +8105,7 @@ postgres_store_wire_transfer_out (
void *cls, void *cls,
struct GNUNET_TIME_Timestamp date, struct GNUNET_TIME_Timestamp date,
const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_WireTransferIdentifierRawP *wtid,
uint64_t wire_target, const struct TALER_PaytoHashP *h_payto,
const char *exchange_account_section, const char *exchange_account_section,
const struct TALER_Amount *amount) const struct TALER_Amount *amount)
{ {
@ -8113,7 +8113,7 @@ postgres_store_wire_transfer_out (
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_timestamp (&date), GNUNET_PQ_query_param_timestamp (&date),
GNUNET_PQ_query_param_auto_from_type (wtid), GNUNET_PQ_query_param_auto_from_type (wtid),
GNUNET_PQ_query_param_uint64 (&wire_target), GNUNET_PQ_query_param_auto_from_type (h_payto),
GNUNET_PQ_query_param_string (exchange_account_section), GNUNET_PQ_query_param_string (exchange_account_section),
TALER_PQ_query_param_amount (amount), TALER_PQ_query_param_amount (amount),
GNUNET_PQ_query_param_end GNUNET_PQ_query_param_end
@ -11774,9 +11774,9 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
plugin->iterate_active_auditors = &postgres_iterate_active_auditors; plugin->iterate_active_auditors = &postgres_iterate_active_auditors;
plugin->iterate_auditor_denominations = plugin->iterate_auditor_denominations =
&postgres_iterate_auditor_denominations; &postgres_iterate_auditor_denominations;
plugin->select_kyc_status = &postgres_select_kyc_status;
plugin->reserves_get = &postgres_reserves_get; plugin->reserves_get = &postgres_reserves_get;
plugin->set_kyc_ok = &postgres_set_kyc_ok; plugin->set_kyc_ok = &postgres_set_kyc_ok;
plugin->select_kyc_status = &postgres_select_kyc_status;
plugin->inselect_wallet_kyc_status = &postgres_inselect_wallet_kyc_status; plugin->inselect_wallet_kyc_status = &postgres_inselect_wallet_kyc_status;
plugin->reserves_in_insert = &postgres_reserves_in_insert; plugin->reserves_in_insert = &postgres_reserves_in_insert;
plugin->get_withdraw_info = &postgres_get_withdraw_info; plugin->get_withdraw_info = &postgres_get_withdraw_info;

View File

@ -616,6 +616,10 @@ static uint64_t deposit_rowid;
*/ */
static uint64_t wire_target_row; static uint64_t wire_target_row;
/**
* Here #deposit_cb() will store the hash of the payto URI.
*/
static struct TALER_PaytoHashP wire_target_h_payto;
/** /**
* Function called with details about deposits that * Function called with details about deposits that
@ -662,6 +666,8 @@ deposit_cb (void *cls,
{ {
deposit_rowid = rowid; deposit_rowid = rowid;
wire_target_row = wire_target; wire_target_row = wire_target;
TALER_payto_hash (payto_uri,
&wire_target_h_payto);
result = 9; result = 9;
} }
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
@ -1048,6 +1054,10 @@ audit_wire_cb (void *cls,
static enum GNUNET_GenericReturnValue static enum GNUNET_GenericReturnValue
test_wire_out (const struct TALER_EXCHANGEDB_Deposit *deposit) test_wire_out (const struct TALER_EXCHANGEDB_Deposit *deposit)
{ {
struct TALER_PaytoHashP h_payto;
TALER_payto_hash (deposit->receiver_wire_account,
&h_payto);
auditor_row_cnt = 0; auditor_row_cnt = 0;
memset (&wire_out_wtid, memset (&wire_out_wtid,
42, 42,
@ -1127,7 +1137,7 @@ test_wire_out (const struct TALER_EXCHANGEDB_Deposit *deposit)
plugin->store_wire_transfer_out (plugin->cls, plugin->store_wire_transfer_out (plugin->cls,
wire_out_date, wire_out_date,
&wire_out_wtid, &wire_out_wtid,
kyc.payment_target_uuid, &h_payto,
"my-config-section", "my-config-section",
&wire_out_amount)); &wire_out_amount));
} }
@ -2267,7 +2277,7 @@ run (void *cls)
FAILIF (8 == result); FAILIF (8 == result);
FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
plugin->iterate_matching_deposits (plugin->cls, plugin->iterate_matching_deposits (plugin->cls,
wire_target_row, &wire_target_h_payto,
&deposit.merchant_pub, &deposit.merchant_pub,
&matching_deposit_cb, &matching_deposit_cb,
&deposit, &deposit,

View File

@ -546,7 +546,7 @@ struct TALER_PaytoHashP
/** /**
* Actual hash value. * Actual hash value.
*/ */
struct GNUNET_HashCode hash; struct GNUNET_ShortHashCode hash;
}; };

View File

@ -2090,10 +2090,10 @@ typedef void
* @return a handle for this request * @return a handle for this request
*/ */
struct TALER_EXCHANGE_LinkHandle * struct TALER_EXCHANGE_LinkHandle *
TALER_EXCHANGE_link (struct TALER_EXCHANGE_Handle *exchange, TALER_EXCHANGE_link (
struct TALER_EXCHANGE_Handle *exchange,
const struct TALER_CoinSpendPrivateKeyP *coin_priv, const struct TALER_CoinSpendPrivateKeyP *coin_priv,
const struct const struct TALER_AgeCommitmentProof *age_commitment_proof,
TALER_AgeCommitmentProof *age_commitment_proof,
TALER_EXCHANGE_LinkCallback link_cb, TALER_EXCHANGE_LinkCallback link_cb,
void *link_cb_cls); void *link_cb_cls);
@ -2699,7 +2699,7 @@ struct TALER_EXCHANGE_KycProofHandle;
* Run interaction with exchange to provide proof of KYC status. * Run interaction with exchange to provide proof of KYC status.
* *
* @param eh exchange handle to use * @param eh exchange handle to use
* @param payment_target number identifying the target * @param h_payto hash of payto URI identifying the target account
* @param code OAuth 2.0 code argument * @param code OAuth 2.0 code argument
* @param state OAuth 2.0 state argument * @param state OAuth 2.0 state argument
* @param cb function to call with the result * @param cb function to call with the result
@ -2708,7 +2708,7 @@ struct TALER_EXCHANGE_KycProofHandle;
*/ */
struct TALER_EXCHANGE_KycProofHandle * struct TALER_EXCHANGE_KycProofHandle *
TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *eh, TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *eh,
uint64_t payment_target, const struct TALER_PaytoHashP *h_payto,
const char *code, const char *code,
const char *state, const char *state,
TALER_EXCHANGE_KycProofCallback cb, TALER_EXCHANGE_KycProofCallback cb,

View File

@ -239,7 +239,7 @@ struct TALER_EXCHANGEDB_TableData
{ {
uint64_t wire_reference; uint64_t wire_reference;
struct TALER_Amount credit; struct TALER_Amount credit;
uint64_t sender_account; struct TALER_PaytoHashP sender_account_h_payto;
char *exchange_account_section; char *exchange_account_section;
struct GNUNET_TIME_Timestamp execution_date; struct GNUNET_TIME_Timestamp execution_date;
struct TALER_ReservePublicKeyP reserve_pub; struct TALER_ReservePublicKeyP reserve_pub;
@ -250,7 +250,7 @@ struct TALER_EXCHANGEDB_TableData
struct TALER_ReservePublicKeyP reserve_pub; struct TALER_ReservePublicKeyP reserve_pub;
struct GNUNET_TIME_Timestamp execution_date; struct GNUNET_TIME_Timestamp execution_date;
struct TALER_WireTransferIdentifierRawP wtid; struct TALER_WireTransferIdentifierRawP wtid;
uint64_t wire_target_serial_id; struct TALER_PaytoHashP sender_account_h_payto;
struct TALER_Amount amount; struct TALER_Amount amount;
struct TALER_Amount closing_fee; struct TALER_Amount closing_fee;
} reserves_close; } reserves_close;
@ -347,7 +347,7 @@ struct TALER_EXCHANGEDB_TableData
struct TALER_PrivateContractHashP h_contract_terms; struct TALER_PrivateContractHashP h_contract_terms;
struct TALER_CoinSpendSignatureP coin_sig; struct TALER_CoinSpendSignatureP coin_sig;
struct TALER_WireSaltP wire_salt; struct TALER_WireSaltP wire_salt;
uint64_t wire_target_serial_id; struct TALER_PaytoHashP wire_target_h_payto;
bool tiny; bool tiny;
bool done; bool done;
bool extension_blocked; bool extension_blocked;
@ -366,7 +366,7 @@ struct TALER_EXCHANGEDB_TableData
{ {
struct GNUNET_TIME_Timestamp execution_date; struct GNUNET_TIME_Timestamp execution_date;
struct TALER_WireTransferIdentifierRawP wtid_raw; struct TALER_WireTransferIdentifierRawP wtid_raw;
uint64_t wire_target_serial_id; struct TALER_PaytoHashP wire_target_h_payto;
char *exchange_account_section; char *exchange_account_section;
struct TALER_Amount amount; struct TALER_Amount amount;
} wire_out; } wire_out;
@ -2479,13 +2479,13 @@ struct TALER_EXCHANGEDB_Plugin
* Set the KYC status to "OK" for a bank account. * Set the KYC status to "OK" for a bank account.
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param payment_target_uuid which account has been checked * @param h_payto which account has been checked
* @param id ID data to persist * @param id ID data to persist
* @return transaction status * @return transaction status
*/ */
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*set_kyc_ok)(void *cls, (*set_kyc_ok)(void *cls,
uint64_t payment_target_uuid, const struct TALER_PaytoHashP *h_payto,
const char *id); const char *id);
@ -2493,15 +2493,13 @@ struct TALER_EXCHANGEDB_Plugin
* Get the @a kyc status and @a h_payto by UUID. * Get the @a kyc status and @a h_payto by UUID.
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param payment_target_uuid which account to get the KYC status for * @param h_payto set to the hash of the account's payto URI (unsalted)
* @param[out] h_payto set to the hash of the account's payto URI (unsalted)
* @param[out] kyc set to the KYC status of the account * @param[out] kyc set to the KYC status of the account
* @return transaction status * @return transaction status
*/ */
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*select_kyc_status)(void *cls, (*select_kyc_status)(void *cls,
uint64_t payment_target_uuid, const struct TALER_PaytoHashP *h_payto,
struct TALER_PaytoHashP *h_payto,
struct TALER_EXCHANGEDB_KycStatus *kyc); struct TALER_EXCHANGEDB_KycStatus *kyc);
@ -3044,7 +3042,7 @@ struct TALER_EXCHANGEDB_Plugin
* destination. Those deposits must not already be "done". * destination. Those deposits must not already be "done".
* *
* @param cls the @e cls of this struct with the plugin-specific state * @param cls the @e cls of this struct with the plugin-specific state
* @param h_wire destination of the wire transfer * @param h_payto destination of the wire transfer
* @param merchant_pub public key of the merchant * @param merchant_pub public key of the merchant
* @param deposit_cb function to call for each deposit * @param deposit_cb function to call for each deposit
* @param deposit_cb_cls closure for @a deposit_cb * @param deposit_cb_cls closure for @a deposit_cb
@ -3057,7 +3055,7 @@ struct TALER_EXCHANGEDB_Plugin
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
(*iterate_matching_deposits)( (*iterate_matching_deposits)(
void *cls, void *cls,
uint64_t wire_target, const struct TALER_PaytoHashP *h_payto,
const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_MerchantPublicKeyP *merchant_pub,
TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb, TALER_EXCHANGEDB_MatchingDepositIterator deposit_cb,
void *deposit_cb_cls, void *deposit_cb_cls,
@ -3399,7 +3397,7 @@ struct TALER_EXCHANGEDB_Plugin
* *
* @param cls closure * @param cls closure
* @param date time of the wire transfer * @param date time of the wire transfer
* @param wtid subject of the wire transfer * @param h_payto identifies the receiver account of the wire transfer
* @param wire_account details about the receiver account of the wire transfer, * @param wire_account details about the receiver account of the wire transfer,
* including 'url' in payto://-format * including 'url' in payto://-format
* @param amount amount that was transmitted * @param amount amount that was transmitted
@ -3412,7 +3410,7 @@ struct TALER_EXCHANGEDB_Plugin
void *cls, void *cls,
struct GNUNET_TIME_Timestamp date, struct GNUNET_TIME_Timestamp date,
const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_WireTransferIdentifierRawP *wtid,
uint64_t wire_target, const struct TALER_PaytoHashP *h_payto,
const char *exchange_account_section, const char *exchange_account_section,
const struct TALER_Amount *amount); const struct TALER_Amount *amount);

View File

@ -141,7 +141,7 @@ handle_kyc_proof_finished (void *cls,
struct TALER_EXCHANGE_KycProofHandle * struct TALER_EXCHANGE_KycProofHandle *
TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange, TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange,
uint64_t payment_target, const struct TALER_PaytoHashP *h_payto,
const char *code, const char *code,
const char *state, const char *state,
TALER_EXCHANGE_KycProofCallback cb, TALER_EXCHANGE_KycProofCallback cb,
@ -158,11 +158,21 @@ TALER_EXCHANGE_kyc_proof (struct TALER_EXCHANGE_Handle *exchange,
return NULL; return NULL;
} }
/* TODO: any escaping of code/state needed??? */ /* TODO: any escaping of code/state needed??? */
{
char hstr[sizeof (struct TALER_PaytoHashP) * 2];
char *end;
end = GNUNET_STRINGS_data_to_string (h_payto,
sizeof (*h_payto),
hstr,
sizeof (hstr));
*end = '\0';
GNUNET_asprintf (&arg_str, GNUNET_asprintf (&arg_str,
"/kyc-proof/%llu?code=%s&state=%s", "/kyc-proof/%s?code=%s&state=%s",
(unsigned long long) payment_target, hstr,
code, code,
state); state);
}
kph = GNUNET_new (struct TALER_EXCHANGE_KycProofHandle); kph = GNUNET_new (struct TALER_EXCHANGE_KycProofHandle);
kph->exchange = exchange; kph->exchange = exchange;
kph->cb = cb; kph->cb = cb;

View File

@ -260,7 +260,7 @@ TALER_EXCHANGE_reserves_get (
end = GNUNET_STRINGS_data_to_string ( end = GNUNET_STRINGS_data_to_string (
reserve_pub, reserve_pub,
sizeof (struct TALER_ReservePublicKeyP), sizeof (*reserve_pub),
pub_str, pub_str,
sizeof (pub_str)); sizeof (pub_str));
*end = '\0'; *end = '\0';

View File

@ -131,13 +131,14 @@ proof_kyc_run (void *cls,
{ {
struct KycProofGetState *kps = cls; struct KycProofGetState *kps = cls;
const struct TALER_TESTING_Command *res_cmd; const struct TALER_TESTING_Command *res_cmd;
const uint64_t *payment_target; const char **payto_uri;
struct TALER_PaytoHashP h_payto;
(void) cmd; (void) cmd;
kps->is = is; kps->is = is;
res_cmd = TALER_TESTING_interpreter_lookup_command (kps->is, res_cmd = TALER_TESTING_interpreter_lookup_command (
kps-> kps->is,
payment_target_reference); kps->payment_target_reference);
if (NULL == res_cmd) if (NULL == res_cmd)
{ {
GNUNET_break (0); GNUNET_break (0);
@ -145,15 +146,17 @@ proof_kyc_run (void *cls,
return; return;
} }
if (GNUNET_OK != if (GNUNET_OK !=
TALER_TESTING_get_trait_payment_target_uuid (res_cmd, TALER_TESTING_get_trait_payto_uri (res_cmd,
&payment_target)) &payto_uri))
{ {
GNUNET_break (0); GNUNET_break (0);
TALER_TESTING_interpreter_fail (kps->is); TALER_TESTING_interpreter_fail (kps->is);
return; return;
} }
TALER_payto_hash (*payto_uri,
&h_payto);
kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange, kps->kph = TALER_EXCHANGE_kyc_proof (is->exchange,
*payment_target, &h_payto,
kps->code, kps->code,
kps->state, kps->state,
&proof_kyc_cb, &proof_kyc_cb,

View File

@ -228,9 +228,16 @@ void
TALER_payto_hash (const char *payto, TALER_payto_hash (const char *payto,
struct TALER_PaytoHashP *h_payto) struct TALER_PaytoHashP *h_payto)
{ {
struct GNUNET_HashCode sha512;
GNUNET_CRYPTO_hash (payto, GNUNET_CRYPTO_hash (payto,
strlen (payto) + 1, strlen (payto) + 1,
&h_payto->hash); &sha512);
GNUNET_static_assert (sizeof (sha512) > sizeof (*h_payto));
/* truncate */
memcpy (h_payto,
&sha512,
sizeof (*h_payto));
} }