aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exchange/taler-exchange-httpd_purses_create.c7
-rw-r--r--src/exchange/taler-exchange-httpd_purses_merge.c42
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_purse.c32
-rw-r--r--src/exchangedb/common-0001.sql1
-rw-r--r--src/exchangedb/exchange-0001-part.sql21
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c18
-rw-r--r--src/include/taler_crypto_lib.h52
-rw-r--r--src/include/taler_exchange_service.h2
-rw-r--r--src/include/taler_exchangedb_plugin.h4
-rw-r--r--src/lib/exchange_api_purse_create_with_merge.c26
-rw-r--r--src/lib/exchange_api_purse_merge.c24
-rw-r--r--src/testing/testing_api_cmd_reserve_purse.c1
-rw-r--r--src/util/wallet_signatures.c29
13 files changed, 216 insertions, 43 deletions
diff --git a/src/exchange/taler-exchange-httpd_purses_create.c b/src/exchange/taler-exchange-httpd_purses_create.c
index 4034978b9..a5702ffeb 100644
--- a/src/exchange/taler-exchange-httpd_purses_create.c
+++ b/src/exchange/taler-exchange-httpd_purses_create.c
@@ -55,7 +55,7 @@ struct Coin
struct TALER_Amount amount;
/**
- * Deposit fee applicable for this coin.
+ * Deposit fee applicable to this coin.
*/
struct TALER_Amount deposit_fee;
@@ -220,8 +220,11 @@ create_transaction (void *cls,
{
struct PurseCreateContext *pcc = cls;
enum GNUNET_DB_QueryStatus qs;
+ struct TALER_Amount purse_fee;
bool in_conflict = true;
+ TALER_amount_set_zero (pcc->amount.currency,
+ &purse_fee);
/* 1) create purse */
qs = TEH_plugin->insert_purse_request (TEH_plugin->cls,
pcc->purse_pub,
@@ -229,7 +232,9 @@ create_transaction (void *cls,
pcc->purse_expiration,
&pcc->h_contract_terms,
pcc->min_age,
+ TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
&pcc->amount,
+ &purse_fee,
&pcc->purse_sig,
&in_conflict);
if (qs < 0)
diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c b/src/exchange/taler-exchange-httpd_purses_merge.c
index a95f4ce44..c2b11ca37 100644
--- a/src/exchange/taler-exchange-httpd_purses_merge.c
+++ b/src/exchange/taler-exchange-httpd_purses_merge.c
@@ -497,24 +497,32 @@ TEH_handler_purses_merge (
TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_MERGE_SIGNATURE,
NULL);
}
- if (GNUNET_OK !=
- TALER_wallet_account_merge_verify (
- pcc.merge_timestamp,
- pcc.purse_pub,
- pcc.purse_expiration,
- &pcc.h_contract_terms,
- &pcc.target_amount,
- pcc.min_age,
- &pcc.reserve_pub,
- &pcc.reserve_sig))
{
- GNUNET_break_op (0);
- GNUNET_free (pcc.provider_url);
- return TALER_MHD_reply_with_error (
- connection,
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE,
- NULL);
+ struct TALER_Amount zero_purse_fee;
+
+ TALER_amount_set_zero (pcc.target_amount.currency,
+ &zero_purse_fee);
+ if (GNUNET_OK !=
+ TALER_wallet_account_merge_verify (
+ pcc.merge_timestamp,
+ pcc.purse_pub,
+ pcc.purse_expiration,
+ &pcc.h_contract_terms,
+ &pcc.target_amount,
+ &zero_purse_fee,
+ pcc.min_age,
+ TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
+ &pcc.reserve_pub,
+ &pcc.reserve_sig))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (pcc.provider_url);
+ return TALER_MHD_reply_with_error (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE,
+ NULL);
+ }
}
/* execute transaction */
diff --git a/src/exchange/taler-exchange-httpd_reserves_purse.c b/src/exchange/taler-exchange-httpd_reserves_purse.c
index 3991b4161..5556f78dd 100644
--- a/src/exchange/taler-exchange-httpd_reserves_purse.c
+++ b/src/exchange/taler-exchange-httpd_reserves_purse.c
@@ -61,6 +61,11 @@ struct ReservePurseContext
struct TALER_Amount amount;
/**
+ * Purse fee the client is willing to pay.
+ */
+ struct TALER_Amount purse_fee;
+
+ /**
* Total amount already put into the purse.
*/
struct TALER_Amount deposit_total;
@@ -129,6 +134,11 @@ struct ReservePurseContext
* Minimum age for deposits into this purse.
*/
uint32_t min_age;
+
+ /**
+ * Flags for the operation.
+ */
+ enum TALER_WalletAccountMergeFlags flags;
};
@@ -209,6 +219,8 @@ purse_transaction (void *cls,
rpc->purse_expiration,
&rpc->h_contract_terms,
rpc->min_age,
+ rpc->flags,
+ &rpc->purse_fee,
&rpc->amount,
&rpc->purse_sig,
&in_conflict);
@@ -449,6 +461,7 @@ TEH_handler_reserves_purse (
.reserve_pub = reserve_pub,
.exchange_timestamp = GNUNET_TIME_timestamp_get ()
};
+ bool no_purse_fee = true;
struct GNUNET_JSON_Specification spec[] = {
TALER_JSON_spec_amount ("purse_value",
TEH_currency,
@@ -456,6 +469,11 @@ TEH_handler_reserves_purse (
GNUNET_JSON_spec_uint32 ("min_age",
&rpc.min_age),
GNUNET_JSON_spec_mark_optional (
+ TALER_JSON_spec_amount ("purse_fee",
+ TEH_currency,
+ &rpc.purse_fee),
+ &no_purse_fee),
+ GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_varsize ("econtract",
&rpc.econtract,
&rpc.econtract_size),
@@ -538,7 +556,17 @@ TEH_handler_reserves_purse (
TALER_EC_EXCHANGE_GENERIC_GLOBAL_FEES_MISSING,
NULL);
}
-
+ if (no_purse_fee)
+ {
+ rpc.flags = TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA;
+ TALER_amount_set_zero (TEH_currency,
+ &rpc.purse_fee);
+ }
+ else
+ {
+ rpc.flags = TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE;
+ // FIXME: check rpc.purse_fee is at or above gf.fees.purse!
+ }
TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++;
if (GNUNET_OK !=
TALER_wallet_purse_create_verify (rpc.purse_expiration,
@@ -578,7 +606,9 @@ TEH_handler_reserves_purse (
rpc.purse_expiration,
&rpc.h_contract_terms,
&rpc.amount,
+ &rpc.purse_fee,
rpc.min_age,
+ rpc.flags,
rpc.reserve_pub,
&rpc.reserve_sig))
{
diff --git a/src/exchangedb/common-0001.sql b/src/exchangedb/common-0001.sql
index 861e85475..3690eb347 100644
--- a/src/exchangedb/common-0001.sql
+++ b/src/exchangedb/common-0001.sql
@@ -1165,6 +1165,7 @@ BEGIN
',purse_expiration INT8 NOT NULL'
',h_contract_terms BYTEA NOT NULL CHECK (LENGTH(h_contract_terms)=64)'
',age_limit INT4 NOT NULL'
+ ',flags INT4 NOT NULL'
',refunded BOOLEAN NOT NULL DEFAULT(FALSE)'
',finished BOOLEAN NOT NULL DEFAULT(FALSE)'
',in_reserve_quota BOOLEAN NOT NULL DEFAULT(FALSE)'
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql
index 4b9493bb1..b0c5171d8 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -1016,8 +1016,8 @@ COMMENT ON COLUMN purse_requests.purse_expiration
IS 'When the purse is set to expire';
COMMENT ON COLUMN purse_requests.h_contract_terms
IS 'Hash of the contract the parties are to agree to';
-COMMENT ON COLUMN purse_requests.shard
- IS 'for load distribution among router processes';
+COMMENT ON COLUMN purse_requests.flags
+ IS 'see the enum TALER_WalletAccountMergeFlags';
COMMENT ON COLUMN purse_requests.finished
IS 'set to TRUE once the purse has been merged (into reserve or wad) or the coins were refunded (transfer aborted)';
COMMENT ON COLUMN purse_requests.refunded
@@ -1312,9 +1312,9 @@ COMMENT ON TABLE purse_actions
IS 'purses awaiting some action by the router';
COMMENT ON COLUMN purse_actions.purse_pub
IS 'public (contract) key of the purse';
-COMMENT ON COLUMN purse_action.action_date
+COMMENT ON COLUMN purse_actions.action_date
IS 'when is the purse ready for action';
-COMMENT ON COLUMN purse_action.partner_serial_id
+COMMENT ON COLUMN purse_actions.partner_serial_id
IS 'wad target of an outgoing wire transfer, 0 for local, NULL if the purse is unmerged and thus the target is still unknown';
CREATE INDEX IF NOT EXISTS purse_action_by_target
@@ -1344,6 +1344,7 @@ CREATE TRIGGER purse_requests_on_insert
ON purse_requests
FOR EACH ROW EXECUTE FUNCTION purse_requests_insert_trigger();
COMMENT ON TRIGGER purse_requests_on_insert
+ ON purse_requests
IS 'Here we install an entry for the purse expiration.';
@@ -1392,6 +1393,7 @@ CREATE TRIGGER purse_merges_on_insert
ON purse_merges
FOR EACH ROW EXECUTE FUNCTION purse_merge_insert_trigger();
COMMENT ON TRIGGER purse_merges_on_insert
+ ON purse_merges
IS 'Here we install an entry that triggers the merge (if the purse is already full).';
@@ -1440,6 +1442,10 @@ BEGIN
(NEW.balance_frac >= NEW.amount_with_fee_frac) );
IF (was_merged AND was_paid)
THEN
+ -- FIXME: If 0==psi, why not simply DO the merge here?
+ -- Adding up reserve balance + setting finished
+ -- is hardly doing much, and could be combined
+ -- with the reserve update above!
UPDATE purse_actions
SET action_date=0 --- "immediately"
,partner_serial_id=psi
@@ -1448,14 +1454,15 @@ BEGIN
RETURN NEW;
END $$;
-COMMENT ON FUNCTION purse_requests_on_update_trigger
- IS 'Trigger the router if the purse is ready. Also removes the entry from the router watchlist once the purse is fnished.';
+COMMENT ON FUNCTION purse_requests_on_update_trigger()
+ IS 'Trigger the router if the purse is ready. Also removes the entry from the router watchlist once the purse is finished.';
CREATE TRIGGER purse_requests_on_update
BEFORE UPDATE
ON purse_requests
- FOR EACH ROW EXECUTE FUNCTION purse_requests_update_trigger();
+ FOR EACH ROW EXECUTE FUNCTION purse_requests_on_update_trigger();
COMMENT ON TRIGGER purse_requests_on_update
+ ON purse_requests
IS 'This covers the case where a deposit is made into a purse, which inherently then changes the purse balance via an UPDATE. If the merge is already present and the balance matches the total, we trigger the router. Once the router sets the purse to finished, the trigger will remove the purse from the watchlist of the router.';
---------------------------------------------------------------------------
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index aa4066e6f..a4807d030 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -3541,13 +3541,17 @@ prepare_statements (struct PostgresClosure *pg)
" ,purse_expiration"
" ,h_contract_terms"
" ,age_limit"
+ " ,flags"
+ " ,in_reserve_quota"
" ,amount_with_fee_val"
" ,amount_with_fee_frac"
+ " ,purse_fee_val"
+ " ,purse_fee_frac"
" ,purse_sig"
" ) VALUES "
- " ($1, $2, $3, $4, $5, $6, $7, $8)"
+ " ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)"
" ON CONFLICT DO NOTHING;",
- 8),
+ 12),
/* Used in #postgres_select_purse */
GNUNET_PQ_make_prepare (
"select_purse",
@@ -13481,6 +13485,8 @@ postgres_select_purse_request (
* @param purse_expiration time when the purse will expire
* @param h_contract_terms hash of the contract for the purse
* @param age_limit age limit to enforce for payments into the purse
+ * @param flags flags for the operation
+ * @param purse_fee fee we are allowed to charge to the reserve (depending on @a flags)
* @param amount target amount (with fees) to be put into the purse
* @param purse_sig signature with @a purse_pub's private key affirming the above
* @param[out] in_conflict set to true if the meta data
@@ -13497,19 +13503,27 @@ postgres_insert_purse_request (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
uint32_t age_limit,
+ enum TALER_WalletAccountMergeFlags flags,
+ const struct TALER_Amount *purse_fee,
const struct TALER_Amount *amount,
const struct TALER_PurseContractSignatureP *purse_sig,
bool *in_conflict)
{
struct PostgresClosure *pg = cls;
enum GNUNET_DB_QueryStatus qs;
+ uint32_t flags32 = (uint32_t) flags;
+ bool in_reserve_quota = (TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE
+ == (flags & TALER_WAMF_MERGE_MODE_MASK));
struct GNUNET_PQ_QueryParam params[] = {
GNUNET_PQ_query_param_auto_from_type (purse_pub),
GNUNET_PQ_query_param_auto_from_type (merge_pub),
GNUNET_PQ_query_param_timestamp (&purse_expiration),
GNUNET_PQ_query_param_auto_from_type (h_contract_terms),
GNUNET_PQ_query_param_uint32 (&age_limit),
+ GNUNET_PQ_query_param_uint32 (&flags32),
+ GNUNET_PQ_query_param_bool (in_reserve_quota),
TALER_PQ_query_param_amount (amount),
+ TALER_PQ_query_param_amount (purse_fee),
GNUNET_PQ_query_param_auto_from_type (purse_sig),
GNUNET_PQ_query_param_end
};
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index e55725604..3c413aaf6 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -2862,8 +2862,7 @@ TALER_wallet_purse_deposit_verify (
/**
* Sign a request by a purse to merge it into an account.
*
- * @param reserve_url identifies the location of the reserve,
- * included public key must match @e reserve_priv
+ * @param reserve_url identifies the location of the reserve
* @param merge_timestamp time when the merge happened
* @param purse_pub key identifying the purse
* @param merge_priv key identifying the merge capability
@@ -2881,8 +2880,7 @@ TALER_wallet_purse_merge_sign (
/**
* Verify a purse merge request.
*
- * @param reserve_url identifies the location of the reserve,
- * included public key must match @e reserve_priv
+ * @param reserve_url identifies the location of the reserve
* @param merge_timestamp time when the merge happened
* @param purse_pub public key of the purse to merge
* @param merge_pub public key of the merge capability
@@ -2899,6 +2897,42 @@ TALER_wallet_purse_merge_verify (
/**
+ * Flags for a merge signature.
+ */
+enum TALER_WalletAccountMergeFlags
+{
+
+ /**
+ * A mode must be set. None is not a legal mode!
+ */
+ TALER_WAMF_MODE_NONE = 0,
+
+ /**
+ * We are merging a fully paid-up purse into a reserve.
+ */
+ TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE = 1,
+
+ /**
+ * We are creating a fresh purse, from the contingent
+ * of free purses that our account brings.
+ */
+ TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA = 2,
+
+ /**
+ * The account owner is willing to pay the purse_fee for the purse to be
+ * created from the account balance.
+ */
+ TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE = 3,
+
+ /**
+ * Bitmask to AND the full flags with to get the mode.
+ */
+ TALER_WAMF_MERGE_MODE_MASK = 3
+
+};
+
+
+/**
* Sign a request by an account to merge a purse.
*
* @param merge_timestamp time when the merge happened
@@ -2906,7 +2940,10 @@ TALER_wallet_purse_merge_verify (
* @param purse_expiration when should the purse expire
* @param h_contract_terms contract the two parties agree on
* @param amount total amount in the purse (including fees)
+ * @param purse_fee purse fee the reserve will pay,
+ * only used if @a flags is #TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE
* @param min_age age restriction to apply for deposits into the purse
+ * @param flags flags for the operation
* @param reserve_priv key identifying the reserve
* @param[out] reserve_sig resulting signature
*/
@@ -2917,7 +2954,9 @@ TALER_wallet_account_merge_sign (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_Amount *amount,
+ const struct TALER_Amount *purse_fee,
uint32_t min_age,
+ enum TALER_WalletAccountMergeFlags flags,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig);
@@ -2930,7 +2969,10 @@ TALER_wallet_account_merge_sign (
* @param purse_expiration when should the purse expire
* @param h_contract_terms contract the two parties agree on
* @param amount total amount in the purse (including fees)
+ * @param purse_fee purse fee the reserve will pay,
+ * only used if @a flags is #TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE
* @param min_age age restriction to apply for deposits into the purse
+ * @param flags flags for the operation
* @param reserve_pub account’s public key
* @param reserve_sig the signature made with purpose #TALER_SIGNATURE_WALLET_ACCOUNT_MERGE
* @return #GNUNET_OK if the signature is valid
@@ -2942,7 +2984,9 @@ TALER_wallet_account_merge_verify (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_Amount *amount,
+ const struct TALER_Amount *purse_fee,
uint32_t min_age,
+ enum TALER_WalletAccountMergeFlags flags,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig);
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 756e9cd99..cb4d83520 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -4441,6 +4441,7 @@ struct TALER_EXCHANGE_PurseCreateMergeHandle;
* @param contract_priv private key to get the contract
* @param contract_terms contract the purse is about
* @param upload_contract true to upload the contract
+ * @param pay_for_purse true to pay for purse creation
* @paran merge_timestamp when should the merge happen (use current time)
* @param cb function to call with the exchange's result
* @param cb_cls closure for @a cb
@@ -4455,6 +4456,7 @@ TALER_EXCHANGE_purse_create_with_merge (
const struct TALER_ContractDiffiePrivateP *contract_priv,
const json_t *contract_terms,
bool upload_contract,
+ bool pay_for_purse,
struct GNUNET_TIME_Timestamp merge_timestamp,
TALER_EXCHANGE_PurseCreateMergeCallback cb,
void *cb_cls);
diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h
index 9cdbb9448..7fafdb26e 100644
--- a/src/include/taler_exchangedb_plugin.h
+++ b/src/include/taler_exchangedb_plugin.h
@@ -4578,6 +4578,8 @@ struct TALER_EXCHANGEDB_Plugin
* @param purse_expiration time when the purse will expire
* @param h_contract_terms hash of the contract for the purse
* @param age_limit age limit to enforce for payments into the purse
+ * @param flags flags for the operation
+ * @param purse_fee fee we are allowed to charge to the reserve (depending on @a flags)
* @param amount target amount (with fees) to be put into the purse
* @param purse_sig signature with @a purse_pub's private key affirming the above
* @param[out] in_conflict set to true if the meta data
@@ -4594,6 +4596,8 @@ struct TALER_EXCHANGEDB_Plugin
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
uint32_t age_limit,
+ enum TALER_WalletAccountMergeFlags flags,
+ const struct TALER_Amount *purse_fee,
const struct TALER_Amount *amount,
const struct TALER_PurseContractSignatureP *purse_sig,
bool *in_conflict);
diff --git a/src/lib/exchange_api_purse_create_with_merge.c b/src/lib/exchange_api_purse_create_with_merge.c
index dddf5e4a5..35d52b915 100644
--- a/src/lib/exchange_api_purse_create_with_merge.c
+++ b/src/lib/exchange_api_purse_create_with_merge.c
@@ -250,6 +250,7 @@ TALER_EXCHANGE_purse_create_with_merge (
const struct TALER_ContractDiffiePrivateP *contract_priv,
const json_t *contract_terms,
bool upload_contract,
+ bool pay_for_purse,
struct GNUNET_TIME_Timestamp merge_timestamp,
TALER_EXCHANGE_PurseCreateMergeCallback cb,
void *cb_cls)
@@ -268,6 +269,8 @@ TALER_EXCHANGE_purse_create_with_merge (
struct TALER_PurseContractSignatureP purse_sig;
void *econtract = NULL;
size_t econtract_size = 0;
+ struct TALER_Amount purse_fee;
+ enum TALER_WalletAccountMergeFlags flags;
pcm = GNUNET_new (struct TALER_EXCHANGE_PurseCreateMergeHandle);
pcm->exchange = exchange;
@@ -315,7 +318,22 @@ TALER_EXCHANGE_purse_create_with_merge (
return NULL;
}
}
+ if (pay_for_purse)
+ {
+ const struct TALER_EXCHANGE_GlobalFee *gf;
+ gf = TALER_EXCHANGE_get_global_fee (
+ TALER_EXCHANGE_get_keys (exchange),
+ GNUNET_TIME_timestamp_get ());
+ purse_fee = gf->fees.purse;
+ flags = TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE;
+ }
+ else
+ {
+ TALER_amount_set_zero (pcm->purse_value_after_fees.currency,
+ &purse_fee);
+ flags = TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA;
+ }
GNUNET_assert (GNUNET_YES ==
TEAH_handle_is_ready (exchange));
@@ -359,7 +377,9 @@ TALER_EXCHANGE_purse_create_with_merge (
pcm->purse_expiration,
&pcm->h_contract_terms,
&pcm->purse_value_after_fees,
+ &purse_fee,
min_age,
+ flags,
reserve_priv,
&reserve_sig);
if (upload_contract)
@@ -398,6 +418,12 @@ TALER_EXCHANGE_purse_create_with_merge (
&contract_pub)
: GNUNET_JSON_pack_string ("dummy",
NULL)),
+ GNUNET_JSON_pack_allow_null (
+ pay_for_purse
+ ? TALER_JSON_pack_amount ("purse_fee",
+ &purse_fee)
+ : GNUNET_JSON_pack_string ("dummy2",
+ NULL)),
GNUNET_JSON_pack_data_auto ("merge_pub",
&merge_pub),
GNUNET_JSON_pack_data_auto ("merge_sig",
diff --git a/src/lib/exchange_api_purse_merge.c b/src/lib/exchange_api_purse_merge.c
index d30d5da26..8bfa4248f 100644
--- a/src/lib/exchange_api_purse_merge.c
+++ b/src/lib/exchange_api_purse_merge.c
@@ -349,14 +349,22 @@ TALER_EXCHANGE_account_merge (
purse_pub,
merge_priv,
&merge_sig);
- TALER_wallet_account_merge_sign (merge_timestamp,
- purse_pub,
- purse_expiration,
- h_contract_terms,
- purse_value_after_fees,
- min_age,
- reserve_priv,
- &reserve_sig);
+ {
+ struct TALER_Amount zero_purse_fee;
+
+ TALER_amount_set_zero (purse_value_after_fees->currency,
+ &zero_purse_fee);
+ TALER_wallet_account_merge_sign (merge_timestamp,
+ purse_pub,
+ purse_expiration,
+ h_contract_terms,
+ purse_value_after_fees,
+ &zero_purse_fee,
+ min_age,
+ TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
+ reserve_priv,
+ &reserve_sig);
+ }
merge_obj = GNUNET_JSON_PACK (
GNUNET_JSON_pack_string ("payto_uri",
reserve_url),
diff --git a/src/testing/testing_api_cmd_reserve_purse.c b/src/testing/testing_api_cmd_reserve_purse.c
index ada803d3d..b923e1cc6 100644
--- a/src/testing/testing_api_cmd_reserve_purse.c
+++ b/src/testing/testing_api_cmd_reserve_purse.c
@@ -187,6 +187,7 @@ purse_run (void *cls,
&ds->contract_priv,
ds->contract_terms,
true /* upload contract */,
+ false /* do not pay purse fee -- FIXME: make this a choice to test this case! */,
ds->merge_timestamp,
&purse_cb,
ds);
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
index 85caaca6e..27a28256c 100644
--- a/src/util/wallet_signatures.c
+++ b/src/util/wallet_signatures.c
@@ -1063,6 +1063,12 @@ struct TALER_AccountMergePS
struct TALER_AmountNBO purse_amount;
/**
+ * Purse creation fee to be paid by the reserve for
+ * this operation.
+ */
+ struct TALER_AmountNBO purse_fee;
+
+ /**
* Contract this purse pays for.
*/
struct TALER_PrivateContractHashP h_contract_terms;
@@ -1078,9 +1084,16 @@ struct TALER_AccountMergePS
struct GNUNET_TIME_TimestampNBO merge_timestamp;
/**
- * Minimum age required for payments into this purse.
+ * Minimum age required for payments into this purse,
+ * in NBO.
*/
uint32_t min_age GNUNET_PACKED;
+
+ /**
+ * Flags for the operation, in NBO. See
+ * `enum TALER_WalletAccountMergeFlags`.
+ */
+ uint32_t flags GNUNET_PACKED;
};
@@ -1091,7 +1104,9 @@ TALER_wallet_account_merge_sign (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_Amount *amount,
+ const struct TALER_Amount *purse_fee,
uint32_t min_age,
+ enum TALER_WalletAccountMergeFlags flags,
const struct TALER_ReservePrivateKeyP *reserve_priv,
struct TALER_ReserveSignatureP *reserve_sig)
{
@@ -1102,11 +1117,14 @@ TALER_wallet_account_merge_sign (
.purse_pub = *purse_pub,
.purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration),
.h_contract_terms = *h_contract_terms,
- .min_age = htonl (min_age)
+ .min_age = htonl (min_age),
+ .flags = htonl ((uint32_t) flags)
};
TALER_amount_hton (&pm.purse_amount,
amount);
+ TALER_amount_hton (&pm.purse_fee,
+ purse_fee);
GNUNET_CRYPTO_eddsa_sign (&reserve_priv->eddsa_priv,
&pm,
&reserve_sig->eddsa_signature);
@@ -1120,7 +1138,9 @@ TALER_wallet_account_merge_verify (
struct GNUNET_TIME_Timestamp purse_expiration,
const struct TALER_PrivateContractHashP *h_contract_terms,
const struct TALER_Amount *amount,
+ const struct TALER_Amount *purse_fee,
uint32_t min_age,
+ enum TALER_WalletAccountMergeFlags flags,
const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_ReserveSignatureP *reserve_sig)
{
@@ -1131,11 +1151,14 @@ TALER_wallet_account_merge_verify (
.purse_pub = *purse_pub,
.purse_expiration = GNUNET_TIME_timestamp_hton (purse_expiration),
.h_contract_terms = *h_contract_terms,
- .min_age = htonl (min_age)
+ .min_age = htonl (min_age),
+ .flags = htonl ((uint32_t) flags)
};
TALER_amount_hton (&pm.purse_amount,
amount);
+ TALER_amount_hton (&pm.purse_fee,
+ purse_fee);
return GNUNET_CRYPTO_eddsa_verify (
TALER_SIGNATURE_WALLET_ACCOUNT_MERGE,
&pm,