From 7b351fbc91fbb5f672585fe43dd3db2d5e7c0f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:27:52 -0300 Subject: [PATCH 1/2] Update utxoracle.js --- src/dlc/utxoracle.js | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/dlc/utxoracle.js b/src/dlc/utxoracle.js index 8b137891..10ceee77 100644 --- a/src/dlc/utxoracle.js +++ b/src/dlc/utxoracle.js @@ -1 +1,46 @@ +const bitcoin = require('bitcoinjs-lib'); +const axios = require('axios'); + +console.log("UTXOracle version 6\n"); + +// Bitcoin Core RPC settings +const rpcConfig = { + protocol: 'http', + host: '127.0.0.1', + port: '8332', + username: 'your_rpc_username', + password: 'your_rpc_password', +}; + +const rpcClient = bitcoin.Client(rpcConfig); + +(async function () { + try { + const blockCount = await rpcClient.getBlockCount(); + const blockHash = await rpcClient.getBlockHash(blockCount); + const block = await rpcClient.getBlock(blockHash, true); + const latestTimeInSeconds = block.time; + const latestTimeDatetime = new Date(latestTimeInSeconds * 1000).toUTCString(); + const latestTimeUTC = latestTimeDatetime.slice(0, -4); + + const yesterdayInSeconds = latestTimeInSeconds - 24 * 60 * 60; + const latestPriceDate = new Date(yesterdayInSeconds * 1000).toISOString().slice(0, 10); + + console.log(`Connected to local node at block #: ${blockCount}`); + console.log(`Latest available price date is: ${latestPriceDate}`); + console.log("Earliest available price date is: 2020-07-26 (full node)"); + + // Your date input logic here + + // Rest of the code (Parts 4 to 9) would go here + + } catch (error) { + console.error("Error connecting to your node. Trouble shooting steps:\n"); + console.error("1) Make sure Bitcoin Core is running and reachable."); + console.error("2) Make sure you have set up your Bitcoin Core RPC configuration."); + console.error("3) Explore the Bitcoin Core RPC options in your JavaScript code."); + console.error("\nThe error was:", error); + process.exit(1); + } +})(); From 73be4bc6b8f8a016de286ed6cb308bd72276d698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22388o=E2=9A=A1=EF=B8=8F?= <83122757+22388o@users.noreply.github.com> Date: Mon, 2 Oct 2023 06:42:20 -0300 Subject: [PATCH 2/2] Update utxoracle.js --- src/dlc/utxoracle.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/dlc/utxoracle.js b/src/dlc/utxoracle.js index 10ceee77..65bb69e5 100644 --- a/src/dlc/utxoracle.js +++ b/src/dlc/utxoracle.js @@ -22,25 +22,9 @@ const rpcClient = bitcoin.Client(rpcConfig); const latestTimeInSeconds = block.time; const latestTimeDatetime = new Date(latestTimeInSeconds * 1000).toUTCString(); const latestTimeUTC = latestTimeDatetime.slice(0, -4); + const latestPriceData = await.priceData.getblockCount(); const yesterdayInSeconds = latestTimeInSeconds - 24 * 60 * 60; const latestPriceDate = new Date(yesterdayInSeconds * 1000).toISOString().slice(0, 10); - console.log(`Connected to local node at block #: ${blockCount}`); - console.log(`Latest available price date is: ${latestPriceDate}`); - console.log("Earliest available price date is: 2020-07-26 (full node)"); - - // Your date input logic here - - // Rest of the code (Parts 4 to 9) would go here - - } catch (error) { - console.error("Error connecting to your node. Trouble shooting steps:\n"); - console.error("1) Make sure Bitcoin Core is running and reachable."); - console.error("2) Make sure you have set up your Bitcoin Core RPC configuration."); - console.error("3) Explore the Bitcoin Core RPC options in your JavaScript code."); - console.error("\nThe error was:", error); - process.exit(1); - } -})();