File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
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
+
1
30
You can’t perform that action at this time.
0 commit comments