aboutsummaryrefslogtreecommitdiff
path: root/src/mintdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/mintdb')
-rw-r--r--src/mintdb/mintdb_keyio.c204
-rw-r--r--src/mintdb/perf_taler_mintdb.c12
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.c20
-rw-r--r--src/mintdb/perf_taler_mintdb_interpreter.h2
-rw-r--r--src/mintdb/plugin_mintdb_common.c37
-rw-r--r--src/mintdb/plugin_mintdb_postgres.c224
6 files changed, 432 insertions, 67 deletions
diff --git a/src/mintdb/mintdb_keyio.c b/src/mintdb/mintdb_keyio.c
index 7cf77558..5bfe5bb1 100644
--- a/src/mintdb/mintdb_keyio.c
+++ b/src/mintdb/mintdb_keyio.c
@@ -351,4 +351,208 @@ TALER_MINTDB_denomination_keys_iterate (const char *mint_base_dir,
}
+/**
+ * Closure for #auditor_iter() and
+ */
+struct AuditorIterateContext
+{
+
+ /**
+ * Function to call with the information for each auditor.
+ */
+ TALER_MINTDB_AuditorIterator it;
+
+ /**
+ * Closure for @e it.
+ */
+ void *it_cls;
+};
+
+
+GNUNET_NETWORK_STRUCT_BEGIN
+
+/**
+ * Header of a file with auditing information.
+ */
+struct AuditorFileHeaderP
+{
+
+ /**
+ * Public key of the auditor.
+ */
+ struct TALER_AuditorPublicKeyP apub;
+
+ /**
+ * Master public key of the mint the auditor is signing
+ * information for.
+ */
+ struct TALER_MasterPublicKeyP mpub;
+
+};
+GNUNET_NETWORK_STRUCT_END
+
+
+/**
+ * Load the auditor signature and the information signed by the
+ * auditor and call the callback in @a cls with the information.
+ *
+ * @param cls the `struct AuditorIterateContext *`
+ * @param filename name of a file that should contain
+ * a denomination key
+ * @return #GNUNET_OK to continue to iterate
+ * #GNUNET_NO to abort iteration with success
+ * #GNUNET_SYSERR to abort iteration with failure
+ */
+static int
+auditor_iter (void *cls,
+ const char *filename)
+{
+ struct AuditorIterateContext *aic = cls;
+ uint64_t size;
+ struct AuditorFileHeaderP *af;
+ const struct TALER_AuditorSignatureP *sigs;
+ const struct TALER_DenominationKeyValidityPS *dki;
+ unsigned int len;
+ int ret;
+
+ if (GNUNET_OK != GNUNET_DISK_file_size (filename,
+ &size,
+ GNUNET_YES,
+ GNUNET_YES))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Skipping inaccessable auditor information file `%s'\n",
+ filename);
+ return GNUNET_SYSERR;
+ }
+ if ( (size < sizeof (struct AuditorFileHeaderP)) ||
+ (0 != (len = ((size - sizeof (struct AuditorFileHeaderP)) %
+ (sizeof (struct TALER_DenominationKeyValidityPS) +
+ sizeof (struct TALER_AuditorSignatureP))))) )
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ af = GNUNET_malloc (size);
+ if (size !=
+ GNUNET_DISK_fn_read (filename,
+ af,
+ size))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+ "read",
+ filename);
+ GNUNET_free (af);
+ return GNUNET_SYSERR;
+ }
+ sigs = (const struct TALER_AuditorSignatureP *) &af[1];
+ dki = (const struct TALER_DenominationKeyValidityPS *) &sigs[len];
+ ret = aic->it (aic->it_cls,
+ &af->apub,
+ &af->mpub,
+ len,
+ sigs,
+ dki);
+ GNUNET_free (af);
+ return ret;
+}
+
+
+/**
+ * Call @a it with information for each auditor found in the @a mint_base_dir.
+ *
+ * @param mint_base_dir base directory for the mint,
+ * the signing keys must be in the #TALER_MINTDB_DIR_DENOMINATION_KEYS
+ * subdirectory
+ * @param it function to call with auditor information
+ * @param it_cls closure for @a it
+ * @return -1 on error, 0 if no files were found, otherwise
+ * a positive number (however, even with a positive
+ * number it is possible that @a it was never called
+ * as maybe none of the files were well-formed)
+ */
+int
+TALER_MINTDB_auditor_iterate (const char *mint_base_dir,
+ TALER_MINTDB_AuditorIterator it,
+ void *it_cls)
+{
+ char *dir;
+ struct AuditorIterateContext aic;
+ int ret;
+
+ GNUNET_asprintf (&dir,
+ "%s" DIR_SEPARATOR_STR TALER_MINTDB_DIR_AUDITORS,
+ mint_base_dir);
+ aic.it = it;
+ aic.it_cls = it_cls;
+ ret = GNUNET_DISK_directory_scan (dir,
+ &auditor_iter,
+ &aic);
+ GNUNET_free (dir);
+ return ret;
+}
+
+
+/**
+ * Write auditor information to the given file.
+ *
+ * @param filename the file where to write the auditor information to
+ * @param apub the auditor's public key
+ * @param asigs the auditor's signatures, array of length @a dki_len
+ * @param mpub the mint's public key (as expected by the auditor)
+ * @param dki_len length of @a dki
+ * @param dki array of denomination coin data signed by the auditor
+ * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure.
+ */
+int
+TALER_MINTDB_auditor_write (const char *filename,
+ const struct TALER_AuditorPublicKeyP *apub,
+ const struct TALER_AuditorSignatureP *asigs,
+ const struct TALER_MasterPublicKeyP *mpub,
+ unsigned int dki_len,
+ const struct TALER_DenominationKeyValidityPS *dki)
+{
+ struct AuditorFileHeaderP af;
+ struct GNUNET_DISK_FileHandle *fh;
+ ssize_t wrote;
+ size_t wsize;
+ int ret;
+ int eno;
+
+ af.apub = *apub;
+ af.mpub = *mpub;
+ ret = GNUNET_SYSERR;
+ if (NULL == (fh = GNUNET_DISK_file_open
+ (filename,
+ GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_TRUNCATE,
+ GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE)))
+ goto cleanup;
+ wsize = sizeof (struct AuditorFileHeaderP);
+ if (GNUNET_SYSERR == (wrote = GNUNET_DISK_file_write (fh,
+ &af,
+ wsize)))
+ goto cleanup;
+ if (wrote != wsize)
+ goto cleanup;
+ wsize = dki_len * sizeof (struct TALER_AuditorSignatureP);
+ if (wsize ==
+ GNUNET_DISK_file_write (fh,
+ asigs,
+ wsize))
+ ret = GNUNET_OK;
+ wsize = dki_len * sizeof (struct TALER_DenominationKeyValidityPS);
+ if (wsize ==
+ GNUNET_DISK_file_write (fh,
+ dki,
+ wsize))
+ ret = GNUNET_OK;
+ cleanup:
+ eno = errno;
+ if (NULL != fh)
+ (void) GNUNET_DISK_file_close (fh);
+ errno = eno;
+ return ret;
+}
+
+
/* end of mintdb_keyio.c */
diff --git a/src/mintdb/perf_taler_mintdb.c b/src/mintdb/perf_taler_mintdb.c
index fd96e797..73708a6c 100644
--- a/src/mintdb/perf_taler_mintdb.c
+++ b/src/mintdb/perf_taler_mintdb.c
@@ -287,28 +287,28 @@ main (int argc, char ** argv)
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of transaction loading"),
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("27 - start"),
- PERF_TALER_MINTDB_INIT_CMD_LOOP ("27 - /withdraw/sign",
+ PERF_TALER_MINTDB_INIT_CMD_LOOP ("27 - /reserve/withdraw",
NB_WITHDRAW_SAVE),
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("27 - reserve",
- "27 - /withdraw/sign",
+ "27 - /reserve/withdraw",
"02 - save reserve"),
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("27 - dki",
- "27 - /withdraw/sign",
+ "27 - /reserve/withdraw",
"01 - save denomination"),
PERF_TALER_MINTDB_INIT_CMD_WITHDRAW_SIGN ("",
"27 - dki",
"27 - reserve"),
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("",
- "27 - /withdraw/sign"),
+ "27 - /reserve/withdraw"),
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("27 - end"),
PERF_TALER_MINTDB_INIT_CMD_GAUGER ("",
"27 - start",
"27 - end",
"POSTGRES",
- "Number of /withdraw/sign per second",
+ "Number of /reserve/withdraw per second",
"item/sec",
NB_WITHDRAW_SAVE),
- PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of /withdraw/sign"),
+ PERF_TALER_MINTDB_INIT_CMD_DEBUG ("End of /reserve/withdraw"),
PERF_TALER_MINTDB_INIT_CMD_GET_TIME ("28 - start"),
PERF_TALER_MINTDB_INIT_CMD_LOOP ("28 - /deposit",
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c
index a814fbd6..31f5d650 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.c
+++ b/src/mintdb/perf_taler_mintdb_interpreter.c
@@ -1757,13 +1757,27 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_COMMIT_LINK:
{
- int hash_index;
-
- hash_index = state->cmd[state->i].details.insert_refresh_commit_link.index_hash;
+// unsigned int hash_index;
+//
+// hash_index = state->cmd[state->i].details.insert_refresh_commit_link.index_hash;
}
break;
case PERF_TALER_MINTDB_CMD_GET_REFRESH_COMMIT_LINK:
+ {
+ int ret;
+ unsigned int hash_index;
+ struct TALER_MINTDB_RefreshCommitCoin commit_coin;
+
+ hash_index = state->cmd[state->i].details.get_refresh_commit_link.index_hash;
+ ret = state->plugin->get_refresh_commit_coins(state->plugin->cls,
+ state->session,
+ state->cmd[hash_index].exposed.data.session_hash,
+ 1,
+ 1,
+ &commit_coin);
+ GNUNET_assert (GNUNET_SYSERR != ret);
+ }
break;
case PERF_TALER_MINTDB_CMD_GET_MELT_COMMITMENT:
diff --git a/src/mintdb/perf_taler_mintdb_interpreter.h b/src/mintdb/perf_taler_mintdb_interpreter.h
index b9283e84..722d1a07 100644
--- a/src/mintdb/perf_taler_mintdb_interpreter.h
+++ b/src/mintdb/perf_taler_mintdb_interpreter.h
@@ -363,7 +363,7 @@
/**
- * The /withdraw/sign api call
+ * The /reserve/withdraw api call
*
* Exposes #PERF_TALER_MINTDB_COIN
*
diff --git a/src/mintdb/plugin_mintdb_common.c b/src/mintdb/plugin_mintdb_common.c
index 11430127..bbe104f6 100644
--- a/src/mintdb/plugin_mintdb_common.c
+++ b/src/mintdb/plugin_mintdb_common.c
@@ -107,10 +107,6 @@ common_free_coin_transaction_list (void *cls,
case TALER_MINTDB_TT_REFRESH_MELT:
GNUNET_free (list->details.melt);
break;
- case TALER_MINTDB_TT_LOCK:
- GNUNET_free (list->details.lock);
- /* FIXME: look at this again once locking is implemented (#3625) */
- break;
}
GNUNET_free (list);
list = next;
@@ -131,19 +127,34 @@ common_free_melt_commitment (void *cls,
unsigned int i;
unsigned int k;
- GNUNET_free (mc->melts);
- for (i=0;i<mc->num_newcoins;i++)
- GNUNET_CRYPTO_rsa_public_key_free (mc->denom_pubs[i].rsa_public_key);
- GNUNET_free (mc->denom_pubs);
- for (k=0;k<TALER_CNC_KAPPA;k++)
+ if (NULL != mc->melts)
+ {
+ for (i=0;i<mc->num_oldcoins;i++)
+ {
+ GNUNET_CRYPTO_rsa_signature_free (mc->melts[i].coin.denom_sig.rsa_signature);
+ GNUNET_CRYPTO_rsa_public_key_free (mc->melts[i].coin.denom_pub.rsa_public_key);
+ }
+ GNUNET_free (mc->melts);
+ }
+ if (NULL != mc->denom_pubs)
{
for (i=0;i<mc->num_newcoins;i++)
+ if (NULL != mc->denom_pubs[i].rsa_public_key)
+ GNUNET_CRYPTO_rsa_public_key_free (mc->denom_pubs[i].rsa_public_key);
+ GNUNET_free (mc->denom_pubs);
+ }
+ for (k=0;k<TALER_CNC_KAPPA;k++)
+ {
+ if (NULL != mc->commit_coins[k])
{
- GNUNET_free (mc->commit_coins[k][i].refresh_link);
- GNUNET_free (mc->commit_coins[k][i].coin_ev);
+ for (i=0;i<mc->num_newcoins;i++)
+ {
+ GNUNET_free (mc->commit_coins[k][i].refresh_link);
+ GNUNET_free (mc->commit_coins[k][i].coin_ev);
+ }
+ GNUNET_free (mc->commit_coins[k]);
}
- GNUNET_free (mc->commit_coins[k]);
- GNUNET_free (mc->commit_links[k]);
+ GNUNET_free_non_null (mc->commit_links[k]);
}
GNUNET_free (mc);
}
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c
index 6e26c82e..1347875e 100644
--- a/src/mintdb/plugin_mintdb_postgres.c
+++ b/src/mintdb/plugin_mintdb_postgres.c
@@ -424,15 +424,10 @@ postgres_create_tables (void *cls,
",ev_sig BYTEA NOT NULL"
")");
/* This table contains the wire transfers the mint is supposed to
- execute to transmit funds to the merchants (and manage refunds).
- TODO: we might want to generate some other primary key
- to internally identify outgoing transactions, as "coin_pub"
- may not be unique if a wallet chooses not to refresh. The
- resulting transaction ID should then be returned to the merchant
- and could be used by the mearchant for further inquriries about
- the deposit's execution. (#3816); */
+ execute to transmit funds to the merchants (and manage refunds). */
SQLEXEC("CREATE TABLE IF NOT EXISTS deposits "
- "(coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
+ "(serial_id BIGSERIAL"
+ ",coin_pub BYTEA NOT NULL CHECK (LENGTH(coin_pub)=32)"
",denom_pub BYTEA NOT NULL REFERENCES denominations (pub)"
",denom_sig BYTEA NOT NULL"
",transaction_id INT8 NOT NULL"
@@ -598,7 +593,7 @@ postgres_prepare (PGconn *db_conn)
1, NULL);
/* Used in #postgres_insert_withdraw_info() to store
the signature of a blinded coin with the blinded coin's
- details before returning it during /withdraw/sign. We store
+ details before returning it during /reserve/withdraw. We store
the coin's denomination information (public key, signature)
and the blinded message as well as the reserve that the coin
is being withdrawn from and the signature of the message
@@ -621,9 +616,9 @@ postgres_prepare (PGconn *db_conn)
"($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);",
12, NULL);
/* Used in #postgres_get_withdraw_info() to
- locate the response for a /withdraw/sign request
+ locate the response for a /reserve/withdraw request
using the hash of the blinded message. Used to
- make sure /withdraw/sign requests are idempotent. */
+ make sure /reserve/withdraw requests are idempotent. */
PREPARE ("get_withdraw_info",
"SELECT"
" denom_pub"
@@ -641,7 +636,7 @@ postgres_prepare (PGconn *db_conn)
" WHERE h_blind_ev=$1",
1, NULL);
/* Used during #postgres_get_reserve_history() to
- obtain all of the /withdraw/sign operations that
+ obtain all of the /reserve/withdraw operations that
have been performed on a given reserve. (i.e. to
demonstrate double-spending) */
PREPARE ("get_reserves_out",
@@ -853,6 +848,25 @@ postgres_prepare (PGconn *db_conn)
" (merchant_pub=$3)"
" )",
3, NULL);
+
+ /* Used in #postgres_iterate_deposits() */
+ PREPARE ("deposits_iterate",
+ "SELECT"
+ " serial_id"
+ ",amount_with_fee_val"
+ ",amount_with_fee_frac"
+ ",amount_with_fee_curr"
+ ",deposit_fee_val"
+ ",deposit_fee_frac"
+ ",deposit_fee_curr"
+ ",transaction_id"
+ ",h_contract"
+ ",wire"
+ " FROM deposits"
+ " WHERE serial_id>=$1"
+ " ORDER BY serial_id ASC"
+ " LIMIT $2;",
+ 2, NULL);
/* Used in #postgres_get_coin_transactions() to obtain information
about how a coin has been spend with /deposit requests. */
PREPARE ("get_deposit_with_coin_pub",
@@ -976,7 +990,7 @@ postgres_get_session (void *cls,
PQstatus (db_conn))
{
TALER_LOG_ERROR ("Database connection failed: %s\n",
- PQerrorMessage (db_conn));
+ PQerrorMessage (db_conn));
GNUNET_break (0);
return NULL;
}
@@ -1081,7 +1095,31 @@ postgres_commit (void *cls,
if (PGRES_COMMAND_OK !=
PQresultStatus (result))
{
- GNUNET_break (0);
+ const char *sqlstate;
+
+ sqlstate = PQresultErrorField (result,
+ PG_DIAG_SQLSTATE);
+ if (NULL == sqlstate)
+ {
+ /* very unexpected... */
+ GNUNET_break (0);
+ PQclear (result);
+ return GNUNET_SYSERR;
+ }
+ /* 40P01: deadlock, 40001: serialization failure */
+ if ( (0 == strcmp (sqlstate,
+ "40P01")) ||
+ (0 == strcmp (sqlstate,
+ "40001")) )
+ {
+ /* These two can be retried and have a fair chance of working
+ the next time */
+ PQclear (result);
+ return GNUNET_NO;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Database commit failure: %s\n",
+ sqlstate);
PQclear (result);
return GNUNET_SYSERR;
}
@@ -1488,7 +1526,7 @@ postgres_reserves_in_insert (void *cls,
/**
- * Locate the response for a /withdraw/sign request under the
+ * Locate the response for a /reserve/withdraw request under the
* key of the hash of the blinded message.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
@@ -1882,6 +1920,119 @@ postgres_have_deposit (void *cls,
/**
+ * Obtain information about deposits. Iterates over all deposits
+ * above a certain ID. Use a @a min_id of 0 to start at the beginning.
+ * This operation is executed in its own transaction in transaction
+ * mode "REPEATABLE READ", i.e. we should only see valid deposits.
+ *
+ * @param cls the @e cls of this struct with the plugin-specific state
+ * @param session connection to the database
+ * @param min_id deposit to start at
+ * @param limit maximum number of transactions to fetch
+ * @param deposit_cb function to call for each deposit
+ * @param deposit_cb_cls closure for @a deposit_cb
+ * @return number of rows processed, 0 if none exist,
+ * #GNUNET_SYSERR on error
+ */
+static int
+postgres_iterate_deposits (void *cls,
+ struct TALER_MINTDB_Session *session,
+ uint64_t min_id,
+ uint32_t limit,
+ TALER_MINTDB_DepositIterator deposit_cb,
+ void *deposit_cb_cls)
+{
+ struct TALER_PQ_QueryParam params[] = {
+ TALER_PQ_query_param_uint64 (&min_id),
+ TALER_PQ_query_param_uint32 (&limit),
+ TALER_PQ_query_param_end
+ };
+ PGresult *result;
+ unsigned int i;
+ unsigned int n;
+
+ if (GNUNET_OK !=
+ postgres_start (cls, session))
+ return GNUNET_SYSERR;
+ result = PQexec (session->conn,
+ "SET TRANSACTION REPEATABLE READ");
+ if (PGRES_COMMAND_OK !=
+ PQresultStatus (result))
+ {
+ TALER_LOG_ERROR ("Failed to set transaction to REPEATABL EREAD: %s\n",
+ PQresultErrorMessage (result));
+ GNUNET_break (0);
+ PQclear (result);
+ return GNUNET_SYSERR;
+ }
+
+ result = TALER_PQ_exec_prepared (session->conn,
+ "deposits_iterate",
+ params);
+ if (PGRES_TUPLES_OK !=
+ PQresultStatus (result))
+ {
+ BREAK_DB_ERR (result);
+ PQclear (result);
+ postgres_rollback (cls, session);
+ return GNUNET_SYSERR;
+ }
+ if (0 == (n = PQntuples (result)))
+ {
+ PQclear (result);
+ postgres_rollback (cls, session);
+ return 0;
+ }
+ for (i=0;i<n;i++)
+ {
+ struct TALER_Amount amount_with_fee;
+ struct TALER_Amount deposit_fee;
+ struct GNUNET_HashCode h_contract;
+ json_t *wire;
+ uint64_t transaction_id;
+ uint64_t id;
+ int ret;
+ struct TALER_PQ_ResultSpec rs[] = {
+ TALER_PQ_result_spec_uint64 ("id",
+ &id),
+ TALER_PQ_result_spec_uint64 ("transaction_id",
+ &transaction_id),
+ TALER_PQ_result_spec_amount ("amount_with_fee",
+ &amount_with_fee),
+ TALER_PQ_result_spec_amount ("deposit_fee",
+ &deposit_fee),
+ TALER_PQ_result_spec_auto_from_type ("h_contract",
+ &h_contract),
+ TALER_PQ_result_spec_json ("wire",
+ &wire),
+ TALER_PQ_result_spec_end
+ };
+ if (GNUNET_OK !=
+ TALER_PQ_extract_result (result, rs, i))
+ {
+ GNUNET_break (0);
+ PQclear (result);
+ postgres_rollback (cls, session);
+ return GNUNET_SYSERR;
+ }
+ ret = deposit_cb (deposit_cb_cls,
+ id,
+ &amount_with_fee,
+ &deposit_fee,
+ transaction_id,
+ &h_contract,
+ wire);
+ TALER_PQ_cleanup_result (rs);
+ PQclear (result);
+ if (GNUNET_OK != ret)
+ break;
+ }
+ postgres_rollback (cls, session);
+ return i;
+}
+
+
+/**
* Insert information about deposited coin into the database.
*
* @param cls the `struct PostgresClosure` with the plugin-specific state
@@ -2122,12 +2273,15 @@ get_known_coin (void *cls,
return GNUNET_YES;
{
struct TALER_PQ_ResultSpec rs[] = {
- TALER_PQ_result_spec_rsa_public_key ("denom_pub", &coin_info->denom_pub.rsa_public_key),
- TALER_PQ_result_spec_rsa_signature ("denom_sig", &coin_info->denom_sig.rsa_signature),
+ TALER_PQ_result_spec_rsa_public_key ("denom_pub",
+ &coin_info->denom_pub.rsa_public_key),
+ TALER_PQ_result_spec_rsa_signature ("denom_sig",
+ &coin_info->denom_sig.rsa_signature),
TALER_PQ_result_spec_end
};
- if (GNUNET_OK != TALER_PQ_extract_result (result, rs, 0))
+ if (GNUNET_OK !=
+ TALER_PQ_extract_result (result, rs, 0))
{
PQclear (result);
GNUNET_break (0);
@@ -2277,7 +2431,11 @@ postgres_get_refresh_melt (void *cls,
&coin))
return GNUNET_SYSERR;
if (NULL == melt)
+ {
+ GNUNET_CRYPTO_rsa_signature_free (coin.denom_sig.rsa_signature);
+ GNUNET_CRYPTO_rsa_public_key_free (coin.denom_pub.rsa_public_key);
return GNUNET_OK;
+ }
melt->coin = coin;
melt->coin_sig = coin_sig;
melt->session_hash = *session_hash;
@@ -2666,7 +2824,7 @@ postgres_insert_refresh_commit_links (void *cls,
PQclear (result);
return GNUNET_SYSERR;
}
-
+
if (0 != strcmp ("1", PQcmdTuples (result)))
{
GNUNET_break (0);
@@ -2734,7 +2892,7 @@ postgres_get_refresh_commit_links (void *cls,
&links[i].shared_secret_enc),
TALER_PQ_result_spec_end
};
-
+
if (GNUNET_YES !=
TALER_PQ_extract_result (result, rs, 0))
{
@@ -2823,28 +2981,7 @@ postgres_get_melt_commitment (void *cls,
return mc;
cleanup:
- GNUNET_free_non_null (mc->melts);
- if (NULL != mc->denom_pubs)
- {
- for (i=0;i<(unsigned int) mc->num_newcoins;i++)
- if (NULL != mc->denom_pubs[i].rsa_public_key)
- GNUNET_CRYPTO_rsa_public_key_free (mc->denom_pubs[i].rsa_public_key);
- GNUNET_free (mc->denom_pubs);
- }
- for (cnc_index=0;cnc_index<TALER_CNC_KAPPA;cnc_index++)
- {
- if (NULL != mc->commit_coins[cnc_index])
- {
- for (i=0;i<(unsigned int) mc->num_newcoins;i++)
- {
- GNUNET_free_non_null (mc->commit_coins[cnc_index][i].refresh_link);
- GNUNET_free_non_null (mc->commit_coins[cnc_index][i].coin_ev);
- }
- GNUNET_free (mc->commit_coins[cnc_index]);
- }
- GNUNET_free_non_null (mc->commit_links[cnc_index]);
- }
- GNUNET_free (mc);
+ common_free_melt_commitment (cls, mc);
return NULL;
}
@@ -3267,6 +3404,7 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
plugin->get_reserve_history = &postgres_get_reserve_history;
plugin->free_reserve_history = &common_free_reserve_history;
plugin->have_deposit = &postgres_have_deposit;
+ plugin->iterate_deposits = &postgres_iterate_deposits;
plugin->insert_deposit = &postgres_insert_deposit;
plugin->get_refresh_session = &postgres_get_refresh_session;
@@ -3286,8 +3424,6 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
plugin->get_link_data_list = &postgres_get_link_data_list;
plugin->free_link_data_list = &common_free_link_data_list;
plugin->get_transfer = &postgres_get_transfer;
- // plugin->have_lock = &postgres_have_lock; /* #3625 */
- // plugin->insert_lock = &postgres_insert_lock; /* #3625 */
plugin->get_coin_transactions = &postgres_get_coin_transactions;
plugin->free_coin_transaction_list = &common_free_coin_transaction_list;
return plugin;