update generator scripts to use new -offline tools (WiP)

This commit is contained in:
Christian Grothoff 2020-12-14 18:27:16 +01:00
parent 45926ec067
commit 4a519078e8
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
12 changed files with 110 additions and 2083 deletions

View File

@ -10,6 +10,7 @@ UNIXPATH_MODE = 660
PORT = 8081 PORT = 8081
BASE_URL = http://localhost:8081/ BASE_URL = http://localhost:8081/
SIGNKEY_DURATION = 4 weeks SIGNKEY_DURATION = 4 weeks
SIGNKEY_LEGAL_DURATION = 4 weeks
LEGAL_DURATION = 2 years LEGAL_DURATION = 2 years
LOOKAHEAD_SIGN = 32 weeks 1 day LOOKAHEAD_SIGN = 32 weeks 1 day
LOOKAHEAD_PROVIDE = 4 weeks 1 day LOOKAHEAD_PROVIDE = 4 weeks 1 day
@ -45,6 +46,7 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
UNIXPATH_MODE = 660 UNIXPATH_MODE = 660
PORT = 8083 PORT = 8083
AUDITOR_URL = http://localhost:8083/ AUDITOR_URL = http://localhost:8083/
BASE_URL = http://localhost:8083/
TINY_AMOUNT = TESTKUDOS:0.01 TINY_AMOUNT = TESTKUDOS:0.01
[PATHS] [PATHS]

View File

@ -98,27 +98,18 @@ taler-config -c $CONF -s bank -o database -V postgres:///$TARGET_DB
# setup exchange # setup exchange
echo "Setting up exchange" echo "Setting up exchange"
taler-exchange-dbinit -c $CONF taler-exchange-dbinit -c $CONF
taler-exchange-wire -c $CONF 2> taler-exchange-wire.log
taler-exchange-keyup -L INFO -c $CONF -o e2a.dat 2> taler-exchange-keyup.log
# setup auditor # setup auditor
echo "Setting up auditor" echo "Setting up auditor"
taler-auditor-dbinit -c $CONF taler-auditor-dbinit -c $CONF
taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
taler-auditor-sign -c $CONF -u $AUDITOR_URL -r e2a.dat -o a2e.dat -m $MASTER_PUB
rm -f e2a.dat
# provide auditor's signature to exchange
ABD=`taler-config -c $CONF -s EXCHANGEDB -o AUDITOR_BASE_DIR -f`
mkdir -p $ABD
mv a2e.dat $ABD
# Launch services # Launch services
echo "Launching services" echo "Launching services"
taler-bank-manage-testing $CONF postgres:///$TARGET_DB serve & taler-bank-manage-testing $CONF postgres:///$TARGET_DB serve &> taler-bank.log &
TFN=`which taler-exchange-httpd` TFN=`which taler-exchange-httpd`
TBINPFX=`dirname $TFN` TBINPFX=`dirname $TFN`
TLIBEXEC=${BINPFX}/../lib/libexec/taler/ TLIBEXEC=${TBINPFX}/../lib/taler/libexec/
$TLIBEXEC/taler-helper-crypto-eddsa -c $CONF 2> taler-helper-crypto-eddsa.log & $TLIBEXEC/taler-helper-crypto-eddsa -c $CONF 2> taler-helper-crypto-eddsa.log &
$TLIBEXEC/taler-helper-crypto-rsa -c $CONF 2> taler-helper-crypto-rsa.log & $TLIBEXEC/taler-helper-crypto-rsa -c $CONF 2> taler-helper-crypto-rsa.log &
taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log & taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
@ -126,6 +117,23 @@ taler-merchant-httpd -c $CONF -L INFO 2> taler-merchant-httpd.log &
taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log & taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log & taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
# Wait for all bank to be available (usually the slowest)
for n in `seq 1 50`
do
echo -n "."
sleep 0.2
OK=0
# bank
wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
OK=1
break
done
if [ 1 != $OK ]
then
exit_skip "Failed to launch services"
fi
# Wait for all services to be available # Wait for all services to be available
for n in `seq 1 50` for n in `seq 1 50`
do do
@ -133,11 +141,9 @@ do
sleep 0.1 sleep 0.1
OK=0 OK=0
# exchange # exchange
wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null || continue wget http://localhost:8081/seed -o /dev/null -O /dev/null >/dev/null || continue
# merchant # merchant
wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
# bank
wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
# Auditor # Auditor
wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
OK=1 OK=1
@ -148,9 +154,41 @@ if [ 1 != $OK ]
then then
exit_skip "Failed to launch services" exit_skip "Failed to launch services"
fi fi
echo " DONE"
echo -n "Setting up keys"
taler-exchange-offline -c $CONF \
download sign \
enable-account payto://x-taler-bank/localhost/2 \
wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 \
upload &> taler-exchange-offline.log
echo -n "."
for n in `seq 1 2`
do
echo -n "."
OK=0
# bank
wget --timeout=1 http://localhost:8081/keys -o /dev/null -O /dev/null >/dev/null || continue
OK=1
break
done
if [ 1 != $OK ]
then
exit_skip "Failed to setup keys"
fi
taler-auditor-offline -c $CONF \
download sign upload &> taler-auditor-offline.log
echo " DONE"
# Setup merchant # Setup merchant
echo -n "Setting up merchant"
curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances

