diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/python-rpc/framework/daemon.py | 154 | ||||
-rw-r--r-- | utils/python-rpc/framework/wallet.py | 327 |
2 files changed, 467 insertions, 14 deletions
diff --git a/utils/python-rpc/framework/daemon.py b/utils/python-rpc/framework/daemon.py index 23d5ec0f0..1d6c57c56 100644 --- a/utils/python-rpc/framework/daemon.py +++ b/utils/python-rpc/framework/daemon.py @@ -49,6 +49,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(getblocktemplate) + get_block_template = getblocktemplate def send_raw_transaction(self, tx_as_hex, do_not_relay = False, do_sanity_checks = True): send_raw_transaction = { @@ -57,6 +58,7 @@ class Daemon(object): 'do_sanity_checks': do_sanity_checks, } return self.rpc.send_request("/send_raw_transaction", send_raw_transaction) + sendrawtransaction = send_raw_transaction def submitblock(self, block): submitblock = { @@ -66,6 +68,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(submitblock) + submit_block = submitblock def getblock(self, hash = '', height = 0, fill_pow_hash = False): getblock = { @@ -79,6 +82,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(getblock) + get_block = getblock def getlastblockheader(self): getlastblockheader = { @@ -89,6 +93,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(getlastblockheader) + get_last_block_header = getlastblockheader def getblockheaderbyhash(self, hash = "", hashes = []): getblockheaderbyhash = { @@ -101,6 +106,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(getblockheaderbyhash) + get_block_header_by_hash = getblockheaderbyhash def getblockheaderbyheight(self, height): getblockheaderbyheight = { @@ -112,6 +118,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(getblockheaderbyheight) + get_block_header_by_height = getblockheaderbyheight def getblockheadersrange(self, start_height, end_height, fill_pow_hash = False): getblockheadersrange = { @@ -125,6 +132,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(getblockheadersrange) + get_block_headers_range = getblockheadersrange def get_connections(self): get_connections = { @@ -141,6 +149,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(get_info) + getinfo = get_info def hard_fork_info(self): hard_fork_info = { @@ -172,6 +181,7 @@ class Daemon(object): 'id': '0' } return self.rpc.send_request("/get_height", get_height) + getheight = get_height def pop_blocks(self, nblocks = 1): pop_blocks = { @@ -208,6 +218,11 @@ class Daemon(object): } return self.rpc.send_request('/get_transaction_pool_hashes', get_transaction_pool_hashes) + def get_transaction_pool_stats(self): + get_transaction_pool_stats = { + } + return self.rpc.send_request('/get_transaction_pool_stats', get_transaction_pool_stats) + def flush_txpool(self, txids = []): flush_txpool = { 'method': 'flush_txpool', @@ -256,6 +271,7 @@ class Daemon(object): 'split': split, } return self.rpc.send_request('/get_transactions', get_transactions) + gettransactions = get_transactions def get_outs(self, outputs = [], get_txid = False): get_outs = { @@ -344,3 +360,141 @@ class Daemon(object): 'id': '0' } return self.rpc.send_json_rpc_request(get_fee_estimate) + + def is_key_image_spent(self, key_images = []): + is_key_image_spent = { + 'key_images': key_images, + } + return self.rpc.send_request('/is_key_image_spent', is_key_image_spent) + + def save_bc(self): + save_bc = { + } + return self.rpc.send_request('/save_bc', save_bc) + + def get_peer_list(self): + get_peer_list = { + } + return self.rpc.send_request('/get_peer_list', get_peer_list) + + def set_log_hash_rate(self, visible): + set_log_hash_rate = { + 'visible': visible, + } + return self.rpc.send_request('/set_log_hash_rate', set_log_hash_rate) + + def stop_daemon(self): + stop_daemon = { + } + return self.rpc.send_request('/stop_daemon', stop_daemon) + + def get_net_stats(self): + get_net_stats = { + } + return self.rpc.send_request('/get_net_stats', get_net_stats) + + def get_limit(self): + get_limit = { + } + return self.rpc.send_request('/get_limit', get_limit) + + def set_limit(self, limit_down, limit_up): + set_limit = { + 'limit_down': limit_down, + 'limit_up': limit_up, + } + return self.rpc.send_request('/set_limit', set_limit) + + def out_peers(self, out_peers): + out_peers = { + 'out_peers': out_peers, + } + return self.rpc.send_request('/out_peers', out_peers) + + def in_peers(self, in_peers): + in_peers = { + 'in_peers': in_peers, + } + return self.rpc.send_request('/in_peers', in_peers) + + def update(self, command, path = None): + update = { + 'command': command, + 'path': path, + } + return self.rpc.send_request('/update', update) + + def get_block_count(self): + get_block_count = { + 'method': 'get_block_count', + 'params': { + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_block_count) + getblockcount = get_block_count + + def get_block_hash(self, height): + get_block_hash = { + 'method': 'get_block_hash', + 'params': [height], + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_block_hash) + on_get_block_hash = get_block_hash + on_getblockhash = get_block_hash + + def relay_tx(self, txids = []): + relay_tx = { + 'method': 'relay_tx', + 'params': { + 'txids': txids, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(relay_tx) + + def sync_info(self): + sync_info = { + 'method': 'sync_info', + 'params': { + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(sync_info) + + def get_txpool_backlog(self): + get_txpool_backlog = { + 'method': 'get_txpool_backlog', + 'params': { + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_txpool_backlog) + + def prune_blockchain(self, check = False): + prune_blockchain = { + 'method': 'prune_blockchain', + 'params': { + 'check': check, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(prune_blockchain) + + def get_block_rate(self, seconds = [3600]): + get_block_rate = { + 'method': 'get_block_rate', + 'params': { + 'seconds': seconds, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_block_rate) diff --git a/utils/python-rpc/framework/wallet.py b/utils/python-rpc/framework/wallet.py index 36ff3644f..6a3fabdc9 100644 --- a/utils/python-rpc/framework/wallet.py +++ b/utils/python-rpc/framework/wallet.py @@ -37,18 +37,6 @@ class Wallet(object): self.port = port self.rpc = JSONRPC('{protocol}://{host}:{port}'.format(protocol=protocol, host=host, port=port if port else 18090+idx)) - def make_uniform_destinations(self, address, transfer_amount, transfer_number_of_destinations=1): - destinations = [] - for i in range(transfer_number_of_destinations): - destinations.append({"amount":transfer_amount,"address":address}) - return destinations - - def make_destinations(self, addresses, transfer_amounts): - destinations = [] - for i in range(len(addresses)): - destinations.append({'amount':transfer_amounts[i],'address':addresses[i]}) - return destinations - def transfer(self, destinations, account_index = 0, subaddr_indices = [], priority = 0, ring_size = 0, unlock_time = 0, payment_id = '', get_tx_key = True, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False): transfer = { 'method': 'transfer', @@ -103,6 +91,17 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(get_transfer_by_txid) + def get_payments(self, payment_id): + get_payments = { + 'method': 'get_payments', + 'params': { + 'payment_id': payment_id, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_payments) + def get_bulk_payments(self, payment_ids = [], min_block_height = 0): get_bulk_payments = { 'method': 'get_bulk_payments', @@ -140,26 +139,35 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(create_wallet) - def get_balance(self, account_index = 0, address_indices = [], all_accounts = False): + def get_balance(self, account_index = 0, address_indices = [], all_accounts = False, strict = False): get_balance = { 'method': 'get_balance', 'params': { 'account_index': account_index, 'address_indices': address_indices, 'all_accounts': all_accounts, + 'strict': strict, }, 'jsonrpc': '2.0', 'id': '0' } return self.rpc.send_json_rpc_request(get_balance) + getbalance = get_balance - def sweep_dust(self): + def sweep_dust(self, get_tx_keys = True, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False): sweep_dust = { 'method': 'sweep_dust', + 'params': { + 'get_tx_keys': get_tx_keys, + 'do_not_relay': do_not_relay, + 'get_tx_hex': get_tx_hex, + 'get_tx_metadata': get_tx_metadata, + }, 'jsonrpc': '2.0', 'id': '0' } return self.rpc.send_json_rpc_request(sweep_dust) + sweep_unmixable = sweep_dust def sweep_all(self, address = '', account_index = 0, subaddr_indices = [], priority = 0, ring_size = 0, outputs = 1, unlock_time = 0, payment_id = '', get_tx_keys = False, below_amount = 0, do_not_relay = False, get_tx_hex = False, get_tx_metadata = False): sweep_all = { @@ -216,6 +224,7 @@ class Wallet(object): 'id': '0' } return self.rpc.send_json_rpc_request(get_address) + getaddress = get_address def create_account(self, label = ""): create_account = { @@ -344,6 +353,34 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(close_wallet) + def change_wallet_password(self, old_password, new_password): + change_wallet_password = { + 'method': 'change_wallet_password', + 'params' : { + 'old_password': old_password, + 'new_password': new_password, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(change_wallet_password) + + def store(self): + store = { + 'method': 'store', + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(store) + + def stop_wallet(self): + stop_wallet = { + 'method': 'stop_wallet', + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(stop_wallet) + def refresh(self): refresh = { 'method': 'refresh', @@ -474,6 +511,18 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(make_multisig) + def finalize_multisig(self, multisig_info, password = ''): + finalize_multisig = { + 'method': 'finalize_multisig', + 'params' : { + 'multisig_info': multisig_info, + 'password': password, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(finalize_multisig) + def exchange_multisig_keys(self, multisig_info, password = ''): exchange_multisig_keys = { 'method': 'exchange_multisig_keys', @@ -604,6 +653,31 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(check_tx_proof) + def get_spend_proof(self, txid = '', message = ''): + get_spend_proof = { + 'method': 'get_spend_proof', + 'params' : { + 'txid': txid, + 'message': message, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_spend_proof) + + def check_spend_proof(self, txid = '', message = '', signature = ''): + check_spend_proof = { + 'method': 'check_spend_proof', + 'params' : { + 'txid': txid, + 'message': message, + 'signature': signature, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(check_spend_proof) + def get_reserve_proof(self, all_ = True, account_index = 0, amount = 0, message = ''): get_reserve_proof = { 'method': 'get_reserve_proof', @@ -662,6 +736,7 @@ class Wallet(object): 'id': '0' } return self.rpc.send_json_rpc_request(get_height) + getheight = get_height def relay_tx(self, hex_): relay_tx = { @@ -763,6 +838,230 @@ class Wallet(object): } return self.rpc.send_json_rpc_request(validate_address) + def get_accounts(self, tag): + get_accounts = { + 'method': 'get_accounts', + 'params': { + 'tag': tag, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_accounts) + + def get_account_tags(self): + get_account_tags = { + 'method': 'get_account_tags', + 'params': { + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_account_tags) + + def tag_accounts(self, tag, accounts = []): + tag_accounts = { + 'method': 'tag_accounts', + 'params': { + 'tag': tag, + 'accounts': accounts, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(tag_accounts) + + def untag_accounts(self, accounts = []): + untag_accounts = { + 'method': 'untag_accounts', + 'params': { + 'accounts': accounts, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(untag_accounts) + + def set_account_tag_description(self, tag, description): + set_account_tag_description = { + 'method': 'set_account_tag_description', + 'params': { + 'tag': tag, + 'description': description, + }, + 'jsonrpc': '2.0', + 'id': '0' + } + return self.rpc.send_json_rpc_request(set_account_tag_description) + + def rescan_blockchain(self, hard = False): + rescan_blockchain = { + 'method': 'rescan_blockchain', + 'jsonrpc': '2.0', + 'params': { + 'hard': hard, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(rescan_blockchain) + + def rescan_spent(self): + rescan_spent = { + 'method': 'rescan_spent', + 'jsonrpc': '2.0', + 'params': { + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(rescan_spent) + + def set_tx_notes(self, txids = [], notes = []): + set_tx_notes = { + 'method': 'set_tx_notes', + 'jsonrpc': '2.0', + 'params': { + 'txids': txids, + 'notes': notes, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(set_tx_notes) + + def get_tx_notes(self, txids = []): + get_tx_notes = { + 'method': 'get_tx_notes', + 'jsonrpc': '2.0', + 'params': { + 'txids': txids, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_tx_notes) + + def set_attribute(self, key, value): + set_attribute = { + 'method': 'set_attribute', + 'jsonrpc': '2.0', + 'params': { + 'key': key, + 'value': value, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(set_attribute) + + def get_attribute(self, key): + get_attribute = { + 'method': 'get_attribute', + 'jsonrpc': '2.0', + 'params': { + 'key': key, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_attribute) + + def make_uri(self, address = '', payment_id = '', amount = 0, tx_description = '', recipient_name = ''): + make_uri = { + 'method': 'make_uri', + 'jsonrpc': '2.0', + 'params': { + 'address': address, + 'payment_id': payment_id, + 'amount': amount, + 'tx_description': tx_description, + 'recipient_name': recipient_name, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(make_uri) + + def parse_uri(self, uri): + parse_uri = { + 'method': 'parse_uri', + 'jsonrpc': '2.0', + 'params': { + 'uri': uri, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(parse_uri) + + def add_address_book(self, address = '', payment_id = '', description = ''): + add_address_book = { + 'method': 'add_address_book', + 'jsonrpc': '2.0', + 'params': { + 'address': address, + 'payment_id': payment_id, + 'description': description, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(add_address_book) + + def edit_address_book(self, index, address = None, payment_id = None, description = None): + edit_address_book = { + 'method': 'edit_address_book', + 'jsonrpc': '2.0', + 'params': { + 'index': index, + 'set_address': address != None, + 'address': address or '', + 'set_payment_id': payment_id != None, + 'payment_id': payment_id or '', + 'set_description': description != None, + 'description': description or '', + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(edit_address_book) + + def get_address_book(self, entries = []): + get_address_book = { + 'method': 'get_address_book', + 'jsonrpc': '2.0', + 'params': { + 'entries': entries, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(get_address_book) + + def delete_address_book(self, index): + delete_address_book = { + 'method': 'delete_address_book', + 'jsonrpc': '2.0', + 'params': { + 'index': index, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(delete_address_book) + + def start_mining(self, threads_count, do_background_mining = False, ignore_battery = False): + start_mining = { + 'method': 'start_mining', + 'jsonrpc': '2.0', + 'params': { + 'threads_count': threads_count, + 'do_background_mining': do_background_mining, + 'ignore_battery': ignore_battery, + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(start_mining) + + def stop_mining(self): + stop_mining = { + 'method': 'stop_mining', + 'jsonrpc': '2.0', + 'params': { + }, + 'id': '0' + } + return self.rpc.send_json_rpc_request(stop_mining) + def get_version(self): get_version = { 'method': 'get_version', |