aboutsummaryrefslogtreecommitdiff
path: root/src/mint/mint_db.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mint/mint_db.c')
-rw-r--r--src/mint/mint_db.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c
index f6fff7e5c..4c836bf92 100644
--- a/src/mint/mint_db.c
+++ b/src/mint/mint_db.c
@@ -1840,17 +1840,21 @@ TALER_MINT_DB_insert_deposit (PGconn *db_conn,
1840 const struct Deposit *deposit) 1840 const struct Deposit *deposit)
1841{ 1841{
1842 struct TALER_DB_QueryParam params[]= { 1842 struct TALER_DB_QueryParam params[]= {
1843 TALER_DB_QUERY_PARAM_PTR (&deposit->coin_pub), 1843 TALER_DB_QUERY_PARAM_PTR (&deposit->coin.coin_pub),
1844 TALER_DB_QUERY_PARAM_PTR (&deposit->denom_pub), 1844 TALER_DB_QUERY_PARAM_PTR (&deposit->coin.denom_pub), // FIXME!
1845 TALER_DB_QUERY_PARAM_PTR (&deposit->coin.denom_sig), // FIXME!
1845 TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id), 1846 TALER_DB_QUERY_PARAM_PTR (&deposit->transaction_id),
1847 TALER_DB_QUERY_PARAM_PTR (&deposit->purpose), // FIXME: enum Ok here?
1846 TALER_DB_QUERY_PARAM_PTR (&deposit->amount.value), 1848 TALER_DB_QUERY_PARAM_PTR (&deposit->amount.value),
1847 TALER_DB_QUERY_PARAM_PTR (&deposit->amount.fraction), 1849 TALER_DB_QUERY_PARAM_PTR (&deposit->amount.fraction),
1848 TALER_DB_QUERY_PARAM_PTR_SIZED (deposit->amount.currency, strlen (deposit->amount.currency)), 1850 TALER_DB_QUERY_PARAM_PTR_SIZED (deposit->amount.currency,
1851 strlen (deposit->amount.currency)),
1849 TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub), 1852 TALER_DB_QUERY_PARAM_PTR (&deposit->merchant_pub),
1850 TALER_DB_QUERY_PARAM_PTR (&deposit->h_contract), 1853 TALER_DB_QUERY_PARAM_PTR (&deposit->h_contract),
1851 TALER_DB_QUERY_PARAM_PTR (&deposit->h_wire), 1854 TALER_DB_QUERY_PARAM_PTR (&deposit->h_wire),
1852 TALER_DB_QUERY_PARAM_PTR (&deposit->coin_sig), 1855 TALER_DB_QUERY_PARAM_PTR (&deposit->csig),
1853 TALER_DB_QUERY_PARAM_PTR_SIZED (deposit->wire, strlen(deposit->wire)), 1856 TALER_DB_QUERY_PARAM_PTR_SIZED (deposit->wire,
1857 strlen ("FIXME")), // FIXME! json!
1854 TALER_DB_QUERY_PARAM_END 1858 TALER_DB_QUERY_PARAM_END
1855 }; 1859 };
1856 PGresult *result; 1860 PGresult *result;
@@ -1869,18 +1873,19 @@ TALER_MINT_DB_insert_deposit (PGconn *db_conn,
1869 1873
1870int 1874int
1871TALER_MINT_DB_get_deposit (PGconn *db_conn, 1875TALER_MINT_DB_get_deposit (PGconn *db_conn,
1872 const struct GNUNET_CRYPTO_EddsaPublicKey *coin_pub, 1876 const struct GNUNET_CRYPTO_EcdsaPublicKey *coin_pub,
1873 struct Deposit **r_deposit) 1877 struct Deposit *deposit)
1874{ 1878{
1875 struct TALER_DB_QueryParam params[] = { 1879 struct TALER_DB_QueryParam params[] = {
1876 TALER_DB_QUERY_PARAM_PTR (coin_pub), 1880 TALER_DB_QUERY_PARAM_PTR (coin_pub),
1877 TALER_DB_QUERY_PARAM_END 1881 TALER_DB_QUERY_PARAM_END
1878 }; 1882 };
1879 PGresult *result; 1883 PGresult *result;
1880 struct Deposit *deposit;
1881 1884
1882 deposit = NULL; 1885 memset (deposit, 0, sizeof (struct Deposit));
1883 result = TALER_DB_exec_prepared (db_conn, "get_deposit", params); 1886 result = TALER_DB_exec_prepared (db_conn,
1887 "get_deposit",
1888 params);
1884 if (PGRES_TUPLES_OK != PQresultStatus (result)) 1889 if (PGRES_TUPLES_OK != PQresultStatus (result))
1885 { 1890 {
1886 break_db_err (result); 1891 break_db_err (result);
@@ -1900,19 +1905,21 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn,
1900 } 1905 }
1901 1906
1902 { 1907 {
1903 deposit = GNUNET_malloc (sizeof (struct Deposit)); /* Without wire data */ 1908 char *denom_sig_buf;
1904 char *sig_buf; 1909 size_t denom_sig_buf_size;
1905 size_t sig_buf_size;
1906 char *dk_buf; 1910 char *dk_buf;
1907 size_t dk_buf_size; 1911 size_t dk_buf_size;
1912
1908 struct TALER_DB_ResultSpec rs[] = { 1913 struct TALER_DB_ResultSpec rs[] = {
1909 TALER_DB_RESULT_SPEC ("coin_pub", &deposit->coin_pub), 1914 TALER_DB_RESULT_SPEC ("coin_pub", &deposit->coin.coin_pub),
1910 TALER_DB_RESULT_SPEC_VAR ("denom_pub", &dk_buf, &dk_buf_size), 1915 TALER_DB_RESULT_SPEC_VAR ("denom_pub", &dk_buf, &dk_buf_size),
1911 TALER_DB_RESULT_SPEC_VAR ("coin_sig", &sig_buf, &sig_buf_size), 1916 TALER_DB_RESULT_SPEC_VAR ("denom_sig", &denom_sig_buf, &denom_sig_buf_size),
1912 TALER_DB_RESULT_SPEC ("transaction_id", &deposit->transaction_id), 1917 TALER_DB_RESULT_SPEC ("transaction_id", &deposit->transaction_id),
1913 TALER_DB_RESULT_SPEC ("merchant_pub", &deposit->merchant_pub), 1918 TALER_DB_RESULT_SPEC ("merchant_pub", &deposit->merchant_pub),
1914 TALER_DB_RESULT_SPEC ("h_contract", &deposit->h_contract), 1919 TALER_DB_RESULT_SPEC ("h_contract", &deposit->h_contract),
1915 TALER_DB_RESULT_SPEC ("h_wire", &deposit->h_wire), 1920 TALER_DB_RESULT_SPEC ("h_wire", &deposit->h_wire),
1921 TALER_DB_RESULT_SPEC ("purpose", &deposit->purpose),
1922 // FIXME: many fields missing...
1916 TALER_DB_RESULT_SPEC_END 1923 TALER_DB_RESULT_SPEC_END
1917 }; 1924 };
1918 EXITIF (GNUNET_OK != 1925 EXITIF (GNUNET_OK !=
@@ -1923,15 +1930,15 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn,
1923 "amount_fraction", 1930 "amount_fraction",
1924 "amount_currency", 1931 "amount_currency",
1925 &deposit->amount)); 1932 &deposit->amount));
1926 deposit->coin_sig = GNUNET_CRYPTO_rsa_signature_decode (sig_buf, 1933 deposit->coin.denom_sig
1927 sig_buf_size); 1934 = GNUNET_CRYPTO_rsa_signature_decode (denom_sig_buf,
1928 deposit->denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (dk_buf, 1935 denom_sig_buf_size);
1929 dk_buf_size); 1936 deposit->coin.denom_pub
1930 // deposit->purpose = htonl (TALER_SIGNATURE_DEPOSIT); // FIXME: struct Deposit not nice 1937 = GNUNET_CRYPTO_rsa_public_key_decode (dk_buf,
1938 dk_buf_size);
1931 } 1939 }
1932 1940
1933 PQclear (result); 1941 PQclear (result);
1934 *r_deposit = deposit;
1935 return GNUNET_OK; 1942 return GNUNET_OK;
1936 1943
1937EXITIF_exit: 1944EXITIF_exit: