exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

taler-exchange-helper-measure-freeze (5540B)


      1 #!/bin/bash
      2 #
      3 #  This file is part of TALER
      4 #  Copyright (C) 2014-2024 Taler Systems SA
      5 #
      6 #  TALER is free software; you can redistribute it and/or modify it under the
      7 #  terms of the GNU General Public License as published by the Free Software
      8 #  Foundation; either version 3, or (at your option) any later version.
      9 #
     10 #  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     11 #  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     12 #  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     13 #
     14 #  You should have received a copy of the GNU General Public License along with
     15 #  TALER; see the file COPYING.  If not, If not, see <http://www.gnu.org/license>
     16 #
     17 
     18 # Hard error reporting on.
     19 set -eu
     20 
     21 
     22 
     23 # Exit, with error message (hard failure)
     24 function exit_fail() {
     25     echo " FAIL: " "$@" >&2
     26     EXIT_STATUS=1
     27     exit "$EXIT_STATUS"
     28 }
     29 
     30 CONF="$HOME/.config/taler-exchange.conf"
     31 VERBOSE=0
     32 
     33 while getopts 'ac:hirvV' OPTION;
     34 do
     35     case "$OPTION" in
     36         a)
     37             # No attributes are required.
     38             exit 0
     39             ;;
     40         c)
     41             # shellcheck disable=SC2034
     42             CONF="$OPTARG"
     43             ;;
     44         h)
     45             echo "This is a KYC measure program that freezes the account and flags it for manual investigation. This is the ultimate fallback measure."
     46             echo 'Supported options:'
     47             echo '  -a           -- show required attributes'
     48             # shellcheck disable=SC2016
     49             echo '  -c $CONF     -- set configuration'
     50             echo '  -h           -- print this help'
     51             echo '  -i           -- show required inputs'
     52             echo '  -r           -- show required context'
     53             echo '  -v           -- show version'
     54             echo '  -V           -- be verbose'
     55             exit 0
     56             ;;
     57         i)
     58             # No inputs are required
     59             exit 0
     60             ;;
     61         r)
     62             # No context is required.
     63             exit 0
     64             ;;
     65         v)
     66             echo "$0 v0.0.1"
     67             exit 0
     68             ;;
     69         V)
     70             VERBOSE=1
     71             ;;
     72         ?)
     73         exit_fail "Unrecognized command line option"
     74         ;;
     75     esac
     76 done
     77 
     78 if [ 1 = "$VERBOSE" ]
     79 then
     80     echo "Running $0" 1>&2
     81 fi
     82 
     83 
     84 # See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput
     85 # for the full JSON with possible inputs.
     86 
     87 # New rules apply for 30 days.
     88 EXPIRATION=$((3600 * 30 + $(date +%s)))
     89 
     90 # Read currency from the config
     91 CURRENCY=$(taler-exchange-config -c "$CONF" -s exchange -o currency)
     92 
     93 # Finally, output the new rules.
     94 # See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
     95 # for the required output format.
     96 
     97 jq -n \
     98     --argjson expiration "$EXPIRATION" \
     99     --arg currency "$CURRENCY" \
    100     '{ "to_investigate": true,
    101        "new_rules" : {
    102          "custom_measures" : {},
    103          "expiration_time" : { "t_s": $expiration },
    104          "rules" : [
    105            {
    106              "operation_type": "WITHDRAW",
    107              "threshold" : "\($currency):0",
    108              "timeframe" : { "d_us" : 3600000000 },
    109              "measures" : [ "verboten" ],
    110              "display_priority" : 1,
    111              "exposed" : false,
    112              "is_and_combinator" : true
    113            },
    114            {
    115              "operation_type": "DEPOSIT",
    116              "threshold" : "\($currency):0",
    117              "timeframe" : { "d_us" : 3600000000 },
    118              "measures" : [ "verboten" ],
    119              "display_priority" : 1,
    120              "exposed" : false,
    121              "is_and_combinator" : true
    122            },
    123            {
    124              "operation_type": "AGGREGATE",
    125              "threshold" : "\($currency):0",
    126              "timeframe" : { "d_us" : 3600000000 },
    127              "measures" : [ "verboten" ],
    128              "display_priority" : 1,
    129              "exposed" : false,
    130              "is_and_combinator" : true
    131            },
    132            {
    133              "operation_type": "MERGE",
    134              "threshold" : "\($currency):0",
    135              "timeframe" : { "d_us" : 3600000000 },
    136              "measures" : [ "verboten" ],
    137              "display_priority" : 1,
    138              "exposed" : false,
    139              "is_and_combinator" : true
    140            },
    141            {
    142              "operation_type": "BALANCE",
    143              "threshold" : "\($currency):0",
    144              "timeframe" : { "d_us" : 3600000000 },
    145              "measures" : [ "verboten" ],
    146              "display_priority" : 1,
    147              "exposed" : false,
    148              "is_and_combinator" : true
    149            },
    150            {
    151              "operation_type": "CLOSE",
    152              "threshold" : "\($currency):0",
    153              "timeframe" : { "d_us" : 3600000000 },
    154              "measures" : [ "verboten" ],
    155              "display_priority" : 1,
    156              "exposed" : false,
    157              "is_and_combinator" : true
    158            },
    159            {
    160              "operation_type": "TRANSACTION",
    161              "threshold" : "\($currency):0",
    162              "timeframe" : { "d_us" : 3600000000 },
    163              "measures" : [ "verboten" ],
    164              "display_priority" : 1,
    165              "exposed" : false,
    166              "is_and_combinator" : true
    167            },
    168            {
    169              "operation_type": "REFUND",
    170              "threshold" : "\($currency):0",
    171              "timeframe" : { "d_us" : 3600000000 },
    172              "measures" : [ "verboten" ],
    173              "display_priority" : 1,
    174              "exposed" : false,
    175              "is_and_combinator" : true
    176            }
    177          ]
    178        }
    179      }' < /dev/null