aboutsummaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_handle.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_handle.c')
-rw-r--r--src/lib/exchange_api_handle.c232
1 files changed, 83 insertions, 149 deletions
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 43eac97a7..615239723 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2014-2018 Taler Systems SA 3 Copyright (C) 2014-2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or modify it 5 TALER is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published 6 under the terms of the GNU General Public License as published
@@ -1612,22 +1612,17 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange)
1612 1612
1613 if (now.abs_value_us > sk->valid_until.abs_value_us) 1613 if (now.abs_value_us > sk->valid_until.abs_value_us)
1614 continue; /* skip keys that have expired */ 1614 continue; /* skip keys that have expired */
1615 signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", 1615 signkey = GNUNET_JSON_PACK (
1616 "key", 1616 GNUNET_JSON_pack_data_auto ("key",
1617 GNUNET_JSON_from_data_auto 1617 &sk->key),
1618 (&sk->key), 1618 GNUNET_JSON_pack_data_auto ("master_sig",
1619 "master_sig", 1619 &sk->master_sig),
1620 GNUNET_JSON_from_data_auto 1620 GNUNET_JSON_pack_time_abs ("stamp_start",
1621 (&sk->master_sig), 1621 sk->valid_from),
1622 "stamp_start", 1622 GNUNET_JSON_pack_time_abs ("stamp_expire",
1623 GNUNET_JSON_from_time_abs 1623 sk->valid_until),
1624 (sk->valid_from), 1624 GNUNET_JSON_pack_time_abs ("stamp_end",
1625 "stamp_expire", 1625 sk->valid_legal));
1626 GNUNET_JSON_from_time_abs
1627 (sk->valid_until),
1628 "stamp_end",
1629 GNUNET_JSON_from_time_abs
1630 (sk->valid_legal));
1631 if (NULL == signkey) 1626 if (NULL == signkey)
1632 { 1627 {
1633 GNUNET_break (0); 1628 GNUNET_break (0);
@@ -1656,57 +1651,35 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange)
1656 1651
1657 if (now.abs_value_us > dk->expire_deposit.abs_value_us) 1652 if (now.abs_value_us > dk->expire_deposit.abs_value_us)
1658 continue; /* skip keys that have expired */ 1653 continue; /* skip keys that have expired */
1659 denom = json_pack ("{s:o, s:o, s:o, s:o, s:o " 1654 denom = GNUNET_JSON_PACK (
1660 ",s:o, s:o, s:o, s:o, s:o " 1655 GNUNET_JSON_pack_time_abs ("stamp_expire_deposit",
1661 ",s:o}", 1656 dk->expire_deposit),
1662 "stamp_expire_deposit", 1657 GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw",
1663 GNUNET_JSON_from_time_abs (dk->expire_deposit), 1658 dk->withdraw_valid_until),
1664 "stamp_expire_withdraw", 1659 GNUNET_JSON_pack_time_abs ("stamp_start",
1665 GNUNET_JSON_from_time_abs (dk->withdraw_valid_until), 1660 dk->valid_from),
1666 "stamp_start", 1661 GNUNET_JSON_pack_time_abs ("stamp_expire_legal",
1667 GNUNET_JSON_from_time_abs (dk->valid_from), 1662 dk->expire_legal),
1668 "stamp_expire_legal", 1663 TALER_JSON_pack_amount ("value",
1669 GNUNET_JSON_from_time_abs (dk->expire_legal), 1664 &dk->value),
1670 "value", 1665 TALER_JSON_pack_amount ("fee_withdraw",
1671 TALER_JSON_from_amount (&dk->value), 1666 &dk->fee_withdraw),
1672 "fee_withdraw", 1667 TALER_JSON_pack_amount ("fee_deposit",
1673 /* #6 */ 1668 &dk->fee_deposit),
1674 TALER_JSON_from_amount (&dk->fee_withdraw), 1669 TALER_JSON_pack_amount ("fee_refresh",
1675 "fee_deposit", 1670 &dk->fee_refresh),
1676 TALER_JSON_from_amount (&dk->fee_deposit), 1671 TALER_JSON_pack_amount ("fee_refund",
1677 "fee_refresh", 1672 &dk->fee_refund),
1678 TALER_JSON_from_amount (&dk->fee_refresh), 1673 GNUNET_JSON_pack_data_auto ("master_sig",
1679 "fee_refund", 1674 &dk->master_sig),
1680 TALER_JSON_from_amount (&dk->fee_refund), 1675 TALER_JSON_pack_denomination_public_key ("denom_pub",
1681 "master_sig", 1676 &dk->key));
1682 GNUNET_JSON_from_data_auto (&dk->master_sig), 1677 GNUNET_assert (0 ==
1683 /* #10 */ 1678 json_array_append_new (denoms,
1684 "denom_pub", 1679 denom));
1685 GNUNET_JSON_from_rsa_public_key (
1686 dk->key.rsa_public_key));
1687 if (NULL == denom)
1688 {
1689 GNUNET_break (0);
1690 continue;
1691 }
1692 if (0 != json_array_append_new (denoms,
1693 denom))
1694 {
1695 GNUNET_break (0);
1696 json_decref (denom);
1697 json_decref (denoms);
1698 json_decref (signkeys);
1699 return NULL;
1700 }
1701 } 1680 }
1702 auditors = json_array (); 1681 auditors = json_array ();
1703 if (NULL == auditors) 1682 GNUNET_assert (NULL != auditors);
1704 {
1705 GNUNET_break (0);
1706 json_decref (denoms);
1707 json_decref (signkeys);
1708 return NULL;
1709 }
1710 for (unsigned int i = 0; i<kd->num_auditors; i++) 1683 for (unsigned int i = 0; i<kd->num_auditors; i++)
1711 { 1684 {
1712 const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; 1685 const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i];
@@ -1733,92 +1706,53 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange)
1733 if (now.abs_value_us > dk->expire_deposit.abs_value_us) 1706 if (now.abs_value_us > dk->expire_deposit.abs_value_us)
1734 continue; /* skip auditor signatures for denomination keys that have expired */ 1707 continue; /* skip auditor signatures for denomination keys that have expired */
1735 GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); 1708 GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys);
1736 k = json_pack ("{s:o, s:o}", 1709 k = GNUNET_JSON_PACK (
1737 "denom_pub_h", 1710 GNUNET_JSON_pack_data_auto ("denom_pub_h",
1738 GNUNET_JSON_from_data_auto (&dk->h_key), 1711 &dk->h_key),
1739 "auditor_sig", 1712 GNUNET_JSON_pack_data_auto ("auditor_sig",
1740 GNUNET_JSON_from_data_auto (&adi->auditor_sig)); 1713 &adi->auditor_sig));
1741 if (NULL == k) 1714 GNUNET_assert (0 ==
1742 { 1715 json_array_append_new (adenoms,
1743 GNUNET_break (0); 1716 k));
1744 json_decref (adenoms);
1745 json_decref (denoms);
1746 json_decref (signkeys);
1747 json_decref (auditors);
1748 return NULL;
1749 }
1750 if (0 != json_array_append_new (adenoms,
1751 k))
1752 {
1753 GNUNET_break (0);
1754 json_decref (k);
1755 json_decref (adenoms);
1756 json_decref (denoms);
1757 json_decref (signkeys);
1758 json_decref (auditors);
1759 return NULL;
1760 }
1761 } 1717 }
1762 1718
1763 a = json_pack ("{s:o, s:s, s:o}", 1719 a = GNUNET_JSON_PACK (
1764 "auditor_pub", 1720 GNUNET_JSON_pack_data_auto ("auditor_pub",
1765 GNUNET_JSON_from_data_auto (&ai->auditor_pub), 1721 &ai->auditor_pub),
1766 "auditor_url", 1722 GNUNET_JSON_pack_string ("auditor_url",
1767 ai->auditor_url, 1723 ai->auditor_url),
1768 "denomination_keys", 1724 GNUNET_JSON_pack_array_steal ("denomination_keys",
1769 adenoms); 1725 adenoms));
1770 if (NULL == a) 1726 GNUNET_assert (0 ==
1771 { 1727 json_array_append_new (auditors,
1772 json_decref (adenoms); 1728 a));
1773 json_decref (denoms);
1774 json_decref (signkeys);
1775 json_decref (auditors);
1776 return NULL;
1777 }
1778 if (0 != json_array_append_new (auditors,
1779 a))
1780 {
1781 json_decref (a);
1782 json_decref (denoms);
1783 json_decref (signkeys);
1784 json_decref (auditors);
1785 return NULL;
1786 }
1787 }
1788 keys = json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o"
1789 ",s:o, s:o}",
1790 /* 1 */
1791 "version",
1792 kd->version,
1793 "currency",
1794 kd->currency,
1795 "master_public_key",
1796 GNUNET_JSON_from_data_auto (&kd->master_pub),
1797 "reserve_closing_delay",
1798 GNUNET_JSON_from_time_rel (kd->reserve_closing_delay),
1799 "list_issue_date",
1800 GNUNET_JSON_from_time_abs (kd->list_issue_date),
1801 "signkeys",
1802 signkeys,
1803 /* #7 */
1804 "denoms",
1805 denoms,
1806 "auditors",
1807 auditors);
1808 if (NULL == keys)
1809 {
1810 GNUNET_break (0);
1811 return NULL;
1812 } 1729 }
1813 return json_pack ("{s:I, s:o, s:s, s:o}", 1730 keys = GNUNET_JSON_PACK (
1814 "version", 1731 GNUNET_JSON_pack_string ("version",
1815 (json_int_t) EXCHANGE_SERIALIZATION_FORMAT_VERSION, 1732 kd->version),
1816 "expire", 1733 GNUNET_JSON_pack_string ("currency",
1817 GNUNET_JSON_from_time_abs (exchange->key_data_expiration), 1734 kd->currency),
1818 "exchange_url", 1735 GNUNET_JSON_pack_data_auto ("master_public_key",
1819 exchange->url, 1736 &kd->master_pub),
1820 "keys", 1737 GNUNET_JSON_pack_time_rel ("reserve_closing_delay",
1821 keys); 1738 kd->reserve_closing_delay),
1739 GNUNET_JSON_pack_time_abs ("list_issue_date",
1740 kd->list_issue_date),
1741 GNUNET_JSON_pack_array_steal ("signkeys",
1742 signkeys),
1743 GNUNET_JSON_pack_array_steal ("denoms",
1744 denoms),
1745 GNUNET_JSON_pack_array_steal ("auditors",
1746 auditors));
1747 return GNUNET_JSON_PACK (
1748 GNUNET_JSON_pack_uint64 ("version",
1749 EXCHANGE_SERIALIZATION_FORMAT_VERSION),
1750 GNUNET_JSON_pack_time_abs ("expire",
1751 exchange->key_data_expiration),
1752 GNUNET_JSON_pack_string ("exchange_url",
1753 exchange->url),
1754 GNUNET_JSON_pack_object_steal ("keys",
1755 keys));
1822} 1756}
1823 1757
1824 1758