diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_auditordb_plugin.h | 6 | ||||
-rw-r--r-- | src/include/taler_bank_service.h | 29 | ||||
-rw-r--r-- | src/include/taler_crypto_lib.h | 49 | ||||
-rw-r--r-- | src/include/taler_error_codes.h | 22 | ||||
-rw-r--r-- | src/include/taler_exchange_service.h | 68 | ||||
-rw-r--r-- | src/include/taler_exchangedb_lib.h | 68 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 51 | ||||
-rw-r--r-- | src/include/taler_json_lib.h | 59 | ||||
-rw-r--r-- | src/include/taler_signatures.h | 27 | ||||
-rw-r--r-- | src/include/taler_testing_lib.h | 38 | ||||
-rw-r--r-- | src/include/taler_wire_lib.h | 36 | ||||
-rw-r--r-- | src/include/taler_wire_plugin.h | 75 |
12 files changed, 362 insertions, 166 deletions
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index 80974cca0..cc583e8e7 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -382,6 +382,7 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange + * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing * @param in_wire_off how far are we in the incoming wire transaction history * @param out_wire_off how far are we in the outgoing wire transaction history @@ -392,6 +393,7 @@ struct TALER_AUDITORDB_Plugin (*insert_wire_auditor_progress)(void *cls, struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, + const char *account_name, const struct TALER_AUDITORDB_WireProgressPoint *pp, const void *in_wire_off, const void *out_wire_off, @@ -405,6 +407,7 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange + * @param account_name name of the wire account we are auditing * @param pp where is the auditor in processing * @param in_wire_off how far are we in the incoming wire transaction history * @param out_wire_off how far are we in the outgoing wire transaction history @@ -415,6 +418,7 @@ struct TALER_AUDITORDB_Plugin (*update_wire_auditor_progress)(void *cls, struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, + const char *account_name, const struct TALER_AUDITORDB_WireProgressPoint *pp, const void *in_wire_off, const void *out_wire_off, @@ -428,6 +432,7 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param session connection to use * @param master_pub master key of the exchange + * @param account_name name of the wire account we are auditing * @param[out] pp set to where the auditor is in processing * @param[out] in_wire_off how far are we in the incoming wire transaction history * @param[out] out_wire_off how far are we in the outgoing wire transaction history @@ -438,6 +443,7 @@ struct TALER_AUDITORDB_Plugin (*get_wire_auditor_progress)(void *cls, struct TALER_AUDITORDB_Session *session, const struct TALER_MasterPublicKeyP *master_pub, + const char *account_name, struct TALER_AUDITORDB_WireProgressPoint *pp, void **in_wire_off, void **out_wire_off, diff --git a/src/include/taler_bank_service.h b/src/include/taler_bank_service.h index bfa050336..1cad5710a 100644 --- a/src/include/taler_bank_service.h +++ b/src/include/taler_bank_service.h @@ -217,9 +217,9 @@ struct TALER_BANK_TransferDetails char *wire_transfer_subject; /** - * The other account that was involved + * payto://-URL of the other account that was involved */ - json_t *account_details; + char *account_url; }; @@ -347,4 +347,29 @@ void TALER_BANK_reject_cancel (struct TALER_BANK_RejectHandle *rh); +/** + * Convenience method for parsing configuration section with bank + * authentication data. The section must contain an option + * "METHOD", plus other options that depend on the METHOD specified. + * + * @param cfg configuration to parse + * @param section the section with the configuration data + * @param auth[out] set to the configuration data found + * @return #GNUNET_OK on success + */ +int +TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, + const char *section, + struct TALER_BANK_AuthenticationData *auth); + + +/** + * Free memory inside of @a auth (but not auth itself). + * Dual to #TALER_BANK_auth_parse_cfg(). + * + * @param auth authentication data to free + */ +void +TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth); + #endif /* _TALER_BANK_SERVICE_H */ diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index d45e7bb28..b22c55ce3 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016, 2017 Taler Systems SA + Copyright (C) 2014-2018 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -730,4 +730,51 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc, const struct TALER_Amount *amount_with_fee); +/* **************** /wire account offline signing **************** */ + + +/** + * Compute the hash of the given wire details. The resulting + * hash is what is put into the contract. + * + * @param payto_url bank account + * @param salt salt used to eliminate brute-force inversion + * @param hc[out] set to the hash + */ +void +TALER_wire_signature_hash (const char *payto_url, + const char *salt, + struct GNUNET_HashCode *hc); + +/** + * Check the signature in @a wire_s. + * + * @param payto_url URL that is signed + * @param salt the salt used to salt the @a payto_url when hashing + * @param master_pub master public key of the exchange + * @param master_sig signature of the exchange + * @return #GNUNET_OK if signature is valid + */ +int +TALER_wire_signature_check (const char *payto_url, + const char *salt, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_MasterSignatureP *master_sig); + + +/** + * Create a signed wire statement for the given account. + * + * @param payto_url account specification + * @param salt the salt used to salt the @a payto_url when hashing + * @param master_priv private key to sign with + * @param master_sig[out] where to write the signature + */ +void +TALER_wire_signature_make (const char *payto_url, + const char *salt, + const struct TALER_MasterPrivateKeyP *master_priv, + struct TALER_MasterSignatureP *master_sig); + + #endif diff --git a/src/include/taler_error_codes.h b/src/include/taler_error_codes.h index 1a20889d8..dbde04df1 100644 --- a/src/include/taler_error_codes.h +++ b/src/include/taler_error_codes.h @@ -165,7 +165,15 @@ enum TALER_ErrorCode */ TALER_EC_INTERNAL_LOGIC_ERROR = 1011, + /** + * The method specified in a payto:// URL is not one we expected. + */ + TALER_EC_PAYTO_WRONG_METHOD = 1012, + /** + * The PAYTO URL is malformed. + */ + TALER_EC_PAYTO_MALFORMED = 1013, /* ********** request-specific error codes ************* */ @@ -1535,6 +1543,20 @@ enum TALER_ErrorCode */ TALER_EC_TEST_RSA_SIGN_ERROR = 4005, + + /** + * The JSON in the server's response was malformed. This response + * is provided with HTTP status code of 0. + */ + TALER_EC_SERVER_JSON_INVALID = 5000, + + /** + * A signature in the server's response was malformed. This response + * is provided with HTTP status code of 0. + */ + TALER_EC_SERVER_SIGNATURE_INVALID = 5001, + + /* *************** Taler BANK/FAKEBANK error codes *************** */ /** diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 30ea4ce66..22ca049eb 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -472,40 +472,32 @@ struct TALER_EXCHANGE_WireAggregateFees /** - * Function called with information about the wire fees - * for each wire method. - * - * @param cls closure - * @param wire_method name of the wire method (i.e. "sepa") - * @param fees fee structure for this method + * Information about a wire account of the exchange. */ -typedef void -(*TALER_EXCHANGE_WireFeeCallback)(void *cls, - const char *wire_method, - const struct TALER_EXCHANGE_WireAggregateFees *fees); +struct TALER_EXCHANGE_WireAccount +{ + /** + * payto://-URL of the exchange. + */ + const char *url; + /** + * Salt used to generate @e master_sig. + */ + const char *salt; -/** - * Obtain information about wire fees encoded in @a obj - * by wire method. - * - * @param master_pub public key to use to verify signatures, NULL to not verify - * @param obj wire information as encoded in the #TALER_EXCHANGE_WireResultCallback - * @param cb callback to invoke for the fees - * @param cb_cls closure for @a cb - * @return #GNUNET_OK in success, #GNUNET_SYSERR if @a obj is ill-formed - */ -int -TALER_EXCHANGE_wire_get_fees (const struct TALER_MasterPublicKeyP *master_pub, - const json_t *obj, - TALER_EXCHANGE_WireFeeCallback cb, - void *cb_cls); + /** + * Signature of the exchange over the account (was checked by the API). + */ + struct TALER_MasterSignatureP master_sig; + /** + * Linked list of wire fees the exchange charges for + * accounts of the wire method matching @e url. + */ + const struct TALER_EXCHANGE_WireAggregateFees *fees; -/** - * @brief A Wire format inquiry handle - */ -struct TALER_EXCHANGE_WireHandle; +}; /** @@ -519,15 +511,21 @@ struct TALER_EXCHANGE_WireHandle; * @param http_status HTTP response code, #MHD_HTTP_OK (200) for successful request; * 0 if the exchange's reply is bogus (fails to follow the protocol) * @param ec taler-specific error code, #TALER_EC_NONE on success - * @param obj the received JSON reply, if successful this should be the wire - * format details as provided by /wire, or NULL if the - * reply was not in JSON format. + * @param accounts_len length of the @a accounts array + * @param accounts list of wire accounts of the exchange, NULL on error */ typedef void (*TALER_EXCHANGE_WireResultCallback) (void *cls, unsigned int http_status, enum TALER_ErrorCode ec, - const json_t *obj); + unsigned int accounts_len, + const struct TALER_EXCHANGE_WireAccount *accounts); + + +/** + * @brief A Wire format inquiry handle + */ +struct TALER_EXCHANGE_WireHandle; /** @@ -843,9 +841,9 @@ struct TALER_EXCHANGE_ReserveHistory */ struct { /** - * Sender account information for the incoming transfer. + * Sender account payto://-URL of the incoming transfer. */ - json_t *sender_account_details; + char *sender_url; /** * Information that uniquely identifies the wire transfer. diff --git a/src/include/taler_exchangedb_lib.h b/src/include/taler_exchangedb_lib.h index e4284c27f..b89dd087d 100644 --- a/src/include/taler_exchangedb_lib.h +++ b/src/include/taler_exchangedb_lib.h @@ -406,4 +406,72 @@ TALER_EXCHANGEDB_fees_write (const char *filename, void TALER_EXCHANGEDB_fees_free (struct TALER_EXCHANGEDB_AggregateFees *af); + +/** + * Information about an account from the configuration. + */ +struct TALER_EXCHANGEDB_AccountInfo +{ + /** + * Section in the configuration file that specifies the + * account. Must start with "account-". + */ + const char *section_name; + + /** + * Name of the wire plugin that should be used to access + * the account. + */ + const char *plugin_name; + + /** + * payto://-URL of the account. + */ + const char *payto_url; + + /** + * Filename containing the signed /wire response, or NULL + * if not given. + */ + const char *wire_response_filename; + + /** + * #GNUNET_YES if this account is enabed to be debited + * by the taler-exchange-aggregator. + */ + int debit_enabled; + + /** + * #GNUNET_YES if this account is enabed to be credited by wallets + * and needs to be watched by the taler-exchange-wirewatch. + * Also, the account will only be included in /wire if credit + * is enabled. + */ + int credit_enabled; +}; + + +/** + * Function called with information about a wire account. + * + * @param cls closure + * @param ai account information + */ +typedef void +(*TALER_EXCHANGEDB_AccountCallback)(void *cls, + const struct TALER_EXCHANGEDB_AccountInfo *ai); + +/** + * Parse the configuration to find account information. + * + * @param cfg configuration to use + * @param cb callback to invoke + * @param cb_cls closure for @a cb + */ +void +TALER_EXCHANGEDB_find_accounts (const struct GNUNET_CONFIGURATION_Handle *cfg, + TALER_EXCHANGEDB_AccountCallback cb, + void *cb_cls); + + #endif diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 33677559a..0d6f9cd90 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -21,7 +21,6 @@ */ #ifndef TALER_EXCHANGEDB_PLUGIN_H #define TALER_EXCHANGEDB_PLUGIN_H - #include <jansson.h> #include <gnunet/gnunet_util_lib.h> #include <gnunet/gnunet_db_lib.h> @@ -52,9 +51,10 @@ struct TALER_EXCHANGEDB_BankTransfer struct GNUNET_TIME_Absolute execution_date; /** - * Detailed wire information about the sending account. + * Detailed wire information about the sending account + * in "payto://" format. */ - json_t *sender_account_details; + char *sender_account_details; /** * Data uniquely identifying the wire transfer (wire transfer-type specific) @@ -97,9 +97,10 @@ struct TALER_EXCHANGEDB_ClosingTransfer struct GNUNET_TIME_Absolute execution_date; /** - * Detailed wire information about the receiving account. + * Detailed wire information about the receiving account + * in payto://-format. */ - json_t *receiver_account_details; + char *receiver_account_details; /** * Detailed wire transfer information that uniquely identifies the @@ -361,6 +362,7 @@ struct TALER_EXCHANGEDB_Deposit /** * Detailed information about the receiver for executing the transaction. + * Includes URL in payto://-format and salt. */ json_t *receiver_wire_account; @@ -638,7 +640,8 @@ struct TALER_EXCHANGEDB_Session; * @param h_contract_terms hash of the proposal data known to merchant and customer * @param wire_deadline by which the merchant adviced that he would like the * wire transfer to be executed - * @param receiver_wire_account wire details for the merchant, NULL from iterate_matching_deposits() + * @param receiver_wire_account wire details for the merchant, includes + * 'url' in payto://-format; NULL from iterate_matching_deposits() * @return transaction status code, #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT to continue to iterate */ typedef enum GNUNET_DB_QueryStatus @@ -687,7 +690,8 @@ typedef void * to get a refund * @param wire_deadline by which the merchant adviced that he would like the * wire transfer to be executed - * @param receiver_wire_account wire details for the merchant, NULL from iterate_matching_deposits() + * @param receiver_wire_account wire details for the merchant including 'url' in payto://-format; + * NULL from iterate_matching_deposits() * @param done flag set if the deposit was already executed (or not) * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ @@ -837,7 +841,7 @@ typedef int * @param rowid unique serial ID for the refresh session in our DB * @param reserve_pub public key of the reserve (also the WTID) * @param credit amount that was received - * @param sender_account_details information about the sender's bank account + * @param sender_account_details information about the sender's bank account, in payto://-format * @param wire_reference unique identifier for the wire transfer (plugin-specific format) * @param wire_reference_size number of bytes in @a wire_reference * @param execution_date when did we receive the funds @@ -848,7 +852,7 @@ typedef int uint64_t rowid, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *credit, - const json_t *sender_account_details, + const char *sender_account_details, const void *wire_reference, size_t wire_reference_size, struct GNUNET_TIME_Absolute execution_date); @@ -923,8 +927,8 @@ typedef void * @param cls closure * @param rowid which row in the table is the information from (for diagnostics) * @param merchant_pub public key of the merchant (should be same for all callbacks with the same @e cls) - * @param wire_method which wire plugin was used for the transfer? * @param h_wire hash of wire transfer details of the merchant (should be same for all callbacks with the same @e cls) + * @param account_details which account did the transfer go to? * @param exec_time execution time of the wire transfer (should be same for all callbacks with the same @e cls) * @param h_contract_terms which proposal was this payment about * @param coin_pub which public key was this payment about @@ -935,8 +939,8 @@ typedef void (*TALER_EXCHANGEDB_WireTransferDataCallback)(void *cls, uint64_t rowid, const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *wire_method, const struct GNUNET_HashCode *h_wire, + const json_t *account_details, struct GNUNET_TIME_Absolute exec_time, const struct GNUNET_HashCode *h_contract_terms, const struct TALER_CoinSpendPublicKeyP *coin_pub, @@ -952,7 +956,7 @@ typedef void * @param rowid identifier of the respective row in the database * @param date timestamp of the wire transfer (roughly) * @param wtid wire transfer subject - * @param wire wire transfer details of the receiver + * @param wire wire transfer details of the receiver, including "url" in payto://-format * @param amount amount that was wired * @return #GNUNET_OK to continue, #GNUNET_SYSERR to stop iteration */ @@ -1019,7 +1023,7 @@ typedef int * @param amount_with_fee how much did we debit the reserve * @param closing_fee how much did we charge for closing the reserve * @param reserve_pub public key of the reserve - * @param receiver_account where did we send the funds + * @param receiver_account where did we send the funds, in payto://-format * @param wtid identifier used for the wire transfer * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ @@ -1030,7 +1034,7 @@ typedef int const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, - const json_t *receiver_account, + const char *receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid); @@ -1040,7 +1044,7 @@ typedef int * @param cls closure * @param reserve_pub public key of the reserve * @param left amount left in the reserve - * @param account_details information about the reserve's bank account + * @param account_details information about the reserve's bank account, in payto://-format * @param expiration_date when did the reserve expire * @return transaction status code to pass on */ @@ -1048,7 +1052,7 @@ typedef enum GNUNET_DB_QueryStatus (*TALER_EXCHANGEDB_ReserveExpiredCallback)(void *cls, const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *left, - const json_t *account_details, + const char *account_details, struct GNUNET_TIME_Absolute expiration_date); @@ -1082,7 +1086,7 @@ typedef void * @param rowid deposit table row of the coin's deposit * @param coin_pub public key of the coin * @param amount value of the deposit, including fee - * @param wire where should the funds be wired + * @param wire where should the funds be wired, including 'url' in payto://-format * @param deadline what was the requested wire transfer deadline * @param tiny did the exchange defer this transfer because it is too small? * @param done did the exchange claim that it made a transfer? @@ -1259,7 +1263,7 @@ struct TALER_EXCHANGEDB_Plugin * @param reserve_pub public key of the reserve * @param balance the amount that has to be added to the reserve * @param execution_time when was the amount added - * @param sender_account_details information about the sender's bank account + * @param sender_account_details information about the sender's bank account, in payto://-format * @param wire_reference unique reference identifying the wire transfer (binary blob) * @param wire_reference_size number of bytes in @a wire_reference * @return transaction status code @@ -1270,7 +1274,8 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *balance, struct GNUNET_TIME_Absolute execution_time, - const json_t *sender_account_details, + const char *sender_account_details, + const char *exchange_account_name, const void *wire_reference, size_t wire_reference_size); @@ -1287,6 +1292,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*get_latest_reserve_in_reference)(void *cls, struct TALER_EXCHANGEDB_Session *db, + const char *exchange_account_name, void **wire_reference, size_t *wire_reference_size); @@ -1781,7 +1787,7 @@ struct TALER_EXCHANGEDB_Plugin * @param session database connection * @param reserve_pub which reserve is this about? * @param execution_date when did we perform the transfer? - * @param receiver_account to which account do we transfer? + * @param receiver_account to which account do we transfer, in payto://-format * @param wtid identifier for the wire transfer * @param amount_with_fee amount we charged to the reserve * @param closing_fee how high is the closing fee @@ -1792,7 +1798,7 @@ struct TALER_EXCHANGEDB_Plugin struct TALER_EXCHANGEDB_Session *session, const struct TALER_ReservePublicKeyP *reserve_pub, struct GNUNET_TIME_Absolute execution_date, - const json_t *receiver_account, + const char *receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount_with_fee, const struct TALER_Amount *closing_fee); @@ -1869,7 +1875,8 @@ struct TALER_EXCHANGEDB_Plugin * @param session database connection * @param date time of the wire transfer * @param wtid subject 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 * @param amount amount that was transmitted * @return transaction status code */ diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 6d019ecca..0504ddfb8 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -126,6 +126,65 @@ enum TALER_ErrorCode TALER_JSON_get_error_code (const json_t *json); +/* **************** /wire account offline signing **************** */ + +/** + * Compute the hash of the given wire details. The resulting + * hash is what is put into the contract. + * + * @param wire_s wire details to hash + * @param hc[out] set to the hash + * @return #GNUNET_OK on success, #GNUNET_SYSERR if @a wire_s is malformed + */ +int +TALER_JSON_wire_signature_hash (const json_t *wire_s, + struct GNUNET_HashCode *hc); + +/** + * Check the signature in @a wire_s. + * + * @param wire_s signed wire information of an exchange + * @param master_pub master public key of the exchange + * @return #GNUNET_OK if signature is valid + */ +int +TALER_JSON_wire_signature_check (const json_t *wire_s, + const struct TALER_MasterPublicKeyP *master_pub); + + +/** + * Create a signed wire statement for the given account. + * + * @param payto_url account specification + * @param master_priv private key to sign with, NULL to not sign + */ +json_t * +TALER_JSON_wire_signature_make (const char *payto_url, + const struct TALER_MasterPrivateKeyP *master_priv); + + +/** + * Obtain the wire method associated with the given + * wire account details. @a wire_s must contain a payto://-URL + * under 'url'. + * + * @return NULL on error + */ +char * +TALER_JSON_wire_to_method (const json_t *wire_s); + + +/** + * Obtain the payto://-URL associated with the given + * wire account details. @a wire_s must contain a payto://-URL + * under 'url'. + * + * @return NULL on error + */ +char * +TALER_JSON_wire_to_payto (const json_t *wire_s); + + #endif /* TALER_JSON_LIB_H_ */ /* End of taler_json_lib.h */ diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index c281d21fd..f1148beb8 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -62,18 +62,6 @@ #define TALER_SIGNATURE_MASTER_DENOMINATION_KEY_VALIDITY 1025 /** - * Signature where the Exchange confirms its SEPA details in - * the /wire response. - */ -#define TALER_SIGNATURE_MASTER_SEPA_DETAILS 1026 - -/** - * Signature where the Exchange confirms its TEST details in - * the /wire response. - */ -#define TALER_SIGNATURE_MASTER_TEST_DETAILS 1027 - -/** * Fees charged per (aggregate) wire transfer to the merchant. */ #define TALER_SIGNATURE_MASTER_WIRE_FEES 1028 @@ -83,6 +71,12 @@ */ #define TALER_SIGNATURE_MASTER_DENOMINATION_KEY_REVOKED 1029 +/** + * Signature where the Exchange confirms its SEPA details in + * the /wire response. + */ +#define TALER_SIGNATURE_MASTER_WIRE_DETAILS 1030 + /*********************************************/ /* Exchange online signatures (with signing key) */ /*********************************************/ @@ -891,16 +885,15 @@ struct TALER_MasterWireDetailsPS { /** - * Purpose is #TALER_SIGNATURE_MASTER_SEPA_DETAILS or - * #TALER_SIGNATURE_MASTER_TEST_DETAILS. + * Purpose is #TALER_SIGNATURE_MASTER_WIRE_DETAILS. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; /** - * Hash over the account holder's name, IBAN and BIC - * code (all as 0-terminated strings). + * Hash over the account holder's payto:// URL and + * the salt, as done by #TALER_wire_signature_hash(). */ - struct GNUNET_HashCode h_sepa_details GNUNET_PACKED; + struct GNUNET_HashCode h_wire_details GNUNET_PACKED; }; diff --git a/src/include/taler_testing_lib.h b/src/include/taler_testing_lib.h index 3914208f1..dce92ceae 100644 --- a/src/include/taler_testing_lib.h +++ b/src/include/taler_testing_lib.h @@ -66,20 +66,22 @@ #define TALER_TESTING_MAKE_TRAIT_ROW_ID(data) \ TALER_TESTING_make_trait_uint64 (3, data) + /** - * Allocate and return a piece of wire-details. Mostly, it adds - * the bank_url to the JSON. + * Allocate and return a piece of wire-details. Combines + * the @a account_no and the @a bank_url to a + * @a payto://-URL and adds some salt to create the JSON. * - * @param template the wire-details template. + * @param account_no account number * @param bank_url the bank_url - * - * @return the filled out and stringified wire-details. To - * be manually free'd. + * @return JSON describing the account, including the + * payto://-URL of the account, must be manually decref'd */ -char * -TALER_TESTING_make_wire_details (const char *template, +json_t * +TALER_TESTING_make_wire_details (unsigned long long account_no, const char *bank_url); + /** * Find denomination key matching the given amount. * @@ -130,10 +132,12 @@ TALER_TESTING_url_port_free (const char *url); * If everything is OK, return the configured URL of the fakebank. * * @param config_filename configuration file to use + * @param config_section which account to use (must match x-taler-bank) * @return NULL on error, fakebank URL otherwise */ char * -TALER_TESTING_prepare_fakebank (const char *config_filename); +TALER_TESTING_prepare_fakebank (const char *config_filename, + const char *config_section); /* ******************* Generic interpreter logic ************ */ @@ -613,8 +617,8 @@ TALER_TESTING_cmd_status (const char *label, * coins, this parameter selects which one in that array * This value is currently ignored, as only one-coin * withdrawals are implemented. - * @param wire_details bank details of the merchant performing the - * deposit + * @param wire_details JSON including payto://-URL of the merchant performing the + * deposit, reference is captured by this command * @param contract_terms contract terms to be signed over by the * coin * @param refund_deadline refund deadline @@ -625,12 +629,12 @@ TALER_TESTING_cmd_status (const char *label, * @return the deposit command to be run by the interpreter */ struct TALER_TESTING_Command -TALER_TESTING_cmd_deposit +TALER_TESTING_cmd_deposit (const char *label, struct TALER_EXCHANGE_Handle *exchange, const char *coin_reference, unsigned int coin_index, - char *wire_details, + json_t *wire_details, const char *contract_terms, struct GNUNET_TIME_Relative refund_deadline, const char *amount, @@ -1209,7 +1213,7 @@ int TALER_TESTING_get_trait_wire_details (const struct TALER_TESTING_Command *cmd, unsigned int index, - const char **wire_details); + const json_t **wire_details); /** @@ -1223,7 +1227,7 @@ TALER_TESTING_get_trait_wire_details struct TALER_TESTING_Trait TALER_TESTING_make_trait_wire_details (unsigned int index, - const char *wire_details); + const json_t *wire_details); /** * Obtain a private key from a "peer". Used e.g. to obtain @@ -1300,11 +1304,11 @@ TALER_TESTING_get_trait_transfer_subject /** - * Offer wire details in a trait. + * Offer wire wire transfer subject in a trait. * * @param index always (?) zero, as one command sticks * to one bank account - * @param wire_details wire details to offer + * @param transfer_subject wire transfer subject to offer * @return the trait, to be put in the traits array of the command */ struct TALER_TESTING_Trait diff --git a/src/include/taler_wire_lib.h b/src/include/taler_wire_lib.h index 68c36e889..0cf38d6d1 100644 --- a/src/include/taler_wire_lib.h +++ b/src/include/taler_wire_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2016 GNUnet e.V. + Copyright (C) 2016,2018 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -26,6 +26,16 @@ /** + * Obtain the payment method from a @a payto_url + * + * @param payto_url the URL to parse + * @return NULL on error (malformed @a payto_url) + */ +char * +TALER_WIRE_payto_get_method (const char *payto_url); + + +/** * Load a WIRE plugin. * * @param cfg configuration to use @@ -45,28 +55,4 @@ void TALER_WIRE_plugin_unload (struct TALER_WIRE_Plugin *plugin); -/** - * Signature of a function to be called on each enabled - * wire plugin. - * - * @param cls closure - * @param name name of the enabled plugin - */ -typedef void -(*TALER_WIRE_EnabledCallback)(void *cls, - const char *name); - - -/** - * Check which wire plugins are enabled in @a cfg and call @a cb for each one. - * - * @param cfg configuration to use - * @param cb callback to invoke - * @param cb_cls closure for @a cb - */ -void -TALER_WIRE_find_enabled (const struct GNUNET_CONFIGURATION_Handle *cfg, - TALER_WIRE_EnabledCallback cb, - void *cb_cls); - #endif diff --git a/src/include/taler_wire_plugin.h b/src/include/taler_wire_plugin.h index c0e29609f..2758d2d2e 100644 --- a/src/include/taler_wire_plugin.h +++ b/src/include/taler_wire_plugin.h @@ -22,7 +22,6 @@ #define TALER_WIRE_PLUGIN_H #include <gnunet/gnunet_util_lib.h> -#include <jansson.h> #include "taler_util.h" #include "taler_error_codes.h" #include "taler_bank_service.h" /* for `enum TALER_BANK_Direction` and `struct TALER_BANK_TransferDetails` */ @@ -72,9 +71,9 @@ struct TALER_WIRE_TransferDetails char *wtid_s; /** - * The other account that was involved + * payto://-URL of the other account that was involved */ - json_t *account_details; + char *account_url; }; @@ -161,6 +160,13 @@ struct TALER_WIRE_Plugin char *library_name; /** + * Which wire method (payto://METHOD/") is supported by this plugin? + * For example, "sepa" or "x-taler-bank". + */ + const char *method; + + + /** * Round amount DOWN to the amount that can be transferred via the wire * method. For example, Taler may support 0.000001 EUR as a unit of * payment, but SEPA only supports 0.01 EUR. This function would @@ -177,62 +183,27 @@ struct TALER_WIRE_Plugin /** - * Obtain wire transfer details in the plugin-specific format - * from the configuration. - * - * @param cls closure - * @param cfg configuration with details about wire accounts - * @param account_name which section in the configuration should we parse - * @return NULL if @a cfg fails to have valid wire details for @a account_name - */ - json_t * - (*get_wire_details)(void *cls, - const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *account_name); - - - /** - * Sign wire transfer details in the plugin-specific format. - * - * @param cls closure - * @param in wire transfer details in JSON format - * @param key private signing key to use - * @param salt salt to add - * @param[out] sig where to write the signature - * @return #GNUNET_OK on success - */ - int - (*sign_wire_details)(void *cls, - const json_t *in, - const struct TALER_MasterPrivateKeyP *key, - const struct GNUNET_HashCode *salt, - struct TALER_MasterSignatureP *sig); - - - /** - * Check if the given wire format JSON object is correctly formatted + * Check if the given payto:// URL is correctly formatted for this plugin * * @param cls the @e cls of this struct with the plugin-specific state - * @param wire the JSON wire format object - * @param master_pub public key of the exchange to verify against - * @param[out] emsg set to an error message, unless we return #TALER_EC_NONE; - * error message must be freed by the caller using GNUNET_free() + * @param account_url the payto:// URL * @return #TALER_EC_NONE if correctly formatted */ enum TALER_ErrorCode (*wire_validate) (void *cls, - const json_t *wire, - const struct TALER_MasterPublicKeyP *master_pub, - char **emsg); + const char *account_url); /** * Prepare for exeuction of a wire transfer. * * @param cls the @e cls of this struct with the plugin-specific state - * @param wire valid wire account information + * @param origin_account_section configuration section specifying the origin + * account of the exchange to use + * @param destination_account_url payto:// URL identifying where to send the money * @param amount amount to transfer, already rounded - * @param exchange_base_url base URL of this exchange + * @param exchange_base_url base URL of this exchange (included in subject + * to facilitate use of tracking API by merchant backend) * @param wtid wire transfer identifier to use * @param ptc function to call with the prepared data to persist * @param ptc_cls closure for @a ptc @@ -240,13 +211,15 @@ struct TALER_WIRE_Plugin */ struct TALER_WIRE_PrepareHandle * (*prepare_wire_transfer) (void *cls, - const json_t *wire, + const char *origin_account_section, + const char *destination_account_url, const struct TALER_Amount *amount, const char *exchange_base_url, const struct TALER_WireTransferIdentifierRawP *wtid, TALER_WIRE_PrepareTransactionCallback ptc, void *ptc_cls); + /** * Abort preparation of a wire transfer. For example, * because we are shutting down. @@ -305,6 +278,8 @@ struct TALER_WIRE_Plugin * (with negative @a num_results). * * @param cls the @e cls of this struct with the plugin-specific state + * @param account_section specifies the configuration section which + * identifies the account for which we should get the history * @param direction what kinds of wire transfers should be returned * @param start_off from which row on do we want to get results, use NULL for the latest; exclusive * @param start_off_len number of bytes in @a start_off @@ -316,6 +291,7 @@ struct TALER_WIRE_Plugin */ struct TALER_WIRE_HistoryHandle * (*get_history) (void *cls, + const char *account_section, enum TALER_BANK_Direction direction, const void *start_off, size_t start_off_len, @@ -323,6 +299,7 @@ struct TALER_WIRE_Plugin TALER_WIRE_HistoryResultCallback hres_cb, void *hres_cb_cls); + /** * Cancel going over the account's history. * @@ -345,6 +322,8 @@ struct TALER_WIRE_Plugin * results returned by @e get_history. * * @param cls plugin's closure + * @param account_section specifies the configuration section which + * identifies the account to use to reject the transfer * @param start_off offset of the wire transfer in plugin-specific format * @param start_off_len number of bytes in @a start_off * @param rej_cb function to call with the result of the operation @@ -353,11 +332,13 @@ struct TALER_WIRE_Plugin */ struct TALER_WIRE_RejectHandle * (*reject_transfer)(void *cls, + const char *account_section, const void *start_off, size_t start_off_len, TALER_WIRE_RejectTransferCallback rej_cb, void *rej_cb_cls); + /** * Cancel ongoing reject operation. Note that the rejection may still * proceed. Basically, if this function is called, the rejection may |