-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathnode_proxy.py
38 lines (28 loc) · 1.06 KB
/
node_proxy.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
# Copyright (C) 2018-2020 The python-litecoin-utils developers
#
# This file is part of python-litecoin-utils
#
# It is subject to the license terms in the LICENSE file found in the top-level
# directory of this distribution.
#
# No part of python-litecoin-utils, including this file, may be copied,
# modified, propagated, or distributed except according to the terms contained
# in the LICENSE file.
from litecoinutils.setup import setup
from litecoinutils.proxy import NodeProxy
def main():
# always remember to setup the network
setup('testnet')
# get a node proxy using default host and port
proxy = NodeProxy('rpcuser', 'rpcpw').get_proxy()
# call the node's getblockcount JSON-RPC method
count = proxy.getblockcount()
# call the node's getblockhash JSON-RPC method
block_hash = proxy.getblockhash(count)
# call the node's getblock JSON-RPC method and print result
block = proxy.getblock(block_hash)
print(block)
# print only the difficulty of the network
print(block['difficulty'])
if __name__ == "__main__":
main()