From f6967ae50f24c72ea3c4a4d631b010c65c1f22da Mon Sep 17 00:00:00 2001 From: simonredfern Date: Thu, 22 May 2025 17:44:54 +0200 Subject: [PATCH 1/4] added more debug.html pages --- obp-api/src/main/webapp/debug.html | 4 +- .../webapp/debug/debug-default-footer.html | 20 ++ .../webapp/debug/debug-default-header.html | 20 ++ .../templates-hidden/default-footer.html | 275 ++++++++++++++++++ .../templates-hidden/default-header.html | 264 +++++++++++++++++ 5 files changed, 582 insertions(+), 1 deletion(-) create mode 100644 obp-api/src/main/webapp/debug/debug-default-footer.html create mode 100644 obp-api/src/main/webapp/debug/debug-default-header.html create mode 100644 obp-api/src/main/webapp/templates-hidden/default-footer.html create mode 100644 obp-api/src/main/webapp/templates-hidden/default-header.html diff --git a/obp-api/src/main/webapp/debug.html b/obp-api/src/main/webapp/debug.html index 02de2e0ae..7e24b175a 100644 --- a/obp-api/src/main/webapp/debug.html +++ b/obp-api/src/main/webapp/debug.html @@ -31,7 +31,9 @@ Berlin 13359, Germany

Here are the debugging pages.

debug-plain -- no Liftweb involved.

-

debug-basic -- call LiftWeb code 'surround'.

+

debug-basic (default)-- call LiftWeb default code 'surround'.

+

debug-default-header -- call LiftWeb default header code 'surround'.

+

debug-default-footer -- call LiftWeb default footer code 'surround'.

debug-localization -- call Localization 'lift:loc' method.

debug-webui -- call webui method 'apiDocumentationLink' method.

diff --git a/obp-api/src/main/webapp/debug/debug-default-footer.html b/obp-api/src/main/webapp/debug/debug-default-footer.html new file mode 100644 index 000000000..ad3c25c9f --- /dev/null +++ b/obp-api/src/main/webapp/debug/debug-default-footer.html @@ -0,0 +1,20 @@ + + + + + + +Basic Liftweb Suround with default + +
+ +

I call LiftWeb code surround

+ with a link +

Link to static

static image +

Link to SDKs

SDKs + +
+ + + + \ No newline at end of file diff --git a/obp-api/src/main/webapp/debug/debug-default-header.html b/obp-api/src/main/webapp/debug/debug-default-header.html new file mode 100644 index 000000000..1b352e080 --- /dev/null +++ b/obp-api/src/main/webapp/debug/debug-default-header.html @@ -0,0 +1,20 @@ + + + + + + +Basic Liftweb Suround with default + +
+ +

I call LiftWeb code surround

+ with a link +

Link to static

static image +

Link to SDKs

