diff options
author | Bryan Bishop <kanzure@gmail.com> | 2015-06-02 01:34:49 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2015-06-02 01:34:49 -0500 |
commit | 6da044ec5e220f1becadb13be28b3333b309c853 (patch) | |
tree | c3eb975d3623b60990fd7bbf976a51d8be1f3d42 | |
parent | 3077ca60ca83b0b22028c9733e618e4eb7475a4f (diff) | |
download | rpcblockchainexplorer-6da044ec5e220f1becadb13be28b3333b309c853.tar.gz rpcblockchainexplorer-6da044ec5e220f1becadb13be28b3333b309c853.zip |
minor tweaks related to block output
-rw-r--r-- | rpcblockchainexplorer/api.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/rpcblockchainexplorer/api.py b/rpcblockchainexplorer/api.py index 77a0c4a..01d865e 100644 --- a/rpcblockchainexplorer/api.py +++ b/rpcblockchainexplorer/api.py @@ -55,6 +55,7 @@ ALLOWED_COMMANDS = [ "getnettotals", "getnetworkinfo", "getpeerinfo", + "getinfo", # transactions "getrawtransaction", @@ -71,6 +72,7 @@ CONVERSION_TABLE = { # convert to bytes "block_hash": lx, "txid": lx, + "verbose": bool, } def converter(name, value): @@ -138,21 +140,29 @@ def create_api_endpoints(commands=ALLOWED_COMMANDS): # default as defined in python-bitcoinlib. for (argument_name, default_value) in keyword_arguments.items(): value = request.args.get(argument_name, default_value) - possibly_converted_value = converter(argument_name, value) - params[argument_name] = possibly_converted_value + params[argument_name] = value # Get a reference to the command, if any. - if command in Proxy.__dict__.keys(): + # Exclude "getblock" so that the json result is shown instead + # of the repr of CBlock. + if command in Proxy.__dict__.keys() and command != "getblock": callable_function = getattr(g.bitcoin_rpc_client, command) rpc_function = functools.partial(callable_function) + + params2 = {} + for (argument_name, default_value) in keyword_arguments.items(): + value = request.args.get(argument_name, default_value) + possibly_converted_value = converter(argument_name, value) + params[argument_name] = possibly_converted_value + + # Call the RPC service command and pass in all of the given + # parameters. + results = rpc_function(**params) else: + #_self = g.bitcoin_rpc_client callable_function = g.bitcoin_rpc_client._call - _self = g.bitcoin_rpc_client rpc_function = functools.partial(callable_function, command) - - # Call the RPC service command and pass in all of the given - # parameters. - results = rpc_function(**params) + results = rpc_function(*(list(params.values()) + [True])) # That's all, folks. return repr(results) |