Skip to content

Commit

Permalink
Merge pull request #10 from AreaLayer/22388o-patch-6
Browse files Browse the repository at this point in the history
Add UTXOracle with DLC support
  • Loading branch information
22388o authored Oct 2, 2023
2 parents 533f3ec + 73be4bc commit 3e08e57
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/dlc/utxoracle.js
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
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 latestPriceData = await.priceData.getblockCount();

const yesterdayInSeconds = latestTimeInSeconds - 24 * 60 * 60;
const latestPriceDate = new Date(yesterdayInSeconds * 1000).toISOString().slice(0, 10);


0 comments on commit 3e08e57

Please sign in to comment.