forked from 8bitsats/Doginals_8bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status-node.py
40 lines (32 loc) · 1.22 KB
/
status-node.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from dotenv import load_dotenv
import requests
import json
# Load environment variables from the .env file
load_dotenv()
NODE_RPC_URL = os.getenv("NODE_RPC_URL")
NODE_RPC_USER = os.getenv("NODE_RPC_USER")
NODE_RPC_PASS = os.getenv("NODE_RPC_PASS")
# Configure the HTTP request header
headers = {
'content-type': 'application/json',
}
# Prepare the request payload to get the fee estimate
payload = json.dumps({
"jsonrpc": "1.0",
"id": "curltest",
"method": "estimatesmartfee",
"params": [1] # Assuming information for the next block is desired
})
# Make the RPC request
response = requests.post(NODE_RPC_URL, auth=(NODE_RPC_USER, NODE_RPC_PASS), headers=headers, data=payload)
# Check if the request was successful and print the fee estimate
if response.status_code == 200:
result = response.json()
doge_fee_rate = result['result']['feerate'] if 'feerate' in result['result'] else 'Not available'
# Convert DOGE to Satoshis
satoshi_fee_rate = float(doge_fee_rate) * 10**8
print(f"Estimated fee for the next block: {doge_fee_rate} DOGE per KB")
print(f"Equivalent in Satoshis per KB: {satoshi_fee_rate} sats per KB")
else:
print("Error calling estimatesmartfee:", response.text)