From 81d0e570be0db784e98fdb7ad63f9b65c6745be3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 19 Aug 2021 13:41:30 +0200 Subject: -implement DB triggers and check for inbound wire transfers in IBAN plugin --- src/authorization/iban.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/authorization/iban.c (limited to 'src/authorization/iban.c') diff --git a/src/authorization/iban.c b/src/authorization/iban.c new file mode 100644 index 0000000..9547790 --- /dev/null +++ b/src/authorization/iban.c @@ -0,0 +1,43 @@ +/** + * Extract a numeric @a code from a @a wire_subject. + * Also checks that the @a wire_subject contains the + * string "anastasis". + * + * @param wire_subject wire subject to extract @a code from + * @param[out] code where to write the extracted code + * @return #GNUNET_OK if a @a code was extracted + */ +static enum GNUNET_GenericReturnValue +extract_code (const char *wire_subject, + uint64_t *code) +{ + unsigned long long c; + const char *pos; + + if (0 != + strcasestr (wire_subject, + "anastasis")) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Keyword 'anastasis' missing in subject `%s', ignoring transfer\n", + wire_subject); + return GNUNET_SYSERR; + } + pos = wire_subject; + while ( ('\0' != *pos) && + (! isdigit ((int) *pos)) ) + pos++; + if (1 != + sscanf (pos, + "%llu", + &c)) + { + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Did not find any code number in subject `%s', ignoring transfer\n", + wire_subject); + return GNUNET_SYSERR; + } + + *code = (uint64_t) c; + return GNUNET_OK; +} -- cgit v1.2.3