View File

@ -86,27 +86,17 @@ taler-config -c $CONF -s exchange -o REVOCATION_DIR -V "${TMP_DIR}/revdir/"
# setup exchange # setup exchange
echo "Setting up exchange" echo "Setting up exchange"
taler-exchange-dbinit -c $CONF taler-exchange-dbinit -c $CONF
taler-exchange-wire -c $CONF 2> taler-exchange-wire.log
taler-exchange-keyup -L INFO -c $CONF -o e2a.dat 2> taler-exchange-keyup.log
# setup auditor # setup auditor
echo "Setting up auditor" echo "Setting up auditor"
taler-auditor-dbinit -c $CONF taler-auditor-dbinit -c $CONF
taler-auditor-exchange -c $CONF -m $MASTER_PUB -u $EXCHANGE_URL
taler-auditor-sign -c $CONF -u $AUDITOR_URL -r e2a.dat -o a2e.dat -m $MASTER_PUB
rm -f e2a.dat
# provide auditor's signature to exchange
ABD=`taler-config -c $CONF -s EXCHANGEDB -o AUDITOR_BASE_DIR -f`
mkdir -p $ABD
mv a2e.dat $ABD
# Launch services # Launch services
echo "Launching services" echo "Launching services"
taler-bank-manage-testing $CONF postgres:///$TARGET_DB serve &> revocation-bank.log & taler-bank-manage-testing $CONF postgres:///$TARGET_DB serve &> revocation-bank.log &
TFN=`which taler-exchange-httpd` TFN=`which taler-exchange-httpd`
TBINPFX=`dirname $TFN` TBINPFX=`dirname $TFN`
TLIBEXEC=${BINPFX}/../lib/libexec/taler/ TLIBEXEC=${TBINPFX}/../lib/taler/libexec/
$TLIBEXEC/taler-helper-crypto-eddsa -c $CONF 2> taler-helper-crypto-eddsa.log & $TLIBEXEC/taler-helper-crypto-eddsa -c $CONF 2> taler-helper-crypto-eddsa.log &
$TLIBEXEC/taler-helper-crypto-rsa -c $CONF 2> taler-helper-crypto-rsa.log & $TLIBEXEC/taler-helper-crypto-rsa -c $CONF 2> taler-helper-crypto-rsa.log &
taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log & taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
@ -127,6 +117,12 @@ do
OK=1 OK=1
break break
done done
if [ 1 != $OK ]
then
exit_skip "Failed to launch services"
fi
# Wait for all other services to be available # Wait for all other services to be available
for n in `seq 1 50` for n in `seq 1 50`
do do
@ -134,7 +130,7 @@ do
sleep 0.1 sleep 0.1
OK=0 OK=0
# exchange # exchange
wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null || continue wget http://localhost:8081/seed -o /dev/null -O /dev/null >/dev/null || continue
# merchant # merchant
wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
# Auditor # Auditor
@ -143,7 +139,6 @@ do
break break
done done
if [ 1 != $OK ] if [ 1 != $OK ]
then then
cleanup cleanup
@ -151,7 +146,39 @@ then
fi fi
echo " DONE" echo " DONE"
echo -n "Setting up keys"
taler-exchange-offline -c $CONF \
download sign \
enable-account payto://x-taler-bank/localhost/2 \
wire-fee now x-taler-bank TESTKUDOS:0.01 TESTKUDOS:0.01 \
upload &> taler-exchange-offline.log
echo -n "."
for n in `seq 1 2`
do
echo -n "."
OK=0
# bank
wget --timeout=1 http://localhost:8081/keys -o /dev/null -O /dev/null >/dev/null || continue
OK=1
break
done
if [ 1 != $OK ]
then
exit_skip "Failed to setup keys"
fi
taler-auditor-offline -c $CONF \
download sign upload &> taler-auditor-offline.log
echo " DONE"
# Setup merchant # Setup merchant
echo -n "Setting up merchant"
curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances curl -H "Content-Type: application/json" -X POST -d '{"payto_uris":["payto://x-taler-bank/localhost/43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"TESTKUDOS:1", "default_max_deposit_fee":"TESTKUDOS:1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_ms" : 3600000},"default_pay_delay":{"d_ms": 3600000}}' http://localhost:9966/private/instances
@ -186,15 +213,14 @@ echo "Revoking denomination ${rd} (to affect coin ${rc})"
export susp=$(echo "$coins" | jq --arg rc "$rc" '[.coins[] | select(.coin_pub != $rc) | .coin_pub]') export susp=$(echo "$coins" | jq --arg rc "$rc" '[.coins[] | select(.coin_pub != $rc) | .coin_pub]')
# Do the revocation # Do the revocation
taler-exchange-keyup -o e2a2.dat -c $CONF -r $rd taler-exchange-offline -c $CONF \
taler-auditor-sign -c $CONF -u $AUDITOR_URL -r e2a2.dat -o a2e2.dat -m $MASTER_PUB revoke-denomination "${rd}" upload &> taler-exchange-offline-revoke.log
rm -f e2a2.dat
mv a2e2.dat $ABD
# Restart the exchange... sleep 1 # Give exchange time to create replacmenent key
kill -SIGUSR1 $EXCHANGE_PID
sleep 1 # Give exchange time to re-scan data # Re-sign replacment keys
echo "Restarted the exchange post revocation" taler-auditor-offline -c $CONF \
download sign upload &> taler-auditor-offline.log
# Now we suspend the other coins, so later we will pay with the recouped coin # Now we suspend the other coins, so later we will pay with the recouped coin
taler-wallet-cli --wallet-db=$WALLET_DB advanced suspend-coins "$susp" taler-wallet-cli --wallet-db=$WALLET_DB advanced suspend-coins "$susp"
@ -280,15 +306,14 @@ export susp=$(echo "$coins" | jq --arg freshc "$freshc" '[.coins[] | select(.coi
# Do the revocation of freshc # Do the revocation of freshc
echo "Revoking ${fresh_denom} (to affect coin ${freshc})" echo "Revoking ${fresh_denom} (to affect coin ${freshc})"
taler-exchange-keyup -c $CONF -o e2a3.dat -r $fresh_denom taler-exchange-offline -c $CONF \
taler-auditor-sign -c $CONF -u $AUDITOR_URL -r e2a3.dat -o a2e3.dat -m $MASTER_PUB revoke-denomination "${fresh_denom}" upload &> taler-exchange-offline-revoke-2.log
rm -f e2a3.dat
mv a2e3.dat $ABD
# Restart the exchange... sleep 1 # Give exchange time to create replacmenent key
kill -SIGUSR1 $EXCHANGE_PID
sleep 1 # give exchange time to re-scan data
# Re-sign replacment keys
taler-auditor-offline -c $CONF \
download sign upload &> taler-auditor-offline.log
# Now we suspend the other coins, so later we will pay with the recouped coin # Now we suspend the other coins, so later we will pay with the recouped coin
taler-wallet-cli $TIMETRAVEL --wallet-db=$WALLET_DB advanced suspend-coins "$susp" taler-wallet-cli $TIMETRAVEL --wallet-db=$WALLET_DB advanced suspend-coins "$susp"

View File

@ -1,5 +1,2 @@
test_taler_exchange_httpd_home/.local/share/taler/exchange/live-keys/
test_taler_exchange_httpd_home/.local/share/taler/exchange/wirefees/
test_taler_exchange_httpd_home/.config/taler/account-1.json
taler-exchange-offline taler-exchange-offline
taler-auditor-offline taler-auditor-offline

View File

@ -14,25 +14,9 @@ endif
bin_PROGRAMS = \ bin_PROGRAMS = \
taler-auditor-offline \ taler-auditor-offline \
taler-exchange-keyup \
taler-exchange-offline \ taler-exchange-offline \
taler-exchange-wire \
taler-exchange-dbinit taler-exchange-dbinit
taler_exchange_keyup_SOURCES = \
taler-exchange-keyup.c
taler_exchange_keyup_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/pq/libtalerpq.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil \
$(XLIB)
taler_exchange_keyup_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_exchange_offline_SOURCES = \ taler_exchange_offline_SOURCES = \
taler-exchange-offline.c taler-exchange-offline.c
taler_exchange_offline_LDADD = \ taler_exchange_offline_LDADD = \
@ -46,7 +30,6 @@ taler_exchange_offline_LDADD = \
-lgnunetutil \ -lgnunetutil \
$(XLIB) $(XLIB)
taler_auditor_offline_SOURCES = \ taler_auditor_offline_SOURCES = \
taler-auditor-offline.c taler-auditor-offline.c
taler_auditor_offline_LDADD = \ taler_auditor_offline_LDADD = \
@ -60,21 +43,6 @@ taler_auditor_offline_LDADD = \
-lgnunetutil \ -lgnunetutil \
$(XLIB) $(XLIB)
taler_exchange_wire_SOURCES = \
taler-exchange-wire.c
taler_exchange_wire_LDADD = \
$(LIBGCRYPT_LIBS) \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
$(top_builddir)/src/bank-lib/libtalerbank.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetjson \
-lgnunetutil \
-ljansson \
$(XLIB)
taler_exchange_wire_LDFLAGS = $(POSTGRESQL_LDFLAGS)
taler_exchange_dbinit_SOURCES = \ taler_exchange_dbinit_SOURCES = \
taler-exchange-dbinit.c taler-exchange-dbinit.c
taler_exchange_dbinit_LDADD = \ taler_exchange_dbinit_LDADD = \
@ -99,8 +67,4 @@ AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=
# Distribution # Distribution
EXTRA_DIST = \ EXTRA_DIST = \
test_taler_exchange_httpd_home/.local/share/taler/exchange/offline-keys/master.priv \
test_taler_exchange_httpd.conf \
key-helper.c \
$(check_SCRIPTS) \
$(pkgcfg_DATA) $(pkgcfg_DATA)

View File

@ -1,130 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2015-2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file key-helper.c
* @brief shared logic between tools that deal with the master private key
* @author Christian Grothoff
*/
/**
* Extract the @a master_priv from the @a cfg or @a masterkeyfile and
* verify that it matches the master public key given in @a cfg.
*
* @param cfg configuration to use
* @param masterkeyfile master private key filename, can be NULL to use from @a cfg
* @param[out] master_priv where to store the master private key on success
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failures
*/
static int
get_and_check_master_key (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *masterkeyfile,
struct TALER_MasterPrivateKeyP *master_priv)
{
struct GNUNET_CRYPTO_EddsaPublicKey mpub;
struct GNUNET_CRYPTO_EddsaPublicKey mpub_cfg;
char *fn;
if (NULL != masterkeyfile)
{
fn = GNUNET_strdup (masterkeyfile);
}
else
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
"exchange",
"MASTER_PRIV_FILE",
&fn))
{
fprintf (stderr,
"Master private key file given neither in configuration nor on command-line\n");
return GNUNET_SYSERR;
}
}
if (GNUNET_YES !=
GNUNET_DISK_file_test (fn))
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exchange master private key `%s' does not exist yet, creating it!\n",
fn);
{
int ret;
ret = GNUNET_CRYPTO_eddsa_key_from_file (fn,
GNUNET_YES,
&master_priv->eddsa_priv);
if (GNUNET_SYSERR == ret)
{
fprintf (stderr,
"Failed to initialize master key from file `%s': %s\n",
fn,
"could not create file");
GNUNET_free (fn);
return GNUNET_SYSERR;
}
GNUNET_CRYPTO_eddsa_key_get_public (&master_priv->eddsa_priv,
&mpub);
}
/* Check our key matches that in the configuration */
{
char *masters;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
"exchange",
"MASTER_PUBLIC_KEY",
&masters))
{
/* Help user by telling them precisely what to fix */
masters = GNUNET_STRINGS_data_to_string_alloc (&mpub,
sizeof (mpub));
fprintf (stderr,
"You must set MASTER_PUBLIC_KEY to `%s' in the [exchange] section of the configuration before proceeding.\n",
masters);
GNUNET_free (masters);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (masters,
strlen (masters),
&mpub_cfg,
sizeof (mpub_cfg)))
{
fprintf (stderr,
"MASTER_PUBLIC_KEY value `%s' specified in section [exchange] of the configuration is not a valid public key\n",
masters);
GNUNET_free (masters);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
if (0 != GNUNET_memcmp (&mpub,
&mpub_cfg))
{
fprintf (stderr,
"MASTER_PUBLIC_KEY value `%s' specified in section [exchange] of the configuration does not match our master private key. You can use `gnunet-ecc -p \"%s\"' to determine the correct value.\n",
masters,
fn);
GNUNET_free (masters);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
GNUNET_free (masters);
}
GNUNET_free (fn);
return GNUNET_OK;
}

