update configuration generators to use new ENABLE option instead of WIREFORMATS, and to support wire fee generation

This commit is contained in:
Christian Grothoff 2017-03-03 19:43:26 +01:00
parent 4d2faa5ec9
commit 243d8d18b1
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
4 changed files with 68 additions and 36 deletions

View File

@ -2,10 +2,6 @@
# Currency supported by the exchange (can only be one)
CURRENCY = EUR
# Wire format supported by the exchange, case-insensitive.
# Examples for formats include 'test' for testing and 'sepa' (for EU IBAN).
WIREFORMAT = SEPA
# HTTP port the exchange listens to
PORT = 4241
@ -21,21 +17,28 @@ TESTRUN = YES
[exchangedb-postgres]
DB_CONN_STR = "postgres:///talercheck"
[wire-incoming-sepa]
[exchange-wire-sepa]
# Change here to enable SEPA wire transfers.
ENABLE = NO
[exchange-wire-incoming-sepa]
SEPA_RESPONSE_FILE = "sepa.json"
[wire-outgoing-sepa]
[exchange-wire-outgoing-sepa]
SEPA_RESPONSE_FILE = "sepa.json"
[exchange-wire-sepa]
ENABLE = YES
[wire-incoming-test]
[exchange-wire-incoming-test]
# What is the main website of the bank?
BANK_URI = "https://bank/"
# Into which account at the 'bank' should incoming
# wire transfers be made?
BANK_ACCOUNT_NUMBER = 2
[wire-outgoing-test]
[exchange-wire-outgoing-test]
# What is the main website of the bank?
BANK_URI = "https://bank/"
# From which account at the 'bank' should outgoing

View File

@ -1,7 +1,7 @@
.TH TALER\-CONFIG\-GENERATE 1 "May 5, 2016" "GNU Taler"
.SH NAME
taler\-config\-generate \- tool to simplfy Taler configuration generation
taler\-config\-generate \- tool to simplify Taler configuration generation
.SH SYNOPSIS
.B taler\-config\-generate
@ -22,6 +22,9 @@ Which currency should we use in the configuration.
.IP "\-e, \-\-exchange"
Generate configuration for a Taler exchange.
.B
.IP "\-f AMOUNT, \-\-wirefee=AMOUNT"
Setup wire transfer fees for the next 5 years for the exchange (for all wire methods).
.B
.IP "\-m, \-\-merchant"
Generate configuration for a Taler merchant.
.B

View File

@ -16,8 +16,6 @@ The following options are from the "[exchange]" section and used by most exchang
.IP CURRENCY
Name of the currency, i.e. "EUR" for Euro.
.IP WIREFORMAT
Format used for wire transfers to the merchant, i.e. "SEPA".
.IP DB
Plugin to use for the database, i.e. "postgres"
.IP PORT
@ -28,7 +26,8 @@ The following options are from the "[exchange]" section and used by most exchang
.SH WIRE transfer details
The following options must be in section "[wire\-incoming\-test]" and "[wire\-outgoing\-test]":
To enable the "test" wire transfer method, you must set "ENABLE = YES" in "[exchange\-wire\-test]".
Then, the following options must be in section "[exchange\-wire\-incoming\-test]" and "[exchange\-wire\-outgoing\-test]":
.IP BANK_URI
URL of the Taler bank.
@ -36,7 +35,8 @@ The following options must be in section "[wire\-incoming\-test]" and "[wire\-ou
.IP BANK_ACCOUNT_NUMBER
Number of the bank account of the exchange.
The following options must be in section "[wire\-incoming\-sepa]" and "[wire\-outgoing\-sepa]":
To enable the "sepa" wire transfer method, you must set "ENABLE = YES" in "[exchange\-wire\-sepa]".
Then, the following options must be in section "[exchange\-wire\-incoming\-sepa]" and "[exchange\-wire\-outgoing\-sepa]":
.IP SEPA_RESPONSE_FILE
Filename with the JSON body for the /wire response, signed using the exchange\'s long-term offline master key. Use taler\-exchange\-sepa to create the SEPA_RESPONSE_FILE.

View File

