Offer contract terms trait as a JSON object.
This commit is contained in:
parent
d3f73936ae
commit
793c57317a
@ -206,7 +206,6 @@ deposit_confirmation_run (void *cls,
|
|||||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
||||||
const struct TALER_EXCHANGE_Keys *keys;
|
const struct TALER_EXCHANGE_Keys *keys;
|
||||||
const struct TALER_EXCHANGE_SigningPublicKey *spk;
|
const struct TALER_EXCHANGE_SigningPublicKey *spk;
|
||||||
const char *contract_terms_s;
|
|
||||||
|
|
||||||
dcs->is = is;
|
dcs->is = is;
|
||||||
GNUNET_assert (NULL != dcs->deposit_reference);
|
GNUNET_assert (NULL != dcs->deposit_reference);
|
||||||
@ -236,15 +235,11 @@ deposit_confirmation_run (void *cls,
|
|||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_TESTING_get_trait_contract_terms (deposit_cmd,
|
TALER_TESTING_get_trait_contract_terms (deposit_cmd,
|
||||||
dcs->coin_index,
|
dcs->coin_index,
|
||||||
&contract_terms_s));
|
&contract_terms));
|
||||||
contract_terms = json_loads (contract_terms_s,
|
|
||||||
JSON_REJECT_DUPLICATES,
|
|
||||||
NULL);
|
|
||||||
/* Very unlikely to fail */
|
/* Very unlikely to fail */
|
||||||
GNUNET_assert (NULL != contract_terms);
|
GNUNET_assert (NULL != contract_terms);
|
||||||
TALER_JSON_hash (contract_terms,
|
TALER_JSON_hash (contract_terms,
|
||||||
&h_contract_terms);
|
&h_contract_terms);
|
||||||
json_decref (contract_terms);
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_TESTING_get_trait_wire_details (deposit_cmd,
|
TALER_TESTING_get_trait_wire_details (deposit_cmd,
|
||||||
dcs->coin_index,
|
dcs->coin_index,
|
||||||
|
@ -63,7 +63,7 @@ struct DepositState
|
|||||||
/**
|
/**
|
||||||
* JSON string describing what a proposal is about.
|
* JSON string describing what a proposal is about.
|
||||||
*/
|
*/
|
||||||
const char *contract_terms;
|
json_t *contract_terms;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relative time (to add to 'now') to compute the refund
|
* Relative time (to add to 'now') to compute the refund
|
||||||
@ -257,7 +257,6 @@ deposit_run (void *cls,
|
|||||||
struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
||||||
struct TALER_MerchantPublicKeyP merchant_pub;
|
struct TALER_MerchantPublicKeyP merchant_pub;
|
||||||
struct GNUNET_HashCode h_contract_terms;
|
struct GNUNET_HashCode h_contract_terms;
|
||||||
json_t *contract_terms;
|
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
|
|
||||||
ds->is = is;
|
ds->is = is;
|
||||||
@ -302,21 +301,11 @@ deposit_run (void *cls,
|
|||||||
TALER_TESTING_interpreter_fail (is);
|
TALER_TESTING_interpreter_fail (is);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
contract_terms = json_loads (ds->contract_terms,
|
|
||||||
JSON_REJECT_DUPLICATES,
|
|
||||||
NULL);
|
|
||||||
if (NULL == contract_terms)
|
|
||||||
{
|
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
||||||
"Failed to parse proposal data `%s' at %u/%s\n",
|
|
||||||
ds->contract_terms, is->ip, this_cmd->label);
|
|
||||||
TALER_TESTING_interpreter_fail (is);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_JSON_hash (contract_terms,
|
TALER_JSON_hash (ds->contract_terms,
|
||||||
&h_contract_terms));
|
&h_contract_terms));
|
||||||
json_decref (contract_terms);
|
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv,
|
||||||
&coin_pub.eddsa_pub);
|
&coin_pub.eddsa_pub);
|
||||||
|
|
||||||
@ -427,6 +416,7 @@ deposit_cleanup (void *cls,
|
|||||||
ds->retry_task = NULL;
|
ds->retry_task = NULL;
|
||||||
}
|
}
|
||||||
json_decref (ds->wire_details);
|
json_decref (ds->wire_details);
|
||||||
|
json_decref (ds->contract_terms);
|
||||||
GNUNET_free (ds);
|
GNUNET_free (ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,7 +535,19 @@ TALER_TESTING_cmd_deposit
|
|||||||
ds->coin_reference = coin_reference;
|
ds->coin_reference = coin_reference;
|
||||||
ds->coin_index = coin_index;
|
ds->coin_index = coin_index;
|
||||||
ds->wire_details = wire_details;
|
ds->wire_details = wire_details;
|
||||||
ds->contract_terms = contract_terms;
|
ds->contract_terms = json_loads (contract_terms,
|
||||||
|
JSON_REJECT_DUPLICATES,
|
||||||
|
NULL);
|
||||||
|
if (NULL == ds->contract_terms)
|
||||||
|
{
|
||||||
|
GNUNET_log
|
||||||
|
(GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"Failed to parse contract terms `%s' for CMD `%s'\n",
|
||||||
|
contract_terms,
|
||||||
|
label);
|
||||||
|
GNUNET_assert (0);
|
||||||
|
}
|
||||||
|
|
||||||
ds->refund_deadline = refund_deadline;
|
ds->refund_deadline = refund_deadline;
|
||||||
ds->amount = amount;
|
ds->amount = amount;
|
||||||
ds->expected_response_code = expected_response_code;
|
ds->expected_response_code = expected_response_code;
|
||||||
|
@ -145,9 +145,8 @@ refund_run (void *cls,
|
|||||||
struct RefundState *rs = cls;
|
struct RefundState *rs = cls;
|
||||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
||||||
struct TALER_CoinSpendPublicKeyP coin;
|
struct TALER_CoinSpendPublicKeyP coin;
|
||||||
const char *contract_terms;
|
const json_t *contract_terms;
|
||||||
struct GNUNET_HashCode h_contract_terms;
|
struct GNUNET_HashCode h_contract_terms;
|
||||||
json_t *j_contract_terms;
|
|
||||||
struct TALER_Amount refund_fee;
|
struct TALER_Amount refund_fee;
|
||||||
struct TALER_Amount refund_amount;
|
struct TALER_Amount refund_amount;
|
||||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
||||||
@ -199,17 +198,10 @@ refund_run (void *cls,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
j_contract_terms = json_loads
|
|
||||||
(contract_terms, JSON_REJECT_DUPLICATES, NULL);
|
|
||||||
|
|
||||||
/* Very unlikely to fail */
|
|
||||||
GNUNET_assert (NULL != j_contract_terms);
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_JSON_hash (j_contract_terms,
|
TALER_JSON_hash (contract_terms,
|
||||||
&h_contract_terms));
|
&h_contract_terms));
|
||||||
|
|
||||||
json_decref (j_contract_terms);
|
|
||||||
|
|
||||||
/* Hunting for a coin .. */
|
/* Hunting for a coin .. */
|
||||||
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
|
if (GNUNET_OK != TALER_TESTING_get_trait_coin_priv
|
||||||
(coin_cmd, 0, &coin_priv))
|
(coin_cmd, 0, &coin_priv))
|
||||||
|
@ -269,9 +269,8 @@ track_transaction_run (void *cls,
|
|||||||
const struct TALER_TESTING_Command *transaction_cmd;
|
const struct TALER_TESTING_Command *transaction_cmd;
|
||||||
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
const struct TALER_CoinSpendPrivateKeyP *coin_priv;
|
||||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
const char *contract_terms;
|
const json_t *contract_terms;
|
||||||
const json_t *wire_details;
|
const json_t *wire_details;
|
||||||
json_t *j_contract_terms;
|
|
||||||
struct GNUNET_HashCode h_wire_details;
|
struct GNUNET_HashCode h_wire_details;
|
||||||
struct GNUNET_HashCode h_contract_terms;
|
struct GNUNET_HashCode h_contract_terms;
|
||||||
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
const struct GNUNET_CRYPTO_EddsaPrivateKey *merchant_priv;
|
||||||
@ -315,11 +314,7 @@ track_transaction_run (void *cls,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse them.. */
|
if ((NULL == wire_details) || (NULL == contract_terms))
|
||||||
j_contract_terms = json_loads
|
|
||||||
(contract_terms, JSON_REJECT_DUPLICATES, NULL);
|
|
||||||
|
|
||||||
if ((NULL == wire_details) || (NULL == j_contract_terms))
|
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TALER_TESTING_interpreter_fail (tts->is);
|
TALER_TESTING_interpreter_fail (tts->is);
|
||||||
@ -332,7 +327,7 @@ track_transaction_run (void *cls,
|
|||||||
TALER_JSON_merchant_wire_signature_hash (wire_details,
|
TALER_JSON_merchant_wire_signature_hash (wire_details,
|
||||||
&h_wire_details)) &&
|
&h_wire_details)) &&
|
||||||
(GNUNET_OK ==
|
(GNUNET_OK ==
|
||||||
TALER_JSON_hash (j_contract_terms,
|
TALER_JSON_hash (contract_terms,
|
||||||
&h_contract_terms)) );
|
&h_contract_terms)) );
|
||||||
|
|
||||||
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key
|
if (GNUNET_OK != TALER_TESTING_get_trait_peer_key
|
||||||
|
@ -49,7 +49,7 @@ int
|
|||||||
TALER_TESTING_get_trait_contract_terms
|
TALER_TESTING_get_trait_contract_terms
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
(const struct TALER_TESTING_Command *cmd,
|
||||||
unsigned int index,
|
unsigned int index,
|
||||||
const char **contract_terms)
|
const json_t **contract_terms)
|
||||||
{
|
{
|
||||||
return cmd->traits (cmd->cls,
|
return cmd->traits (cmd->cls,
|
||||||
(const void **) contract_terms,
|
(const void **) contract_terms,
|
||||||
@ -67,7 +67,7 @@ TALER_TESTING_get_trait_contract_terms
|
|||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_contract_terms
|
TALER_TESTING_make_trait_contract_terms
|
||||||
(unsigned int index,
|
(unsigned int index,
|
||||||
const char *contract_terms)
|
const json_t *contract_terms)
|
||||||
{
|
{
|
||||||
struct TALER_TESTING_Trait ret = {
|
struct TALER_TESTING_Trait ret = {
|
||||||
.index = index,
|
.index = index,
|
||||||
|
@ -1880,7 +1880,7 @@ int
|
|||||||
TALER_TESTING_get_trait_contract_terms
|
TALER_TESTING_get_trait_contract_terms
|
||||||
(const struct TALER_TESTING_Command *cmd,
|
(const struct TALER_TESTING_Command *cmd,
|
||||||
unsigned int index,
|
unsigned int index,
|
||||||
const char **contract_terms);
|
const json_t **contract_terms);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1893,7 +1893,7 @@ TALER_TESTING_get_trait_contract_terms
|
|||||||
struct TALER_TESTING_Trait
|
struct TALER_TESTING_Trait
|
||||||
TALER_TESTING_make_trait_contract_terms
|
TALER_TESTING_make_trait_contract_terms
|
||||||
(unsigned int index,
|
(unsigned int index,
|
||||||
const char *contract_terms);
|
const json_t *contract_terms);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user