-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbit.py
More file actions
22 lines (17 loc) · 724 Bytes
/
bit.py
File metadata and controls
22 lines (17 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from datetime import datetime
def getpercentfin():
try:
# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_connection = AuthServiceProxy("http://%s:%s@%s:8332"%("user", "user", "192.168.2.100"))
best_block_hash = rpc_connection.getblockchaininfo()
if round(best_block_hash["blocks"]/best_block_hash["headers"]*100,2)== 100:
mineblock(rpc_connection.getblocktemplate())
except JSONRPCException:
print ("You can't divide by zero, you're silly.")
return
def mineblock(blocktemplate):
print(blocktemplate)
if __name__ == "__main__":
getpercentfin()
input()