diff options
Diffstat (limited to 'src/mint/mint_db.c')
-rw-r--r-- | src/mint/mint_db.c | 228 |
1 files changed, 153 insertions, 75 deletions
diff --git a/src/mint/mint_db.c b/src/mint/mint_db.c index 60ad14493..eb83e61a9 100644 --- a/src/mint/mint_db.c +++ b/src/mint/mint_db.c | |||
@@ -754,7 +754,9 @@ TALER_MINT_DB_transaction (PGconn *db_conn) | |||
754 | result = PQexec(db_conn, "BEGIN"); | 754 | result = PQexec(db_conn, "BEGIN"); |
755 | if (PGRES_COMMAND_OK != PQresultStatus (result)) | 755 | if (PGRES_COMMAND_OK != PQresultStatus (result)) |
756 | { | 756 | { |
757 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Can't start transaction: %s\n", PQresultErrorMessage (result)); | 757 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
758 | "Can't start transaction: %s\n", | ||
759 | PQresultErrorMessage (result)); | ||
758 | PQclear (result); | 760 | PQclear (result); |
759 | GNUNET_break (0); | 761 | GNUNET_break (0); |
760 | return GNUNET_SYSERR; | 762 | return GNUNET_SYSERR; |
@@ -775,28 +777,36 @@ TALER_MINT_DB_insert_refresh_order (PGconn *db_conn, | |||
775 | const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub) | 777 | const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub) |
776 | { | 778 | { |
777 | uint16_t newcoin_index_nbo = htons (newcoin_index); | 779 | uint16_t newcoin_index_nbo = htons (newcoin_index); |
778 | struct TALER_DB_QueryParam params[] = { | 780 | char *buf; |
779 | TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), | 781 | size_t buf_size; |
780 | TALER_DB_QUERY_PARAM_PTR(session_pub), | 782 | PGresult *result; |
781 | TALER_DB_QUERY_PARAM_PTR(denom_pub), | ||
782 | TALER_DB_QUERY_PARAM_END | ||
783 | }; | ||
784 | 783 | ||
785 | PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_refresh_order", params); | 784 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pub, |
785 | &buf); | ||
786 | 786 | ||
787 | { | ||
788 | struct TALER_DB_QueryParam params[] = { | ||
789 | TALER_DB_QUERY_PARAM_PTR (&newcoin_index_nbo), | ||
790 | TALER_DB_QUERY_PARAM_PTR (session_pub), | ||
791 | TALER_DB_QUERY_PARAM_PTR_SIZED (buf, buf_size), | ||
792 | TALER_DB_QUERY_PARAM_END | ||
793 | }; | ||
794 | result = TALER_DB_exec_prepared (db_conn, | ||
795 | "insert_refresh_order", | ||
796 | params); | ||
797 | } | ||
798 | GNUNET_free (buf); | ||
787 | if (PGRES_COMMAND_OK != PQresultStatus (result)) | 799 | if (PGRES_COMMAND_OK != PQresultStatus (result)) |
788 | { | 800 | { |
789 | break_db_err (result); | 801 | break_db_err (result); |
790 | PQclear (result); | 802 | PQclear (result); |
791 | return GNUNET_SYSERR; | 803 | return GNUNET_SYSERR; |
792 | } | 804 | } |
793 | |||
794 | if (0 != strcmp ("1", PQcmdTuples (result))) | 805 | if (0 != strcmp ("1", PQcmdTuples (result))) |
795 | { | 806 | { |
796 | GNUNET_break (0); | 807 | GNUNET_break (0); |
797 | return GNUNET_SYSERR; | 808 | return GNUNET_SYSERR; |
798 | } | 809 | } |
799 | |||
800 | PQclear (result); | 810 | PQclear (result); |
801 | return GNUNET_OK; | 811 | return GNUNET_OK; |
802 | } | 812 | } |
@@ -817,7 +827,9 @@ TALER_MINT_DB_get_refresh_session (PGconn *db_conn, | |||
817 | 827 | ||
818 | if (PGRES_TUPLES_OK != PQresultStatus (result)) | 828 | if (PGRES_TUPLES_OK != PQresultStatus (result)) |
819 | { | 829 | { |
820 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Query failed: %s\n", PQresultErrorMessage (result)); | 830 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
831 | "Query failed: %s\n", | ||
832 | PQresultErrorMessage (result)); | ||
821 | PQclear (result); | 833 | PQclear (result); |
822 | return GNUNET_SYSERR; | 834 | return GNUNET_SYSERR; |
823 | } | 835 | } |
@@ -885,7 +897,9 @@ TALER_MINT_DB_get_known_coin (PGconn *db_conn, | |||
885 | 897 | ||
886 | if (PGRES_TUPLES_OK != PQresultStatus (result)) | 898 | if (PGRES_TUPLES_OK != PQresultStatus (result)) |
887 | { | 899 | { |
888 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Query failed: %s\n", PQresultErrorMessage (result)); | 900 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
901 | "Query failed: %s\n", | ||
902 | PQresultErrorMessage (result)); | ||
889 | PQclear (result); | 903 | PQclear (result); |
890 | return GNUNET_SYSERR; | 904 | return GNUNET_SYSERR; |
891 | } | 905 | } |
@@ -915,11 +929,13 @@ TALER_MINT_DB_get_known_coin (PGconn *db_conn, | |||
915 | 929 | ||
916 | /* extract the expended amount of the coin */ | 930 | /* extract the expended amount of the coin */ |
917 | 931 | ||
918 | if (GNUNET_OK != TALER_DB_extract_amount (result, 0, | 932 | if (GNUNET_OK != |
919 | "expended_value", | 933 | TALER_DB_extract_amount (result, |
920 | "expended_fraction", | 934 | 0, |
921 | "expended_currency", | 935 | "expended_value", |
922 | &known_coin->expended_balance)) | 936 | "expended_fraction", |
937 | "expended_currency", | ||
938 | &known_coin->expended_balance)) | ||
923 | { | 939 | { |
924 | GNUNET_break (0); | 940 | GNUNET_break (0); |
925 | PQclear (result); | 941 | PQclear (result); |
@@ -943,7 +959,9 @@ TALER_MINT_DB_get_known_coin (PGconn *db_conn, | |||
943 | if (GNUNET_NO == res) | 959 | if (GNUNET_NO == res) |
944 | { | 960 | { |
945 | known_coin->is_refreshed = GNUNET_NO; | 961 | known_coin->is_refreshed = GNUNET_NO; |
946 | memset (&known_coin->refresh_session_pub, 0, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); | 962 | memset (&known_coin->refresh_session_pub, |
963 | 0, | ||
964 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); | ||
947 | } | 965 | } |
948 | else | 966 | else |
949 | { | 967 | { |
@@ -1201,7 +1219,8 @@ TALER_MINT_DB_insert_refresh_commit_coin (PGconn *db_conn, | |||
1201 | int | 1219 | int |
1202 | TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn, | 1220 | TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn, |
1203 | const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, | 1221 | const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, |
1204 | int cnc_index, int oldcoin_index, | 1222 | int cnc_index, |
1223 | int oldcoin_index, | ||
1205 | struct RefreshCommitLink *cc) | 1224 | struct RefreshCommitLink *cc) |
1206 | { | 1225 | { |
1207 | uint16_t cnc_index_nbo = htons (cnc_index); | 1226 | uint16_t cnc_index_nbo = htons (cnc_index); |
@@ -1255,7 +1274,8 @@ TALER_MINT_DB_get_refresh_commit_link (PGconn *db_conn, | |||
1255 | int | 1274 | int |
1256 | TALER_MINT_DB_get_refresh_commit_coin (PGconn *db_conn, | 1275 | TALER_MINT_DB_get_refresh_commit_coin (PGconn *db_conn, |
1257 | const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, | 1276 | const struct GNUNET_CRYPTO_EddsaPublicKey *refresh_session_pub, |
1258 | int cnc_index, int newcoin_index, | 1277 | int cnc_index, |
1278 | int newcoin_index, | ||
1259 | struct RefreshCommitCoin *cc) | 1279 | struct RefreshCommitCoin *cc) |
1260 | { | 1280 | { |
1261 | uint16_t cnc_index_nbo = htons (cnc_index); | 1281 | uint16_t cnc_index_nbo = htons (cnc_index); |
@@ -1305,12 +1325,15 @@ TALER_MINT_DB_get_refresh_commit_coin (PGconn *db_conn, | |||
1305 | } | 1325 | } |
1306 | 1326 | ||
1307 | 1327 | ||
1308 | int | 1328 | struct GNUNET_CRYPTO_rsa_PublicKey * |
1309 | TALER_MINT_DB_get_refresh_order (PGconn *db_conn, | 1329 | TALER_MINT_DB_get_refresh_order (PGconn *db_conn, |
1310 | uint16_t newcoin_index, | 1330 | uint16_t newcoin_index, |
1311 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, | 1331 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub) |
1312 | struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub) | 1332 | |
1313 | { | 1333 | { |
1334 | char *buf; | ||
1335 | size_t buf_size; | ||
1336 | struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; | ||
1314 | uint16_t newcoin_index_nbo = htons (newcoin_index); | 1337 | uint16_t newcoin_index_nbo = htons (newcoin_index); |
1315 | 1338 | ||
1316 | struct TALER_DB_QueryParam params[] = { | 1339 | struct TALER_DB_QueryParam params[] = { |
@@ -1325,31 +1348,30 @@ TALER_MINT_DB_get_refresh_order (PGconn *db_conn, | |||
1325 | { | 1348 | { |
1326 | break_db_err (result); | 1349 | break_db_err (result); |
1327 | PQclear (result); | 1350 | PQclear (result); |
1328 | return GNUNET_SYSERR; | 1351 | return NULL; |
1329 | } | 1352 | } |
1330 | 1353 | ||
1331 | if (0 == PQntuples (result)) | 1354 | if (0 == PQntuples (result)) |
1332 | { | 1355 | { |
1333 | PQclear (result); | 1356 | PQclear (result); |
1334 | return GNUNET_NO; | 1357 | /* FIXME: may want to distinguish between different error cases! */ |
1358 | return NULL; | ||
1335 | } | 1359 | } |
1336 | |||
1337 | GNUNET_assert (1 == PQntuples (result)); | 1360 | GNUNET_assert (1 == PQntuples (result)); |
1338 | |||
1339 | struct TALER_DB_ResultSpec rs[] = { | 1361 | struct TALER_DB_ResultSpec rs[] = { |
1340 | TALER_DB_RESULT_SPEC("denom_pub", denom_pub), | 1362 | TALER_DB_RESULT_SPEC_VAR ("denom_pub", &buf, &buf_size), |
1341 | TALER_DB_RESULT_SPEC_END | 1363 | TALER_DB_RESULT_SPEC_END |
1342 | }; | 1364 | }; |
1343 | |||
1344 | if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)) | 1365 | if (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)) |
1345 | { | 1366 | { |
1346 | PQclear (result); | 1367 | PQclear (result); |
1347 | GNUNET_break (0); | 1368 | GNUNET_break (0); |
1348 | return GNUNET_SYSERR; | 1369 | return NULL; |
1349 | } | 1370 | } |
1350 | |||
1351 | PQclear (result); | 1371 | PQclear (result); |
1352 | return GNUNET_OK; | 1372 | denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (buf, buf_size); |
1373 | GNUNET_free (buf); | ||
1374 | return denom_pub; | ||
1353 | } | 1375 | } |
1354 | 1376 | ||
1355 | 1377 | ||
@@ -1360,34 +1382,43 @@ TALER_MINT_DB_insert_refresh_collectable (PGconn *db_conn, | |||
1360 | const struct GNUNET_CRYPTO_rsa_Signature *ev_sig) | 1382 | const struct GNUNET_CRYPTO_rsa_Signature *ev_sig) |
1361 | { | 1383 | { |
1362 | uint16_t newcoin_index_nbo = htons (newcoin_index); | 1384 | uint16_t newcoin_index_nbo = htons (newcoin_index); |
1363 | struct TALER_DB_QueryParam params[] = { | 1385 | char *buf; |
1364 | TALER_DB_QUERY_PARAM_PTR(session_pub), | 1386 | size_t buf_size; |
1365 | TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), | 1387 | PGresult *result; |
1366 | TALER_DB_QUERY_PARAM_PTR(ev_sig), | ||
1367 | TALER_DB_QUERY_PARAM_END | ||
1368 | }; | ||
1369 | |||
1370 | PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_refresh_collectable", params); | ||
1371 | 1388 | ||
1389 | buf_size = GNUNET_CRYPTO_rsa_signature_encode (ev_sig, | ||
1390 | &buf); | ||
1391 | { | ||
1392 | struct TALER_DB_QueryParam params[] = { | ||
1393 | TALER_DB_QUERY_PARAM_PTR(session_pub), | ||
1394 | TALER_DB_QUERY_PARAM_PTR(&newcoin_index_nbo), | ||
1395 | TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size), | ||
1396 | TALER_DB_QUERY_PARAM_END | ||
1397 | }; | ||
1398 | result = TALER_DB_exec_prepared (db_conn, | ||
1399 | "insert_refresh_collectable", | ||
1400 | params); | ||
1401 | } | ||
1402 | GNUNET_free (buf); | ||
1372 | if (PGRES_COMMAND_OK != PQresultStatus (result)) | 1403 | if (PGRES_COMMAND_OK != PQresultStatus (result)) |
1373 | { | 1404 | { |
1374 | break_db_err (result); | 1405 | break_db_err (result); |
1375 | PQclear (result); | 1406 | PQclear (result); |
1376 | return GNUNET_SYSERR; | 1407 | return GNUNET_SYSERR; |
1377 | } | 1408 | } |
1378 | |||
1379 | PQclear (result); | 1409 | PQclear (result); |
1380 | return GNUNET_OK; | 1410 | return GNUNET_OK; |
1381 | } | 1411 | } |
1382 | 1412 | ||
1383 | 1413 | ||
1384 | int | 1414 | struct GNUNET_CRYPTO_rsa_Signature * |
1385 | TALER_MINT_DB_get_refresh_collectable (PGconn *db_conn, | 1415 | TALER_MINT_DB_get_refresh_collectable (PGconn *db_conn, |
1386 | uint16_t newcoin_index, | 1416 | uint16_t newcoin_index, |
1387 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, | 1417 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub) |
1388 | struct GNUNET_CRYPTO_rsa_Signature *ev_sig) | ||
1389 | { | 1418 | { |
1390 | 1419 | struct GNUNET_CRYPTO_rsa_Signature *ev_sig; | |
1420 | char *buf; | ||
1421 | size_t buf_size; | ||
1391 | uint16_t newcoin_index_nbo = htons (newcoin_index); | 1422 | uint16_t newcoin_index_nbo = htons (newcoin_index); |
1392 | 1423 | ||
1393 | struct TALER_DB_QueryParam params[] = { | 1424 | struct TALER_DB_QueryParam params[] = { |
@@ -1402,19 +1433,20 @@ TALER_MINT_DB_get_refresh_collectable (PGconn *db_conn, | |||
1402 | { | 1433 | { |
1403 | break_db_err (result); | 1434 | break_db_err (result); |
1404 | PQclear (result); | 1435 | PQclear (result); |
1405 | return GNUNET_SYSERR; | 1436 | return NULL; |
1406 | } | 1437 | } |
1407 | 1438 | ||
1408 | if (0 == PQntuples (result)) | 1439 | if (0 == PQntuples (result)) |
1409 | { | 1440 | { |
1410 | PQclear (result); | 1441 | PQclear (result); |
1411 | return GNUNET_NO; | 1442 | /* FIXME: may want to distinguish between different error cases! */ |
1443 | return NULL; | ||
1412 | } | 1444 | } |
1413 | 1445 | ||
1414 | GNUNET_assert (1 == PQntuples (result)); | 1446 | GNUNET_assert (1 == PQntuples (result)); |
1415 | 1447 | ||
1416 | struct TALER_DB_ResultSpec rs[] = { | 1448 | struct TALER_DB_ResultSpec rs[] = { |
1417 | TALER_DB_RESULT_SPEC("ev_sig", ev_sig), | 1449 | TALER_DB_RESULT_SPEC_VAR("ev_sig", &buf, &buf_size), |
1418 | TALER_DB_RESULT_SPEC_END | 1450 | TALER_DB_RESULT_SPEC_END |
1419 | }; | 1451 | }; |
1420 | 1452 | ||
@@ -1422,11 +1454,14 @@ TALER_MINT_DB_get_refresh_collectable (PGconn *db_conn, | |||
1422 | { | 1454 | { |
1423 | PQclear (result); | 1455 | PQclear (result); |
1424 | GNUNET_break (0); | 1456 | GNUNET_break (0); |
1425 | return GNUNET_SYSERR; | 1457 | return NULL; |
1426 | } | 1458 | } |
1427 | 1459 | ||
1428 | PQclear (result); | 1460 | PQclear (result); |
1429 | return GNUNET_OK; | 1461 | ev_sig = GNUNET_CRYPTO_rsa_signature_decode (buf, |
1462 | buf_size); | ||
1463 | GNUNET_free (buf); | ||
1464 | return ev_sig; | ||
1430 | } | 1465 | } |
1431 | 1466 | ||
1432 | 1467 | ||
@@ -1439,16 +1474,23 @@ TALER_MINT_DB_insert_refresh_melt (PGconn *db_conn, | |||
1439 | const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub) | 1474 | const struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub) |
1440 | { | 1475 | { |
1441 | uint16_t oldcoin_index_nbo = htons (oldcoin_index); | 1476 | uint16_t oldcoin_index_nbo = htons (oldcoin_index); |
1442 | struct TALER_DB_QueryParam params[] = { | 1477 | char *buf; |
1443 | TALER_DB_QUERY_PARAM_PTR(session_pub), | 1478 | size_t buf_size; |
1444 | TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo), | 1479 | PGresult *result; |
1445 | TALER_DB_QUERY_PARAM_PTR(coin_pub), | ||
1446 | TALER_DB_QUERY_PARAM_PTR(denom_pub), | ||
1447 | TALER_DB_QUERY_PARAM_END | ||
1448 | }; | ||
1449 | |||
1450 | PGresult *result = TALER_DB_exec_prepared (db_conn, "insert_refresh_melt", params); | ||
1451 | 1480 | ||
1481 | buf_size = GNUNET_CRYPTO_rsa_public_key_encode (denom_pub, | ||
1482 | &buf); | ||
1483 | { | ||
1484 | struct TALER_DB_QueryParam params[] = { | ||
1485 | TALER_DB_QUERY_PARAM_PTR(session_pub), | ||
1486 | TALER_DB_QUERY_PARAM_PTR(&oldcoin_index_nbo), | ||
1487 | TALER_DB_QUERY_PARAM_PTR(coin_pub), | ||
1488 | TALER_DB_QUERY_PARAM_PTR_SIZED(buf, buf_size), | ||
1489 | TALER_DB_QUERY_PARAM_END | ||
1490 | }; | ||
1491 | result = TALER_DB_exec_prepared (db_conn, "insert_refresh_melt", params); | ||
1492 | } | ||
1493 | GNUNET_free (buf); | ||
1452 | if (PGRES_COMMAND_OK != PQresultStatus (result)) | 1494 | if (PGRES_COMMAND_OK != PQresultStatus (result)) |
1453 | { | 1495 | { |
1454 | break_db_err (result); | 1496 | break_db_err (result); |
@@ -1541,12 +1583,16 @@ TALER_db_get_link (PGconn *db_conn, | |||
1541 | for (i = 0; i < PQntuples (result); i++) | 1583 | for (i = 0; i < PQntuples (result); i++) |
1542 | { | 1584 | { |
1543 | struct LinkDataEnc link_data_enc; | 1585 | struct LinkDataEnc link_data_enc; |
1544 | struct GNUNET_CRYPTO_rsa__PublicKey *denom_pub; | 1586 | struct GNUNET_CRYPTO_rsa_PublicKey *denom_pub; |
1545 | struct GNUNET_CRYPTO_rsa_Signature *sig; | 1587 | struct GNUNET_CRYPTO_rsa_Signature *sig; |
1588 | char *pk_buf; | ||
1589 | size_t pk_buf_size; | ||
1590 | char *sig_buf; | ||
1591 | size_t sig_buf_size; | ||
1546 | struct TALER_DB_ResultSpec rs[] = { | 1592 | struct TALER_DB_ResultSpec rs[] = { |
1547 | TALER_DB_RESULT_SPEC("link_vector_enc", &link_data_enc), | 1593 | TALER_DB_RESULT_SPEC("link_vector_enc", &link_data_enc), |
1548 | TALER_DB_RESULT_SPEC("denom_pub", &denom_pub), | 1594 | TALER_DB_RESULT_SPEC_VAR("denom_pub", &pk_buf, &pk_buf_size), |
1549 | TALER_DB_RESULT_SPEC("ev_sig", &ev_sig), | 1595 | TALER_DB_RESULT_SPEC_VAR("ev_sig", &sig_buf, &sig_buf_size), |
1550 | TALER_DB_RESULT_SPEC_END | 1596 | TALER_DB_RESULT_SPEC_END |
1551 | }; | 1597 | }; |
1552 | 1598 | ||
@@ -1556,13 +1602,36 @@ TALER_db_get_link (PGconn *db_conn, | |||
1556 | GNUNET_break (0); | 1602 | GNUNET_break (0); |
1557 | return GNUNET_SYSERR; | 1603 | return GNUNET_SYSERR; |
1558 | } | 1604 | } |
1559 | 1605 | sig = GNUNET_CRYPTO_rsa_signature_decode (sig_buf, | |
1560 | if (GNUNET_OK != (res = link_iter (cls, &link_data_enc, &denom_pub, &ev_sig))) | 1606 | sig_buf_size); |
1607 | denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (pk_buf, | ||
1608 | pk_buf_size); | ||
1609 | GNUNET_free (pk_buf); | ||
1610 | GNUNET_free (sig_buf); | ||
1611 | if ( (NULL == sig) || | ||
1612 | (NULL == denom_pub) ) | ||
1613 | { | ||
1614 | PQclear (result); | ||
1615 | if (NULL != denom_pub) | ||
1616 | GNUNET_CRYPTO_rsa_public_key_free (denom_pub); | ||
1617 | if (NULL != sig) | ||
1618 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
1619 | GNUNET_break (0); | ||
1620 | return GNUNET_SYSERR; | ||
1621 | } | ||
1622 | if (GNUNET_OK != (res = link_iter (cls, | ||
1623 | &link_data_enc, | ||
1624 | denom_pub, | ||
1625 | sig))) | ||
1561 | { | 1626 | { |
1562 | GNUNET_assert (GNUNET_SYSERR != res); | 1627 | GNUNET_assert (GNUNET_SYSERR != res); |
1628 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
1629 | GNUNET_CRYPTO_rsa_public_key_free (denom_pub); | ||
1563 | PQclear (result); | 1630 | PQclear (result); |
1564 | return res; | 1631 | return res; |
1565 | } | 1632 | } |
1633 | GNUNET_CRYPTO_rsa_signature_free (sig); | ||
1634 | GNUNET_CRYPTO_rsa_public_key_free (denom_pub); | ||
1566 | } | 1635 | } |
1567 | 1636 | ||
1568 | PQclear (result); | 1637 | PQclear (result); |
@@ -1742,6 +1811,7 @@ TALER_MINT_DB_insert_deposit (PGconn *db_conn, | |||
1742 | return GNUNET_OK; | 1811 | return GNUNET_OK; |
1743 | } | 1812 | } |
1744 | 1813 | ||
1814 | |||
1745 | int | 1815 | int |
1746 | TALER_MINT_DB_get_deposit (PGconn *db_conn, | 1816 | TALER_MINT_DB_get_deposit (PGconn *db_conn, |
1747 | const struct GNUNET_CRYPTO_EddsaPublicKey *coin_pub, | 1817 | const struct GNUNET_CRYPTO_EddsaPublicKey *coin_pub, |
@@ -1776,25 +1846,33 @@ TALER_MINT_DB_get_deposit (PGconn *db_conn, | |||
1776 | 1846 | ||
1777 | { | 1847 | { |
1778 | deposit = GNUNET_malloc (sizeof (struct Deposit)); /* Without wire data */ | 1848 | deposit = GNUNET_malloc (sizeof (struct Deposit)); /* Without wire data */ |
1849 | char *sig_buf; | ||
1850 | size_t sig_buf_size; | ||
1851 | char *dk_buf; | ||
1852 | size_t dk_buf_size; | ||
1779 | struct TALER_DB_ResultSpec rs[] = { | 1853 | struct TALER_DB_ResultSpec rs[] = { |
1780 | TALER_DB_RESULT_SPEC ("coin_pub", &deposit->coin_pub), | 1854 | TALER_DB_RESULT_SPEC ("coin_pub", &deposit->coin_pub), |
1781 | TALER_DB_RESULT_SPEC ("denom_pub", &deposit->denom_pub), | 1855 | TALER_DB_RESULT_SPEC_VAR ("denom_pub", &dk_buf, &dk_buf_size), |
1782 | TALER_DB_RESULT_SPEC ("coin_sig", &deposit->coin_sig), | 1856 | TALER_DB_RESULT_SPEC_VAR ("coin_sig", &sig_buf, &sig_buf_size), |
1783 | TALER_DB_RESULT_SPEC ("transaction_id", &deposit->transaction_id), | 1857 | TALER_DB_RESULT_SPEC ("transaction_id", &deposit->transaction_id), |
1784 | TALER_DB_RESULT_SPEC ("merchant_pub", &deposit->merchant_pub), | 1858 | TALER_DB_RESULT_SPEC ("merchant_pub", &deposit->merchant_pub), |
1785 | TALER_DB_RESULT_SPEC ("h_contract", &deposit->h_contract), | 1859 | TALER_DB_RESULT_SPEC ("h_contract", &deposit->h_contract), |
1786 | TALER_DB_RESULT_SPEC ("h_wire", &deposit->h_wire), | 1860 | TALER_DB_RESULT_SPEC ("h_wire", &deposit->h_wire), |
1787 | TALER_DB_RESULT_SPEC_END | 1861 | TALER_DB_RESULT_SPEC_END |
1788 | }; | 1862 | }; |
1789 | EXITIF (GNUNET_OK != TALER_DB_extract_result (result, rs, 0)); | 1863 | EXITIF (GNUNET_OK != |
1790 | EXITIF (GNUNET_OK != TALER_DB_extract_amount_nbo (result, 0, | 1864 | TALER_DB_extract_result (result, rs, 0)); |
1791 | "amount_value", | 1865 | EXITIF (GNUNET_OK != |
1792 | "amount_fraction", | 1866 | TALER_DB_extract_amount_nbo (result, 0, |
1793 | "amount_currency", | 1867 | "amount_value", |
1794 | &deposit->amount)); | 1868 | "amount_fraction", |
1795 | deposit->purpose.purpose = htonl (TALER_SIGNATURE_DEPOSIT); | 1869 | "amount_currency", |
1796 | deposit->purpose.size = htonl (sizeof (struct Deposit) | 1870 | &deposit->amount)); |
1797 | - offsetof (struct Deposit, purpose)); | 1871 | deposit->coin_sig = GNUNET_CRYPTO_rsa_signature_decode (sig_buf, |
1872 | sig_buf_size); | ||
1873 | deposit->denom_pub = GNUNET_CRYPTO_rsa_public_key_decode (dk_buf, | ||
1874 | dk_buf_size); | ||
1875 | // deposit->purpose = htonl (TALER_SIGNATURE_DEPOSIT); // FIXME: struct Deposit not nice | ||
1798 | } | 1876 | } |
1799 | 1877 | ||
1800 | PQclear (result); | 1878 | PQclear (result); |