BitShares Forum
Main => General Discussion => Topic started by: xeroc on January 25, 2015, 05:54:08 pm
-
python-bitsharesrpc
Python module for the BitShares client
Download
https://github.com/xeroc/python-bitsharesrpc
Installation
git clone https://github.com/xeroc/python-bitsharesrpc
cd python-bitsharesrpc
python setup install # (optionally with parameter --user fo non-root installations)
Requirements
Usage
All RPC commands of the BitShares client are exposed as methods in the class bitsharesrpc. Once an instance of bitsharesrpc is created, i.e.,
import bitsharesrpc
import config
rpc = bitsharesrpc.client(config.url, config.user, config.passwd)
any rpc command can be issued using the instance via the syntax rpc.command(parameters). Example:
rpc.get_info()
rpc.open_wallet("default")
rpc.ask(account, amount, quote, price, base)
...
Example to unlock the wallet
#!/usr/bin/python
import bitsharesrpc
import config
if __name__ == "__main__":
rpc = bitsharesrpc.client(config.url, config.user, config.passwd)
print(rpc.wallet_open(config.wallet))
print(rpc.unlock(999999, config.unlock))
Example to lock the wallet
#!/usr/bin/python
import bitsharesrpc
import config
if __name__ == "__main__":
rpc = bitsharesrpc.client(config.url, config.user, config.passwd)
print rpc.wallet_open("delegate")
print rpc.lock()
Minimalistic CLI:
#!/usr/bin/python
import bitsharesrpc, json
rpc = bitsharesrpc.client("http://localhost:1998/rpc", "username", "password")
while 1:
cmd = raw_input(">>").split()
print(json.dumps(rpc.rpcexec({"method":cmd[0],"params":list(cmd[1:]),
"jsonrpc":"2.0","id":0}),indent=4))
-
So is this a potential vulnerability you fixed?
-
So is this a potential vulnerability you fixed?
Hu? .. what vulnerability are you talking about?
The issues I recently fixed concerned the "genbtskey.py" script that replicated the generation of BTS pubkeys and addresses ..
The module in the OP is just a rewrite of the btsrpcapi.py class to make it alot easier to use and a standalone module ..
the only security issue I can see with this module is if people run this over the plain internet and not via tunnel .. I am unaware that the RPC can be run via SSL .. @toast ?
If it can run via SSL .. it's the responsibility of the coder to also ACCESS the RPC via SSL .. but if there is SSL available I could modify the script to ENFORCE the use of SSL if you wish
//edit: I reread you post and figured out yo meant it differently. The OP announces a python module that makes it alot easier to use inferface python with BitShares ..
-
you can write a bitshares command line interface with just a few lines of python:
Minimalistic CLI:
#!/usr/bin/python
import bitsharesrpc, json
rpc = bitsharesrpc.client("http://localhost:1998/rpc", "username", "password")
while 1:
cmd = raw_input(">>").split()
print(json.dumps(rpc.rpcexec({"method":cmd[0],"params":list(cmd[1:]),
"jsonrpc":"2.0","id":0}),indent=4))