eliminate libtalerwire
This commit is contained in:
parent
258ed8617b
commit
4d6ef1da29
@ -557,6 +557,5 @@ AC_CONFIG_FILES([Makefile
|
|||||||
src/pq/Makefile
|
src/pq/Makefile
|
||||||
src/util/Makefile
|
src/util/Makefile
|
||||||
src/util/taler-config
|
src/util/taler-config
|
||||||
src/wire/Makefile
|
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
@ -22,7 +22,7 @@ pkgcfg_DATA = \
|
|||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
taler.conf
|
taler.conf
|
||||||
|
|
||||||
SUBDIRS = include util wire json curl $(PQ_DIR) mhd $(BANK_LIB) exchangedb exchange exchange-tools auditordb auditor
|
SUBDIRS = include util json curl $(PQ_DIR) mhd $(BANK_LIB) exchangedb exchange exchange-tools auditordb auditor
|
||||||
if HAVE_LIBCURL
|
if HAVE_LIBCURL
|
||||||
SUBDIRS += lib benchmark
|
SUBDIRS += lib benchmark
|
||||||
else
|
else
|
||||||
|
@ -40,7 +40,7 @@ taler_auditor_LDADD = \
|
|||||||
$(LIBGCRYPT_LIBS) \
|
$(LIBGCRYPT_LIBS) \
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
$(top_builddir)/src/json/libtalerjson.la \
|
$(top_builddir)/src/json/libtalerjson.la \
|
||||||
$(top_builddir)/src/wire/libtalerwire.la \
|
$(top_builddir)/src/bank-lib/libtalerbank.la \
|
||||||
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
|
$(top_builddir)/src/exchangedb/libtalerexchangedb.la \
|
||||||
$(top_builddir)/src/auditordb/libtalerauditordb.la \
|
$(top_builddir)/src/auditordb/libtalerauditordb.la \
|
||||||
-ljansson \
|
-ljansson \
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "taler_auditordb_plugin.h"
|
#include "taler_auditordb_plugin.h"
|
||||||
#include "taler_exchangedb_plugin.h"
|
#include "taler_exchangedb_plugin.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
#include "taler_wire_lib.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
|
|
||||||
|
|
||||||
@ -1459,7 +1459,7 @@ get_closing_fee (const char *receiver_account,
|
|||||||
struct TALER_Amount wire_fee;
|
struct TALER_Amount wire_fee;
|
||||||
char *method;
|
char *method;
|
||||||
|
|
||||||
method = TALER_WIRE_payto_get_method (receiver_account);
|
method = TALER_payto_get_method (receiver_account);
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Method is `%s'\n",
|
"Method is `%s'\n",
|
||||||
method);
|
method);
|
||||||
@ -2894,7 +2894,7 @@ check_wire_out_cb
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Round down to amount supported by wire method */
|
/* Round down to amount supported by wire method */
|
||||||
GNUNET_break (TALER_WIRE_amount_round (&final_amount));
|
GNUNET_break (TALER_amount_round (&final_amount));
|
||||||
|
|
||||||
/* Calculate the exchange's gain as the fees plus rounding differences! */
|
/* Calculate the exchange's gain as the fees plus rounding differences! */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
|
@ -652,7 +652,7 @@ do_shutdown (void *cls)
|
|||||||
wa_tail,
|
wa_tail,
|
||||||
wa);
|
wa);
|
||||||
TALER_BANK_auth_free (&wa->auth);
|
TALER_BANK_auth_free (&wa->auth);
|
||||||
TALER_WIRE_account_free (&wa->account);
|
TALER_BANK_account_free (&wa->account);
|
||||||
GNUNET_free (wa->section_name);
|
GNUNET_free (wa->section_name);
|
||||||
GNUNET_free (wa);
|
GNUNET_free (wa);
|
||||||
}
|
}
|
||||||
@ -2082,7 +2082,7 @@ process_account_cb (void *cls,
|
|||||||
if (TALER_PAC_X_TALER_BANK != wa->account.type)
|
if (TALER_PAC_X_TALER_BANK != wa->account.type)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
TALER_WIRE_account_free (&wa->account);
|
TALER_BANK_account_free (&wa->account);
|
||||||
TALER_BANK_auth_free (&wa->auth);
|
TALER_BANK_auth_free (&wa->auth);
|
||||||
GNUNET_free (wa->section_name);
|
GNUNET_free (wa->section_name);
|
||||||
GNUNET_free (wa);
|
GNUNET_free (wa);
|
||||||
|
@ -41,6 +41,7 @@ libtalerbank_la_SOURCES = \
|
|||||||
bank_api_credit.c \
|
bank_api_credit.c \
|
||||||
bank_api_debit.c \
|
bank_api_debit.c \
|
||||||
bank_api_transfer.c \
|
bank_api_transfer.c \
|
||||||
|
bank_api_payto.c \
|
||||||
bank_api_parse.c
|
bank_api_parse.c
|
||||||
libtalerbank_la_LIBADD = \
|
libtalerbank_la_LIBADD = \
|
||||||
$(top_builddir)/src/json/libtalerjson.la \
|
$(top_builddir)/src/json/libtalerjson.la \
|
||||||
|
@ -50,7 +50,7 @@ TALER_BANK_account_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
if (TALER_EC_NONE !=
|
if (TALER_EC_NONE !=
|
||||||
TALER_WIRE_payto_to_account (account_url,
|
TALER_BANK_payto_to_account (account_url,
|
||||||
acc))
|
acc))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
|
||||||
@ -67,7 +67,7 @@ TALER_BANK_account_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
"URL",
|
"URL",
|
||||||
"Malformed payto:// URL for x-taler-bank method");
|
"Malformed payto:// URL for x-taler-bank method");
|
||||||
GNUNET_free (account_url);
|
GNUNET_free (account_url);
|
||||||
TALER_WIRE_account_free (acc);
|
TALER_BANK_account_free (acc);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_free (account_url);
|
GNUNET_free (account_url);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
(C) 2015--2019 GNUnet e.V.
|
(C) 2015--2020 Taler Systems SA
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
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
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -14,14 +14,13 @@
|
|||||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file wire/payto.c
|
* @file bank-lib/bank_api_payto.c
|
||||||
* @brief Functions for parsing payto:// URIs
|
* @brief Functions for parsing payto:// URIs
|
||||||
* @author Christian Grothoff <christian@grothoff.org>
|
* @author Christian Grothoff <christian@grothoff.org>
|
||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "taler_util.h"
|
#include "taler_util.h"
|
||||||
#include "taler_bank_service.h"
|
#include "taler_bank_service.h"
|
||||||
#include "taler_wire_lib.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum legal 'value' for an account number, based on IEEE double (for JavaScript compatibility).
|
* Maximum legal 'value' for an account number, based on IEEE double (for JavaScript compatibility).
|
||||||
@ -35,7 +34,7 @@
|
|||||||
* @param acc account to free, the pointer itself is NOT free'd.
|
* @param acc account to free, the pointer itself is NOT free'd.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TALER_WIRE_account_free (struct TALER_Account *acc)
|
TALER_BANK_account_free (struct TALER_Account *acc)
|
||||||
{
|
{
|
||||||
switch (acc->type)
|
switch (acc->type)
|
||||||
{
|
{
|
||||||
@ -482,11 +481,11 @@ typedef enum TALER_ErrorCode
|
|||||||
* Parse @a payto_url and store the result in @a acc
|
* Parse @a payto_url and store the result in @a acc
|
||||||
*
|
*
|
||||||
* @param payto_url URL to parse
|
* @param payto_url URL to parse
|
||||||
* @param acc[in,out] account to initialize, free using #TALER_WIRE_account_free() later
|
* @param acc[in,out] account to initialize, free using #TALER_BANK_account_free() later
|
||||||
* @return #TALER_EC_NONE if @a payto_url is well-formed
|
* @return #TALER_EC_NONE if @a payto_url is well-formed
|
||||||
*/
|
*/
|
||||||
enum TALER_ErrorCode
|
enum TALER_ErrorCode
|
||||||
TALER_WIRE_payto_to_account (const char *payto_url,
|
TALER_BANK_payto_to_account (const char *payto_url,
|
||||||
struct TALER_Account *acc)
|
struct TALER_Account *acc)
|
||||||
{
|
{
|
||||||
Parser parsers[] = {
|
Parser parsers[] = {
|
@ -858,7 +858,7 @@ main (int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (TALER_EC_NONE !=
|
if (TALER_EC_NONE !=
|
||||||
TALER_WIRE_payto_to_account (exchange_payto_url,
|
TALER_BANK_payto_to_account (exchange_payto_url,
|
||||||
&exchange_bank_account))
|
&exchange_bank_account))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
@ -172,7 +172,7 @@ struct AggregationUnit
|
|||||||
/**
|
/**
|
||||||
* Wire preparation handle.
|
* Wire preparation handle.
|
||||||
*/
|
*/
|
||||||
struct TALER_WIRE_PrepareHandle *ph;
|
struct TALER_BANK_PrepareHandle *ph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of #aggregation_limit row_ids from the
|
* Array of #aggregation_limit row_ids from the
|
||||||
@ -416,7 +416,7 @@ find_account_by_url (const char *url)
|
|||||||
char *method;
|
char *method;
|
||||||
struct WireAccount *wa;
|
struct WireAccount *wa;
|
||||||
|
|
||||||
method = TALER_WIRE_payto_get_method (url);
|
method = TALER_payto_get_method (url);
|
||||||
if (NULL == method)
|
if (NULL == method)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@ -573,7 +573,7 @@ shutdown_task (void *cls)
|
|||||||
GNUNET_CONTAINER_DLL_remove (wa_head,
|
GNUNET_CONTAINER_DLL_remove (wa_head,
|
||||||
wa_tail,
|
wa_tail,
|
||||||
wa);
|
wa);
|
||||||
TALER_WIRE_account_free (&wa->account);
|
TALER_BANK_account_free (&wa->account);
|
||||||
TALER_BANK_auth_free (&wa->auth);
|
TALER_BANK_auth_free (&wa->auth);
|
||||||
TALER_EXCHANGEDB_fees_free (wa->af);
|
TALER_EXCHANGEDB_fees_free (wa->af);
|
||||||
GNUNET_free (wa->section_name);
|
GNUNET_free (wa->section_name);
|
||||||
@ -1117,7 +1117,7 @@ expired_reserve_cb (void *cls,
|
|||||||
}
|
}
|
||||||
/* round down to enable transfer */
|
/* round down to enable transfer */
|
||||||
if (GNUNET_SYSERR ==
|
if (GNUNET_SYSERR ==
|
||||||
TALER_WIRE_amount_round (&amount_without_fee))
|
TALER_amount_round (&amount_without_fee))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
global_ret = GNUNET_SYSERR;
|
global_ret = GNUNET_SYSERR;
|
||||||
@ -1182,7 +1182,7 @@ expired_reserve_cb (void *cls,
|
|||||||
ctc = GNUNET_new (struct CloseTransferContext);
|
ctc = GNUNET_new (struct CloseTransferContext);
|
||||||
ctc->wa = wa;
|
ctc->wa = wa;
|
||||||
ctc->session = session;
|
ctc->session = session;
|
||||||
ctc->method = TALER_WIRE_payto_get_method (account_details);
|
ctc->method = TALER_payto_get_method (account_details);
|
||||||
TALER_BANK_prepare_wire_transfer (account_details,
|
TALER_BANK_prepare_wire_transfer (account_details,
|
||||||
&amount_without_fee,
|
&amount_without_fee,
|
||||||
exchange_base_url,
|
exchange_base_url,
|
||||||
@ -1449,7 +1449,7 @@ run_aggregation (void *cls)
|
|||||||
&au->total_amount,
|
&au->total_amount,
|
||||||
&au->wire_fee)) ||
|
&au->wire_fee)) ||
|
||||||
(GNUNET_SYSERR ==
|
(GNUNET_SYSERR ==
|
||||||
TALER_WIRE_amount_round (&au->final_amount)) ||
|
TALER_amount_round (&au->final_amount)) ||
|
||||||
( (0 == au->final_amount.value) &&
|
( (0 == au->final_amount.value) &&
|
||||||
(0 == au->final_amount.fraction) ) )
|
(0 == au->final_amount.fraction) ) )
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ load_account (void *cls,
|
|||||||
*ret = GNUNET_SYSERR;
|
*ret = GNUNET_SYSERR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
method = TALER_WIRE_payto_get_method (ai->payto_url);
|
method = TALER_payto_get_method (ai->payto_url);
|
||||||
if (GNUNET_OK ==
|
if (GNUNET_OK ==
|
||||||
load_fee (method))
|
load_fee (method))
|
||||||
{
|
{
|
||||||
|
@ -213,7 +213,7 @@ shutdown_task (void *cls)
|
|||||||
GNUNET_CONTAINER_DLL_remove (wa_head,
|
GNUNET_CONTAINER_DLL_remove (wa_head,
|
||||||
wa_tail,
|
wa_tail,
|
||||||
wa);
|
wa);
|
||||||
TALER_WIRE_account_free (&wa->account);
|
TALER_BANK_account_free (&wa->account);
|
||||||
TALER_BANK_auth_free (&wa->auth);
|
TALER_BANK_auth_free (&wa->auth);
|
||||||
GNUNET_free (wa->section_name);
|
GNUNET_free (wa->section_name);
|
||||||
GNUNET_free (wa);
|
GNUNET_free (wa);
|
||||||
|
@ -422,7 +422,7 @@ postgres_create_tables (void *cls)
|
|||||||
"(wireout_uuid BIGSERIAL PRIMARY KEY"
|
"(wireout_uuid BIGSERIAL PRIMARY KEY"
|
||||||
",execution_date INT8 NOT NULL"
|
",execution_date INT8 NOT NULL"
|
||||||
",wtid_raw BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid_raw)="
|
",wtid_raw BYTEA UNIQUE NOT NULL CHECK (LENGTH(wtid_raw)="
|
||||||
TALER_WIRE_TRANSFER_IDENTIFIER_LEN_STR ")"
|
TALER_BANK_TRANSFER_IDENTIFIER_LEN_STR ")"
|
||||||
",wire_target TEXT NOT NULL"
|
",wire_target TEXT NOT NULL"
|
||||||
",exchange_account_section TEXT NOT NULL"
|
",exchange_account_section TEXT NOT NULL"
|
||||||
",amount_val INT8 NOT NULL"
|
",amount_val INT8 NOT NULL"
|
||||||
|
@ -27,7 +27,6 @@ talerinclude_HEADERS = \
|
|||||||
taler_json_lib.h \
|
taler_json_lib.h \
|
||||||
taler_testing_auditor_lib.h \
|
taler_testing_auditor_lib.h \
|
||||||
taler_testing_lib.h \
|
taler_testing_lib.h \
|
||||||
taler_wire_lib.h \
|
|
||||||
taler_util.h \
|
taler_util.h \
|
||||||
taler_mhd_lib.h \
|
taler_mhd_lib.h \
|
||||||
taler_pq_lib.h \
|
taler_pq_lib.h \
|
||||||
|
@ -309,6 +309,18 @@ const char *
|
|||||||
TALER_amount2s (const struct TALER_Amount *amount);
|
TALER_amount2s (const struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Round the amount to something that can be
|
||||||
|
* transferred on the wire.
|
||||||
|
*
|
||||||
|
* @param[in,out] amount amount to round down
|
||||||
|
* @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary,
|
||||||
|
* #GNUNET_SYSERR if the amount or currency was invalid
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_amount_round (struct TALER_Amount *amount);
|
||||||
|
|
||||||
|
|
||||||
#if 0 /* keep Emacsens' auto-indent happy */
|
#if 0 /* keep Emacsens' auto-indent happy */
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
@ -85,6 +85,83 @@ struct TALER_BANK_AuthenticationData
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different account types supported by payto://.
|
||||||
|
*/
|
||||||
|
enum TALER_PaytoAccountType
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to indicate an uninitialized struct.
|
||||||
|
*/
|
||||||
|
TALER_PAC_NONE = 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account type of a bank running the x-taler-bank protocol.
|
||||||
|
*/
|
||||||
|
TALER_PAC_X_TALER_BANK,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Account identified by IBAN number.
|
||||||
|
*/
|
||||||
|
TALER_PAC_IBAN
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about an account extracted from a payto://-URL.
|
||||||
|
*/
|
||||||
|
struct TALER_Account
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How this the account represented.
|
||||||
|
*/
|
||||||
|
enum TALER_PaytoAccountType type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internals depending on @e type.
|
||||||
|
*/
|
||||||
|
union
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Taler bank address from x-taler-bank. Set if
|
||||||
|
* @e type is #TALER_AC_X_TALER_BANK.
|
||||||
|
*/
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bank account base URL.
|
||||||
|
*/
|
||||||
|
char *account_base_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only the hostname of the bank.
|
||||||
|
*/
|
||||||
|
char *hostname;
|
||||||
|
|
||||||
|
} x_taler_bank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Taler bank address from iban. Set if
|
||||||
|
* @e type is #TALER_AC_IBAN.
|
||||||
|
*/
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IBAN number.
|
||||||
|
*/
|
||||||
|
char *number;
|
||||||
|
|
||||||
|
} iban;
|
||||||
|
|
||||||
|
} details;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* ********************* /admin/add/incoming *********************** */
|
/* ********************* /admin/add/incoming *********************** */
|
||||||
|
|
||||||
|
|
||||||
@ -447,6 +524,8 @@ void
|
|||||||
TALER_BANK_debit_history_cancel (struct TALER_BANK_DebitHistoryHandle *hh);
|
TALER_BANK_debit_history_cancel (struct TALER_BANK_DebitHistoryHandle *hh);
|
||||||
|
|
||||||
|
|
||||||
|
/* ******************** Convenience functions **************** */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for parsing configuration section with bank account data.
|
* Convenience method for parsing configuration section with bank account data.
|
||||||
*
|
*
|
||||||
@ -460,6 +539,26 @@ TALER_BANK_account_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
const char *section,
|
const char *section,
|
||||||
struct TALER_Account *acc);
|
struct TALER_Account *acc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Release memory allocated in @a acc.
|
||||||
|
*
|
||||||
|
* @param acc account to free, the pointer itself is NOT free'd.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TALER_BANK_account_free (struct TALER_Account *acc);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse @a payto_url and store the result in @a acc
|
||||||
|
*
|
||||||
|
* @param payto_url URL to parse
|
||||||
|
* @param acc[in,out] account to initialize, free using #TALER_BANK_account_free() later
|
||||||
|
* @return #TALER_EC_NONE if @a payto_url is well-formed
|
||||||
|
*/
|
||||||
|
enum TALER_ErrorCode
|
||||||
|
TALER_BANK_payto_to_account (const char *payto_url,
|
||||||
|
struct TALER_Account *acc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method for parsing configuration section with bank
|
* Convenience method for parsing configuration section with bank
|
||||||
@ -486,4 +585,5 @@ TALER_BANK_auth_parse_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg,
|
|||||||
void
|
void
|
||||||
TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth);
|
TALER_BANK_auth_free (struct TALER_BANK_AuthenticationData *auth);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _TALER_BANK_SERVICE_H */
|
#endif /* _TALER_BANK_SERVICE_H */
|
||||||
|
@ -510,12 +510,12 @@ struct TALER_TransferSecretP
|
|||||||
* Length of the raw value in the Taler wire transfer identifier
|
* Length of the raw value in the Taler wire transfer identifier
|
||||||
* (in binary representation).
|
* (in binary representation).
|
||||||
*/
|
*/
|
||||||
#define TALER_WIRE_TRANSFER_IDENTIFIER_LEN 32
|
#define TALER_BANK_TRANSFER_IDENTIFIER_LEN 32
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #TALER_WIRE_TRANSFER_IDENTIFIER_LEN as a string.
|
* #TALER_BANK_TRANSFER_IDENTIFIER_LEN as a string.
|
||||||
*/
|
*/
|
||||||
#define TALER_WIRE_TRANSFER_IDENTIFIER_LEN_STR "32"
|
#define TALER_BANK_TRANSFER_IDENTIFIER_LEN_STR "32"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -536,7 +536,7 @@ struct TALER_WireTransferIdentifierRawP
|
|||||||
* encode the actual value (i.e. a 256-bit / 32-byte public key or
|
* encode the actual value (i.e. a 256-bit / 32-byte public key or
|
||||||
* a hash code), and the last byte for a minimalistic checksum.
|
* a hash code), and the last byte for a minimalistic checksum.
|
||||||
*/
|
*/
|
||||||
uint8_t raw[TALER_WIRE_TRANSFER_IDENTIFIER_LEN];
|
uint8_t raw[TALER_BANK_TRANSFER_IDENTIFIER_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,4 +381,14 @@ TALER_url_absolute_mhd (struct MHD_Connection *connection,
|
|||||||
...);
|
...);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the payment method from a @a payto_url
|
||||||
|
*
|
||||||
|
* @param payto_url the URL to parse
|
||||||
|
* @return NULL on error (malformed @a payto_url)
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_payto_get_method (const char *payto_url);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,130 +18,10 @@
|
|||||||
* @brief Interface for loading and unloading wire plugins
|
* @brief Interface for loading and unloading wire plugins
|
||||||
* @author Christian Grothoff <christian@grothoff.org>
|
* @author Christian Grothoff <christian@grothoff.org>
|
||||||
*/
|
*/
|
||||||
#ifndef TALER_WIRE_H
|
#ifndef TALER_BANK_H
|
||||||
#define TALER_WIRE_H
|
#define TALER_BANK_H
|
||||||
|
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Different account types supported by payto://.
|
|
||||||
*/
|
|
||||||
enum TALER_PaytoAccountType
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to indicate an uninitialized struct.
|
|
||||||
*/
|
|
||||||
TALER_PAC_NONE = 0,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account type of a bank running the x-taler-bank protocol.
|
|
||||||
*/
|
|
||||||
TALER_PAC_X_TALER_BANK,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Account identified by IBAN number.
|
|
||||||
*/
|
|
||||||
TALER_PAC_IBAN
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Information about an account extracted from a payto://-URL.
|
|
||||||
*/
|
|
||||||
struct TALER_Account
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How this the account represented.
|
|
||||||
*/
|
|
||||||
enum TALER_PaytoAccountType type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internals depending on @e type.
|
|
||||||
*/
|
|
||||||
union
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Taler bank address from x-taler-bank. Set if
|
|
||||||
* @e type is #TALER_AC_X_TALER_BANK.
|
|
||||||
*/
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bank account base URL.
|
|
||||||
*/
|
|
||||||
char *account_base_url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only the hostname of the bank.
|
|
||||||
*/
|
|
||||||
char *hostname;
|
|
||||||
|
|
||||||
} x_taler_bank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Taler bank address from iban. Set if
|
|
||||||
* @e type is #TALER_AC_IBAN.
|
|
||||||
*/
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IBAN number.
|
|
||||||
*/
|
|
||||||
char *number;
|
|
||||||
|
|
||||||
} iban;
|
|
||||||
|
|
||||||
} details;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Release memory allocated in @a acc.
|
|
||||||
*
|
|
||||||
* @param acc account to free, the pointer itself is NOT free'd.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
TALER_WIRE_account_free (struct TALER_Account *acc);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Round the amount to something that can be
|
|
||||||
* transferred on the wire.
|
|
||||||
*
|
|
||||||
* @param[in,out] amount amount to round down
|
|
||||||
* @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary,
|
|
||||||
* #GNUNET_SYSERR if the amount or currency was invalid
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
TALER_WIRE_amount_round (struct TALER_Amount *amount);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse @a payto_url and store the result in @a acc
|
|
||||||
*
|
|
||||||
* @param payto_url URL to parse
|
|
||||||
* @param acc[in,out] account to initialize, free using #TALER_WIRE_account_free() later
|
|
||||||
* @return #TALER_EC_NONE if @a payto_url is well-formed
|
|
||||||
*/
|
|
||||||
enum TALER_ErrorCode
|
|
||||||
TALER_WIRE_payto_to_account (const char *payto_url,
|
|
||||||
struct TALER_Account *acc);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain the payment method from a @a payto_url
|
|
||||||
*
|
|
||||||
* @param payto_url the URL to parse
|
|
||||||
* @return NULL on error (malformed @a payto_url)
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
TALER_WIRE_payto_get_method (const char *payto_url);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +18,6 @@ libtalerjson_la_LDFLAGS = \
|
|||||||
-export-dynamic -no-undefined
|
-export-dynamic -no-undefined
|
||||||
libtalerjson_la_LIBADD = \
|
libtalerjson_la_LIBADD = \
|
||||||
-lgnunetjson \
|
-lgnunetjson \
|
||||||
$(top_builddir)/src/wire/libtalerwire.la \
|
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
-lgnunetutil \
|
-lgnunetutil \
|
||||||
-ljansson \
|
-ljansson \
|
||||||
|
@ -197,7 +197,7 @@ TALER_JSON_wire_to_method (const json_t *wire_s)
|
|||||||
"Fatally malformed wire record encountered: lacks payto://-url\n");
|
"Fatally malformed wire record encountered: lacks payto://-url\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return TALER_WIRE_payto_get_method (payto_str);
|
return TALER_payto_get_method (payto_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,7 +133,6 @@ libtalertesting_la_SOURCES = \
|
|||||||
testing_api_trait_wtid.c
|
testing_api_trait_wtid.c
|
||||||
libtalertesting_la_LIBADD = \
|
libtalertesting_la_LIBADD = \
|
||||||
libtalerexchange.la \
|
libtalerexchange.la \
|
||||||
$(top_builddir)/src/wire/libtalerwire.la \
|
|
||||||
$(top_builddir)/src/json/libtalerjson.la \
|
$(top_builddir)/src/json/libtalerjson.la \
|
||||||
$(top_builddir)/src/util/libtalerutil.la \
|
$(top_builddir)/src/util/libtalerutil.la \
|
||||||
$(top_builddir)/src/bank-lib/libtalerbank.la \
|
$(top_builddir)/src/bank-lib/libtalerbank.la \
|
||||||
|
@ -301,7 +301,7 @@ handle_wire_finished (void *cls,
|
|||||||
ec = TALER_EC_SERVER_JSON_INVALID;
|
ec = TALER_EC_SERVER_JSON_INVALID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (NULL == (method = TALER_WIRE_payto_get_method (wa->url)))
|
if (NULL == (method = TALER_payto_get_method (wa->url)))
|
||||||
{
|
{
|
||||||
/* bogus reply */
|
/* bogus reply */
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
|
@ -109,7 +109,7 @@ wire_cb (void *cls,
|
|||||||
{
|
{
|
||||||
char *method;
|
char *method;
|
||||||
|
|
||||||
method = TALER_WIRE_payto_get_method (accounts[i].url);
|
method = TALER_payto_get_method (accounts[i].url);
|
||||||
if (0 == strcmp (ws->expected_method,
|
if (0 == strcmp (ws->expected_method,
|
||||||
method))
|
method))
|
||||||
{
|
{
|
||||||
|
@ -17,15 +17,17 @@
|
|||||||
<http://www.gnu.org/licenses/>
|
<http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @file bank-lib/testing_api_helpers.c
|
* @file lib/testing_api_helpers_bank.c
|
||||||
* @brief convenience functions for bank-lib tests.
|
* @brief convenience functions for bank tests.
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
|
* @author Christian Grothoff
|
||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include "taler_testing_lib.h"
|
#include "taler_testing_lib.h"
|
||||||
#include "taler_fakebank_lib.h"
|
#include "taler_fakebank_lib.h"
|
||||||
|
|
||||||
|
#define EXCHANGE_ACCOUNT_NAME "2"
|
||||||
|
|
||||||
#define BANK_FAIL() \
|
#define BANK_FAIL() \
|
||||||
do {GNUNET_break (0); return NULL; } while (0)
|
do {GNUNET_break (0); return NULL; } while (0)
|
||||||
@ -332,14 +334,23 @@ TALER_TESTING_prepare_bank (const char *config_filename,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_OS_process_destroy (dbreset_proc);
|
GNUNET_OS_process_destroy (dbreset_proc);
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
TALER_BANK_auth_parse_cfg (cfg,
|
||||||
|
"account-" EXCHANGE_ACCOUNT_NAME,
|
||||||
|
&bc->exchange_auth))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
GNUNET_asprintf (&bc->bank_url,
|
GNUNET_asprintf (&bc->bank_url,
|
||||||
"http://localhost:%llu/",
|
"http://localhost:%llu/",
|
||||||
port);
|
port);
|
||||||
// FIXME: initialize rest of 'bc':
|
GNUNET_asprintf (&bc->exchange_account_url,
|
||||||
bc->exchange_account_url = NULL; // FIXME
|
"%s%s",
|
||||||
bc->exchange_auth; // FIXME
|
bc->bank_url,
|
||||||
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
|
EXCHANGE_ACCOUNT_NAME);
|
||||||
|
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url,
|
||||||
|
EXCHANGE_ACCOUNT_NAME);
|
||||||
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
||||||
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
@ -412,9 +423,11 @@ TALER_TESTING_prepare_fakebank (const char *config_filename,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
bc->bank_url = fakebank_url;
|
bc->bank_url = fakebank_url;
|
||||||
// FIXME: initialize rest of 'bc':
|
GNUNET_asprintf (&bc->exchange_account_url,
|
||||||
bc->exchange_account_url = NULL; // FIXME
|
"%s%s",
|
||||||
bc->exchange_auth; // FIXME
|
bc->bank_url,
|
||||||
|
EXCHANGE_ACCOUNT_NAME);
|
||||||
|
bc->exchange_auth.method = TALER_BANK_AUTH_NONE;
|
||||||
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
|
bc->exchange_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "2");
|
||||||
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
bc->user42_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "42");
|
||||||
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
bc->user43_payto = TALER_TESTING_make_xtalerbank_payto (bc->bank_url, "43");
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file exchange-lib/testing_api_helpers.c
|
* @file lib/testing_api_helpers_exchange.c
|
||||||
* @brief helper functions
|
* @brief helper functions
|
||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
* @author Marcello Stanisci
|
* @author Marcello Stanisci
|
||||||
@ -958,4 +958,4 @@ TALER_TESTING_url_port_free (const char *url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of testing_api_helpers.c */
|
/* end of testing_api_helpers_exchange.c */
|
||||||
|
@ -672,4 +672,25 @@ TALER_amount_divide (struct TALER_Amount *result,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Round the amount to something that can be
|
||||||
|
* transferred on the wire.
|
||||||
|
*
|
||||||
|
* @param[in,out] amount amount to round down
|
||||||
|
* @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary,
|
||||||
|
* #GNUNET_SYSERR if the amount or currency was invalid
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TALER_amount_round (struct TALER_Amount *amount)
|
||||||
|
{
|
||||||
|
uint32_t delta;
|
||||||
|
|
||||||
|
delta = amount->fraction % (TALER_AMOUNT_FRAC_BASE / 100);
|
||||||
|
if (0 == delta)
|
||||||
|
return GNUNET_NO;
|
||||||
|
amount->fraction -= delta;
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of amount.c */
|
/* end of amount.c */
|
||||||
|
@ -744,4 +744,36 @@ TALER_buffer_write_vfstr (struct TALER_Buffer *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix of PAYTO URLs.
|
||||||
|
*/
|
||||||
|
#define PAYTO "payto://"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the payment method from a @a payto_url
|
||||||
|
*
|
||||||
|
* @param payto_url the URL to parse
|
||||||
|
* @return NULL on error (malformed @a payto_url)
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
TALER_payto_get_method (const char *payto_url)
|
||||||
|
{
|
||||||
|
const char *start;
|
||||||
|
const char *end;
|
||||||
|
|
||||||
|
if (0 != strncmp (payto_url,
|
||||||
|
PAYTO,
|
||||||
|
strlen (PAYTO)))
|
||||||
|
return NULL;
|
||||||
|
start = &payto_url[strlen (PAYTO)];
|
||||||
|
end = strchr (start,
|
||||||
|
(unsigned char) '/');
|
||||||
|
if (NULL == end)
|
||||||
|
return NULL;
|
||||||
|
return GNUNET_strndup (start,
|
||||||
|
end - start);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* end of util.c */
|
/* end of util.c */
|
||||||
|
3
src/wire/.gitignore
vendored
3
src/wire/.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
test_wire_plugin
|
|
||||||
test_wire_plugin_transactions_test
|
|
||||||
test_sepa_wireformat
|
|
@ -1,22 +0,0 @@
|
|||||||
# This Makefile.am is in the public domain
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/src/include
|
|
||||||
|
|
||||||
if USE_COVERAGE
|
|
||||||
AM_CFLAGS = --coverage -O0
|
|
||||||
XLIB = -lgcov
|
|
||||||
endif
|
|
||||||
|
|
||||||
pkgcfgdir = $(prefix)/share/taler/config.d/
|
|
||||||
|
|
||||||
lib_LTLIBRARIES = \
|
|
||||||
libtalerwire.la
|
|
||||||
|
|
||||||
libtalerwire_la_SOURCES = \
|
|
||||||
payto.c \
|
|
||||||
wire_helper.c
|
|
||||||
libtalerwire_la_LIBADD = \
|
|
||||||
-lgnunetutil \
|
|
||||||
$(XLIB)
|
|
||||||
libtalerwire_la_LDFLAGS = \
|
|
||||||
-version-info 1:0:0 \
|
|
||||||
-export-dynamic -no-undefined
|
|
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is part of TALER
|
|
||||||
(C) 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 wire/wire_helper.c
|
|
||||||
* @brief Helper functions for dealing with wire formats
|
|
||||||
|
|
||||||
* @author Christian Grothoff <christian@grothoff.org>
|
|
||||||
*/
|
|
||||||
#include "platform.h"
|
|
||||||
#include "taler_util.h"
|
|
||||||
#include "taler_wire_lib.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prefix of PAYTO URLs.
|
|
||||||
*/
|
|
||||||
#define PAYTO "payto://"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain the payment method from a @a payto_url
|
|
||||||
*
|
|
||||||
* @param payto_url the URL to parse
|
|
||||||
* @return NULL on error (malformed @a payto_url)
|
|
||||||
*/
|
|
||||||
char *
|
|
||||||
TALER_WIRE_payto_get_method (const char *payto_url)
|
|
||||||
{
|
|
||||||
const char *start;
|
|
||||||
const char *end;
|
|
||||||
|
|
||||||
if (0 != strncmp (payto_url,
|
|
||||||
PAYTO,
|
|
||||||
strlen (PAYTO)))
|
|
||||||
return NULL;
|
|
||||||
start = &payto_url[strlen (PAYTO)];
|
|
||||||
end = strchr (start,
|
|
||||||
(unsigned char) '/');
|
|
||||||
if (NULL == end)
|
|
||||||
return NULL;
|
|
||||||
return GNUNET_strndup (start,
|
|
||||||
end - start);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Round the amount to something that can be
|
|
||||||
* transferred on the wire.
|
|
||||||
*
|
|
||||||
* @param[in,out] amount amount to round down
|
|
||||||
* @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary,
|
|
||||||
* #GNUNET_SYSERR if the amount or currency was invalid
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
TALER_WIRE_amount_round (struct TALER_Amount *amount)
|
|
||||||
{
|
|
||||||
uint32_t delta;
|
|
||||||
|
|
||||||
delta = amount->fraction % (TALER_AMOUNT_FRAC_BASE / 100);
|
|
||||||
if (0 == delta)
|
|
||||||
return GNUNET_NO;
|
|
||||||
amount->fraction -= delta;
|
|
||||||
return GNUNET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* end of wire_helper.c */
|
|
Loading…
Reference in New Issue
Block a user