commit 506ff1a2b660572163d86ddf504d569e8496b670
parent 295ce2bc3fbb3adbae7a96a36c62151d671ce253
Author: Antoine A <>
Date: Thu, 2 Nov 2023 16:34:35 +0000
Remove ISO20022 logic for now
Diffstat:
5 files changed, 28 insertions(+), 101 deletions(-)
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Database.kt b/bank/src/main/kotlin/tech/libeufin/bank/Database.kt
@@ -34,8 +34,6 @@ import kotlinx.coroutines.*
import com.zaxxer.hikari.*
import tech.libeufin.util.*
-private const val DB_CTR_LIMIT = 1000000
-
private val logger: Logger = LoggerFactory.getLogger("tech.libeufin.bank.Database")
/**
@@ -337,15 +335,12 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
if (bonus != null) {
conn.prepareStatement("""
SELECT out_balance_insufficient
- FROM bank_transaction(?,'admin','bonus',(?,?)::taler_amount,?,?,?,?)
+ FROM bank_transaction(?,'admin','bonus',(?,?)::taler_amount,?)
""").run {
setString(1, internalPaytoUri.canonical)
setLong(2, bonus.value)
setInt(3, bonus.frac)
setLong(4, Instant.now().toDbMicros() ?: throw faultyTimestampByBank())
- setString(5, "not used") // ISO20022
- setString(6, "not used") // ISO20022
- setString(7, "not used") // ISO20022
executeQuery().use {
when {
!it.next() -> throw internalServerError("Bank transaction didn't properly return")
@@ -687,9 +682,6 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
subject: String,
amount: TalerAmount,
timestamp: Instant,
- accountServicerReference: String = "not used", // ISO20022
- endToEndId: String = "not used", // ISO20022
- paymentInformationId: String = "not used" // ISO20022
): BankTransactionResult = conn { conn ->
conn.transaction {
val stmt = conn.prepareStatement("""
@@ -704,7 +696,7 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
,out_debit_row_id
,out_creditor_is_exchange
,out_debtor_is_exchange
- FROM bank_transaction(?,?,?,(?,?)::taler_amount,?,?,?,?)
+ FROM bank_transaction(?,?,?,(?,?)::taler_amount,?)
"""
)
stmt.setString(1, creditAccountPayto.canonical)
@@ -713,9 +705,6 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
stmt.setLong(4, amount.value)
stmt.setInt(5, amount.frac)
stmt.setLong(6, timestamp.toDbMicros() ?: throw faultyTimestampByBank())
- stmt.setString(7, accountServicerReference)
- stmt.setString(8, paymentInformationId)
- stmt.setString(9, endToEndId)
stmt.executeQuery().use {
when {
!it.next() -> throw internalServerError("Bank transaction didn't properly return")
@@ -744,9 +733,6 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
,(amount).val AS amount_val
,(amount).frac AS amount_frac
,transaction_date
- ,account_servicer_reference
- ,payment_information_id
- ,end_to_end_id
,direction
,bank_account_id
,bank_transaction_id
@@ -765,11 +751,8 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
it.getInt("amount_frac"),
bankCurrency
),
- accountServicerReference = it.getString("account_servicer_reference"),
- endToEndId = it.getString("end_to_end_id"),
direction = TransactionDirection.valueOf(it.getString("direction")),
bankAccountId = it.getLong("bank_account_id"),
- paymentInformationId = it.getString("payment_information_id"),
subject = it.getString("subject"),
transactionDate = it.getLong("transaction_date").microsToJavaInstant() ?: throw faultyTimestampByBank(),
dbRowId = it.getLong("bank_transaction_id")
@@ -1068,10 +1051,7 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
*/
suspend fun talerWithdrawalConfirm(
opUuid: UUID,
- timestamp: Instant,
- accountServicerReference: String = "NOT-USED",
- endToEndId: String = "NOT-USED",
- paymentInfId: String = "NOT-USED"
+ timestamp: Instant
): WithdrawalConfirmationResult = conn { conn ->
val stmt = conn.prepareStatement("""
SELECT
@@ -1080,14 +1060,11 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
out_balance_insufficient,
out_not_selected,
out_aborted
- FROM confirm_taler_withdrawal(?, ?, ?, ?, ?);
+ FROM confirm_taler_withdrawal(?, ?);
"""
)
stmt.setObject(1, opUuid)
stmt.setLong(2, timestamp.toDbMicros() ?: throw faultyTimestampByBank())
- stmt.setString(3, accountServicerReference)
- stmt.setString(4, endToEndId)
- stmt.setString(5, paymentInfId)
stmt.executeQuery().use {
when {
!it.next() ->
@@ -1329,10 +1306,7 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
suspend fun talerTransferCreate(
req: TransferRequest,
username: String,
- timestamp: Instant,
- acctSvcrRef: String = "not used",
- pmtInfId: String = "not used",
- endToEndId: String = "not used",
+ timestamp: Instant
): TalerTransferCreationResult = conn { conn ->
val subject = OutgoingTxMetadata(req.wtid, req.exchange_base_url).encode()
val stmt = conn.prepareStatement("""
@@ -1349,7 +1323,7 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
taler_transfer (
?, ?, ?,
(?,?)::taler_amount,
- ?, ?, ?, ?, ?, ?, ?
+ ?, ?, ?, ?
);
""")
@@ -1362,9 +1336,6 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
stmt.setString(7, req.credit_account.canonical)
stmt.setString(8, username)
stmt.setLong(9, timestamp.toDbMicros() ?: throw faultyTimestampByBank())
- stmt.setString(10, acctSvcrRef)
- stmt.setString(11, pmtInfId)
- stmt.setString(12, endToEndId)
stmt.executeQuery().use {
when {
@@ -1414,10 +1385,7 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
suspend fun talerAddIncomingCreate(
req: AddIncomingRequest,
username: String,
- timestamp: Instant,
- acctSvcrRef: String = "not used",
- pmtInfId: String = "not used",
- endToEndId: String = "not used",
+ timestamp: Instant
): TalerAddIncomingCreationResult = conn { conn ->
val subject = IncomingTxMetadata(req.reserve_pub).encode()
val stmt = conn.prepareStatement("""
@@ -1433,7 +1401,7 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
taler_add_incoming (
?, ?,
(?,?)::taler_amount,
- ?, ?, ?, ?, ?, ?
+ ?, ?, ?
);
""")
@@ -1444,9 +1412,6 @@ class Database(dbConfig: String, private val bankCurrency: String, private val f
stmt.setString(5, req.debit_account.canonical)
stmt.setString(6, username)
stmt.setLong(7, timestamp.toDbMicros() ?: throw faultyTimestampByBank())
- stmt.setString(8, acctSvcrRef)
- stmt.setString(9, pmtInfId)
- stmt.setString(10, endToEndId)
stmt.executeQuery().use {
when {
diff --git a/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt b/bank/src/main/kotlin/tech/libeufin/bank/TalerMessage.kt
@@ -205,11 +205,7 @@ data class BankAccountTransaction(
*/
val bankAccountId: Long,
// Null if this type is used to _create_ one transaction.
- val dbRowId: Long,
- // Following are ISO20022 specific.
- val accountServicerReference: String,
- val paymentInformationId: String,
- val endToEndId: String,
+ val dbRowId: Long
)
/**
diff --git a/bank/src/test/kotlin/CoreBankApiTest.kt b/bank/src/test/kotlin/CoreBankApiTest.kt
@@ -692,7 +692,7 @@ class CoreBankTransactionsApiTest {
// POST /transactions
@Test
- fun testCreate() = bankSetup { _ ->
+ fun create() = bankSetup { _ ->
val valid_req = json {
"payto_uri" to "payto://iban/EXCHANGE-IBAN-XYZ?message=payout"
"amount" to "KUDOS:0.3"
diff --git a/database-versioning/libeufin-bank-0001.sql b/database-versioning/libeufin-bank-0001.sql
@@ -135,7 +135,7 @@ CREATE TABLE IF NOT EXISTS bank_account_transactions
,subject TEXT NOT NULL
,amount taler_amount NOT NULL
,transaction_date BIGINT NOT NULL -- is this ISO20022 terminology? document format (microseconds since epoch)
- ,account_servicer_reference TEXT NOT NULL
+ ,account_servicer_reference TEXT
,payment_information_id TEXT
,end_to_end_id TEXT
,direction direction_enum NOT NULL
diff --git a/database-versioning/libeufin-bank-procedures.sql b/database-versioning/libeufin-bank-procedures.sql
@@ -318,9 +318,6 @@ CREATE OR REPLACE FUNCTION taler_transfer(
IN in_credit_account_payto TEXT,
IN in_username TEXT,
IN in_timestamp BIGINT,
- IN in_account_servicer_reference TEXT,
- IN in_payment_information_id TEXT,
- IN in_end_to_end_id TEXT,
-- Error status
OUT out_debtor_not_found BOOLEAN,
OUT out_debtor_not_exchange BOOLEAN,
@@ -390,9 +387,9 @@ SELECT
in_subject,
in_amount,
in_timestamp,
- in_account_servicer_reference,
- in_payment_information_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_exchange_balance_insufficient THEN
RETURN;
@@ -401,20 +398,8 @@ out_timestamp=in_timestamp;
-- Register outgoing transaction
CALL register_outgoing(in_request_uid, in_wtid, in_exchange_base_url, out_tx_row_id);
END $$;
-COMMENT ON FUNCTION taler_transfer(
- bytea,
- bytea,
- text,
- taler_amount,
- text,
- text,
- text,
- bigint,
- text,
- text,
- text
- )-- TODO new comment
- IS 'function that (1) inserts the TWG requests'
+-- TODO new comment
+COMMENT ON FUNCTION taler_transfer IS 'function that (1) inserts the TWG requests'
'details into the database and (2) performs '
'the actual bank transaction to pay the merchant';
@@ -426,9 +411,6 @@ CREATE OR REPLACE FUNCTION taler_add_incoming(
IN in_debit_account_payto TEXT,
IN in_username TEXT,
IN in_timestamp BIGINT,
- IN in_account_servicer_reference TEXT,
- IN in_payment_information_id TEXT,
- IN in_end_to_end_id TEXT,
-- Error status
OUT out_creditor_not_found BOOLEAN,
OUT out_creditor_not_exchange BOOLEAN,
@@ -491,9 +473,9 @@ SELECT
in_subject,
in_amount,
in_timestamp,
- in_account_servicer_reference,
- in_payment_information_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_debitor_balance_insufficient THEN
RETURN;
@@ -501,18 +483,8 @@ END IF;
-- Register incoming transaction
CALL register_incoming(in_reserve_pub, out_tx_row_id, exchange_bank_account_id);
END $$;
-COMMENT ON FUNCTION taler_add_incoming(
- bytea,
- text,
- taler_amount,
- text,
- text,
- bigint,
- text,
- text,
- text
- ) -- TODO new comment
- IS 'function that (1) inserts the TWG requests'
+-- TODO new comment
+COMMENT ON FUNCTION taler_add_incoming IS 'function that (1) inserts the TWG requests'
'details into the database and (2) performs '
'the actual bank transaction to pay the merchant';
@@ -522,9 +494,6 @@ CREATE OR REPLACE FUNCTION bank_transaction(
IN in_subject TEXT,
IN in_amount taler_amount,
IN in_timestamp BIGINT,
- IN in_account_servicer_reference TEXT,
- IN in_payment_information_id TEXT,
- IN in_end_to_end_id TEXT,
-- Error status
OUT out_creditor_not_found BOOLEAN,
OUT out_debtor_not_found BOOLEAN,
@@ -581,9 +550,9 @@ SELECT
in_subject,
in_amount,
in_timestamp,
- in_account_servicer_reference,
- in_payment_information_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_balance_insufficient THEN
RETURN;
@@ -693,9 +662,6 @@ END $$;
CREATE OR REPLACE FUNCTION confirm_taler_withdrawal(
IN in_withdrawal_uuid uuid,
IN in_confirmation_date BIGINT,
- IN in_acct_svcr_ref TEXT,
- IN in_pmt_inf_id TEXT,
- IN in_end_to_end_id TEXT,
OUT out_no_op BOOLEAN,
OUT out_balance_insufficient BOOLEAN,
OUT out_creditor_not_found BOOLEAN,
@@ -758,9 +724,9 @@ FROM bank_wire_transfer(
subject_local,
amount_local,
in_confirmation_date,
- in_acct_svcr_ref,
- in_pmt_inf_id,
- in_end_to_end_id
+ NULL,
+ NULL,
+ NULL
) as transfer;
IF out_balance_insufficient THEN
RETURN;
@@ -774,7 +740,7 @@ UPDATE taler_withdrawal_operations
-- Register incoming transaction
CALL register_incoming(reserve_pub_local, tx_row_id, exchange_bank_account_id);
END $$;
-COMMENT ON FUNCTION confirm_taler_withdrawal(uuid, bigint, text, text, text)
+COMMENT ON FUNCTION confirm_taler_withdrawal
IS 'Set a withdrawal operation as confirmed and wire the funds to the exchange.';
CREATE OR REPLACE FUNCTION bank_wire_transfer(