Skip to content

Commit 3e08e57

Browse files
authored
Merge pull request #10 from AreaLayer/22388o-patch-6
Add UTXOracle with DLC support
2 parents 533f3ec + 73be4bc commit 3e08e57

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/dlc/utxoracle.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1+
const bitcoin = require('bitcoinjs-lib');
2+
const axios = require('axios');
3+
4+
console.log("UTXOracle version 6\n");
5+
6+
// Bitcoin Core RPC settings
7+
const rpcConfig = {
8+
protocol: 'http',
9+
host: '127.0.0.1',
10+
port: '8332',
11+
username: 'your_rpc_username',
12+
password: 'your_rpc_password',
13+
};
14+
15+
const rpcClient = bitcoin.Client(rpcConfig);
16+
17+
(async function () {
18+
try {
19+
const blockCount = await rpcClient.getBlockCount();
20+
const blockHash = await rpcClient.getBlockHash(blockCount);
21+
const block = await rpcClient.getBlock(blockHash, true);
22+
const latestTimeInSeconds = block.time;
23+
const latestTimeDatetime = new Date(latestTimeInSeconds * 1000).toUTCString();
24+
const latestTimeUTC = latestTimeDatetime.slice(0, -4);
25+
const latestPriceData = await.priceData.getblockCount();
26+
27+
const yesterdayInSeconds = latestTimeInSeconds - 24 * 60 * 60;
28+
const latestPriceDate = new Date(yesterdayInSeconds * 1000).toISOString().slice(0, 10);
29+
130

0 commit comments

Comments
 (0)