setup drain_profits table (#4960)
This commit is contained in:
parent
ba0ab58cdd
commit
75888adff2
@ -92,7 +92,6 @@ drain (void *cls,
|
|||||||
struct DrainContext *dc = cls;
|
struct DrainContext *dc = cls;
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
#if 0
|
|
||||||
qs = TEH_plugin->insert_drain_profit (
|
qs = TEH_plugin->insert_drain_profit (
|
||||||
TEH_plugin->cls,
|
TEH_plugin->cls,
|
||||||
&dc->wtid,
|
&dc->wtid,
|
||||||
@ -101,9 +100,6 @@ drain (void *cls,
|
|||||||
dc->date,
|
dc->date,
|
||||||
&dc->amount,
|
&dc->amount,
|
||||||
&dc->master_sig);
|
&dc->master_sig);
|
||||||
#else
|
|
||||||
qs = -1;
|
|
||||||
#endif
|
|
||||||
if (qs < 0)
|
if (qs < 0)
|
||||||
{
|
{
|
||||||
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
|
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
|
||||||
|
@ -63,6 +63,37 @@ COMMENT ON TABLE denomination_revocations
|
|||||||
IS 'remembering which denomination keys have been revoked';
|
IS 'remembering which denomination keys have been revoked';
|
||||||
|
|
||||||
|
|
||||||
|
-- ------------------------------ profit drains ----------------------------------------
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS profit_drains
|
||||||
|
(profit_drain_serial_id BIGINT GENERATED BY DEFAULT AS IDENTITY UNIQUE
|
||||||
|
,wtid BYTEA PRIMARY KEY CHECK (LENGTH(wtid)=32)
|
||||||
|
,account_section VARCHAR NOT NULL
|
||||||
|
,payto_uri VARCHAR NOT NULL
|
||||||
|
,trigger_date INT8 NOT NULL
|
||||||
|
,amount_val INT8 NOT NULL
|
||||||
|
,amount_frac INT8 NOT NULL
|
||||||
|
,master_sig BYTEA NOT NULL CHECK (LENGTH(master_sig)=64)
|
||||||
|
,executed BOOLEAN NOT NULL DEFAULT FALSE
|
||||||
|
);
|
||||||
|
COMMENT ON TABLE profit_drains
|
||||||
|
IS 'transactions to be performed to move profits from the escrow account of the exchange to a regular account';
|
||||||
|
COMMENT ON COLUMN profit_drains.wtid
|
||||||
|
IS 'randomly chosen nonce, unique to prevent double-submission';
|
||||||
|
COMMENT ON COLUMN profit_drains.account_section
|
||||||
|
IS 'specifies the configuration section in the taler-exchange-drain configuration with the wire account to drain';
|
||||||
|
COMMENT ON COLUMN profit_drains.payto_uri
|
||||||
|
IS 'specifies the account to be credited';
|
||||||
|
COMMENT ON COLUMN profit_drains.trigger_date
|
||||||
|
IS 'set by taler-exchange-offline at the time of making the signature; not necessarily the exact date of execution of the wire transfer, just for orientation';
|
||||||
|
COMMENT ON COLUMN profit_drains.amount_val
|
||||||
|
IS 'amount to be transferred';
|
||||||
|
COMMENT ON COLUMN profit_drains.master_sig
|
||||||
|
IS 'EdDSA signature of type TALER_SIGNATURE_MASTER_DRAIN_PROFIT';
|
||||||
|
COMMENT ON COLUMN profit_drains.executed
|
||||||
|
IS 'set to TRUE by taler-exchange-drain on execution of the transaction, not replicated to auditor';
|
||||||
|
|
||||||
|
|
||||||
-- ------------------------------ wire_targets ----------------------------------------
|
-- ------------------------------ wire_targets ----------------------------------------
|
||||||
|
|
||||||
SELECT create_table_wire_targets();
|
SELECT create_table_wire_targets();
|
||||||
|
@ -677,6 +677,19 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
",closing_fee_frac"
|
",closing_fee_frac"
|
||||||
") VALUES ($1, $2, $3, $4, $5, $6, $7, $8);",
|
") VALUES ($1, $2, $3, $4, $5, $6, $7, $8);",
|
||||||
8),
|
8),
|
||||||
|
/* Used in #postgres_insert_drain_profit() */
|
||||||
|
GNUNET_PQ_make_prepare (
|
||||||
|
"drain_profit_insert",
|
||||||
|
"INSERT INTO profit_drains "
|
||||||
|
"(wtid"
|
||||||
|
",account_section"
|
||||||
|
",payto_uri"
|
||||||
|
",trigger_date"
|
||||||
|
",amount_val"
|
||||||
|
",amount_frac"
|
||||||
|
",master_sig"
|
||||||
|
") VALUES ($1, $2, $3, $4, $5, $6, $7);",
|
||||||
|
7),
|
||||||
/* Used in #reserves_update() when the reserve is updated */
|
/* Used in #reserves_update() when the reserve is updated */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"reserve_update",
|
"reserve_update",
|
||||||
@ -16146,6 +16159,45 @@ postgres_insert_close_request (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called to persist a request to drain profits.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param wtid wire transfer ID to use
|
||||||
|
* @param account_section account to drain
|
||||||
|
* @param payto_uri account to wire funds to
|
||||||
|
* @param date time of the signature
|
||||||
|
* @param amount amount to wire
|
||||||
|
* @param master_sig signature affirming the opearation
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
static enum GNUNET_DB_QueryStatus
|
||||||
|
postgres_insert_drain_profit (
|
||||||
|
void *cls,
|
||||||
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
|
const char *account_section,
|
||||||
|
const char *payto_uri,
|
||||||
|
struct GNUNET_TIME_Timestamp request_timestamp,
|
||||||
|
const struct TALER_Amount *amount,
|
||||||
|
const struct TALER_MasterSignatureP *master_sig)
|
||||||
|
{
|
||||||
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (wtid),
|
||||||
|
GNUNET_PQ_query_param_string (account_section),
|
||||||
|
GNUNET_PQ_query_param_string (payto_uri),
|
||||||
|
GNUNET_PQ_query_param_timestamp (&request_timestamp),
|
||||||
|
TALER_PQ_query_param_amount (amount),
|
||||||
|
GNUNET_PQ_query_param_auto_from_type (master_sig),
|
||||||
|
GNUNET_PQ_query_param_end
|
||||||
|
};
|
||||||
|
|
||||||
|
return GNUNET_PQ_eval_prepared_non_select (pg->conn,
|
||||||
|
"drain_profit_insert",
|
||||||
|
params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize Postgres database subsystem.
|
* Initialize Postgres database subsystem.
|
||||||
*
|
*
|
||||||
@ -16462,6 +16514,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls)
|
|||||||
= &postgres_insert_history_request;
|
= &postgres_insert_history_request;
|
||||||
plugin->insert_close_request
|
plugin->insert_close_request
|
||||||
= &postgres_insert_close_request;
|
= &postgres_insert_close_request;
|
||||||
|
plugin->insert_drain_profit
|
||||||
|
= &postgres_insert_drain_profit;
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5512,6 +5512,28 @@ struct TALER_EXCHANGEDB_Plugin
|
|||||||
struct TALER_Amount *final_balance);
|
struct TALER_Amount *final_balance);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called to persist a request to drain profits.
|
||||||
|
*
|
||||||
|
* @param cls the @e cls of this struct with the plugin-specific state
|
||||||
|
* @param wtid wire transfer ID to use
|
||||||
|
* @param account_section account to drain
|
||||||
|
* @param payto_uri account to wire funds to
|
||||||
|
* @param date time of the signature
|
||||||
|
* @param amount amount to wire
|
||||||
|
* @param master_sig signature affirming the opearation
|
||||||
|
* @return transaction status code
|
||||||
|
*/
|
||||||
|
enum GNUNET_DB_QueryStatus
|
||||||
|
(*insert_drain_profit)(void *cls,
|
||||||
|
const struct TALER_WireTransferIdentifierRawP *wtid,
|
||||||
|
const char *account_section,
|
||||||
|
const char *payto_uri,
|
||||||
|
struct GNUNET_TIME_Timestamp request_timestamp,
|
||||||
|
const struct TALER_Amount *amount,
|
||||||
|
const struct TALER_MasterSignatureP *master_sig);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _TALER_EXCHANGE_DB_H */
|
#endif /* _TALER_EXCHANGE_DB_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user