aboutsummaryrefslogtreecommitdiff
path: root/utils/python-rpc/framework/daemon.py
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-11 13:14:44 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-11 13:14:44 +0200
commit083271375ae14bf8b3495c9c3f4490ae29cb9905 (patch)
treef384a6e92c3dbb40c8644275fa121b699b2ce7a6 /utils/python-rpc/framework/daemon.py
parente03b9bcdfdb1961e9928b31daa3d548ee5d7291f (diff)
parent0575794f53b3481a08a8d680e80765c1f1b13729 (diff)
downloadmonzero-core-083271375ae14bf8b3495c9c3f4490ae29cb9905.tar.gz
monzero-core-083271375ae14bf8b3495c9c3f4490ae29cb9905.tar.xz
monzero-core-083271375ae14bf8b3495c9c3f4490ae29cb9905.zip
Merge pull request #5383
0575794f console: simple shell over console.py (moneromooo-monero) 047af5c3 console.py: can now connect to several daemons/wallets (moneromooo-monero) 9f9571aa cmake: always detect python, it's neeed for some tests (moneromooo-monero) 8646bd00 functional_tests: exit with 1 if any test fails (moneromooo-monero) 6fd8834d console.py: add tab completion (moneromooo-monero) 04a20cb2 functional_tests: cold signing key images/outputs import/export (moneromooo-monero) 798e3cad functional_tests: add double spend detection tests (moneromooo-monero) 7c657bb2 functional_tests: add alt chains tests (moneromooo-monero) f8be31d2 functional_tests: add wallet creation language tests (moneromooo-monero) 2d68b31f functional_tests: add more wallet tests (moneromooo-monero) 23f86dad python-rpc: add set_log_level and set_log_categories (moneromooo-monero) b3a32d55 functional_tests: add describe_transfer tests (moneromooo-monero) 108f4375 console.py: support connecting to any host, not just 127.0.0.1 (moneromooo-monero) 064ab123 functional_tests: add more blockchain related tests (moneromooo-monero) 21b1ac1d functional_tests: add bans tests (moneromooo-monero)
Diffstat (limited to 'utils/python-rpc/framework/daemon.py')
-rw-r--r--utils/python-rpc/framework/daemon.py120
1 files changed, 116 insertions, 4 deletions
diff --git a/utils/python-rpc/framework/daemon.py b/utils/python-rpc/framework/daemon.py
index f60fe62db..f4d5e90f0 100644
--- a/utils/python-rpc/framework/daemon.py
+++ b/utils/python-rpc/framework/daemon.py
@@ -33,14 +33,17 @@ from .rpc import JSONRPC
class Daemon(object):
def __init__(self, protocol='http', host='127.0.0.1', port=0, idx=0):
+ self.host = host
+ self.port = port
self.rpc = JSONRPC('{protocol}://{host}:{port}'.format(protocol=protocol, host=host, port=port if port else 18180+idx))
- def getblocktemplate(self, address):
+ def getblocktemplate(self, address, prev_block = ""):
getblocktemplate = {
'method': 'getblocktemplate',
'params': {
'wallet_address': address,
- 'reserve_size' : 1
+ 'reserve_size' : 1,
+ 'prev_block' : prev_block,
},
'jsonrpc': '2.0',
'id': '0'
@@ -143,13 +146,15 @@ class Daemon(object):
}
return self.rpc.send_json_rpc_request(hard_fork_info)
- def generateblocks(self, address, blocks=1):
+ def generateblocks(self, address, blocks=1, prev_block = "", starting_nonce = 0):
generateblocks = {
'method': 'generateblocks',
'params': {
'amount_of_blocks' : blocks,
'reserve_size' : 20,
- 'wallet_address': address
+ 'wallet_address': address,
+ 'prev_block': prev_block,
+ 'starting_nonce': starting_nonce,
},
'jsonrpc': '2.0',
'id': '0'
@@ -217,3 +222,110 @@ class Daemon(object):
'id': '0'
}
return self.rpc.send_json_rpc_request(get_version)
+
+ def get_bans(self):
+ get_bans = {
+ 'method': 'get_bans',
+ 'params': {
+ },
+ 'jsonrpc': '2.0',
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(get_bans)
+
+ def set_bans(self, bans = []):
+ set_bans = {
+ 'method': 'set_bans',
+ 'params': {
+ 'bans': bans
+ },
+ 'jsonrpc': '2.0',
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(set_bans)
+
+ def get_transactions(self, txs_hashes = [], decode_as_json = False, prune = False, split = False):
+ get_transactions = {
+ 'txs_hashes': txs_hashes,
+ 'decode_as_json': decode_as_json,
+ 'prune': prune,
+ 'split': split,
+ }
+ return self.rpc.send_request('/get_transactions', get_transactions)
+
+ def get_outs(self, outputs = [], get_txid = False):
+ get_outs = {
+ 'outputs': outputs,
+ 'get_txid': get_txid,
+ }
+ return self.rpc.send_request('/get_outs', get_outs)
+
+ def get_coinbase_tx_sum(self, height, count):
+ get_coinbase_tx_sum = {
+ 'method': 'get_coinbase_tx_sum',
+ 'params': {
+ 'height': height,
+ 'count': count,
+ },
+ 'jsonrpc': '2.0',
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(get_coinbase_tx_sum)
+
+ def get_output_distribution(self, amounts = [], from_height = 0, to_height = 0, cumulative = False, binary = False, compress = False):
+ get_output_distribution = {
+ 'method': 'get_output_distribution',
+ 'params': {
+ 'amounts': amounts,
+ 'from_height': from_height,
+ 'to_height': to_height,
+ 'cumulative': cumulative,
+ 'binary': binary,
+ 'compress': compress,
+ },
+ 'jsonrpc': '2.0',
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(get_output_distribution)
+
+ def get_output_histogram(self, amounts = [], min_count = 0, max_count = 0, unlocked = False, recent_cutoff = 0):
+ get_output_histogram = {
+ 'method': 'get_output_histogram',
+ 'params': {
+ 'amounts': amounts,
+ 'min_count': min_count,
+ 'max_count': max_count,
+ 'unlocked': unlocked,
+ 'recent_cutoff': recent_cutoff,
+ },
+ 'jsonrpc': '2.0',
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(get_output_histogram)
+
+ def set_log_level(self, level):
+ set_log_level = {
+ 'level': level,
+ }
+ return self.rpc.send_request('/set_log_level', set_log_level)
+
+ def set_log_categories(self, categories = ''):
+ set_log_categories = {
+ 'categories': categories,
+ }
+ return self.rpc.send_request('/set_log_categories', set_log_categories)
+
+ def get_alt_blocks_hashes(self):
+ get_alt_blocks_hashes = {
+ }
+ return self.rpc.send_request('/get_alt_blocks_hashes', get_alt_blocks_hashes)
+
+ def get_alternate_chains(self):
+ get_alternate_chains = {
+ 'method': 'get_alternate_chains',
+ 'params': {
+ },
+ 'jsonrpc': '2.0',
+ 'id': '0'
+ }
+ return self.rpc.send_json_rpc_request(get_alternate_chains)