@ -6,6 +6,7 @@
# -c FILENAME, --config=FILENAME (where to write config, defaults to ~/.config/taler.conf)
# -C CURRENCY, --currency=CURRENCY (name of the currency)
# -e, --exchange (generate configuration for the exchange)
# -f AMOUNT, --wirefee=AMOUNT (wire transfer fees charged to merchant, generated for next 5 years)
# -j WIREJSON, --wire-json-merchant=WIREJSON (wire plugin details in JSON)
# -J WIREJSON, --wire-json-exchange=WIREJSON (wire plugin details in JSON)
# -m, --merchant (generate configuration for the merchant)
@ -32,7 +33,7 @@ ARG_MERCHANT_BANK_ACCOUNT=
##################################
# read the options
TEMP=`getopt -o c:C:ehj:J:mtw: --long config:,currency:,exchange,help,wire-json-exchange:,wire-json-merchant:,merchant,trusted,wire:,bank-uri:,exchange-bank-account:,merchant-bank-account: -n 'taler-config-generate' -- "$@"`
TEMP=`getopt -o c:C:ef:hj:J:mtw: --long config:,currency:,exchange,wirefee:,help,wire-json-exchange:,wire-json-merchant:,merchant,trusted,wire:,bank-uri:,exchange-bank-account:,merchant-bank-account: -n 'taler-config-generate' -- "$@"`
eval set -- "$TEMP"
####################################################
@ -48,6 +49,9 @@ while true ; do
-e|--exchange)
ARG_E=1
shift ;;
-f|--wirefee)
ARG_WIRE_FEE="$2"
shift 2 ;;
-h|--help)
ARG_H=1
shift ;;
@ -172,33 +176,55 @@ then
# Obtain public master key of exchange
MASTER_PUB=`gnunet-ecc -p "$MASTER_KEY"`
# Setup wire format
$CS -s exchange -o WIREFORMAT -V "$ARG_W" || exit 1
# Setup master public key
$CS -s exchange -o MASTER_PUBLIC_KEY -V "$MASTER_PUB" || exit 1
# Setup wire transfer methods
for $WMETHOD in $ARG_W
do
$CS -s exchange-wire-$WMETHOD -o ENABLE -V YES || exit 1
# If possible, initialize outgoing wire account details ('test' method only)
if (test "test" = "$ARG_W" -a ! -z "$ARG_BANK_URI")
then
$CS -s exchange-wire-outgoing-test -o BANK_URI -V "$ARG_BANK_URI" || exit 1
else
echo "Skipped generating outgoing wire account details for exchange"
fi
if (test "test" = "$ARG_W" -a ! -z "$ARG_EXCHANGE_BANK_ACCOUNT")
then
$CS -s exchange-wire-outgoing-test -o BANK_ACCOUNT_NUMBER -V "$ARG_EXCHANGE_BANK_ACCOUNT" || exit 1
else
echo "Skipped generating outgoing wire account details for exchange"
fi
if (test "test" = "$WMETHOD" -a ! -z "$ARG_BANK_URI")
then
$CS -s exchange-wire-outgoing-test -o BANK_URI -V "$ARG_BANK_URI" || exit 1
else
echo "Skipped generating outgoing wire account details for exchange"
fi
if (test "test" = "$ARG_W" -a ! -z "$ARG_EXCHANGE_BANK_ACCOUNT")
then
$CS -s exchange-wire-outgoing-test -o BANK_ACCOUNT_NUMBER -V "$ARG_EXCHANGE_BANK_ACCOUNT" || exit 1
else
echo "Skipped generating outgoing wire account details for exchange"
fi
# If possible, initialize /wire response from JSON (with signature)
if (test ! -z $ARG_JE)
then
JSONF=`$CS -s exchange-wire-incoming-${ARG_W} -o ${ARG_W}_RESPONSE_FILE -f`
if (test ! -z $ARG_JE)
then
JSONF=`$CS -s exchange-wire-incoming-${ARG_W} -o ${ARG_W}_RESPONSE_FILE -f`
# echo "Generating /wire response at $JSONF"
mkdir -p `dirname $JSONF`
taler-exchange-wire -c "$ARG_CONFIG" -t "$ARG_W" -j "$ARG_JE" -m "$MASTER_KEY" -o "$JSONF" || exit 1
else
echo "Skipped generating /wire response for exchange"
fi
mkdir -p `dirname $JSONF`
taler-exchange-wire -c "$ARG_CONFIG" -t "$ARG_W" -j "$ARG_JE" -m "$MASTER_KEY" -o "$JSONF" || exit 1
else
echo "Skipped generating /wire response for exchange"
fi
# Setup wire transfer fee structure.
if (test -z "$ARG_WIRE_FEE")
then
today=`date '+%Y'`
future=`expr $today + 5`
for YEAR in `seq $today $future`
do
$CS -s exchange-wire-$WMETHOD -o wire-fee-$YEAR -V $ARG_WIRE_FEE
done
else
echo "Skipped generating wire fee structure for exchange"
fi
# End of for loop over all wire transfer methods
done
else
echo "Skipped exchange setup"
fi