summaryrefslogtreecommitdiff
path: root/src/backenddb/plugin_merchantdb_postgres.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 2db6bca0..a81854d2 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -4543,6 +4543,7 @@ postgres_store_wire_fee_by_exchange (
* @param reserve_priv which reserve is topped up or created
* @param reserve_pub which reserve is topped up or created
* @param exchange_url what URL is the exchange reachable at where the reserve is located
+ * @param payto_uri URI to use to fund the reserve
* @param initial_balance how much money will be added to the reserve
* @param expiration when does the reserve expire?
* @return transaction status, usually
@@ -4554,6 +4555,7 @@ postgres_insert_reserve (void *cls,
const struct TALER_ReservePrivateKeyP *reserve_priv,
const struct TALER_ReservePublicKeyP *reserve_pub,
const char *exchange_url,
+ const char *payto_uri,
const struct TALER_Amount *initial_balance,
struct GNUNET_TIME_Absolute expiration)
{
@@ -4606,6 +4608,7 @@ RETRY:
GNUNET_PQ_query_param_auto_from_type (reserve_pub),
GNUNET_PQ_query_param_auto_from_type (reserve_priv),
GNUNET_PQ_query_param_string (exchange_url),
+ GNUNET_PQ_query_param_string (payto_uri),
GNUNET_PQ_query_param_end
};
@@ -5072,6 +5075,8 @@ postgres_lookup_reserve (void *cls,
struct TALER_Amount pickup_amount;
struct TALER_Amount committed_amount;
uint8_t active;
+ char *exchange_url = NULL;
+ char *payto_uri = NULL;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_absolute_time ("creation_time",
&creation_time),
@@ -5087,6 +5092,14 @@ postgres_lookup_reserve (void *cls,
&committed_amount),
GNUNET_PQ_result_spec_auto_from_type ("active",
&active),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("exchange_url",
+ &exchange_url),
+ NULL),
+ GNUNET_PQ_result_spec_allow_null (
+ GNUNET_PQ_result_spec_string ("payto_uri",
+ &payto_uri),
+ NULL),
GNUNET_PQ_result_spec_end
};
enum GNUNET_DB_QueryStatus qs;
@@ -5108,8 +5121,11 @@ postgres_lookup_reserve (void *cls,
&pickup_amount,
&committed_amount,
(0 != active),
+ exchange_url,
+ payto_uri,
0,
NULL);
+ GNUNET_PQ_cleanup_result (rs);
return qs;
}
@@ -5130,6 +5146,8 @@ postgres_lookup_reserve (void *cls,
&pickup_amount,
&committed_amount,
0 != active,
+ exchange_url,
+ payto_uri,
ltc.tips_length,
ltc.tips);
}
@@ -5138,6 +5156,7 @@ postgres_lookup_reserve (void *cls,
GNUNET_array_grow (ltc.tips,
ltc.tips_length,
0);
+ GNUNET_PQ_cleanup_result (rs);
return ltc.qs;
}
@@ -8213,15 +8232,16 @@ postgres_connect (void *cls)
"(reserve_serial"
",reserve_priv"
",exchange_url"
+ ",payto_uri"
")"
- "SELECT reserve_serial, $3, $4"
+ "SELECT reserve_serial, $3, $4, $5"
" FROM merchant_tip_reserves"
" WHERE reserve_pub=$2"
" AND merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
" WHERE merchant_id=$1)",
- 4),
+ 5),
/* For postgres_lookup_reserves() */
GNUNET_PQ_make_prepare ("lookup_reserves",
"SELECT"
@@ -8273,6 +8293,8 @@ postgres_connect (void *cls)
",tips_picked_up_val"
",tips_picked_up_frac"
",reserve_priv IS NOT NULL AS active"
+ ",exchange_url"
+ ",payto_uri"
" FROM merchant_tip_reserves"
" FULL OUTER JOIN merchant_tip_reserve_keys USING (reserve_serial)"
" WHERE reserve_pub = $2"