summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/auditor_api_exchanges.c2
-rw-r--r--src/lib/auditor_api_get_config.c25
-rw-r--r--src/lib/exchange_api_batch_deposit.c2
-rw-r--r--src/lib/exchange_api_coins_history.c2
-rw-r--r--src/lib/exchange_api_common.c22
-rw-r--r--src/lib/exchange_api_deposits_get.c7
-rw-r--r--src/lib/exchange_api_handle.c37
-rw-r--r--src/lib/exchange_api_kyc_check.c24
-rw-r--r--src/lib/exchange_api_lookup_aml_decision.c6
-rw-r--r--src/lib/exchange_api_lookup_aml_decisions.c6
-rw-r--r--src/lib/exchange_api_reserves_history.c10
11 files changed, 47 insertions, 96 deletions
diff --git a/src/lib/auditor_api_exchanges.c b/src/lib/auditor_api_exchanges.c
index 897dfe60f..1988c2faf 100644
--- a/src/lib/auditor_api_exchanges.c
+++ b/src/lib/auditor_api_exchanges.c
@@ -125,7 +125,7 @@ handle_exchanges_finished (void *cls,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("master_pub",
&ei[i].master_pub),
- GNUNET_JSON_spec_string ("exchange_url",
+ TALER_JSON_spec_web_url ("exchange_url",
&ei[i].exchange_url),
GNUNET_JSON_spec_end ()
};
diff --git a/src/lib/auditor_api_get_config.c b/src/lib/auditor_api_get_config.c
index c9f366568..5d0b4db81 100644
--- a/src/lib/auditor_api_get_config.c
+++ b/src/lib/auditor_api_get_config.c
@@ -104,12 +104,11 @@ decode_config_json (const json_t *resp_obj,
struct TALER_AUDITOR_ConfigInformation *vi,
enum TALER_AUDITOR_VersionCompatibility *vc)
{
- unsigned int age;
- unsigned int revision;
- unsigned int current;
- char dummy;
+ struct TALER_JSON_ProtocolVersion pv;
const char *ver;
struct GNUNET_JSON_Specification spec[] = {
+ TALER_JSON_spec_version ("version",
+ &pv),
GNUNET_JSON_spec_string ("version",
&ver),
GNUNET_JSON_spec_fixed_auto ("auditor_public_key",
@@ -131,28 +130,18 @@ decode_config_json (const json_t *resp_obj,
GNUNET_break_op (0);
return TALER_EC_GENERIC_JSON_INVALID;
}
- if (3 != sscanf (ver,
- "%u:%u:%u%c",
- &current,
- &revision,
- &age,
- &dummy))
- {
- GNUNET_break_op (0);
- return TALER_EC_GENERIC_VERSION_MALFORMED;
- }
vi->version = ver;
*vc = TALER_AUDITOR_VC_MATCH;
- if (TALER_PROTOCOL_CURRENT < current)
+ if (TALER_PROTOCOL_CURRENT < pv.current)
{
*vc |= TALER_AUDITOR_VC_NEWER;
- if (TALER_PROTOCOL_CURRENT < current - age)
+ if (TALER_PROTOCOL_CURRENT < pv.current - pv.age)
*vc |= TALER_AUDITOR_VC_INCOMPATIBLE;
}
- if (TALER_PROTOCOL_CURRENT > current)
+ if (TALER_PROTOCOL_CURRENT > pv.current)
{
*vc |= TALER_AUDITOR_VC_OLDER;
- if (TALER_PROTOCOL_CURRENT - TALER_PROTOCOL_AGE > current)
+ if (TALER_PROTOCOL_CURRENT - TALER_PROTOCOL_AGE > pv.current)
*vc |= TALER_AUDITOR_VC_INCOMPATIBLE;
}
return TALER_EC_NONE;
diff --git a/src/lib/exchange_api_batch_deposit.c b/src/lib/exchange_api_batch_deposit.c
index f9d505dcd..56b9b11e3 100644
--- a/src/lib/exchange_api_batch_deposit.c
+++ b/src/lib/exchange_api_batch_deposit.c
@@ -360,7 +360,7 @@ handle_deposit_finished (void *cls,
GNUNET_JSON_spec_fixed_auto ("exchange_pub",
&dh->exchange_pub),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("transaction_base_url",
+ TALER_JSON_spec_web_url ("transaction_base_url",
&dr->details.ok.transaction_base_url),
NULL),
GNUNET_JSON_spec_timestamp ("exchange_timestamp",
diff --git a/src/lib/exchange_api_coins_history.c b/src/lib/exchange_api_coins_history.c
index 34eca62db..6981fad5a 100644
--- a/src/lib/exchange_api_coins_history.c
+++ b/src/lib/exchange_api_coins_history.c
@@ -576,7 +576,7 @@ help_purse_deposit (struct CoinHistoryParseContext *pc,
GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
&rh->details.purse_deposit.phac),
NULL),
- GNUNET_JSON_spec_string ("exchange_base_url",
+ TALER_JSON_spec_web_url ("exchange_base_url",
&rh->details.purse_deposit.exchange_base_url),
GNUNET_JSON_spec_bool ("refunded",
&rh->details.purse_deposit.refunded),
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 4846e1188..239632656 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -119,7 +119,7 @@ TALER_EXCHANGE_check_purse_merge_conflict_ (
struct TALER_ReservePublicKeyP reserve_pub;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("partner_url",
+ TALER_JSON_spec_web_url ("partner_url",
&partner_url),
NULL),
GNUNET_JSON_spec_timestamp ("merge_timestamp",
@@ -191,7 +191,7 @@ TALER_EXCHANGE_check_purse_coin_conflict_ (
GNUNET_JSON_spec_fixed_auto ("coin_pub",
coin_pub),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("partner_url",
+ TALER_JSON_spec_web_url ("partner_url",
&partner_url),
NULL),
TALER_JSON_spec_amount_any ("amount",
@@ -515,10 +515,10 @@ TALER_EXCHANGE_parse_accounts (
const json_t *credit_restrictions;
const json_t *debit_restrictions;
struct GNUNET_JSON_Specification spec_account[] = {
- GNUNET_JSON_spec_string ("payto_uri",
- &payto_uri),
+ TALER_JSON_spec_payto_uri ("payto_uri",
+ &payto_uri),
GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_string ("conversion_url",
+ TALER_JSON_spec_web_url ("conversion_url",
&conversion_url),
NULL),
GNUNET_JSON_spec_array_const ("credit_restrictions",
@@ -542,18 +542,6 @@ TALER_EXCHANGE_parse_accounts (
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- {
- char *err;
-
- err = TALER_payto_validate (payto_uri);
- if (NULL != err)
- {
- GNUNET_break_op (0);
- GNUNET_free (err);
- return GNUNET_SYSERR;
- }
- }
-
if ( (NULL != master_pub) &&
(GNUNET_OK !=
TALER_exchange_wire_signature_check (
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c
index 8b145dabd..ee5f9dc68 100644
--- a/src/lib/exchange_api_deposits_get.c
+++ b/src/lib/exchange_api_deposits_get.c
@@ -177,7 +177,6 @@ handle_deposit_wtid_finished (void *cls,
{
/* Transaction known, but not executed yet */
bool no_legi = false;
- uint32_t state32;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp ("execution_time",
&dr.details.accepted.execution_time),
@@ -185,8 +184,8 @@ handle_deposit_wtid_finished (void *cls,
GNUNET_JSON_spec_uint64 ("requirement_row",
&dr.details.accepted.requirement_row),
&no_legi),
- GNUNET_JSON_spec_uint32 ("aml_decision",
- &state32),
+ TALER_JSON_spec_aml_decision ("aml_decision",
+ &dr.details.accepted.aml_decision),
GNUNET_JSON_spec_bool ("kyc_ok",
&dr.details.accepted.kyc_ok),
GNUNET_JSON_spec_end ()
@@ -202,8 +201,6 @@ handle_deposit_wtid_finished (void *cls,
dr.hr.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
break;
}
- dr.details.accepted.aml_decision
- = (enum TALER_AmlDecisionState) state32;
if (no_legi)
dr.details.accepted.requirement_row = 0;
dwh->cb (dwh->cb_cls,
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index 410c01245..ab3c387df 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -550,7 +550,7 @@ parse_json_auditor (struct TALER_EXCHANGE_AuditorInformation *auditor,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("auditor_pub",
&auditor->auditor_pub),
- GNUNET_JSON_spec_string ("auditor_url",
+ TALER_JSON_spec_web_url ("auditor_url",
&auditor_url),
GNUNET_JSON_spec_array_const ("denomination_keys",
&keys),
@@ -791,14 +791,10 @@ decode_keys_json (const json_t *resp_obj,
#endif
/* check the version first */
{
- const char *ver;
- unsigned int age;
- unsigned int revision;
- unsigned int current;
- char dummy;
+ struct TALER_JSON_ProtocolVersion pv;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("version",
- &ver),
+ TALER_JSON_spec_version ("version",
+ &pv),
GNUNET_JSON_spec_end ()
};
@@ -810,33 +806,23 @@ decode_keys_json (const json_t *resp_obj,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (3 != sscanf (ver,
- "%u:%u:%u%c",
- &current,
- &revision,
- &age,
- &dummy))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
*vc = TALER_EXCHANGE_VC_MATCH;
- if (EXCHANGE_PROTOCOL_CURRENT < current)
+ if (EXCHANGE_PROTOCOL_CURRENT < pv.current)
{
*vc |= TALER_EXCHANGE_VC_NEWER;
- if (EXCHANGE_PROTOCOL_CURRENT < current - age)
+ if (EXCHANGE_PROTOCOL_CURRENT < pv.current - pv.age)
*vc |= TALER_EXCHANGE_VC_INCOMPATIBLE;
}
- if (EXCHANGE_PROTOCOL_CURRENT > current)
+ if (EXCHANGE_PROTOCOL_CURRENT > pv.current)
{
*vc |= TALER_EXCHANGE_VC_OLDER;
- if (EXCHANGE_PROTOCOL_CURRENT - EXCHANGE_PROTOCOL_AGE > current)
+ if (EXCHANGE_PROTOCOL_CURRENT - EXCHANGE_PROTOCOL_AGE > pv.current)
*vc |= TALER_EXCHANGE_VC_INCOMPATIBLE;
}
- key_data->version = GNUNET_strdup (ver);
}
{
+ const char *ver;
const char *currency;
const char *asset_type;
struct GNUNET_JSON_Specification mspec[] = {
@@ -901,6 +887,8 @@ decode_keys_json (const json_t *resp_obj,
"extensions_sig",
&key_data->extensions_sig),
&no_signature),
+ GNUNET_JSON_spec_string ("version",
+ &ver),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_array_const (
"wallet_balance_limit_without_kyc",
@@ -946,6 +934,7 @@ decode_keys_json (const json_t *resp_obj,
}
key_data->currency = GNUNET_strdup (currency);
+ key_data->version = GNUNET_strdup (ver);
key_data->asset_type = GNUNET_strdup (asset_type);
if (! no_extensions)
key_data->extensions = json_incref ((json_t *) manifests);
@@ -1896,7 +1885,7 @@ TALER_EXCHANGE_keys_from_json (const json_t *j)
&version),
GNUNET_JSON_spec_object_const ("keys",
&jkeys),
- GNUNET_JSON_spec_string ("exchange_url",
+ TALER_JSON_spec_web_url ("exchange_url",
&url),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_timestamp ("expire",
diff --git a/src/lib/exchange_api_kyc_check.c b/src/lib/exchange_api_kyc_check.c
index 373dd89a7..5d3b3792b 100644
--- a/src/lib/exchange_api_kyc_check.c
+++ b/src/lib/exchange_api_kyc_check.c
@@ -97,7 +97,6 @@ handle_kyc_check_finished (void *cls,
case MHD_HTTP_OK:
{
const json_t *kyc_details;
- uint32_t status;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("exchange_sig",
&ks.details.ok.exchange_sig),
@@ -107,8 +106,8 @@ handle_kyc_check_finished (void *cls,
&ks.details.ok.timestamp),
GNUNET_JSON_spec_object_const ("kyc_details",
&kyc_details),
- GNUNET_JSON_spec_uint32 ("aml_status",
- &status),
+ TALER_JSON_spec_aml_decision ("aml_status",
+ &ks.details.ok.aml_status),
GNUNET_JSON_spec_end ()
};
@@ -123,8 +122,6 @@ handle_kyc_check_finished (void *cls,
break;
}
ks.details.ok.kyc_details = kyc_details;
- ks.details.ok.aml_status
- = (enum TALER_AmlDecisionState) status;
if (GNUNET_OK !=
TALER_EXCHANGE_test_signing_key (kch->keys,
&ks.details.ok.exchange_pub))
@@ -158,12 +155,11 @@ handle_kyc_check_finished (void *cls,
}
case MHD_HTTP_ACCEPTED:
{
- uint32_t status;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("kyc_url",
+ TALER_JSON_spec_web_url ("kyc_url",
&ks.details.accepted.kyc_url),
- GNUNET_JSON_spec_uint32 ("aml_status",
- &status),
+ TALER_JSON_spec_aml_decision ("aml_status",
+ &ks.details.accepted.aml_status),
GNUNET_JSON_spec_end ()
};
@@ -177,8 +173,6 @@ handle_kyc_check_finished (void *cls,
ks.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
- ks.details.accepted.aml_status
- = (enum TALER_AmlDecisionState) status;
kch->cb (kch->cb_cls,
&ks);
GNUNET_JSON_parse_free (spec);
@@ -200,10 +194,10 @@ handle_kyc_check_finished (void *cls,
break;
case MHD_HTTP_UNAVAILABLE_FOR_LEGAL_REASONS:
{
- uint32_t status;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_uint32 ("aml_status",
- &status),
+ TALER_JSON_spec_aml_decision (
+ "aml_status",
+ &ks.details.unavailable_for_legal_reasons.aml_status),
GNUNET_JSON_spec_end ()
};
@@ -217,8 +211,6 @@ handle_kyc_check_finished (void *cls,
ks.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
- ks.details.unavailable_for_legal_reasons.aml_status
- = (enum TALER_AmlDecisionState) status;
kch->cb (kch->cb_cls,
&ks);
GNUNET_JSON_parse_free (spec);
diff --git a/src/lib/exchange_api_lookup_aml_decision.c b/src/lib/exchange_api_lookup_aml_decision.c
index 01e98213b..501b9d185 100644
--- a/src/lib/exchange_api_lookup_aml_decision.c
+++ b/src/lib/exchange_api_lookup_aml_decision.c
@@ -80,7 +80,6 @@ parse_aml_history (const json_t *aml_history,
json_array_foreach (aml_history, idx, obj)
{
struct TALER_EXCHANGE_AmlDecisionDetail *aml = &aml_history_ar[idx];
- uint32_t state32;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_timestamp ("decision_time",
&aml->decision_time),
@@ -88,8 +87,8 @@ parse_aml_history (const json_t *aml_history,
&aml->justification),
TALER_JSON_spec_amount_any ("new_threshold",
&aml->new_threshold),
- GNUNET_JSON_spec_uint32 ("new_state",
- &state32),
+ TALER_JSON_spec_aml_decision ("new_state",
+ &aml->new_state),
GNUNET_JSON_spec_fixed_auto ("decider_pub",
&aml->decider_pub),
GNUNET_JSON_spec_end ()
@@ -104,7 +103,6 @@ parse_aml_history (const json_t *aml_history,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- aml->new_state = (enum TALER_AmlDecisionState) state32;
}
return GNUNET_OK;
}
diff --git a/src/lib/exchange_api_lookup_aml_decisions.c b/src/lib/exchange_api_lookup_aml_decisions.c
index 22222b1e4..bb3c18b68 100644
--- a/src/lib/exchange_api_lookup_aml_decisions.c
+++ b/src/lib/exchange_api_lookup_aml_decisions.c
@@ -80,12 +80,11 @@ parse_aml_decisions (const json_t *decisions,
json_array_foreach (decisions, idx, obj)
{
struct TALER_EXCHANGE_AmlDecisionSummary *decision = &decision_ar[idx];
- uint32_t state32;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("h_payto",
&decision->h_payto),
- GNUNET_JSON_spec_uint32 ("current_state",
- &state32),
+ TALER_JSON_spec_aml_decision ("current_state",
+ &decision->current_state),
TALER_JSON_spec_amount_any ("threshold",
&decision->threshold),
GNUNET_JSON_spec_uint64 ("rowid",
@@ -102,7 +101,6 @@ parse_aml_decisions (const json_t *decisions,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- decision->current_state = (enum TALER_AmlDecisionState) state32;
}
return GNUNET_OK;
}
diff --git a/src/lib/exchange_api_reserves_history.c b/src/lib/exchange_api_reserves_history.c
index 7b8eb95e6..0654ad837 100644
--- a/src/lib/exchange_api_reserves_history.c
+++ b/src/lib/exchange_api_reserves_history.c
@@ -148,7 +148,7 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
struct HistoryParseContext *uc,
const json_t *transaction)
{
- const char *wire_url;
+ const char *wire_uri;
uint64_t wire_reference;
struct GNUNET_TIME_Timestamp timestamp;
struct GNUNET_JSON_Specification withdraw_spec[] = {
@@ -156,8 +156,8 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
&wire_reference),
GNUNET_JSON_spec_timestamp ("timestamp",
&timestamp),
- GNUNET_JSON_spec_string ("sender_account_url",
- &wire_url),
+ TALER_JSON_spec_payto_uri ("sender_account_url",
+ &wire_uri),
GNUNET_JSON_spec_end ()
};
@@ -179,7 +179,7 @@ parse_credit (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- rh->details.in_details.sender_url = GNUNET_strdup (wire_url);
+ rh->details.in_details.sender_url = GNUNET_strdup (wire_uri);
rh->details.in_details.wire_reference = wire_reference;
rh->details.in_details.timestamp = timestamp;
return GNUNET_OK;
@@ -379,7 +379,7 @@ parse_closing (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
{
const struct TALER_EXCHANGE_Keys *key_state;
struct GNUNET_JSON_Specification closing_spec[] = {
- GNUNET_JSON_spec_string (
+ TALER_JSON_spec_payto_uri (
"receiver_account_details",
&rh->details.close_details.receiver_account_details),
GNUNET_JSON_spec_fixed_auto ("wtid",