[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated (4482f8d4 -> 1d50e1fc)
From: |
gnunet |
Subject: |
[libeufin] branch master updated (4482f8d4 -> 1d50e1fc) |
Date: |
Mon, 20 Dec 2021 17:44:43 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a change to branch master
in repository libeufin.
from 4482f8d4 Access API: implement create transactions.
new d9220861 serve SPA
new 915e594f t_ms -> t_s
new 0e95165d Withdrawal.
new 6e1837c6 move default exchange selection at /confirm
new 19d8bb16 Withdrawal.
new c62f8960 SPA
new 1d50e1fc SPA
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../main/kotlin/tech/libeufin/nexus/Anastasis.kt | 2 +-
nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt | 14 ++-----
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 47 ++++++++++++++++++----
sandbox/src/main/resources/static/hello.html | 10 -----
sandbox/src/main/resources/static/spa.html | 3 ++
sandbox/src/main/resources/templates/hello.html | 1 -
6 files changed, 47 insertions(+), 30 deletions(-)
delete mode 100644 sandbox/src/main/resources/static/hello.html
create mode 100644 sandbox/src/main/resources/static/spa.html
delete mode 100644 sandbox/src/main/resources/templates/hello.html
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Anastasis.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Anastasis.kt
index 4697567e..a7ec84ef 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Anastasis.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Anastasis.kt
@@ -89,7 +89,7 @@ private suspend fun historyIncoming(call: ApplicationCall) {
history.incoming_transactions.add(
AnastasisIncomingBankTransaction(
// Rounded timestamp
- date = GnunetTimestamp((it.timestampMs / 1000) * 1000),
+ date = GnunetTimestamp(it.timestampMs / 1000L),
row_id = it.id.value,
amount = "${it.payment.currency}:${it.payment.amount}",
subject = it.subject,
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
index 60cbe80f..f7e8fd88 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Taler.kt
@@ -92,9 +92,7 @@ data class TalerOutgoingHistory(
var outgoing_transactions: MutableList<TalerOutgoingBankTransaction> =
mutableListOf()
)
-data class GnunetTimestamp(
- val t_ms: Long
-)
+data class GnunetTimestamp(val t_s: Long)
/**
* Sort query results in descending order for negative deltas, and ascending
otherwise.
@@ -228,7 +226,7 @@ private suspend fun talerTransfer(call: ApplicationCall) {
* Normally should point to the next round where the
background
* routine will send new PAIN.001 data to the bank; work
in progress..
*/
- timestamp =
roundTimestamp(GnunetTimestamp(System.currentTimeMillis())),
+ timestamp = GnunetTimestamp(System.currentTimeMillis() /
1000L),
row_id = opaqueRowId
)
),
@@ -237,10 +235,6 @@ private suspend fun talerTransfer(call: ApplicationCall) {
)
}
-fun roundTimestamp(t: GnunetTimestamp): GnunetTimestamp {
- return GnunetTimestamp(t.t_ms - (t.t_ms % 1000))
-}
-
fun talerFilter(payment: NexusBankTransactionEntity, txDtls:
TransactionDetails) {
val subject = txDtls.unstructuredRemittanceInformation
val debtorName = txDtls.debtor?.name
@@ -402,7 +396,7 @@ private suspend fun historyOutgoing(call: ApplicationCall) {
row_id = it.id.value,
amount = it.amount,
wtid = it.wtid,
- date =
GnunetTimestamp(it.preparedPayment.preparationDate),
+ date =
GnunetTimestamp(it.preparedPayment.preparationDate / 1000L),
credit_account = it.creditAccount,
debit_account = buildIbanPaytoUri(
subscriberBankAccount.iban,
@@ -442,7 +436,7 @@ private suspend fun historyIncoming(call: ApplicationCall) {
history.incoming_transactions.add(
TalerIncomingBankTransaction(
// Rounded timestamp
- date = GnunetTimestamp((it.timestampMs / 1000) * 1000),
+ date = GnunetTimestamp(it.timestampMs / 1000L),
row_id = it.id.value,
amount = "${it.payment.currency}:${it.payment.amount}",
reserve_pub = it.reservePublicKey,
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 08945b33..b2dd5a93 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -73,6 +73,7 @@ import org.slf4j.LoggerFactory
import org.w3c.dom.Document
import startServer
import tech.libeufin.util.*
+import java.io.IOException
import java.math.BigDecimal
import java.net.BindException
import java.net.URL
@@ -937,7 +938,7 @@ val sandboxApp: Application.() -> Unit = {
// debt limit and possibly other configuration
// (could also be a CLI command for now)
post("/demobanks") {
- throw NotImplementedError("Only available in the CLI.")
+ throw NotImplementedError("Only available in the Sandbox CLI.")
}
get("/demobanks") {
@@ -953,6 +954,26 @@ val sandboxApp: Application.() -> Unit = {
}
get("/demobanks/{demobankid}") {
+ /**
+ * Respond the SPA if the content type is not "application/json".
+ */
+ if (call.request.headers["Content-Type"] != "application/json") {
+ val spa =
ClassLoader.getSystemClassLoader().getResourceAsStream("static/spa.html")
+ if (spa == null) throw internalServerError("SPA not found!")
+ call.respondBytesWriter(contentType = ContentType.Text.Html) {
+ writeWhile {
+ val content = try {
+ spa.read()
+ } catch (e: IOException) {
+ throw internalServerError("Could not load the SPA")
+ }
+ if (content == -1) return@writeWhile false
+ it.put(content.toByte())
+ true
+ }
+ }
+ return@get
+ }
expectAdmin(call.request.basicAuth())
val demobankId = call.getUriComponent("demobankid")
val ret: DemobankConfigEntity = transaction {
@@ -1020,12 +1041,10 @@ val sandboxApp: Application.() -> Unit = {
}.firstOrNull() ?: throw SandboxError(
HttpStatusCode.NotFound, "Withdrawal operation
$wopid not found."
)
+ if (wo.confirmationDone) {
+ return@newSuspendedTransaction true
+ }
if (wo.selectionDone) {
- if (wo.confirmationDone) {
- logger.info("Wallet performs again this
operation that was paid out earlier: idempotent")
- return@newSuspendedTransaction wo.selectionDone
- }
- // Selected already but NOT paid, check
consistency.
if (body.reserve_pub != wo.reservePub) throw
SandboxError(
HttpStatusCode.Conflict,
"Selecting a different reserve from the one
already selected"
@@ -1034,12 +1053,17 @@ val sandboxApp: Application.() -> Unit = {
HttpStatusCode.Conflict,
"Selecting a different exchange from the one
already selected"
)
+ return@newSuspendedTransaction false
}
+ // Flow here means never selected, hence must as well
never be paid.
+ if (wo.confirmationDone) throw internalServerError(
+ "Withdrawal ${wo.wopid} knew NO exchange and
reserve pub, " +
+ "but is marked as paid!"
+ )
wo.reservePub = body.reserve_pub
wo.selectedExchangePayto = body.selected_exchange
wo.selectionDone = true
- wo.confirmationDone
- false // not confirmed (AKA transferred)
+ false
}
call.respond(object {
val transfer_done: Boolean = transferDone
@@ -1190,6 +1214,13 @@ val sandboxApp: Application.() -> Unit = {
"Cannot confirm a unselected withdrawal: " +
"specify exchange and reserve public key
via Integration API first."
)
+ /**
+ * The wallet chose not to select any exchange, use
the default.
+ */
+ val demobank = ensureDemobank(call)
+ if (wo.selectedExchangePayto == null) {
+ wo.selectedExchangePayto =
demobank.suggestedExchangePayto
+ }
val exchangeBankAccount = getBankAccountFromPayto(
wo.selectedExchangePayto ?: throw
internalServerError(
"Cannot withdraw without an exchange."
diff --git a/sandbox/src/main/resources/static/hello.html
b/sandbox/src/main/resources/static/hello.html
deleted file mode 100644
index 9dc42994..00000000
--- a/sandbox/src/main/resources/static/hello.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>Hello</title>
-</head>
-<body>
-Testing the static folder.
-</body>
-</html>
\ No newline at end of file
diff --git a/sandbox/src/main/resources/static/spa.html
b/sandbox/src/main/resources/static/spa.html
new file mode 100644
index 00000000..25405ff7
--- /dev/null
+++ b/sandbox/src/main/resources/static/spa.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html><html lang="en" class="has-aside-left
has-aside-mobile-transition has-navbar-fixed-top
has-aside-expanded"><head><meta charset="utf-8"><title>taler-bank</title><meta
name="viewport" content="width=device-width,initial-scale=1"><meta
name="mobile-web-app-capable" content="yes"><meta
name="apple-mobile-web-app-capable" content="yes"><link rel="icon"
href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD/////////////////////////
[...]
+//#
sourceMappingURL=polyfills.61bd8.js.map</script><script>!function(t){function
e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return
t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var
n={};e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof
Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=funct
[...]
+//# sourceMappingURL=bundle.ea805.js.map</script></body></html>
\ No newline at end of file
diff --git a/sandbox/src/main/resources/templates/hello.html
b/sandbox/src/main/resources/templates/hello.html
deleted file mode 100644
index 70e073e2..00000000
--- a/sandbox/src/main/resources/templates/hello.html
+++ /dev/null
@@ -1 +0,0 @@
-Hello, I'm a Jinja '{{ token }}' page!
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (4482f8d4 -> 1d50e1fc),
gnunet <=
- [libeufin] 01/07: serve SPA, gnunet, 2021/12/20
- [libeufin] 02/07: t_ms -> t_s, gnunet, 2021/12/20
- [libeufin] 03/07: Withdrawal., gnunet, 2021/12/20
- [libeufin] 07/07: SPA, gnunet, 2021/12/20
- [libeufin] 05/07: Withdrawal., gnunet, 2021/12/20
- [libeufin] 06/07: SPA, gnunet, 2021/12/20
- [libeufin] 04/07: move default exchange selection at /confirm, gnunet, 2021/12/20