diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/taler_auditordb_plugin.h | 495 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 116 |
2 files changed, 420 insertions, 191 deletions
diff --git a/src/include/taler_auditordb_plugin.h b/src/include/taler_auditordb_plugin.h index dff96700f..d26e42b78 100644 --- a/src/include/taler_auditordb_plugin.h +++ b/src/include/taler_auditordb_plugin.h @@ -130,6 +130,25 @@ struct TALER_AUDITORDB_WireAccountProgressPoint /** + * Structure for remembering the wire auditor's progress + * with respect to the bank transaction histories. + */ +struct TALER_AUDITORDB_BankAccountProgressPoint +{ + /** + * How far are we in the incoming wire transaction history + */ + uint64_t in_wire_off; + + /** + * How far are we in the outgoing wire transaction history + */ + uint64_t out_wire_off; + +}; + + +/** * Structure for remembering the auditor's progress over the various * tables and (auditor) transactions when analyzing reserves. */ @@ -141,7 +160,7 @@ struct TALER_AUDITORDB_ProgressPointReserve uint64_t last_reserve_in_serial_id; /** - * serial ID of the last reserve_out the auditor processed + * serial ID of the last reserve_out (withdraw) the auditor processed */ uint64_t last_reserve_out_serial_id; @@ -152,40 +171,64 @@ struct TALER_AUDITORDB_ProgressPointReserve uint64_t last_reserve_recoup_serial_id; /** - * serial ID of the last reserve_close - * entry the auditor processed. + * serial ID of the last open_requests entry the auditor processed. */ - uint64_t last_reserve_close_serial_id; + uint64_t last_reserve_open_serial_id; /** - * serial ID of the last purse_merges - * entry the auditor processed. + * serial ID of the last reserve_close entry the auditor processed. */ - uint64_t last_purse_merges_serial_id; + uint64_t last_reserve_close_serial_id; /** - * Serial ID of the last purse_deposits - * entry the auditor processed. + * Serial ID of the last purse_decisions entry the auditor processed. */ - uint64_t last_purse_deposits_serial_id; + uint64_t last_purse_decisions_serial_id; /** - * serial ID of the last account_merges - * entry the auditor processed. + * serial ID of the last account_merges entry the auditor processed. */ uint64_t last_account_merges_serial_id; /** - * serial ID of the last history_requests - * entry the auditor processed. + * serial ID of the last history_requests entry the auditor processed. */ uint64_t last_history_requests_serial_id; +}; + + +/** + * Structure for remembering the auditor's progress over the various + * tables and (auditor) transactions when analyzing purses. + */ +struct TALER_AUDITORDB_ProgressPointPurse +{ /** - * serial ID of the last close_requests - * entry the auditor processed. + * serial ID of the last purse_request transfer the auditor processed */ - uint64_t last_close_requests_serial_id; + uint64_t last_purse_request_serial_id; + + /** + * serial ID of the last purse_decision the auditor processed + */ + uint64_t last_purse_decision_serial_id; + + /** + * serial ID of the last purse_merge entry the auditor processed when + * considering reserves. + */ + uint64_t last_purse_merge_serial_id; + + /** + * serial ID of the last account_merge entry the auditor processed. + */ + uint64_t last_account_merge_serial_id; + + /** + * serial ID of the last purse_deposits entry the auditor processed. + */ + uint64_t last_purse_deposits_serial_id; }; @@ -255,6 +298,11 @@ struct TALER_AUDITORDB_ProgressPointCoin uint64_t last_recoup_refresh_serial_id; /** + * Serial ID of the last reserve_open_deposits operation the auditor processed. + */ + uint64_t last_open_deposits_serial_id; + + /** * Serial ID of the last purse_deposits operation the auditor processed. */ uint64_t last_purse_deposits_serial_id; @@ -390,6 +438,140 @@ struct TALER_AUDITORDB_DepositConfirmation /** + * Balance values for a reserve (or all reserves). + */ +struct TALER_AUDITORDB_ReserveFeeBalance +{ + /** + * Remaining funds. + */ + struct TALER_Amount reserve_balance; + + /** + * Losses from operations that should not have + * happened (e.g. negative balance). + */ + struct TALER_Amount reserve_loss; + + /** + * Fees charged for withdraw. + */ + struct TALER_Amount withdraw_fee_balance; + + /** + * Fees charged for closing. + */ + struct TALER_Amount close_fee_balance; + + /** + * Fees charged for purse creation. + */ + struct TALER_Amount purse_fee_balance; + + /** + * Opening fees charged. + */ + struct TALER_Amount open_fee_balance; + + /** + * History fees charged. + */ + struct TALER_Amount history_fee_balance; +}; + + +/** + * Balance data for denominations in circulation. + */ +struct TALER_AUDITORDB_DenominationCirculationData +{ + /** + * Amount of outstanding coins in circulation. + */ + struct TALER_Amount denom_balance; + + /** + * Amount lost due coins illicitly accepted (effectively, a + * negative @a denom_balance). + */ + struct TALER_Amount denom_loss; + + /** + * Total amount that could still be theoretically lost in the future due to + * recoup operations. (Total put into circulation minus @e recoup_loss). + */ + struct TALER_Amount denom_risk; + + /** + * Amount lost due to recoups. + */ + struct TALER_Amount recoup_loss; + + /** + * Number of coins of this denomination that the exchange signed into + * existence. + */ + uint64_t num_issued; +}; + + +/** + * Balance values for all denominations. + */ +struct TALER_AUDITORDB_GlobalCoinBalance +{ + /** + * Amount of outstanding coins in circulation. + */ + struct TALER_Amount total_escrowed; + + /** + * Amount collected in deposit fees. + */ + struct TALER_Amount deposit_fee_balance; + + /** + * Amount collected in melt fees. + */ + struct TALER_Amount melt_fee_balance; + + /** + * Amount collected in refund fees. + */ + struct TALER_Amount refund_fee_balance; + + /** + * Amount collected in purse fees from coins. + */ + struct TALER_Amount purse_fee_balance; + + /** + * Amount collected in reserve open deposit fees from coins. + */ + struct TALER_Amount open_deposit_fee_balance; + + /** + * Total amount that could still be theoretically + * lost in the future due to recoup operations. + * (Total put into circulation minus @e loss + * and @e irregular_recoup.) + */ + struct TALER_Amount risk; + + /** + * Amount lost due to recoups. + */ + struct TALER_Amount loss; + + /** + * Amount lost due to coin operations that the exchange + * should not have permitted. + */ + struct TALER_Amount irregular_loss; +}; + + +/** * Function called with deposit confirmations stored in * the auditor's database. * @@ -639,14 +821,14 @@ struct TALER_AUDITORDB_Plugin struct TALER_AUDITORDB_ProgressPointCoin *ppc); /** - * Insert information about the auditor's progress with an exchange's - * data. - * - * @param cls the @e cls of this struct with the plugin-specific state - * @param master_pub master key of the exchange - * @param ppr where is the auditor in processing - * @return transaction status code - */ + * Insert information about the auditor's progress with an exchange's + * data. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param master_pub master key of the exchange + * @param ppr where is the auditor in processing + * @return transaction status code + */ enum GNUNET_DB_QueryStatus (*insert_auditor_progress_reserve)( void *cls, @@ -690,6 +872,53 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master key of the exchange + * @param ppp where is the auditor in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*insert_auditor_progress_purse)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointPurse *ppp); + + + /** + * Update information about the progress of the auditor. There + * must be an existing record for the exchange. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param master_pub master key of the exchange + * @param ppp where is the auditor in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*update_auditor_progress_purse)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ProgressPointPurse *ppp); + + + /** + * Get information about the progress of the auditor. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param master_pub master key of the exchange + * @param[out] ppp set to where the auditor is in processing + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*get_auditor_progress_purse)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_ProgressPointPurse *ppp); + + + /** + * Insert information about the auditor's progress with an exchange's + * data. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param master_pub master key of the exchange * @param ppdc where is the auditor in processing * @return transaction status code */ @@ -786,8 +1015,7 @@ struct TALER_AUDITORDB_Plugin * @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 + * @param bapp progress in wire transaction histories * @return transaction status code */ enum GNUNET_DB_QueryStatus @@ -796,8 +1024,7 @@ struct TALER_AUDITORDB_Plugin const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, - uint64_t in_wire_off, - uint64_t out_wire_off); + const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp); /** @@ -808,8 +1035,7 @@ struct TALER_AUDITORDB_Plugin * @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 + * @param bapp progress in wire transaction histories * @return transaction status code */ enum GNUNET_DB_QueryStatus @@ -818,8 +1044,7 @@ struct TALER_AUDITORDB_Plugin const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, const struct TALER_AUDITORDB_WireAccountProgressPoint *pp, - uint64_t in_wire_off, - uint64_t out_wire_off); + const struct TALER_AUDITORDB_BankAccountProgressPoint *bapp); /** @@ -829,8 +1054,7 @@ struct TALER_AUDITORDB_Plugin * @param master_pub master key of the exchange * @param account_name name of the wire account we are auditing * @param[out] pp where is the auditor 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 + * @param[out] bapp how far are we in the wire transaction histories * @return transaction status code */ enum GNUNET_DB_QueryStatus @@ -839,8 +1063,7 @@ struct TALER_AUDITORDB_Plugin const struct TALER_MasterPublicKeyP *master_pub, const char *account_name, struct TALER_AUDITORDB_WireAccountProgressPoint *pp, - uint64_t *in_wire_off, - uint64_t *out_wire_off); + struct TALER_AUDITORDB_BankAccountProgressPoint *bapp); /** @@ -887,9 +1110,10 @@ struct TALER_AUDITORDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_wire_auditor_progress)(void *cls, - const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_AUDITORDB_WireProgressPoint *pp); + (*get_wire_auditor_progress)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + struct TALER_AUDITORDB_WireProgressPoint *pp); /** @@ -899,21 +1123,19 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange - * @param reserve_balance amount stored in the reserve - * @param withdraw_fee_balance amount the exchange gained in withdraw fees - * due to withdrawals from this reserve + * @param rfb balance amounts for the reserve * @param expiration_date expiration date of the reserve * @param origin_account where did the money in the reserve originally come from * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_reserve_info)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance, - struct GNUNET_TIME_Timestamp expiration_date, - const char *origin_account); + (*insert_reserve_info)( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, + struct GNUNET_TIME_Timestamp expiration_date, + const char *origin_account); /** @@ -923,19 +1145,17 @@ struct TALER_AUDITORDB_Plugin * @param cls the @e cls of this struct with the plugin-specific state * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange - * @param reserve_balance amount stored in the reserve - * @param withdraw_fee_balance amount the exchange gained in withdraw fees - * due to withdrawals from this reserve + * @param rfb balance amounts for the reserve * @param expiration_date expiration date of the reserve * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_reserve_info)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance, - struct GNUNET_TIME_Timestamp expiration_date); + (*update_reserve_info)( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ReserveFeeBalance *rfb, + struct GNUNET_TIME_Timestamp expiration_date); /** @@ -945,22 +1165,20 @@ struct TALER_AUDITORDB_Plugin * @param reserve_pub public key of the reserve * @param master_pub master public key of the exchange * @param[out] rowid which row did we get the information from - * @param[out] reserve_balance amount stored in the reserve - * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees - * due to withdrawals from this reserve + * @param[out] rfb set to balances associated with the reserve * @param[out] expiration_date expiration date of the reserve * @param[out] sender_account from where did the money in the reserve originally come from * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*get_reserve_info)(void *cls, - const struct TALER_ReservePublicKeyP *reserve_pub, - const struct TALER_MasterPublicKeyP *master_pub, - uint64_t *rowid, - struct TALER_Amount *reserve_balance, - struct TALER_Amount *withdraw_fee_balance, - struct GNUNET_TIME_Timestamp *expiration_date, - char **sender_account); + (*get_reserve_info)( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_MasterPublicKeyP *master_pub, + uint64_t *rowid, + struct TALER_AUDITORDB_ReserveFeeBalance *rfb, + struct GNUNET_TIME_Timestamp *expiration_date, + char **sender_account); /** @@ -983,19 +1201,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master public key of the exchange - * @param reserve_balance amount stored in the reserve - * @param withdraw_fee_balance amount the exchange gained in withdraw fees - * @param purse_fee_balance amount the exchange gained in purse fees - * @param history_fee_balance amount the exchange gained in history fees + * @param rfb reserve balances summary to store * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_reserve_summary)(void *cls, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance, - const struct TALER_Amount *purse_fee_balance, - const struct TALER_Amount *history_fee_balance); + (*insert_reserve_summary)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ReserveFeeBalance *rfb); /** @@ -1004,19 +1217,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master public key of the exchange - * @param reserve_balance amount stored in the reserve - * @param withdraw_fee_balance amount the exchange gained in withdraw fees - * @param purse_fee_balance amount the exchange gained in purse fees - * @param history_fee_balance amount the exchange gained in history fees + * @param rfb reserve balances summary to store * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_reserve_summary)(void *cls, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_Amount *reserve_balance, - const struct TALER_Amount *withdraw_fee_balance, - const struct TALER_Amount *purse_fee_balance, - const struct TALER_Amount *history_fee_balance); + (*update_reserve_summary)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_ReserveFeeBalance *rfb); /** @@ -1024,19 +1232,13 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master public key of the exchange - * @param[out] reserve_balance amount stored in reserves - * @param[out] withdraw_fee_balance amount the exchange gained in withdraw fees - * @param[out] purse_fee_balance amount the exchange gained in purse fees - * @param[out] history_fee_balance amount the exchange gained in history fees + * @param[out] rfb reserve balances summary to initialize * @return transaction status code */ enum GNUNET_DB_QueryStatus (*get_reserve_summary)(void *cls, const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_Amount *reserve_balance, - struct TALER_Amount *withdraw_fee_balance, - struct TALER_Amount *purse_fee_balance, - struct TALER_Amount *history_fee_balance); + struct TALER_AUDITORDB_ReserveFeeBalance *rfb); /** @@ -1089,22 +1291,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param denom_pub_hash hash of the denomination public key - * @param denom_balance value of coins outstanding with this denomination key - * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) - * @param denom_risk value of coins issued with this denomination key - * @param denom_recoup value of coins paid back if this denomination key was revoked - * @param num_issued how many coins of this denomination did the exchange blind-sign + * @param dcd denomination circulation data to store * @return transaction status code */ enum GNUNET_DB_QueryStatus (*insert_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, - const struct TALER_Amount *denom_balance, - const struct TALER_Amount *denom_loss, - const struct TALER_Amount *denom_risk, - const struct TALER_Amount *recoup_loss, - uint64_t num_issued); + const struct TALER_AUDITORDB_DenominationCirculationData *dcd); /** @@ -1113,22 +1307,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param denom_pub_hash hash of the denomination public key - * @param denom_balance value of coins outstanding with this denomination key - * @param denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) - * @param denom_risk value of coins issued with this denomination key - * @param denom_recoup value of coins paid back if this denomination key was revoked - * @param num_issued how many coins of this denomination did the exchange blind-sign + * @param dcd denomination circulation data to store * @return transaction status code */ enum GNUNET_DB_QueryStatus (*update_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, - const struct TALER_Amount *denom_balance, - const struct TALER_Amount *denom_loss, - const struct TALER_Amount *denom_risk, - const struct TALER_Amount *recoup_loss, - uint64_t num_issued); + const struct TALER_AUDITORDB_DenominationCirculationData *dcd); /** @@ -1136,22 +1322,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param denom_pub_hash hash of the denomination public key - * @param[out] denom_balance value of coins outstanding with this denomination key - * @param[out] denom_loss value of coins redeemed that were not outstanding (effectively, negative @a denom_balance) - * @param[out] denom_risk value of coins issued with this denomination key - * @param[out] denom_recoup value of coins paid back if this denomination key was revoked - * @param[out] num_issued how many coins of this denomination did the exchange blind-sign + * @param[out] dcd denomination circulation data to initialize * @return transaction status code */ enum GNUNET_DB_QueryStatus (*get_denomination_balance)( void *cls, const struct TALER_DenominationHashP *denom_pub_hash, - struct TALER_Amount *denom_balance, - struct TALER_Amount *denom_loss, - struct TALER_Amount *denom_risk, - struct TALER_Amount *recoup_loss, - uint64_t *num_issued); + struct TALER_AUDITORDB_DenominationCirculationData *dcd); /** @@ -1173,26 +1351,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master key of the exchange - * @param denom_balance value of coins outstanding with this denomination key - * @param deposit_fee_balance total deposit fees collected for this DK - * @param melt_fee_balance total melt fees collected for this DK - * @param refund_fee_balance total refund fees collected for this DK - * @param risk maximum risk exposure of the exchange - * @param recoup_loss actual losses from recoup (actualized @a risk) - * @param irregular_recoups recoups made of non-revoked coins (reduces - * risk, but should never happen) + * @param dfb denomination balance data to store * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*insert_balance_summary)(void *cls, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_Amount *denom_balance, - const struct TALER_Amount *deposit_fee_balance, - const struct TALER_Amount *melt_fee_balance, - const struct TALER_Amount *refund_fee_balance, - const struct TALER_Amount *risk, - const struct TALER_Amount *recoup_loss, - const struct TALER_Amount *irregular_recoups); + (*insert_balance_summary)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_GlobalCoinBalance *dfb); /** @@ -1201,26 +1367,14 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master key of the exchange - * @param denom_balance value of coins outstanding with this denomination key - * @param deposit_fee_balance total deposit fees collected for this DK - * @param melt_fee_balance total melt fees collected for this DK - * @param refund_fee_balance total refund fees collected for this DK - * @param risk maximum risk exposure of the exchange - * @param recoup_loss actual losses from recoup (actualized @a risk) - * @param irregular_recoups recoups made of non-revoked coins (reduces - * risk, but should never happen) + * @param dfb denomination balance data to store * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*update_balance_summary)(void *cls, - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_Amount *denom_balance, - const struct TALER_Amount *deposit_fee_balance, - const struct TALER_Amount *melt_fee_balance, - const struct TALER_Amount *refund_fee_balance, - const struct TALER_Amount *risk, - const struct TALER_Amount *recoup_loss, - const struct TALER_Amount *irregular_recoups); + (*update_balance_summary)( + void *cls, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_AUDITORDB_GlobalCoinBalance *dfb); /** @@ -1228,26 +1382,13 @@ struct TALER_AUDITORDB_Plugin * * @param cls the @e cls of this struct with the plugin-specific state * @param master_pub master key of the exchange - * @param[out] denom_balance value of coins outstanding with this denomination key - * @param[out] deposit_fee_balance total deposit fees collected for this DK - * @param[out] melt_fee_balance total melt fees collected for this DK - * @param[out] refund_fee_balance total refund fees collected for this DK - * @param[out] risk maximum risk exposure of the exchange - * @param[out] recoup_loss actual losses from recoup (actualized @a risk) - * @param[out] irregular_recoups recoups made of non-revoked coins (reduces - * risk, but should never happen) + * @param[out] dfb where to return the denomination balances * @return transaction status code */ enum GNUNET_DB_QueryStatus (*get_balance_summary)(void *cls, const struct TALER_MasterPublicKeyP *master_pub, - struct TALER_Amount *denom_balance, - struct TALER_Amount *deposit_fee_balance, - struct TALER_Amount *melt_fee_balance, - struct TALER_Amount *refund_fee_balance, - struct TALER_Amount *risk, - struct TALER_Amount *recoup_loss, - struct TALER_Amount *irregular_recoup); + struct TALER_AUDITORDB_GlobalCoinBalance *dfb); /** diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 107d88cca..4965a27b1 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -222,7 +222,7 @@ enum TALER_EXCHANGEDB_ReplicatedTable TALER_EXCHANGEDB_RT_EXTENSIONS, TALER_EXCHANGEDB_RT_EXTENSION_DETAILS, TALER_EXCHANGEDB_RT_PURSE_REQUESTS, - TALER_EXCHANGEDB_RT_PURSE_REFUNDS, + TALER_EXCHANGEDB_RT_PURSE_DECISION, TALER_EXCHANGEDB_RT_PURSE_MERGES, TALER_EXCHANGEDB_RT_PURSE_DEPOSITS, TALER_EXCHANGEDB_RT_ACCOUNT_MERGES, @@ -536,7 +536,9 @@ struct TALER_EXCHANGEDB_TableData struct { struct TALER_PurseContractPublicKeyP purse_pub; - } purse_refunds; + struct GNUNET_TIME_Timestamp action_timestamp; + bool refunded; + } purse_decision; struct { @@ -2348,19 +2350,23 @@ typedef enum GNUNET_GenericReturnValue /** - * Function called with details about purse refunds that have been made, with - * the goal of auditing the purse refund's execution. + * Function called with details about purse decisions that have been made, with + * the goal of auditing the purse's execution. * * @param cls closure * @param rowid unique serial ID for the deposit in our DB - * @param purse_pub public key of the refunded purse + * @param purse_pub public key of the purse + * @param reserve_pub public key of the target reserve, NULL if not known + * @param purse_value what is the (target) value of the purse * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ typedef enum GNUNET_GenericReturnValue -(*TALER_EXCHANGEDB_PurseRefundCallback)( +(*TALER_EXCHANGEDB_PurseDecisionCallback)( void *cls, uint64_t rowid, - const struct TALER_PurseContractPublicKeyP *purse_pub); + const struct TALER_PurseContractPublicKeyP *purse_pub, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_Amount *purse_value); /** @@ -2850,6 +2856,33 @@ typedef enum GNUNET_GenericReturnValue /** + * Function called about reserve opening operations. + * + * @param cls closure + * @param rowid row identifier used to uniquely identify the reserve closing operation + * @param reserve_payment how much to pay from the + * reserve's own balance for opening the reserve + * @param request_timestamp when was the request created + * @param reserve_expiration desired expiration time for the reserve + * @param purse_limit minimum number of purses the client + * wants to have concurrently open for this reserve + * @param reserve_pub public key of the reserve + * @param reserve_sig signature affirming the operation + * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop + */ +typedef enum GNUNET_GenericReturnValue +(*TALER_EXCHANGEDB_ReserveOpenCallback)( + void *cls, + uint64_t rowid, + const struct TALER_Amount *reserve_payment, + struct GNUNET_TIME_Timestamp request_timestamp, + struct GNUNET_TIME_Timestamp reserve_expiration, + uint32_t purse_limit, + const struct TALER_ReservePublicKeyP *reserve_pub, + const struct TALER_ReserveSignatureP *reserve_sig); + + +/** * Function called about reserve closing operations * the aggregator triggered. * @@ -2861,6 +2894,8 @@ typedef enum GNUNET_GenericReturnValue * @param reserve_pub public key of the reserve * @param receiver_account where did we send the funds, in payto://-format * @param wtid identifier used for the wire transfer + * @param close_request_row row with the responsible close + * request, 0 if regular expiration triggered close * @return #GNUNET_OK to continue to iterate, #GNUNET_SYSERR to stop */ typedef enum GNUNET_GenericReturnValue @@ -2872,7 +2907,8 @@ typedef enum GNUNET_GenericReturnValue const struct TALER_Amount *closing_fee, const struct TALER_ReservePublicKeyP *reserve_pub, const char *receiver_account, - const struct TALER_WireTransferIdentifierRawP *wtid); + const struct TALER_WireTransferIdentifierRawP *wtid, + uint64_t close_request_row); /** @@ -2895,6 +2931,8 @@ typedef void * @param left amount left in the reserve * @param account_details information about the reserve's bank account, in payto://-format * @param expiration_date when did the reserve expire + * @param close_request_row row that caused the reserve + * to be closed, 0 if it expired without request * @return #GNUNET_OK on success, * #GNUNET_NO to retry * #GNUNET_SYSERR on hard failures (exit) @@ -2905,7 +2943,8 @@ typedef enum GNUNET_GenericReturnValue const struct TALER_ReservePublicKeyP *reserve_pub, const struct TALER_Amount *left, const char *account_details, - struct GNUNET_TIME_Timestamp expiration_date); + struct GNUNET_TIME_Timestamp expiration_date, + uint64_t close_request_row); /** @@ -4362,6 +4401,33 @@ struct TALER_EXCHANGEDB_Plugin /** + * Select information about reserve close requests. + * + * @param cls closure + * @param reserve_pub which reserve is this about? + * @param rowid row ID of the close request + * @param[out] reserve_sig reserve signature affirming + * @param[out] request_timestamp when was the request made + * @param[out] close_balance reserve balance at close time + * @param[out] close_fee closing fee to be charged + * @param[out] payto_uri set to URL of account that + * should receive the money; + * could be set to NULL for origin + * @return transaction status code, 0 if reserve unknown + */ + enum GNUNET_DB_QueryStatus + (*select_reserve_close_request_info)( + void *cls, + const struct TALER_ReservePublicKeyP *reserve_pub, + uint64_t rowid, + struct TALER_ReserveSignatureP *reserve_sig, + struct GNUNET_TIME_Timestamp *request_timestamp, + struct TALER_Amount *close_balance, + struct TALER_Amount *close_fee, + char **payto_uri); + + + /** * Select information needed for KYC checks on reserve close: historic * reserve closures going to the same account. * @@ -4392,6 +4458,7 @@ struct TALER_EXCHANGEDB_Plugin * @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 + * @param close_request_row identifies explicit close request, 0 for none * @return transaction status code */ enum GNUNET_DB_QueryStatus @@ -4401,7 +4468,8 @@ struct TALER_EXCHANGEDB_Plugin const char *receiver_account, const struct TALER_WireTransferIdentifierRawP *wtid, const struct TALER_Amount *amount_with_fee, - const struct TALER_Amount *closing_fee); + const struct TALER_Amount *closing_fee, + uint64_t close_request_row); /** @@ -4604,15 +4672,17 @@ struct TALER_EXCHANGEDB_Plugin * * @param cls closure * @param serial_id highest serial ID to exclude (select strictly larger) + * @param refunded which refund status to select for * @param cb function to call on each result * @param cb_cls closure for @a cb * @return transaction status code */ enum GNUNET_DB_QueryStatus - (*select_purse_refunds_above_serial_id)( + (*select_purse_decisions_above_serial_id)( void *cls, uint64_t serial_id, - TALER_EXCHANGEDB_PurseRefundCallback cb, + bool refunded, + TALER_EXCHANGEDB_PurseDecisionCallback cb, void *cb_cls); @@ -4795,8 +4865,8 @@ struct TALER_EXCHANGEDB_Plugin /** - * Function called to select reserve close operations the aggregator - * triggered, ordered by serial ID (monotonically increasing). + * Function called to select reserve open operations, ordered by serial ID + * (monotonically increasing). * * @param cls closure * @param serial_id lowest serial ID to include (select larger or equal) @@ -4805,6 +4875,24 @@ struct TALER_EXCHANGEDB_Plugin * @return transaction status code */ enum GNUNET_DB_QueryStatus + (*select_reserve_open_above_serial_id)( + void *cls, + uint64_t serial_id, + TALER_EXCHANGEDB_ReserveOpenCallback cb, + void *cb_cls); + + + /** + * Function called to select reserve close operations the aggregator + * triggered, ordered by serial ID (monotonically increasing). + * + * @param cls closure + * @param serial_id lowest serial ID to include (select larger or equal) + * @param cb function to call + * @param cb_cls closure for @a cb + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus (*select_reserve_closed_above_serial_id)( void *cls, uint64_t serial_id, |