aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_status.c21
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c2
-rw-r--r--src/exchangedb/plugin_exchangedb_common.c2
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c12
-rw-r--r--src/include/taler_exchange_service.h5
-rw-r--r--src/lib/exchange_api_common.c2
-rw-r--r--src/lib/exchange_api_reserves_status.c2
-rw-r--r--src/testing/test_exchange_p2p.c8
-rw-r--r--src/testing/testing_api_cmd_purse_deposit.c17
-rw-r--r--src/testing/testing_api_cmd_purse_merge.c14
-rw-r--r--src/testing/testing_api_cmd_reserve_history.c11
-rw-r--r--src/testing/testing_api_cmd_reserve_purse.c8
-rw-r--r--src/testing/testing_api_cmd_reserve_status.c17
13 files changed, 93 insertions, 28 deletions
diff --git a/src/exchange/taler-exchange-httpd_reserves_status.c b/src/exchange/taler-exchange-httpd_reserves_status.c
index 6a3260d12..69931e242 100644
--- a/src/exchange/taler-exchange-httpd_reserves_status.c
+++ b/src/exchange/taler-exchange-httpd_reserves_status.c
@@ -54,6 +54,11 @@ struct ReserveStatusContext
struct TALER_EXCHANGEDB_ReserveHistory *rh;
/**
+ * Current KYC status.
+ */
+ struct TALER_EXCHANGEDB_KycStatus kyc;
+
+ /**
* Current reserve balance.
*/
struct TALER_Amount balance;
@@ -85,6 +90,8 @@ reply_reserve_status_success (struct MHD_Connection *connection,
MHD_HTTP_OK,
TALER_JSON_pack_amount ("balance",
&rhc->balance),
+ GNUNET_JSON_pack_bool ("kyc_passed",
+ rhc->kyc.ok),
GNUNET_JSON_pack_array_steal ("history",
json_history));
}
@@ -114,6 +121,20 @@ reserve_status_transaction (void *cls,
struct ReserveStatusContext *rsc = cls;
enum GNUNET_DB_QueryStatus qs;
+ qs = TEH_plugin->inselect_wallet_kyc_status (TEH_plugin->cls,
+ rsc->reserve_pub,
+ &rsc->kyc);
+ if (qs < 0)
+ {
+ if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
+ return qs;
+ GNUNET_break (0);
+ *mhd_ret = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_GENERIC_DB_FETCH_FAILED,
+ "inselect_wallet_status");
+ return qs;
+ }
qs = TEH_plugin->get_reserve_history (TEH_plugin->cls,
rsc->reserve_pub,
&rsc->balance,
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 46499f55c..b52f0b88e 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -741,7 +741,7 @@ TEH_RESPONSE_compile_reserve_history (
pos->details.merge;
struct TALER_Amount amount;
- GNUNET_assert (0 >=
+ GNUNET_assert (0 <=
TALER_amount_subtract (&amount,
&merge->amount_with_fee,
&merge->purse_fee));
diff --git a/src/exchangedb/plugin_exchangedb_common.c b/src/exchangedb/plugin_exchangedb_common.c
index c9ffa5b87..e36074e32 100644
--- a/src/exchangedb/plugin_exchangedb_common.c
+++ b/src/exchangedb/plugin_exchangedb_common.c
@@ -77,6 +77,7 @@ common_free_reserve_history (void *cls,
merge = rh->details.merge;
GNUNET_free (merge);
+ break;
}
case TALER_EXCHANGEDB_RO_HISTORY_REQUEST:
{
@@ -84,6 +85,7 @@ common_free_reserve_history (void *cls,
history = rh->details.history;
GNUNET_free (history);
+ break;
}
}
{
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index ddb8069bc..0db3d4df0 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -4909,7 +4909,7 @@ postgres_inselect_wallet_kyc_status (
payto_uri,
&h_payto,
kyc);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Wire account for `%s' is %llu\n",
payto_uri,
(unsigned long long) kyc->payment_target_uuid);
@@ -6230,8 +6230,8 @@ add_p2p_merge (void *cls,
merge->flags = (enum TALER_WalletAccountMergeFlags) flags32;
}
GNUNET_assert (0 <=
- TALER_amount_add (&rhc->balance_out,
- &rhc->balance_out,
+ TALER_amount_add (&rhc->balance_in,
+ &rhc->balance_in,
&merge->amount_with_fee));
GNUNET_assert (0 <=
TALER_amount_subtract (&rhc->balance_out,
@@ -6443,6 +6443,12 @@ postgres_get_reserve_status (void *cls,
/** #TALER_EXCHANGEDB_RO_EXCHANGE_TO_BANK */
{ "close_by_reserve",
&add_exchange_to_bank },
+ /** #TALER_EXCHANGEDB_RO_PURSE_MERGE */
+ { "merge_by_reserve",
+ &add_p2p_merge },
+ /** #TALER_EXCHANGEDB_RO_HISTORY_REQUEST */
+ { "history_by_reserve",
+ &add_history_requests },
/* List terminator */
{ NULL,
NULL }
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 3cca8b9a2..634e78324 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1696,11 +1696,6 @@ struct TALER_EXCHANGE_ReserveStatus
*/
bool kyc_ok;
- /**
- * KYC required to withdraw?
- */
- bool kyc_required;
-
} ok;
} details;
diff --git a/src/lib/exchange_api_common.c b/src/lib/exchange_api_common.c
index 9ef2d3f44..a4282283d 100644
--- a/src/lib/exchange_api_common.c
+++ b/src/lib/exchange_api_common.c
@@ -415,6 +415,8 @@ parse_merge (struct TALER_EXCHANGE_ReserveHistoryEntry *rh,
&rh->details.merge_details.purse_fee),
GNUNET_JSON_spec_timestamp ("merge_timestamp",
&rh->details.merge_details.merge_timestamp),
+ GNUNET_JSON_spec_timestamp ("purse_expiration",
+ &rh->details.merge_details.purse_expiration),
GNUNET_JSON_spec_end ()
};
diff --git a/src/lib/exchange_api_reserves_status.c b/src/lib/exchange_api_reserves_status.c
index f1221c2ba..35f5846f3 100644
--- a/src/lib/exchange_api_reserves_status.c
+++ b/src/lib/exchange_api_reserves_status.c
@@ -100,8 +100,6 @@ handle_reserves_status_ok (struct TALER_EXCHANGE_ReservesStatusHandle *rsh,
&rs.details.ok.balance),
GNUNET_JSON_spec_bool ("kyc_passed",
&rs.details.ok.kyc_ok),
- GNUNET_JSON_spec_bool ("kyc_required",
- &rs.details.ok.kyc_required),
GNUNET_JSON_spec_json ("history",
&history),
GNUNET_JSON_spec_end ()
diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c
index 50422b2c9..aad0465b7 100644
--- a/src/testing/test_exchange_p2p.c
+++ b/src/testing/test_exchange_p2p.c
@@ -197,14 +197,12 @@ run (void *cls,
"create-reserve-1",
"EUR:1",
MHD_HTTP_OK),
-#if FIXME
/* POST history doesn't yet support P2P transfers */
- TALER_TESTING_cmd_reserves_status (
+ TALER_TESTING_cmd_reserve_status (
"push-check-post-merge-reserve-balance-post",
"create-reserve-1",
"EUR:1",
MHD_HTTP_OK),
-#endif
/* Test conflicting merge */
TALER_TESTING_cmd_purse_merge (
"purse-merge-into-reserve",
@@ -374,8 +372,6 @@ run (void *cls,
"payto://x-taler-bank/localhost/2",
MHD_HTTP_NO_CONTENT,
false),
- TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
- config_file),
TALER_TESTING_cmd_exec_offline_sign_fees ("offline-sign-wire-fees",
config_file,
"EUR:0.01",
@@ -391,6 +387,8 @@ run (void *cls,
GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_DAYS,
1),
+ TALER_TESTING_cmd_exec_offline_sign_keys ("offline-sign-future-keys",
+ config_file),
TALER_TESTING_cmd_check_keys_pull_all_keys ("refetch /keys",
1),
TALER_TESTING_cmd_batch ("withdraw",
diff --git a/src/testing/testing_api_cmd_purse_deposit.c b/src/testing/testing_api_cmd_purse_deposit.c
index b15ba97cf..86ed1b185 100644
--- a/src/testing/testing_api_cmd_purse_deposit.c
+++ b/src/testing/testing_api_cmd_purse_deposit.c
@@ -73,6 +73,12 @@ struct PurseDepositState
struct TALER_PurseContractPublicKeyP purse_pub;
/**
+ * The reserve we are being deposited into.
+ * Set as a trait once we know the reserve.
+ */
+ struct TALER_ReservePublicKeyP reserve_pub;
+
+ /**
* PurseDeposit handle while operation is running.
*/
struct TALER_EXCHANGE_PurseDepositHandle *dh;
@@ -151,6 +157,7 @@ deposit_cb (void *cls,
{
const struct TALER_TESTING_Command *purse_cmd;
const struct TALER_ReserveSignatureP *reserve_sig;
+ const struct TALER_ReservePublicKeyP *reserve_pub;
const struct GNUNET_TIME_Timestamp *merge_timestamp;
purse_cmd = TALER_TESTING_interpreter_lookup_command (ds->is,
@@ -165,6 +172,15 @@ deposit_cb (void *cls,
return;
}
if (GNUNET_OK !=
+ TALER_TESTING_get_trait_reserve_pub (purse_cmd,
+ &reserve_pub))
+ {
+ GNUNET_break (0);
+ TALER_TESTING_interpreter_fail (ds->is);
+ return;
+ }
+ ds->reserve_pub = *reserve_pub;
+ if (GNUNET_OK !=
TALER_TESTING_get_trait_timestamp (purse_cmd,
0,
&merge_timestamp))
@@ -370,6 +386,7 @@ deposit_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_reserve_history (&ds->reserve_history),
+ TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
TALER_TESTING_make_trait_purse_pub (&ds->purse_pub),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_purse_merge.c b/src/testing/testing_api_cmd_purse_merge.c
index 456ba66fc..50e0ac1bc 100644
--- a/src/testing/testing_api_cmd_purse_merge.c
+++ b/src/testing/testing_api_cmd_purse_merge.c
@@ -131,21 +131,16 @@ merge_cb (void *cls,
ds->dh = NULL;
if (MHD_HTTP_OK == dr->hr.http_status)
{
- const struct TALER_EXCHANGE_Keys *keys;
- const struct TALER_EXCHANGE_GlobalFee *gf;
-
ds->reserve_history.type = TALER_EXCHANGE_RTT_MERGE;
- keys = TALER_EXCHANGE_get_keys (ds->is->exchange);
- GNUNET_assert (NULL != keys);
- gf = TALER_EXCHANGE_get_global_fee (keys,
- ds->merge_timestamp);
- GNUNET_assert (NULL != gf);
ds->reserve_history.amount = ds->value_after_fees;
- ds->reserve_history.details.merge_details.purse_fee = gf->fees.purse;
+ TALER_amount_set_zero (ds->value_after_fees.currency,
+ &ds->reserve_history.details.merge_details.purse_fee);
ds->reserve_history.details.merge_details.h_contract_terms
= ds->h_contract_terms;
ds->reserve_history.details.merge_details.merge_pub
= ds->merge_pub;
+ ds->reserve_history.details.merge_details.purse_pub
+ = ds->purse_pub;
ds->reserve_history.details.merge_details.reserve_sig
= *dr->reserve_sig;
ds->reserve_history.details.merge_details.merge_timestamp
@@ -356,6 +351,7 @@ merge_traits (void *cls,
struct TALER_TESTING_Trait traits[] = {
/* history entry MUST be first due to response code logic below! */
TALER_TESTING_make_trait_reserve_history (&ds->reserve_history),
+ TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
TALER_TESTING_make_trait_timestamp (0,
&ds->merge_timestamp),
TALER_TESTING_trait_end ()
diff --git a/src/testing/testing_api_cmd_reserve_history.c b/src/testing/testing_api_cmd_reserve_history.c
index ec190d5ce..6cee5af15 100644
--- a/src/testing/testing_api_cmd_reserve_history.c
+++ b/src/testing/testing_api_cmd_reserve_history.c
@@ -122,7 +122,12 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
history_length,
history,
found))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Entry for batch step `%s' missing in history\n",
+ step->label);
return GNUNET_SYSERR;
+ }
}
return GNUNET_OK;
}
@@ -251,6 +256,9 @@ reserve_history_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Entry for command `%s' missing in history\n",
cmd->label);
+ json_dumpf (rs->hr.reply,
+ stderr,
+ JSON_INDENT (2));
TALER_TESTING_interpreter_fail (ss->is);
return;
}
@@ -262,6 +270,9 @@ reserve_history_cb (void *cls,
"History entry at index %u of type %d not justified by command history\n",
i,
rs->details.ok.history[i].type);
+ json_dumpf (rs->hr.reply,
+ stderr,
+ JSON_INDENT (2));
TALER_TESTING_interpreter_fail (ss->is);
return;
}
diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c
index b57fff2bd..ffdd00053 100644
--- a/src/testing/testing_api_cmd_reserve_purse.c
+++ b/src/testing/testing_api_cmd_reserve_purse.c
@@ -47,6 +47,11 @@ struct ReservePurseState
struct TALER_ReservePrivateKeyP reserve_priv;
/**
+ * Reserve public key.
+ */
+ struct TALER_ReservePublicKeyP reserve_pub;
+
+ /**
* Reserve signature generated for the request
* (client-side).
*/
@@ -176,6 +181,8 @@ purse_run (void *cls,
GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv);
GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv,
&ds->purse_pub.eddsa_pub);
+ GNUNET_CRYPTO_eddsa_key_get_public (&ds->reserve_priv.eddsa_priv,
+ &ds->reserve_pub.eddsa_pub);
GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv);
GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv);
ds->purse_expiration = GNUNET_TIME_absolute_to_timestamp (
@@ -261,6 +268,7 @@ purse_traits (void *cls,
TALER_TESTING_make_trait_merge_priv (&ds->merge_priv),
TALER_TESTING_make_trait_contract_priv (&ds->contract_priv),
TALER_TESTING_make_trait_reserve_priv (&ds->reserve_priv),
+ TALER_TESTING_make_trait_reserve_pub (&ds->reserve_pub),
TALER_TESTING_make_trait_reserve_sig (&ds->reserve_sig),
TALER_TESTING_trait_end ()
};
diff --git a/src/testing/testing_api_cmd_reserve_status.c b/src/testing/testing_api_cmd_reserve_status.c
index 63f50772f..1d104cc3e 100644
--- a/src/testing/testing_api_cmd_reserve_status.c
+++ b/src/testing/testing_api_cmd_reserve_status.c
@@ -87,7 +87,7 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_TESTING_Command *cmd,
unsigned int history_length,
const struct TALER_EXCHANGE_ReserveHistoryEntry *history,
- int *found)
+ bool *found)
{
if (TALER_TESTING_cmd_is_batch (cmd))
{
@@ -114,7 +114,12 @@ analyze_command (const struct TALER_ReservePublicKeyP *reserve_pub,
history_length,
history,
found))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Entry for batch step `%s' missing in history\n",
+ step->label);
return GNUNET_SYSERR;
+ }
}
return GNUNET_OK;
}
@@ -186,7 +191,7 @@ reserve_status_cb (void *cls,
__LINE__);
json_dumpf (rs->hr.reply,
stderr,
- 0);
+ JSON_INDENT (2));
TALER_TESTING_interpreter_fail (ss->is);
return;
}
@@ -209,7 +214,7 @@ reserve_status_cb (void *cls,
return;
}
{
- int found[rs->details.ok.history_len];
+ bool found[rs->details.ok.history_len];
memset (found,
0,
@@ -228,6 +233,9 @@ reserve_status_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Entry for command `%s' missing in history\n",
cmd->label);
+ json_dumpf (rs->hr.reply,
+ stderr,
+ JSON_INDENT (2));
TALER_TESTING_interpreter_fail (ss->is);
return;
}
@@ -239,6 +247,9 @@ reserve_status_cb (void *cls,
"History entry at index %u of type %d not justified by command status\n",
i,
rs->details.ok.history[i].type);
+ json_dumpf (rs->hr.reply,
+ stderr,
+ JSON_INDENT (2));
TALER_TESTING_interpreter_fail (ss->is);
return;
}