View File

@ -417,7 +417,7 @@ upload_denomination_add (const char *exchange_url,
&err_line)) &err_line))
{ {
fprintf (stderr, fprintf (stderr,
"Invalid input for adding wire account: %s#%u at %u (skipping)\n", "Invalid input for adding denomination: %s#%u at %u (skipping)\n",
err_name, err_name,
err_line, err_line,
(unsigned int) idx); (unsigned int) idx);
@ -996,8 +996,8 @@ sign_denomkeys (const json_t *denomkeys)
&auditor_priv, &auditor_priv,
&auditor_sig); &auditor_sig);
output_operation ("sign-denomination", output_operation ("sign-denomination",
json_pack ("{s:o,s:o}", json_pack ("{s:o, s:o}",
"h_denomn_pub", "h_denom_pub",
GNUNET_JSON_from_data_auto (&h_denom_pub), GNUNET_JSON_from_data_auto (&h_denom_pub),
"auditor_sig", "auditor_sig",
GNUNET_JSON_from_data_auto (&auditor_sig))); GNUNET_JSON_from_data_auto (&auditor_sig)));

File diff suppressed because it is too large Load Diff

View File

@ -1,225 +0,0 @@
/*
This file is part of TALER
Copyright (C) 2015-2018 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* @file taler-exchange-wire.c
* @brief Create signed response for /wire requests.
* @author Christian Grothoff
*/
#include <platform.h>
#include <jansson.h>
#include <gnunet/gnunet_json_lib.h>
#include "taler_crypto_lib.h"
#include "taler_util.h"
#include "taler_json_lib.h"
#include "taler_exchangedb_lib.h"
#include "taler_signatures.h"
/**
* Filename of the master private key.
*/
static char *masterkeyfile;
/**
* Private key for signing.
*/
static struct TALER_MasterPrivateKeyP master_priv;
/**
* Return value from main().
*/
static int global_ret;
#include "key-helper.c"
/**
* Function called with information about a wire account. Signs
* the account's wire details and writes out the JSON file to disk.
*
* @param cls closure
* @param ai account information
*/
static void
sign_account_data (void *cls,
const struct TALER_EXCHANGEDB_AccountInfo *ai)
{
char *json_out;
FILE *out;
int ret;
(void) cls;
if (GNUNET_NO == ai->credit_enabled)
return;
if (NULL == ai->wire_response_filename)
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
ai->section_name,
"WIRE_RESPONSE");
global_ret = 1;
return;
}
{
json_t *wire;
wire = TALER_JSON_exchange_wire_signature_make (ai->payto_uri,
&master_priv);
if (NULL == wire)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Could not sign wire account `%s'. Is the URI well-formed?\n",
ai->payto_uri);
global_ret = 1;
return;
}
GNUNET_assert (NULL != wire);
json_out = json_dumps (wire,
JSON_INDENT (2));
json_decref (wire);
}
GNUNET_assert (NULL != json_out);
if (GNUNET_OK !=
GNUNET_DISK_directory_create_for_file (ai->wire_response_filename))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"mkdir",
ai->wire_response_filename);
global_ret = 1;
free (json_out);
return;
}
out = fopen (ai->wire_response_filename,
"w+"); /* create, if exists, truncate */
if (NULL == out)
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"fopen(w+)",
ai->wire_response_filename);
global_ret = 1;
free (json_out);
return;
}
ret = fprintf (out,
"%s",
json_out);
if ( (0 != fclose (out)) ||
(-1 == ret) )
{
fprintf (stderr,
"Failure creating wire account file `%s': %s\n",
ai->wire_response_filename,
strerror (errno));
/* attempt to remove malformed file */
if (0 != unlink (ai->wire_response_filename))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
"unlink",
ai->wire_response_filename);
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Created wire account file `%s'\n",
ai->wire_response_filename);
}
free (json_out);
}
/**
* Main function that will be run.
*
* @param cls closure
* @param args remaining command-line arguments
* @param cfgfile name of the configuration file used (for saving, can be NULL!)
* @param cfg configuration
*/
static void
run (void *cls,
char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
(void) cls;
(void) args;
(void) cfgfile;
if (GNUNET_OK !=
get_and_check_master_key (cfg,
masterkeyfile,
&master_priv))
{
global_ret = 1;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Signing /wire responses\n");
if (GNUNET_OK !=
TALER_EXCHANGEDB_find_accounts (cfg,
&sign_account_data,
NULL))
{
global_ret = 1;
return;
}
}
/**
* The main function of the taler-exchange-wire tool. This tool is
* used to sign the bank account details using the master key.
*
* @param argc number of arguments from the command line
* @param argv command line arguments
* @return 0 ok, 1 on error
*/
int
main (int argc,
char *const *argv)
{
const struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_timetravel ('T',
"timetravel"),
GNUNET_GETOPT_option_filename ('m',
"master-key",
"FILENAME",
"master key file (private key)",
&masterkeyfile),
GNUNET_GETOPT_OPTION_END
};
/* force linker to link against libtalerutil; if we do
not do this, the linker may "optimize" libtalerutil
away and skip #TALER_OS_init(), which we do need */
(void) TALER_project_data_default ();
GNUNET_assert (GNUNET_OK ==
GNUNET_log_setup ("taler-exchange-wire",
"WARNING",
NULL));
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv,
"taler-exchange-wire",
"Setup /wire response",
options,
&run, NULL))
return 1;
return global_ret;
}
/* end of taler-exchange-wire.c */

View File

@ -1,130 +0,0 @@
[PATHS]
# Persistent data storage for the testcase
TALER_TEST_HOME = test_taler_exchange_httpd_home/
[taler]
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
CURRENCY_ROUND_UNIT = EUR:0.01
[exchange]
# Directory with our terms of service.
TERMS_DIR = ../../contrib/tos
# Etag / filename for the terms of service.
TERMS_ETAG = 0
# Directory with our privacy policy.
PRIVACY_DIR = ../../contrib/pp
# Etag / filename for the privacy policy.
PRIVACY_ETAG = 0
# MAX_REQUESTS = 2
# how long is one signkey valid?
SIGNKEY_DURATION = 4 weeks
# how long are the signatures with the signkey valid?
LEGAL_DURATION = 2 years
# how long do we generate denomination and signing keys
# ahead of time?
LOOKAHEAD_SIGN = 2 weeks 1 day
# how long do we provide to clients denomination and signing keys
# ahead of time?
LOOKAHEAD_PROVIDE = 1 weeks 1 day
# HTTP port the exchange listens to
PORT = 8081
# Master public key used to sign the exchange's various keys
MASTER_PUBLIC_KEY = 98NJW3CQHZQGQXTY3K85K531XKPAPAVV4Q5V8PYYRR00NJGZWNVG
# How to access our database
DB = postgres
[exchangedb]
# After how long do we close idle reserves? The exchange
# and the auditor must agree on this value. We currently
# expect it to be globally defined for the whole system,
# as there is no way for wallets to query this value. Thus,
# it is only configurable for testing, and should be treated
# as constant in production.
IDLE_RESERVE_EXPIRATION_TIME = 4 weeks
[exchangedb-postgres]
CONFIG = "postgres:///talercheck"
[exchange-account-1]
PAYTO_URI = "payto://x-taler-bank/localhost:8082/3"
WIRE_RESPONSE = ${TALER_CONFIG_HOME}/account-1.json
ENABLE_DEBIT = YES
ENABLE_CREDIT = YES
TALER_BANK_AUTH_METHOD = NONE
# Wire fees are specified by wire method
[fees-x-taler-bank]
# Fees for the foreseeable future...
# If you see this after 2018, update to match the next 10 years...
WIRE-FEE-2018 = EUR:0.01
WIRE-FEE-2019 = EUR:0.01
WIRE-FEE-2020 = EUR:0.01
WIRE-FEE-2021 = EUR:0.01
WIRE-FEE-2022 = EUR:0.01
WIRE-FEE-2023 = EUR:0.01
WIRE-FEE-2024 = EUR:0.01
WIRE-FEE-2025 = EUR:0.01
WIRE-FEE-2026 = EUR:0.01
WIRE-FEE-2027 = EUR:0.01
CLOSING-FEE-2018 = EUR:0.01
CLOSING-FEE-2019 = EUR:0.01
CLOSING-FEE-2020 = EUR:0.01
CLOSING-FEE-2021 = EUR:0.01
CLOSING-FEE-2022 = EUR:0.01
CLOSING-FEE-2023 = EUR:0.01
CLOSING-FEE-2024 = EUR:0.01
CLOSING-FEE-2025 = EUR:0.01
CLOSING-FEE-2026 = EUR:0.01
CLOSING-FEE-2027 = EUR:0.01
# Coins for the tests.
[coin_eur_ct_1]
value = EUR:0.01
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.00
fee_deposit = EUR:0.00
fee_refresh = EUR:0.01
fee_refund = EUR:0.01
rsa_keysize = 1024
[coin_eur_ct_10]
value = EUR:0.10
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024
[coin_eur_1]
value = EUR:1
duration_withdraw = 7 days
duration_spend = 2 years
duration_legal = 3 years
fee_withdraw = EUR:0.01
fee_deposit = EUR:0.01
fee_refresh = EUR:0.03
fee_refund = EUR:0.01
rsa_keysize = 1024

View File

@ -1,8 +0,0 @@
{
"salt": "AZPRFVJ58NM6M7J5CZQPJAH3EW5DYM52AEZ9Y1C1ER3W94QV8D8TQKF6CK8MYQRA9QMSKDQTGZ306ZS9GQ0M6R01CJ20KPP49WFDZK8",
"name": "The exchange",
"account_number": 3,
"bank_url": "http://localhost:8082/",
"type": "test",
"sig": "RPQXP9S4P8PQP7HEZQNRSZCT0ATNEP8GW0P5TPM34V5RX86FCD670V44R9NETSYDDKB8SZV7TKY9PAJYTY51D3VDWY9XXQ5BPFRXR28"
}

View File

@ -1 +0,0 @@
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>