-
Notifications
You must be signed in to change notification settings - Fork 793
cli_wallet
Nathaniel Caldwell edited this page May 15, 2018
·
2 revisions
This is some quick notes on how to test cli_wallet
locally. This procedure assumes you're running things manually (as opposed to using the Docker container).
make -j$(nproc) steemd && make -j$(nproc) cli_wallet && make -j$(nproc) get_dev_key
DATADIR=$HOME/data/wtest
mkdir -p "$DATADIR"
programs/steemd/steemd --data-dir="$DATADIR"
# Press Ctrl+C here
cat >> "$DATADIR/config.ini" <<EOF
webserver-ws-endpoint=127.0.0.1:8090
witness="initminer"
plugin=network_broadcast_api
EOF
(echo -n "private-key=" ; programs/util/get_dev_key "" init_key | cut -d '"' -f 4) >> "$DATADIR/config.ini"
programs/steemd/steemd --data-dir="$DATADIR" --enable-stale-production --required-participation=0
Now run the cli_wallet
:
mkdir -p testwallet
cd testwallet
../programs/cli_wallet/cli_wallet -w my.wallet -s ws://127.0.0.1:8090 --chain-id testnet
Now inside cli_wallet
run some commands, check and make sure the output makes sense:
help
about
info
set_password 1234
unlock 1234
lock
unlock 1234
list_my_accounts
get_account initminer
import_key 5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n
create_account initminer alice "" true
transfer initminer alice {"amount":"100000", "precision":3, "nai":"@@000000021"} "hello world" true
get_account alice
transfer_to_vesting initminer alice {"amount":"1000", "precision":3, "nai":"@@000000021"} true
get_account alice
transfer_to_vesting alice alice {"amount":"45000", "precision":3, "nai":"@@000000021"} true
withdraw_vesting alice {"amount":"1000000", "precision":6, "nai":"@@000000037"} true
If things aren't going well, it may help to implement a proxy for Websockets. Here's a quick one I (@theoreticalbts) wrote using the tornado
framework in Python (if you want to change the port numbers, you need to edit the script):
#!/usr/bin/env python3
import tornado.websocket
from tornado.ioloop import IOLoop
# A server websocket that interfaces to external client
class ProxyHandler(tornado.websocket.WebSocketHandler):
def open(self):
print("Client websocket opened")
self.server_connection_future = None
self.server_connection = None
self.server_url = "ws://127.0.0.1:8090/"
self.server_connection_future = IOLoop.current().spawn_callback(self.open_server_connection)
async def open_server_connection(self):
self.server_connection = await tornado.websocket.websocket_connect(self.server_url)
async def on_message(self, req_message):
print("Client: {}".format(req_message))
if self.server_connection is None:
await self.server_connection_future
await self.server_connection.write_message(req_message)
resp_message = await self.server_connection.read_message()
print("Server: {}".format(resp_message))
await self.write_message(resp_message)
def on_close(self):
print("Client websocket closed")
if __name__ == "__main__":
app = tornado.web.Application([
(r"/", ProxyHandler),
])
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(8092)
IOLoop.current().start()