<div dir="ltr"><div><div><div><div>Hello there.<br></div><div><br></div>I wrote some code to call Pettycoin from Python 3.<br><br>  <a href="https://github.com/arhuaco/pypettycoin/">https://github.com/arhuaco/pypettycoin/</a><br><br></div>First, fun with JSON.<br><br></div>When Pettycoin sends JSON replies the size of the reply is not known in advance, so you have to use non-blocking UNIX sockets and parse on the fly.<br><br>I don't know if there is an easy way to do this, I could not find it. I wrote a Python class to read Pettycoin replies:<br>  <a href="https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/json_socket_reader.py">https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/json_socket_reader.py</a><br>It makes use of a simple socket wrapper:<br>  <a href="https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/socket_wrapper.py">https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/socket_wrapper.py</a><br><br></div><div>The  code does not parse JSON on the fly, or better, it has trivial parsing and only counts '{' and '}'. Thus it will fail if a JSON reply contains a string with those characters. It has not happened with the calls I have done so far. I can improve this later if needed.<br></div><div></div><div><br></div><div>Second, Bad Proxy.<br><br></div><div>A casual user might find it difficult to call the Pettycoin JSON interface so I wrote a proxy. It is less efficient but easier to call. It is also insecure because another user could make Pettycoin calls (by default from localhost). I called it Bad Proxy to keep this in mind, in case someone wants to use it for something serious.<br></div><div>  <a href="https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/bad_proxy.py">https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/bad_proxy.py</a><br></div><div>Sample usage:<br>  <a href="https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/bad_proxy_usage_example.py">https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/bad_proxy_usage_example.py</a><br><br></div><div>And last, say 'hello' to the web. Just the output from the 'getinfo' call:<br>  <a href="http://104.131.198.157:10002">http://104.131.198.157:10002</a><br></div><div>code:<br></div><div>  <a href="https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/simple_explorer.py">https://github.com/arhuaco/pypettycoin/blob/master/pettycoin/simple_explorer.py</a><br><br></div><div>As time permits I would like to write a simple explorer. It will help me learn about the Pettycoin data structures. I make no promises but I will try to make time for it.<br><br></div><div>Cheers,<br></div><div>Nel.-<br></div></div>