diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_refresh.c')
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 103 |
1 files changed, 10 insertions, 93 deletions
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 2030eb3d6..863b812db 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c | |||
@@ -41,36 +41,6 @@ | |||
41 | #include "taler-mint-httpd_responses.h" | 41 | #include "taler-mint-httpd_responses.h" |
42 | 42 | ||
43 | 43 | ||
44 | /** | ||
45 | * FIXME: document! | ||
46 | */ | ||
47 | static int | ||
48 | link_iter (void *cls, | ||
49 | const struct LinkDataEnc *link_data_enc, | ||
50 | const struct TALER_RSA_PublicKeyBinaryEncoded *denom_pub, | ||
51 | const struct TALER_RSA_Signature *ev_sig) | ||
52 | { | ||
53 | json_t *list = cls; | ||
54 | json_t *obj = json_object (); | ||
55 | |||
56 | json_array_append_new (list, obj); | ||
57 | |||
58 | json_object_set_new (obj, "link_enc", | ||
59 | TALER_JSON_from_data (link_data_enc, | ||
60 | sizeof (struct LinkDataEnc))); | ||
61 | |||
62 | json_object_set_new (obj, "denom_pub", | ||
63 | TALER_JSON_from_data (denom_pub, | ||
64 | sizeof (struct TALER_RSA_PublicKeyBinaryEncoded))); | ||
65 | |||
66 | json_object_set_new (obj, "ev_sig", | ||
67 | TALER_JSON_from_data (ev_sig, | ||
68 | sizeof (struct TALER_RSA_Signature))); | ||
69 | |||
70 | return GNUNET_OK; | ||
71 | } | ||
72 | |||
73 | |||
74 | static int | 44 | static int |
75 | check_confirm_signature (struct MHD_Connection *connection, | 45 | check_confirm_signature (struct MHD_Connection *connection, |
76 | json_t *coin_info, | 46 | json_t *coin_info, |
@@ -780,6 +750,8 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
780 | return res; | 750 | return res; |
781 | } | 751 | } |
782 | 752 | ||
753 | |||
754 | |||
783 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) | 755 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) |
784 | { | 756 | { |
785 | GNUNET_break (0); | 757 | GNUNET_break (0); |
@@ -791,9 +763,13 @@ TALER_MINT_handler_refresh_reveal (struct RequestHandler *rh, | |||
791 | * and the session commited already. | 763 | * and the session commited already. |
792 | * Do _not_ care about fields other than session_pub in this case. */ | 764 | * Do _not_ care about fields other than session_pub in this case. */ |
793 | 765 | ||
794 | res = TALER_MINT_DB_get_refresh_session (db_conn, &refresh_session_pub, &refresh_session); | 766 | res = TALER_MINT_DB_get_refresh_session (db_conn, |
767 | &refresh_session_pub, | ||
768 | &refresh_session); | ||
795 | if (GNUNET_YES == res && 0 != refresh_session.reveal_ok) | 769 | if (GNUNET_YES == res && 0 != refresh_session.reveal_ok) |
796 | return helper_refresh_reveal_send_response (connection, db_conn, &refresh_session_pub); | 770 | return helper_refresh_reveal_send_response (connection, |
771 | db_conn, | ||
772 | &refresh_session_pub); | ||
797 | if (GNUNET_SYSERR == res) | 773 | if (GNUNET_SYSERR == res) |
798 | { | 774 | { |
799 | GNUNET_break (0); | 775 | GNUNET_break (0); |
@@ -1070,11 +1046,6 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, | |||
1070 | { | 1046 | { |
1071 | struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; | 1047 | struct GNUNET_CRYPTO_EcdsaPublicKey coin_pub; |
1072 | int res; | 1048 | int res; |
1073 | json_t *root; | ||
1074 | json_t *list; | ||
1075 | PGconn *db_conn; | ||
1076 | struct GNUNET_CRYPTO_EcdsaPublicKey transfer_pub; | ||
1077 | struct SharedSecretEnc shared_secret_enc; | ||
1078 | 1049 | ||
1079 | res = TALER_MINT_mhd_request_arg_data (connection, | 1050 | res = TALER_MINT_mhd_request_arg_data (connection, |
1080 | "coin_pub", | 1051 | "coin_pub", |
@@ -1089,62 +1060,8 @@ TALER_MINT_handler_refresh_link (struct RequestHandler *rh, | |||
1089 | if (GNUNET_OK != res) | 1060 | if (GNUNET_OK != res) |
1090 | return MHD_YES; | 1061 | return MHD_YES; |
1091 | 1062 | ||
1092 | if (NULL == (db_conn = TALER_MINT_DB_get_connection ())) | 1063 | return TALER_MINT_db_execute_refresh_link (connection, |
1093 | { | 1064 | &coin_pub); |
1094 | GNUNET_break (0); | ||
1095 | // FIXME: return error code! | ||
1096 | return MHD_NO; | ||
1097 | } | ||
1098 | |||
1099 | list = json_array (); | ||
1100 | root = json_object (); | ||
1101 | json_object_set_new (root, "new_coins", list); | ||
1102 | |||
1103 | res = TALER_db_get_transfer (db_conn, | ||
1104 | &coin_pub, | ||
1105 | &transfer_pub, | ||
1106 | &shared_secret_enc); | ||
1107 | if (GNUNET_SYSERR == res) | ||
1108 | { | ||
1109 | GNUNET_break (0); | ||
1110 | // FIXME: return error code! | ||
1111 | return MHD_NO; | ||
1112 | } | ||
1113 | if (GNUNET_NO == res) | ||
1114 | { | ||
1115 | return TALER_MINT_reply_json_pack (connection, | ||
1116 | MHD_HTTP_NOT_FOUND, | ||
1117 | "{s:s}", | ||
1118 | "error", | ||
1119 | "link data not found (transfer)"); | ||
1120 | } | ||
1121 | GNUNET_assert (GNUNET_OK == res); | ||
1122 | |||
1123 | res = TALER_db_get_link (db_conn, &coin_pub, link_iter, list); | ||
1124 | if (GNUNET_SYSERR == res) | ||
1125 | { | ||
1126 | GNUNET_break (0); | ||
1127 | // FIXME: return error code! | ||
1128 | return MHD_NO; | ||
1129 | } | ||
1130 | if (GNUNET_NO == res) | ||
1131 | { | ||
1132 | return TALER_MINT_reply_json_pack (connection, | ||
1133 | MHD_HTTP_NOT_FOUND, | ||
1134 | "{s:s}", | ||
1135 | "error", | ||
1136 | "link data not found (link)"); | ||
1137 | } | ||
1138 | GNUNET_assert (GNUNET_OK == res); | ||
1139 | json_object_set_new (root, "transfer_pub", | ||
1140 | TALER_JSON_from_data (&transfer_pub, | ||
1141 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey))); | ||
1142 | json_object_set_new (root, "secret_enc", | ||
1143 | TALER_JSON_from_data (&shared_secret_enc, | ||
1144 | sizeof (struct SharedSecretEnc))); | ||
1145 | return TALER_MINT_reply_json (connection, | ||
1146 | root, | ||
1147 | MHD_HTTP_OK); | ||
1148 | } | 1065 | } |
1149 | 1066 | ||
1150 | 1067 | ||