From 4f82885560d5d468ef5230f7ec383c612cc9625c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 7 May 2020 20:22:02 +0200 Subject: towards changing timestamp in deposit confirmation (tests failing) --- src/include/taler_auditordb_plugin.h | 4 ++-- src/include/taler_error_codes.h | 45 +++++++++++++++++++++++++---------- src/include/taler_exchange_service.h | 2 ++ src/include/taler_exchangedb_plugin.h | 18 +++++++++++--- src/include/taler_signatures.h | 7 +++--- src/include/taler_testing_lib.h | 18 +++++++------- 6 files changed, 65 insertions(+), 29 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 9a7f6ed7a..7c58e654e 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -300,9 +300,9 @@ struct TALER_AUDITORDB_DepositConfirmation struct GNUNET_HashCode h_wire; /** - * Time when this confirmation was generated. + * Time when this deposit confirmation was generated by the exchange. */ - struct GNUNET_TIME_Absolute timestamp; + struct GNUNET_TIME_Absolute exchange_timestamp; /** * How much time does the @e merchant have to issue a refund diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index 74660303d..eded23339 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -1542,73 +1542,92 @@ enum TALER_ErrorCode * This response is provided with HTTP status code * #MHD_HTTP_SERVICE_UNAVAILABLE. */ - TALER_EC_TRACK_TRANSFER_EXCHANGE_TIMEOUT = 2400, + TALER_EC_POST_TRANSFERS_EXCHANGE_TIMEOUT = 2400, /** * We failed to obtain an acceptable /keys response from the exchange * for the /track/transfer request. This response is provided with * HTTP status code #MHD_HTTP_FAILED_DEPENDENCY. */ - TALER_EC_TRACK_TRANSFER_EXCHANGE_KEYS_FAILURE = 2401, + TALER_EC_POST_TRANSFERS_EXCHANGE_KEYS_FAILURE = 2401, /** * We failed to persist coin wire transfer information in our merchant * database. The response is provided with HTTP status code * #MHD_HTTP_INTERNAL_SERVER_ERROR. */ - TALER_EC_TRACK_TRANSFER_DB_STORE_COIN_ERROR = 2402, + TALER_EC_POST_TRANSFERS_DB_STORE_COIN_ERROR = 2402, /** * We internally failed to execute the /track/transfer request. The * response is provided with HTTP status code * #MHD_HTTP_INTERNAL_SERVER_ERROR. */ - TALER_EC_TRACK_TRANSFER_REQUEST_ERROR = 2403, + TALER_EC_POST_TRANSFERS_REQUEST_ERROR = 2403, /** * We failed to persist wire transfer information in our merchant * database. The response is provided with HTTP status code * #MHD_HTTP_INTERNAL_SERVER_ERROR. */ - TALER_EC_TRACK_TRANSFER_DB_STORE_TRANSFER_ERROR = 2404, + TALER_EC_POST_TRANSFERS_DB_STORE_TRANSFER_ERROR = 2404, /** * The exchange returned an error from /track/transfer. The response * is provided with HTTP status code #MHD_HTTP_FAILED_DEPENDENCY. */ - TALER_EC_TRACK_TRANSFER_EXCHANGE_ERROR = 2405, + TALER_EC_POST_TRANSFERS_EXCHANGE_ERROR = 2405, /** * We failed to fetch deposit information from our merchant database. * The response is provided with HTTP status code * #MHD_HTTP_INTERNAL_SERVER_ERROR. */ - TALER_EC_TRACK_TRANSFER_DB_FETCH_DEPOSIT_ERROR = 2406, + TALER_EC_POST_TRANSFERS_DB_FETCH_DEPOSIT_ERROR = 2406, /** * We encountered an internal logic error. The response is provided * with HTTP status code #MHD_HTTP_INTERNAL_SERVER_ERROR. */ - TALER_EC_TRACK_TRANSFER_DB_INTERNAL_LOGIC_ERROR = 2407, + TALER_EC_POST_TRANSFERS_DB_INTERNAL_LOGIC_ERROR = 2407, /** * The exchange gave conflicting information about a coin which has * been wire transferred. The response is provided with HTTP status * code #MHD_HTTP_FAILED_DEPENDENCY. */ - TALER_EC_TRACK_TRANSFER_CONFLICTING_REPORTS = 2408, + TALER_EC_POST_TRANSFERS_CONFLICTING_REPORTS = 2408, /** * The merchant backend had problems in creating the JSON response. */ - TALER_EC_TRACK_TRANSFER_JSON_RESPONSE_ERROR = 2409, + TALER_EC_POST_TRANSFERS_JSON_RESPONSE_ERROR = 2409, /** * The exchange charged a different wire fee than what it originally - * advertised, and it is higher. The response is provied with an HTTP - * status of #MHD_HTTP_FAILED_DEPENDENCY. + * advertised, and it is higher. The response is provided with an + * HTTP status of #MHD_HTTP_FAILED_DEPENDENCY. */ - TALER_EC_TRACK_TRANSFER_JSON_BAD_WIRE_FEE = 2410, + TALER_EC_POST_TRANSFERS_JSON_BAD_WIRE_FEE = 2410, + + /** + * We did not find the account that the transfer was made to. The + * response is provided with an HTTP status of #MHD_HTTP_NOT_FOUND. + */ + TALER_EC_POST_TRANSFERS_ACCOUNT_NOT_FOUND = 2411, + + /** + * We did failed to store information in our database. The response is + * provided with an HTTP status of #MHD_HTTP_INTERNAL_SERVER_ERROR. + */ + TALER_EC_POST_TRANSFERS_DB_STORE_ERROR = 2412, + + /** + * We did failed to retrieve information from our database. The + * response is provided with an HTTP status of + * #MHD_HTTP_INTERNAL_SERVER_ERROR. + */ + TALER_EC_POST_TRANSFERS_DB_LOOKUP_ERROR = 2413, /** * The merchant backend cannot create an instance under the given diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 82b9b83df..38928dc18 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -756,6 +756,7 @@ struct TALER_EXCHANGE_DepositHandle; * * @param cls closure * @param hr HTTP response data + * @param deposit_timestamp time when the exchange generated the deposit confirmation * @param exchange_sig signature provided by the exchange * @param exchange_pub exchange key used to sign @a obj, or NULL */ @@ -763,6 +764,7 @@ typedef void (*TALER_EXCHANGE_DepositResultCallback) ( void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, + struct GNUNET_TIME_Absolute deposit_timestamp, const struct TALER_ExchangeSignatureP *exchange_sig, const struct TALER_ExchangePublicKeyP *exchange_pub); diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 4fd580724..9fb932362 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -975,6 +975,8 @@ struct TALER_EXCHANGEDB_Session; * @param cls closure * @param rowid unique ID for the deposit in our DB, used for marking * it as 'tiny' or 'done' + * @param exchange_timestamp when did the exchange receive the deposit + * @param wallet_timestamp when did the wallet sign the contract * @param merchant_pub public key of the merchant * @param coin_pub public key of the coin * @param amount_with_fee amount that was deposited including fee @@ -990,6 +992,8 @@ typedef enum GNUNET_DB_QueryStatus (*TALER_EXCHANGEDB_DepositIterator)( void *cls, uint64_t rowid, + struct GNUNET_TIME_Absolute exchange_timestamp, + struct GNUNET_TIME_Absolute wallet_timestamp, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_Amount *amount_with_fee, @@ -1022,7 +1026,8 @@ typedef void * * @param cls closure * @param rowid unique serial ID for the deposit in our DB - * @param timestamp when did the deposit happen + * @param exchange_timestamp when did the deposit happen + * @param wallet_timestamp when did the contract happen * @param merchant_pub public key of the merchant * @param denom_pub denomination public key of @a coin_pub * @param coin_pub public key of the coin @@ -1042,7 +1047,8 @@ typedef int (*TALER_EXCHANGEDB_DepositCallback)( void *cls, uint64_t rowid, - struct GNUNET_TIME_Absolute timestamp, + struct GNUNET_TIME_Absolute exchange_timestamp, + struct GNUNET_TIME_Absolute wallet_timestamp, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct TALER_DenominationPublicKey *denom_pub, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -1841,6 +1847,8 @@ struct TALER_EXCHANGEDB_Plugin * @param session database connection * @param deposit deposit to search for * @param check_extras whether to check extra fields or not + * @param[out] deposit_fee set to the deposit fee the exchange charged + * @param[out] exchange_timestamp set to the time when the exchange received the deposit * @return 1 if we know this operation, * 0 if this exact deposit is unknown to us, * otherwise transaction error status @@ -1849,7 +1857,9 @@ struct TALER_EXCHANGEDB_Plugin (*have_deposit)(void *cls, struct TALER_EXCHANGEDB_Session *session, const struct TALER_EXCHANGEDB_Deposit *deposit, - int check_extras); + int check_extras, + struct TALER_Amount *deposit_fee, + struct GNUNET_TIME_Absolute *exchange_timestamp); /** @@ -1857,12 +1867,14 @@ struct TALER_EXCHANGEDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to the database + * @param exchange_timestamp time the exchange received the deposit request * @param deposit deposit information to store * @return query result status */ enum GNUNET_DB_QueryStatus (*insert_deposit)(void *cls, struct TALER_EXCHANGEDB_Session *session, + struct GNUNET_TIME_Absolute exchange_timestamp, const struct TALER_EXCHANGEDB_Deposit *deposit); diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index c346a6cee..38b895d7f 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -363,7 +363,7 @@ struct TALER_DepositRequestPS * deposit request in a timely fashion (so back-dating is not * prevented). */ - struct GNUNET_TIME_AbsoluteNBO timestamp; + struct GNUNET_TIME_AbsoluteNBO wallet_timestamp; /** * How much time does the merchant have to issue a refund request? @@ -429,9 +429,10 @@ struct TALER_DepositConfirmationPS struct GNUNET_HashCode h_wire GNUNET_PACKED; /** - * Time when this confirmation was generated. + * Time when this confirmation was generated / when the exchange received + * the deposit request. */ - struct GNUNET_TIME_AbsoluteNBO timestamp; + struct GNUNET_TIME_AbsoluteNBO exchange_timestamp; /** * How much time does the @e merchant have to issue a refund diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 9abb0cca7..53a004c8c 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -1917,6 +1917,7 @@ TALER_TESTING_cmd_connect_with_state (const char *label, * @param dbc collects plugin and session handles * @param merchant_name Human-readable name of the merchant. * @param merchant_account merchant's account name (NOT a payto:// URI) + * @param exchange_timestamp when did the exchange receive the deposit * @param wire_deadline point in time where the aggregator should have * wired money to the merchant. * @param amount_with_fee amount to deposit (inclusive of deposit fee) @@ -1924,14 +1925,15 @@ TALER_TESTING_cmd_connect_with_state (const char *label, * @return the command. */ struct TALER_TESTING_Command -TALER_TESTING_cmd_insert_deposit (const char *label, - const struct - TALER_TESTING_DatabaseConnection *dbc, - const char *merchant_name, - const char *merchant_account, - struct GNUNET_TIME_Relative wire_deadline, - const char *amount_with_fee, - const char *deposit_fee); +TALER_TESTING_cmd_insert_deposit ( + const char *label, + const struct TALER_TESTING_DatabaseConnection *dbc, + const char *merchant_name, + const char *merchant_account, + struct GNUNET_TIME_Absolute exchange_timestamp, + struct GNUNET_TIME_Relative wire_deadline, + const char *amount_with_fee, + const char *deposit_fee); /** -- cgit v1.2.3