diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-11-01 05:29:30 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-11-05 10:37:37 +0100 |
commit | 869ee4b4859c80d1f789a4da77d7b517e462f210 (patch) | |
tree | 52fd5400b67dc5d0e05018dacab32ac8cbca4077 | |
parent | 41b32f3fbc12149ad2754bcd896a128a26b614b3 (diff) |
working through auditors
-rw-r--r-- | src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c | 4 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-aggregation.c | 22 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-purses.c | 6 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-reserves.c | 57 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-transfer.c | 2 | ||||
-rw-r--r-- | src/auditor/taler-helper-auditor-wire-credit.c | 25 | ||||
-rw-r--r-- | src/include/taler_auditordb_plugin.h | 6 | ||||
-rw-r--r-- | src/include/taler_util.h | 14 | ||||
-rw-r--r-- | src/util/payto.c | 16 |
9 files changed, 91 insertions, 61 deletions
diff --git a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c index c7cddceb2..be0acf477 100644 --- a/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c +++ b/src/auditor/taler-auditor-httpd_wire-out-inconsistency-get.c @@ -43,8 +43,8 @@ process_wire_out_inconsistency ( obj = GNUNET_JSON_PACK ( GNUNET_JSON_pack_int64 ("row_id", dc->row_id), - GNUNET_JSON_pack_string ("destination_account", - dc->destination_account), + TALER_JSON_pack_full_payto ("destination_account", + dc->destination_account), GNUNET_JSON_pack_int64 ("wire_out_row_id", dc->wire_out_row_id), GNUNET_JSON_pack_string ("diagnostic", diff --git a/src/auditor/taler-helper-auditor-aggregation.c b/src/auditor/taler-helper-auditor-aggregation.c index 3066d85a7..f88665b9a 100644 --- a/src/auditor/taler-helper-auditor-aggregation.c +++ b/src/auditor/taler-helper-auditor-aggregation.c @@ -362,7 +362,7 @@ struct WireCheckContext /** * Target account details of the receiver. */ - const char *payto_uri; + struct TALER_FullPayto payto_uri; /** * Execution time of the wire transfer. @@ -778,8 +778,8 @@ wire_transfer_information_cb ( void *cls, uint64_t rowid, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *account_pay_uri, - const struct TALER_PaytoHashP *h_payto, + const struct TALER_FullPayto account_pay_uri, + const struct TALER_FullPaytoHashP *h_payto, struct GNUNET_TIME_Timestamp exec_time, const struct TALER_PrivateContractHashP *h_contract_terms, const struct TALER_DenominationPublicKey *denom_pub, @@ -794,13 +794,13 @@ wire_transfer_information_cb ( struct TALER_EXCHANGEDB_TransactionList *tl; struct TALER_CoinPublicInfo coin; enum GNUNET_DB_QueryStatus qs; - struct TALER_PaytoHashP hpt; + struct TALER_FullPaytoHashP hpt; uint64_t etag_out; if (0 > wcc->qs) return; - TALER_payto_hash (account_pay_uri, - &hpt); + TALER_full_payto_hash (account_pay_uri, + &hpt); if (0 != GNUNET_memcmp (&hpt, h_payto)) @@ -998,8 +998,8 @@ wire_transfer_information_cb ( } } /* Check other details of wire transfer match */ - if (0 != strcmp (account_pay_uri, - wcc->payto_uri)) + if (0 != TALER_full_payto_cmp (account_pay_uri, + wcc->payto_uri)) { qs = report_row_inconsistency ("aggregation", rowid, @@ -1189,7 +1189,7 @@ check_wire_out_cb (void *cls, uint64_t rowid, struct GNUNET_TIME_Timestamp date, const struct TALER_WireTransferIdentifierRawP *wtid, - const char *payto_uri, + const struct TALER_FullPayto payto_uri, const struct TALER_Amount *amount) { struct AggregationContext *ac = cls; @@ -1209,7 +1209,7 @@ check_wire_out_cb (void *cls, TALER_B2S (wtid), TALER_amount2s (amount), GNUNET_TIME_timestamp2s (date)); - if (NULL == (method = TALER_payto_get_method (payto_uri))) + if (NULL == (method = TALER_payto_get_method (payto_uri.full_payto))) { qs = report_row_inconsistency ("wire_out", rowid, @@ -1341,7 +1341,7 @@ check_wire_out_cb (void *cls, { struct TALER_AUDITORDB_WireOutInconsistency woi = { - .destination_account = (char *) payto_uri, + .destination_account = payto_uri, .diagnostic = "aggregated amount does not match expectations", .wire_out_row_id = rowid, .expected = final_amount, diff --git a/src/auditor/taler-helper-auditor-purses.c b/src/auditor/taler-helper-auditor-purses.c index 854cb8064..2ad99aacf 100644 --- a/src/auditor/taler-helper-auditor-purses.c +++ b/src/auditor/taler-helper-auditor-purses.c @@ -722,7 +722,7 @@ handle_purse_merged ( TALER_ARL_USE_PP (purse_merges_serial_id) = rowid + 1; { - char *reserve_url; + struct TALER_NormalizedPayto reserve_url; reserve_url = TALER_reserve_make_payto (NULL == partner_base_url @@ -743,7 +743,7 @@ handle_purse_merged ( .operation_specific_pub = merge_pub->eddsa_pub }; - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); qs = TALER_ARL_adb->insert_bad_sig_losses ( TALER_ARL_adb->cls, &bsl); @@ -758,7 +758,7 @@ handle_purse_merged ( amount); return GNUNET_OK; } - GNUNET_free (reserve_url); + GNUNET_free (reserve_url.normalized_payto); } ps = setup_purse (pc, diff --git a/src/auditor/taler-helper-auditor-reserves.c b/src/auditor/taler-helper-auditor-reserves.c index 3c8891d97..c51c63416 100644 --- a/src/auditor/taler-helper-auditor-reserves.c +++ b/src/auditor/taler-helper-auditor-reserves.c @@ -279,7 +279,7 @@ struct ReserveSummary /** * Which account did originally put money into the reserve? */ - char *sender_account; + struct TALER_FullPayto sender_account; /** * Did we have a previous reserve info? Used to decide between @@ -468,7 +468,7 @@ handle_reserve_in ( uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const char *sender_account_details, + const struct TALER_FullPayto sender_account_details, uint64_t wire_reference, struct GNUNET_TIME_Timestamp execution_date) { @@ -487,8 +487,9 @@ handle_reserve_in ( GNUNET_break (0); return GNUNET_SYSERR; } - if (NULL == rs->sender_account) - rs->sender_account = GNUNET_strdup (sender_account_details); + if (NULL == rs->sender_account.full_payto) + rs->sender_account.full_payto + = GNUNET_strdup (sender_account_details.full_payto); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Additional incoming wire transfer for reserve `%s' of %s\n", TALER_B2S (reserve_pub), @@ -853,7 +854,7 @@ handle_recoup_by_reserve ( * @return #GNUNET_OK on success */ static enum GNUNET_GenericReturnValue -get_closing_fee (const char *receiver_account, +get_closing_fee (const struct TALER_FullPayto receiver_account, struct GNUNET_TIME_Timestamp atime, struct TALER_Amount *fee) { @@ -863,7 +864,7 @@ get_closing_fee (const char *receiver_account, struct TALER_WireFeeSet fees; char *method; - method = TALER_payto_get_method (receiver_account); + method = TALER_payto_get_method (receiver_account.full_payto); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Method is `%s'\n", method); @@ -1007,7 +1008,7 @@ handle_reserve_closed ( const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, - const char *receiver_account, + const struct TALER_FullPayto receiver_account, const struct TALER_WireTransferIdentifierRawP *transfer_details, uint64_t close_request_row) { @@ -1066,7 +1067,7 @@ handle_reserve_closed ( struct GNUNET_TIME_Timestamp request_timestamp; struct TALER_Amount close_balance; struct TALER_Amount close_fee; - char *payto_uri; + struct TALER_FullPayto payto_uri; enum GNUNET_DB_QueryStatus qs; qs = TALER_ARL_edb->select_reserve_close_request_info ( @@ -1088,10 +1089,10 @@ handle_reserve_closed ( } else { - struct TALER_PaytoHashP h_payto; + struct TALER_FullPaytoHashP h_payto; - TALER_payto_hash (payto_uri, - &h_payto); + TALER_full_payto_hash (payto_uri, + &h_payto); if (GNUNET_OK != TALER_wallet_reserve_close_verify ( request_timestamp, @@ -1114,7 +1115,7 @@ handle_reserve_closed ( { GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); rc->qs = qs; - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); return GNUNET_SYSERR; } TALER_ARL_amount_add (&TALER_ARL_USE_AB (reserves_total_bad_sig_loss), @@ -1122,8 +1123,8 @@ handle_reserve_closed ( amount_with_fee); } } - if ( (NULL == payto_uri) && - (NULL == rs->sender_account) ) + if ( (NULL == payto_uri.full_payto) && + (NULL == rs->sender_account.full_payto) ) { GNUNET_break (! rs->had_ri); report_row_inconsistency ("reserves_close", @@ -1132,11 +1133,11 @@ handle_reserve_closed ( if (global_qs < 0) return GNUNET_SYSERR; } - if (NULL == payto_uri) + if (NULL == payto_uri.full_payto) { - if ((NULL == rs->sender_account) || - (0 != strcmp (rs->sender_account, - receiver_account))) + if ((NULL == rs->sender_account.full_payto) || + (0 != TALER_full_payto_cmp (rs->sender_account, + receiver_account))) { report_row_inconsistency ("reserves_close", rowid, @@ -1147,24 +1148,24 @@ handle_reserve_closed ( } else { - if (0 != strcmp (payto_uri, - receiver_account)) + if (0 != TALER_full_payto_cmp (payto_uri, + receiver_account)) { report_row_inconsistency ("reserves_close", rowid, "target account does not match origin account"); if (global_qs < 0) { - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); return GNUNET_SYSERR; } } } - GNUNET_free (payto_uri); + GNUNET_free (payto_uri.full_payto); } else { - if (NULL == rs->sender_account) + if (NULL == rs->sender_account.full_payto) { GNUNET_break (! rs->had_ri); report_row_inconsistency ("reserves_close", @@ -1173,8 +1174,8 @@ handle_reserve_closed ( if (global_qs < 0) return GNUNET_SYSERR; } - else if (0 != strcmp (rs->sender_account, - receiver_account)) + else if (0 != TALER_full_payto_cmp (rs->sender_account, + receiver_account)) { report_row_inconsistency ("reserves_close", rowid, @@ -1527,7 +1528,7 @@ verify_reserve_balance (void *cls, /* Reserve is expired */ struct TALER_Amount cfee; - if ( (NULL != rs->sender_account) && + if ( (NULL != rs->sender_account.full_payto) && (GNUNET_OK == get_closing_fee (rs->sender_account, rs->a_expiration_date, @@ -1541,7 +1542,7 @@ verify_reserve_balance (void *cls, .reserve_pub = rs->reserve_pub, .expiration_time = rs->a_expiration_date.abs_time, .balance = nbalance, - .diagnostic = rs->sender_account + .diagnostic = rs->sender_account.full_payto }; /* remaining balance (according to us) exceeds closing fee */ @@ -1705,7 +1706,7 @@ verify_reserve_balance (void *cls, GNUNET_CONTAINER_multihashmap_remove (rc->reserves, key, rs)); - GNUNET_free (rs->sender_account); + GNUNET_free (rs->sender_account.full_payto); GNUNET_free (rs); return ret; } diff --git a/src/auditor/taler-helper-auditor-transfer.c b/src/auditor/taler-helper-auditor-transfer.c index 3ebc04a4e..e2ab47ffa 100644 --- a/src/auditor/taler-helper-auditor-transfer.c +++ b/src/auditor/taler-helper-auditor-transfer.c @@ -121,7 +121,7 @@ import_wire_missing_cb ( void *cls, uint64_t batch_deposit_serial_id, const struct TALER_Amount *total_amount, - const struct TALER_PaytoHashP *wire_target_h_payto, + const struct TALER_FullPaytoHashP *wire_target_h_payto, struct GNUNET_TIME_Timestamp deadline) { struct ImportMissingWireContext *wc = cls; diff --git a/src/auditor/taler-helper-auditor-wire-credit.c b/src/auditor/taler-helper-auditor-wire-credit.c index c37636e42..f2a3c9571 100644 --- a/src/auditor/taler-helper-auditor-wire-credit.c +++ b/src/auditor/taler-helper-auditor-wire-credit.c @@ -445,16 +445,14 @@ reserve_in_cb (void *cls, uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const char *sender_account_details, + const struct TALER_FullPayto sender_account_details, uint64_t wire_reference, struct GNUNET_TIME_Timestamp execution_date) { struct WireAccount *wa = cls; struct ReserveInInfo *rii; size_t slen; - char *snp; - snp = TALER_payto_normalize (sender_account_details); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Analyzing exchange wire IN (%llu) at %s of %s with reserve_pub %s\n", (unsigned long long) rowid, @@ -464,18 +462,17 @@ reserve_in_cb (void *cls, TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_wire_in), &TALER_ARL_USE_AB (total_wire_in), credit); - slen = strlen (snp) + 1; + slen = strlen (sender_account_details.full_payto) + 1; rii = GNUNET_malloc (sizeof (struct ReserveInInfo) + slen); rii->rowid = rowid; rii->credit_details.type = TALER_BANK_CT_RESERVE; rii->credit_details.amount = *credit; rii->credit_details.execution_date = execution_date; rii->credit_details.details.reserve.reserve_pub = *reserve_pub; - rii->credit_details.debit_account_uri = (const char *) &rii[1]; + rii->credit_details.debit_account_uri.full_payto = (const char *) &rii[1]; GNUNET_memcpy (&rii[1], - snp, + sender_account_details.full_payto, slen); - GNUNET_free (snp); GNUNET_CRYPTO_hash (&wire_reference, sizeof (uint64_t), &rii->row_off_hash); @@ -731,11 +728,13 @@ analyze_credit ( } { - char *np; + struct TALER_NormalizedPayto np; + struct TALER_NormalizedPayto np2; np = TALER_payto_normalize (credit_details->debit_account_uri); - if (0 != strcasecmp (np, - rii->credit_details.debit_account_uri)) + np2 = TALER_payto_normalize (rii->credit_details.debit_account_uri); + if (0 != TALER_normalized_payto_cmp (np, + np2)) { struct TALER_AUDITORDB_MisattributionInInconsistency mii = { .reserve_pub = rii->credit_details.details.reserve.reserve_pub, @@ -753,14 +752,16 @@ analyze_credit ( { global_qs = qs; GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); - GNUNET_free (np); + GNUNET_free (np.normalized_payto); + GNUNET_free (np2.normalized_payto); return false; } TALER_ARL_amount_add (&TALER_ARL_USE_AB (total_misattribution_in), &TALER_ARL_USE_AB (total_misattribution_in), &rii->credit_details.amount); } - GNUNET_free (np); + GNUNET_free (np.normalized_payto); + GNUNET_free (np2.normalized_payto); } if (GNUNET_TIME_timestamp_cmp (credit_details->execution_date, !=, diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index dab35acbf..01ada58e4 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -768,7 +768,7 @@ struct TALER_AUDITORDB_WireFormatInconsistency struct TALER_AUDITORDB_WireOutInconsistency { uint64_t row_id; - char *destination_account; + struct TALER_FullPayto destination_account; char *diagnostic; uint64_t wire_out_row_id; struct TALER_Amount expected; @@ -1781,7 +1781,7 @@ struct TALER_AUDITORDB_Plugin const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp expiration_date, - const char *origin_account); + const struct TALER_FullPayto origin_account); /** @@ -1820,7 +1820,7 @@ struct TALER_AUDITORDB_Plugin uint64_t *rowid, struct TALER_AUDITORDB_ReserveFeeBalance *rfb, struct GNUNET_TIME_Timestamp *expiration_date, - char **sender_account); + struct TALER_FullPayto *sender_account); /** diff --git a/src/include/taler_util.h b/src/include/taler_util.h index c484e8294..a9d9d204a 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -382,7 +382,7 @@ TALER_url_valid_charset (const char *url); /** - * Compare two payto URIs for equality. + * Compare two full payto URIs for equality. * * @param a a full payto URI, NULL is permitted * @param b a full payto URI, NULL is permitted @@ -394,6 +394,18 @@ TALER_full_payto_cmp (const struct TALER_FullPayto a, /** + * Compare two normalized payto URIs for equality. + * + * @param a a full payto URI, NULL is permitted + * @param b a full payto URI, NULL is permitted + * @return 0 if both are equal, otherwise -1 or 1 + */ +int +TALER_normalized_payto_cmp (const struct TALER_NormalizedPayto a, + const struct TALER_NormalizedPayto b); + + +/** * Test if the URL is a valid "http" (or "https") * URL (includes test for #TALER_url_valid_charset()). * diff --git a/src/util/payto.c b/src/util/payto.c index 1190d7e23..df65ade3c 100644 --- a/src/util/payto.c +++ b/src/util/payto.c @@ -44,6 +44,22 @@ TALER_full_payto_cmp (const struct TALER_FullPayto a, } +int +TALER_normalized_payto_cmp (const struct TALER_NormalizedPayto a, + const struct TALER_NormalizedPayto b) +{ + if ( (NULL == a.normalized_payto) && + (NULL == b.normalized_payto) ) + return 0; + if (NULL == a.normalized_payto) + return -1; + if (NULL == b.normalized_payto) + return 1; + return strcmp (a.normalized_payto, + b.normalized_payto); +} + + void TALER_full_payto_normalize_and_hash (const struct TALER_FullPayto in, struct TALER_NormalizedPaytoHashP *out) |