SDKs + +
+ + + + \ No newline at end of file diff --git a/obp-api/src/main/webapp/templates-hidden/default-footer.html b/obp-api/src/main/webapp/templates-hidden/default-footer.html new file mode 100644 index 000000000..91bee85c2 --- /dev/null +++ b/obp-api/src/main/webapp/templates-hidden/default-footer.html @@ -0,0 +1,275 @@ + + + + + + + + + + + Open Bank Project: + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
+ + The main content gets bound here +
+ + + +
+ + diff --git a/obp-api/src/main/webapp/templates-hidden/default-header.html b/obp-api/src/main/webapp/templates-hidden/default-header.html new file mode 100644 index 000000000..96384d792 --- /dev/null +++ b/obp-api/src/main/webapp/templates-hidden/default-header.html @@ -0,0 +1,264 @@ + + + + + + + + + + + Open Bank Project: + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + +
+ + + + + + + + +
+ +
+ left logo image +
+
+
+ right logo image +
+
+
+
+
+ Skip to main content + Skip to main content + Skip to main content + Skip to main content + Skip to main content + Skip to main content + +
+ + +
+ +
+
+ + +
+ + The main content gets bound here +
+ + +
+ + From 34d457efa2a362675acc716ed6cd35ce9e7c2fcf Mon Sep 17 00:00:00 2001 From: simonredfern Date: Thu, 22 May 2025 17:47:57 +0200 Subject: [PATCH 2/4] new debug pages in menu --- obp-api/src/main/scala/bootstrap/liftweb/Boot.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala b/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala index e097bd7b7..81b577ef1 100644 --- a/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala @@ -572,6 +572,8 @@ class Boot extends MdcLoggable { Menu.i("SDKs") / "sdks", Menu.i("Debug") / "debug", Menu.i("debug-basic") / "debug" / "debug-basic", + Menu.i("debug-default-header") / "debug" / "debug-default-header", + Menu.i("debug-default-footer") / "debug" / "debug-default-footer", Menu.i("debug-localization") / "debug" / "debug-localization", Menu.i("debug-plain") / "debug" / "debug-plain", Menu.i("debug-webui") / "debug" / "debug-webui", From 30c0f2b7b7b2058455030b2019377f510541f46d Mon Sep 17 00:00:00 2001 From: simonredfern Date: Thu, 22 May 2025 17:49:52 +0200 Subject: [PATCH 3/4] tweaking sample props --- obp-api/src/main/resources/props/sample.props.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/obp-api/src/main/resources/props/sample.props.template b/obp-api/src/main/resources/props/sample.props.template index e2a7ddba7..694807761 100644 --- a/obp-api/src/main/resources/props/sample.props.template +++ b/obp-api/src/main/resources/props/sample.props.template @@ -300,7 +300,7 @@ sandbox_data_import_secret=change_me payments_enabled=true ## Transaction requests are replacing simple payments starting from 1.4.0 -transactionRequests_enabled=true +transactionRequests_enabled=false transactionRequests_connector=mapped ## Transaction Request Types that are supported on this server. Possible values might include SANDBOX_TAN, COUNTERPARTY, SEPA, FREE_FORM From 0df03f5067515a989e15450362726ac07e61f23b Mon Sep 17 00:00:00 2001 From: simonredfern Date: Thu, 22 May 2025 17:51:50 +0200 Subject: [PATCH 4/4] cardano test --- .../src/main/scala/code/cardano/cardano.scala | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 obp-api/src/main/scala/code/cardano/cardano.scala diff --git a/obp-api/src/main/scala/code/cardano/cardano.scala b/obp-api/src/main/scala/code/cardano/cardano.scala new file mode 100644 index 000000000..586127c66 --- /dev/null +++ b/obp-api/src/main/scala/code/cardano/cardano.scala @@ -0,0 +1,154 @@ +import java.io.{File, PrintWriter} +import scala.sys.process._ +import java.security.MessageDigest + +object CardanoMetadataWriter { + + // Function to generate SHA-256 hash of a string + def generateHash(transactionData: String): String = { + val digest = MessageDigest.getInstance("SHA-256") + val hashBytes = digest.digest(transactionData.getBytes("UTF-8")) + hashBytes.map("%02x".format(_)).mkString + } + + // Function to write metadata JSON file + def writeMetadataFile(transactionHash: String, filePath: String): Unit = { + val jsonContent = + s""" + |{ + | "674": { + | "transaction_hash": "$transactionHash" + | } + |} + |""".stripMargin + + val file = new File(filePath) + val writer = new PrintWriter(file) + writer.write(jsonContent) + writer.close() + println(s"Metadata file written to: $filePath") + } + + // Function to submit transaction to Cardano + def submitHashToCardano(transactionHash: String, txIn: String, txOut: String, signingKey: String, network: String): Unit = { + val metadataFilePath = "metadata.json" + + // Write metadata to file + writeMetadataFile(transactionHash, metadataFilePath) + + // Build transaction + val buildCommand = s"cardano-cli transaction build-raw --tx-in $txIn --tx-out $txOut --metadata-json-file $metadataFilePath --out-file tx.raw" + buildCommand.! + + // Sign transaction + val signCommand = s"cardano-cli transaction sign --tx-body-file tx.raw --signing-key-file $signingKey --$network --out-file tx.signed" + signCommand.! + + // Submit transaction + val submitCommand = s"cardano-cli transaction submit --tx-file tx.signed --$network" + submitCommand.! + + println("Transaction submitted to Cardano blockchain.") + } + + // Example Usage + def main(args: Array[String]): Unit = { + val transactionData = "123|100.50|EUR|2025-03-16 12:30:00" + val transactionHash = generateHash(transactionData) + + val txIn = "8c293647e5cb51c4d29e57e162a0bb4a0500096560ce6899a4b801f2b69f2813:0" // This is a tx_id:0 ///"YOUR_UTXO_HERE" // Replace with actual UTXO + val txOut = "addr_test1qruvtthh7mndxu2ncykn47tksar9yqr3u97dlkq2h2dhzwnf3d755n99t92kp4rydpzgv7wmx4nx2j0zzz0g802qvadqtczjhn:1234" // "YOUR_RECEIVER_ADDRESS+LOVELACE" // Replace with receiver address and amount + val signingKey = "payment.skey" // Path to your signing key file + val network = "--testnet-magic" // "--testnet-magic 1097911063" // Use --mainnet for mainnet transactions + + submitHashToCardano(transactionHash, txIn, txOut, signingKey, network) + } +} + +// TODO +// Create second wallet +// Find version of Pre Prod i'm running +// Get CLI for that version +// Use faucet to get funds + + + + + +/* +import com.bloxbean.cardano.client.account.Account +import com.bloxbean.cardano.client.api.UtxoSupplier +import com.bloxbean.cardano.client.backend.impl.local.LocalNodeBackendService +import com.bloxbean.cardano.client.backend.api.TransactionService +import com.bloxbean.cardano.client.backend.api.UtxoService +import com.bloxbean.cardano.client.backend.model.Utxo +import com.bloxbean.cardano.client.common.model.Network +import com.bloxbean.cardano.client.metadata.cbor.CBORMetadata +import com.bloxbean.cardano.client.transaction.spec.Transaction +import com.bloxbean.cardano.client.api.helper.TransactionBuilder +import java.security.MessageDigest + +object CardanoMetadataWriter { + + // Function to generate SHA-256 hash + def generateHash(transactionData: String): String = { + val digest = MessageDigest.getInstance("SHA-256") + val hashBytes = digest.digest(transactionData.getBytes("UTF-8")) + hashBytes.map("%02x".format(_)).mkString + } + + // Function to submit metadata transaction + def submitMetadataToCardano(mnemonic: String, transactionData: String): Unit = { + val network = Network.TESTNET // Change to Network.MAINNET for mainnet + + // Load Daedalus wallet from mnemonic + val account = new Account(network, mnemonic) + + // Generate hash of transaction data + val transactionHash = generateHash(transactionData) + + println(s"Generated Hash: $transactionHash") + + // Create metadata object + val metadata = new CBORMetadata() + metadata.put("674", Map("transaction_hash" -> transactionHash)) + + // Initialize local Cardano node backend + val backendService = new LocalNodeBackendService("http://localhost:8080") + val transactionService: TransactionService = backendService.getTransactionService + val utxoService: UtxoService = backendService.getUtxoService + + // Get available UTXOs from the wallet + val utxos: java.util.List[Utxo] = utxoService.getUtxos(account.baseAddress, 1, 10).getValue + + if (utxos.isEmpty) { + println("No UTXOs found. Please fund your wallet.") + return + } + + // Build transaction + val transaction = TransactionBuilder.create() + .account(account) + .metadata(metadata) + .utxos(utxos) + .changeAddress(account.baseAddress) + .network(network) + .build() + + // Sign transaction + val signedTransaction: Transaction = account.sign(transaction) + + // Submit transaction + val txHash: String = transactionService.submitTransaction(signedTransaction).getValue + println(s"✅ Transaction submitted! TxHash: $txHash") + } + + // Main method + def main(args: Array[String]): Unit = { + val mnemonic = "YOUR_12_OR_24_WORD_MNEMONIC_HERE" + val transactionData = "123|100.50|USD|2025-03-16 12:30:00" + + submitMetadataToCardano(mnemonic, transactionData) + } +} +*/