diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-04-24 15:29:50 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-04-24 15:29:58 +0200 |
commit | aedd2014ec50e2b52cad76d9c40c218ed0c9ccfc (patch) | |
tree | 3b4ef17e90f152a161c6929fbe1da07c366a4268 /src/lib | |
parent | 36c568ab8df9b8e523c9ffc45271533af77accc7 (diff) |
-misc p2p fixes
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/exchange_api_purse_create_with_deposit.c | 9 | ||||
-rw-r--r-- | src/lib/exchange_api_purse_merge.c | 21 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/lib/exchange_api_purse_create_with_deposit.c b/src/lib/exchange_api_purse_create_with_deposit.c index f6f8c2d86..60f0f7361 100644 --- a/src/lib/exchange_api_purse_create_with_deposit.c +++ b/src/lib/exchange_api_purse_create_with_deposit.c @@ -242,7 +242,6 @@ TALER_EXCHANGE_purse_create_with_deposit ( const struct TALER_PurseMergePrivateKeyP *merge_priv, const struct TALER_ContractDiffiePrivateP *contract_priv, const json_t *contract_terms, - struct GNUNET_TIME_Timestamp purse_expiration, unsigned int num_deposits, const struct TALER_EXCHANGE_PurseDeposit *deposits, bool upload_contract, @@ -265,10 +264,10 @@ TALER_EXCHANGE_purse_create_with_deposit ( pch->exchange = exchange; pch->cb = cb; pch->cb_cls = cb_cls; - // FIXME: get expiration from pay deadline of contract? - pch->purse_expiration = purse_expiration; { struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_timestamp ("pay_deadline", + &pch->purse_expiration), TALER_JSON_spec_amount_any ("amount", &pch->purse_value_after_fees), GNUNET_JSON_spec_mark_optional ( @@ -390,7 +389,7 @@ TALER_EXCHANGE_purse_create_with_deposit ( jdeposit)); } GNUNET_free (url); - TALER_wallet_purse_create_sign (purse_expiration, + TALER_wallet_purse_create_sign (pch->purse_expiration, &pch->h_contract_terms, &pch->merge_pub, min_age, @@ -443,7 +442,7 @@ TALER_EXCHANGE_purse_create_with_deposit ( GNUNET_JSON_pack_data_auto ("h_contract_terms", &pch->h_contract_terms), GNUNET_JSON_pack_timestamp ("purse_expiration", - purse_expiration), + pch->purse_expiration), GNUNET_JSON_pack_array_steal ("deposits", deposit_arr)); GNUNET_free (econtract); diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c index e541afaba..2dc9e4ca0 100644 --- a/src/lib/exchange_api_purse_merge.c +++ b/src/lib/exchange_api_purse_merge.c @@ -272,7 +272,10 @@ TALER_EXCHANGE_account_merge ( pch->h_contract_terms = *h_contract_terms; pch->purse_expiration = purse_expiration; pch->purse_value_after_fees = *purse_value_after_fees; - pch->provider_url = GNUNET_strdup (reserve_exchange_url); + if (NULL == reserve_exchange_url) + pch->provider_url = GNUNET_strdup (exchange->url); + else + pch->provider_url = GNUNET_strdup (reserve_exchange_url); GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv, &pch->reserve_pub.eddsa_pub); @@ -305,31 +308,33 @@ TALER_EXCHANGE_account_merge ( pub_str, sizeof (pub_str)); *end = '\0'; - if (0 == strncmp (reserve_exchange_url, + if (0 == strncmp (pch->provider_url, "http://", strlen ("http://"))) { is_http = true; - exchange_url = &reserve_exchange_url[strlen ("http://")]; + exchange_url = &pch->provider_url[strlen ("http://")]; } - else if (0 == strncmp (reserve_exchange_url, + else if (0 == strncmp (pch->provider_url, "https://", strlen ("https://"))) { is_http = false; - exchange_url = &reserve_exchange_url[strlen ("https://")]; + exchange_url = &pch->provider_url[strlen ("https://")]; } else { GNUNET_break (0); + GNUNET_free (pch->provider_url); GNUNET_free (pch); return NULL; } + /* exchange_url includes trailing '/' */ GNUNET_asprintf (&reserve_url, - "payto://%s/%s/%s", + "payto://%s/%s%s", is_http ? "taler+http" : "taler", - pub_str, - exchange_url); + exchange_url, + pub_str); } pch->url = TEAH_path_to_url (exchange, arg_str); |