diff options
Diffstat (limited to 'src/bank-lib/fakebank.c')
-rw-r--r-- | src/bank-lib/fakebank.c | 110 |
1 files changed, 59 insertions, 51 deletions
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c index c6871938b..1fac5e1b6 100644 --- a/src/bank-lib/fakebank.c +++ b/src/bank-lib/fakebank.c | |||
@@ -1083,13 +1083,12 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h, | |||
1083 | json_decref (json); | 1083 | json_decref (json); |
1084 | 1084 | ||
1085 | /* Finally build response object */ | 1085 | /* Finally build response object */ |
1086 | return TALER_MHD_reply_json_pack (connection, | 1086 | return TALER_MHD_REPLY_JSON_PACK (connection, |
1087 | MHD_HTTP_OK, | 1087 | MHD_HTTP_OK, |
1088 | "{s:I, s:o}", | 1088 | GNUNET_JSON_pack_uint64 ("row_id", |
1089 | "row_id", | 1089 | row_id), |
1090 | (json_int_t) row_id, | 1090 | GNUNET_JSON_pack_time_abs ("timestamp", |
1091 | "timestamp", | 1091 | timestamp)); |
1092 | GNUNET_JSON_from_time_abs (timestamp)); | ||
1093 | } | 1092 | } |
1094 | 1093 | ||
1095 | 1094 | ||
@@ -1211,14 +1210,14 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h, | |||
1211 | json_decref (json); | 1210 | json_decref (json); |
1212 | 1211 | ||
1213 | /* Finally build response object */ | 1212 | /* Finally build response object */ |
1214 | return TALER_MHD_reply_json_pack (connection, | 1213 | return TALER_MHD_REPLY_JSON_PACK ( |
1215 | MHD_HTTP_OK, | 1214 | connection, |
1216 | "{s:I, s:o}", | 1215 | MHD_HTTP_OK, |
1217 | "row_id", | 1216 | GNUNET_JSON_pack_uint64 ("row_id", |
1218 | (json_int_t) row_id, | 1217 | row_id), |
1219 | /* dummy timestamp */ | 1218 | /* dummy timestamp */ |
1220 | "timestamp", GNUNET_JSON_from_time_abs ( | 1219 | GNUNET_JSON_pack_time_abs ("timestamp", |
1221 | GNUNET_TIME_UNIT_ZERO_ABS)); | 1220 | GNUNET_TIME_UNIT_ZERO_ABS)); |
1222 | } | 1221 | } |
1223 | 1222 | ||
1224 | 1223 | ||
@@ -1438,11 +1437,12 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, | |||
1438 | pthread_mutex_unlock (&h->big_lock)); | 1437 | pthread_mutex_unlock (&h->big_lock)); |
1439 | GNUNET_free (debit_payto); | 1438 | GNUNET_free (debit_payto); |
1440 | /* FIXME: suspend for long-polling instead */ | 1439 | /* FIXME: suspend for long-polling instead */ |
1441 | return TALER_MHD_reply_json_pack (connection, | 1440 | return TALER_MHD_REPLY_JSON_PACK ( |
1442 | MHD_HTTP_OK, | 1441 | connection, |
1443 | "{s:o}", | 1442 | MHD_HTTP_OK, |
1444 | "outgoing_transactions", | 1443 | GNUNET_JSON_pack_array_steal ( |
1445 | history); | 1444 | "outgoing_transactions", |
1445 | history)); | ||
1446 | } | 1446 | } |
1447 | if (t->debit_account != acc) | 1447 | if (t->debit_account != acc) |
1448 | { | 1448 | { |
@@ -1487,17 +1487,21 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, | |||
1487 | GNUNET_asprintf (&credit_payto, | 1487 | GNUNET_asprintf (&credit_payto, |
1488 | "payto://x-taler-bank/localhost/%s", | 1488 | "payto://x-taler-bank/localhost/%s", |
1489 | pos->credit_account->account_name); | 1489 | pos->credit_account->account_name); |
1490 | trans = json_pack ( | 1490 | trans = GNUNET_JSON_PACK ( |
1491 | "{s:I, s:o, s:o, s:s, s:s, s:s, s:o}", | 1491 | GNUNET_JSON_pack_uint64 ("row_id", |
1492 | "row_id", (json_int_t) pos->row_id, | 1492 | pos->row_id), |
1493 | "date", GNUNET_JSON_from_time_abs (pos->date), | 1493 | GNUNET_JSON_pack_time_abs ("date", |
1494 | "amount", TALER_JSON_from_amount (&pos->amount), | 1494 | pos->date), |
1495 | "credit_account", credit_payto, | 1495 | TALER_JSON_pack_amount ("amount", |
1496 | "debit_account", debit_payto, // FIXME: inefficient to return this here always! | 1496 | &pos->amount), |
1497 | "exchange_base_url", | 1497 | GNUNET_JSON_pack_string ("credit_account", |
1498 | pos->subject.debit.exchange_base_url, | 1498 | credit_payto), |
1499 | "wtid", GNUNET_JSON_from_data_auto ( | 1499 | GNUNET_JSON_pack_string ("debit_account", |
1500 | &pos->subject.debit.wtid)); | 1500 | debit_payto), // FIXME: inefficient to return this here always! |
1501 | GNUNET_JSON_pack_string ("exchange_base_url", | ||
1502 | pos->subject.debit.exchange_base_url), | ||
1503 | GNUNET_JSON_pack_data_auto ("wtid", | ||
1504 | &pos->subject.debit.wtid)); | ||
1501 | GNUNET_assert (NULL != trans); | 1505 | GNUNET_assert (NULL != trans); |
1502 | GNUNET_free (credit_payto); | 1506 | GNUNET_free (credit_payto); |
1503 | GNUNET_assert (0 == | 1507 | GNUNET_assert (0 == |
@@ -1515,11 +1519,11 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h, | |||
1515 | GNUNET_assert (0 == | 1519 | GNUNET_assert (0 == |
1516 | pthread_mutex_unlock (&h->big_lock)); | 1520 | pthread_mutex_unlock (&h->big_lock)); |
1517 | GNUNET_free (debit_payto); | 1521 | GNUNET_free (debit_payto); |
1518 | return TALER_MHD_reply_json_pack (connection, | 1522 | return TALER_MHD_REPLY_JSON_PACK (connection, |
1519 | MHD_HTTP_OK, | 1523 | MHD_HTTP_OK, |
1520 | "{s:o}", | 1524 | GNUNET_JSON_pack_array_steal ( |
1521 | "outgoing_transactions", | 1525 | "outgoing_transactions", |
1522 | history); | 1526 | history)); |
1523 | } | 1527 | } |
1524 | 1528 | ||
1525 | 1529 | ||
@@ -1593,11 +1597,11 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h, | |||
1593 | pthread_mutex_unlock (&h->big_lock)); | 1597 | pthread_mutex_unlock (&h->big_lock)); |
1594 | GNUNET_free (credit_payto); | 1598 | GNUNET_free (credit_payto); |
1595 | /* FIXME: suspend for long-polling instead */ | 1599 | /* FIXME: suspend for long-polling instead */ |
1596 | return TALER_MHD_reply_json_pack (connection, | 1600 | return TALER_MHD_REPLY_JSON_PACK (connection, |
1597 | MHD_HTTP_OK, | 1601 | MHD_HTTP_OK, |
1598 | "{s:o}", | 1602 | GNUNET_JSON_pack_array_steal ( |
1599 | "incoming_transactions", | 1603 | "incoming_transactions", |
1600 | history); | 1604 | history)); |
1601 | } | 1605 | } |
1602 | if (skip) | 1606 | if (skip) |
1603 | { | 1607 | { |
@@ -1631,15 +1635,19 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h, | |||
1631 | GNUNET_asprintf (&debit_payto, | 1635 | GNUNET_asprintf (&debit_payto, |
1632 | "payto://x-taler-bank/localhost/%s", | 1636 | "payto://x-taler-bank/localhost/%s", |
1633 | pos->debit_account->account_name); | 1637 | pos->debit_account->account_name); |
1634 | trans = json_pack ( | 1638 | trans = GNUNET_JSON_PACK ( |
1635 | "{s:I, s:o, s:o, s:s, s:s, s:o}", | 1639 | GNUNET_JSON_pack_uint64 ("row_id", |
1636 | "row_id", (json_int_t) pos->row_id, | 1640 | pos->row_id), |
1637 | "date", GNUNET_JSON_from_time_abs (pos->date), | 1641 | GNUNET_JSON_pack_time_abs ("date", |
1638 | "amount", TALER_JSON_from_amount (&pos->amount), | 1642 | pos->date), |
1639 | "credit_account", credit_payto, // FIXME: inefficient to repeat this always here! | 1643 | TALER_JSON_pack_amount ("amount", |
1640 | "debit_account", debit_payto, | 1644 | &pos->amount), |
1641 | "reserve_pub", GNUNET_JSON_from_data_auto ( | 1645 | GNUNET_JSON_pack_string ("credit_account", |
1642 | &pos->subject.credit.reserve_pub)); | 1646 | credit_payto), // FIXME: inefficient to repeat this always here! |
1647 | GNUNET_JSON_pack_string ("debit_account", | ||
1648 | debit_payto), | ||
1649 | GNUNET_JSON_pack_data_auto ("reserve_pub", | ||
1650 | &pos->subject.credit.reserve_pub)); | ||
1643 | GNUNET_assert (NULL != trans); | 1651 | GNUNET_assert (NULL != trans); |
1644 | GNUNET_free (debit_payto); | 1652 | GNUNET_free (debit_payto); |
1645 | GNUNET_assert (0 == | 1653 | GNUNET_assert (0 == |
@@ -1657,11 +1665,11 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h, | |||
1657 | GNUNET_assert (0 == | 1665 | GNUNET_assert (0 == |
1658 | pthread_mutex_unlock (&h->big_lock)); | 1666 | pthread_mutex_unlock (&h->big_lock)); |
1659 | GNUNET_free (credit_payto); | 1667 | GNUNET_free (credit_payto); |
1660 | return TALER_MHD_reply_json_pack (connection, | 1668 | return TALER_MHD_REPLY_JSON_PACK (connection, |
1661 | MHD_HTTP_OK, | 1669 | MHD_HTTP_OK, |
1662 | "{s:o}", | 1670 | GNUNET_JSON_pack_array_steal ( |
1663 | "incoming_transactions", | 1671 | "incoming_transactions", |
1664 | history); | 1672 | history)); |
1665 | } | 1673 | } |
1666 | 1674 | ||
1667 | 1675 | ||