diff options
Diffstat (limited to 'src/exchange/taler-exchange-httpd_deposit.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_deposit.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index f44775c0..ab431f8f 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -132,8 +132,25 @@ struct DepositContext */ uint64_t known_coin_id; + /* + * True if @e policy_json was provided + */ + bool has_policy; + + /** + * If @e has_policy is true, the corresponding policy extension calculates + * these details. These will be persisted in the policy_details table. + */ + struct TALER_PolicyDetails policy_details; + /** - * When deposit->has_policy is true, and deposit->policy_details are + * Hash over the policy data for this deposit (remains unknown to the + * Exchange). Needed for the verification of the deposit's signature + */ + struct TALER_ExtensionPolicyHashP h_policy; + + /** + * When has_policy is true, and deposit->policy_details are * persisted, this contains the id of the record in the policy_details table. */ uint64_t policy_details_serial_id; @@ -173,17 +190,14 @@ deposit_transaction (void *cls, /* If the deposit has a policy associated to it, persist it. This will * insert or update the record. */ - if (dc->deposit->has_policy) + if (dc->has_policy) { - struct TALER_Amount accumulated_total; - enum TALER_PolicyFulfillmentState fulfillment_state; - qs = TEH_plugin->persist_policy_details (TEH_plugin->cls, - &dc->deposit->policy_details, - &dc->policy_details_serial_id, - &accumulated_total, - &fulfillment_state); - - /* FIXME: what to do with accumulated_total and fulfillment_state ? */ + qs = TEH_plugin->persist_policy_details ( + TEH_plugin->cls, + &dc->policy_details, + &dc->policy_details_serial_id, + &dc->policy_details.accumulated_total, + &dc->policy_details.fulfillment_state); if (qs < 0) return qs; @@ -194,7 +208,7 @@ deposit_transaction (void *cls, dc->deposit, dc->known_coin_id, &dc->h_payto, - (dc->deposit->has_policy) + (dc->has_policy) ? &dc->policy_details_serial_id : NULL, &dc->exchange_timestamp, @@ -283,7 +297,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, &deposit.wire_deadline), GNUNET_JSON_spec_mark_optional ( GNUNET_JSON_spec_json ("policy", - &deposit.policy_json), + &dc.policy_details.policy_json), &no_policy_json), GNUNET_JSON_spec_end () }; @@ -312,7 +326,7 @@ TEH_handler_deposit (struct MHD_Connection *connection, } /* set the state of the policy presence in the deposit struct */ - deposit.has_policy = ! no_policy_json; + dc.has_policy = ! no_policy_json; /* validate merchant's wire details (as far as we can) */ { @@ -463,23 +477,23 @@ TEH_handler_deposit (struct MHD_Connection *connection, } /* Check policy input and create policy details */ - if (deposit.has_policy) + if (dc.has_policy) { const char *error_hint = NULL; if (GNUNET_OK != TALER_extensions_create_policy_details ( - deposit.policy_json, - &deposit.policy_details, + dc.policy_details.policy_json, + &dc.policy_details, &error_hint)) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_EXCHANGE_DEPOSITS_POLICY_NOT_ACCEPTED, error_hint); - TALER_deposit_policy_hash (deposit.policy_json, - &deposit.h_policy); - ph_policy = &deposit.h_policy; + TALER_deposit_policy_hash (dc.policy_details.policy_json, + &dc.h_policy); + ph_policy = &dc.h_policy; } |