python-bitcoinlib icon indicating copy to clipboard operation
python-bitcoinlib copied to clipboard

Add complete set of RPC Calls (as of 0.19.0.1)

Open SachinMeier opened this issue 5 years ago • 0 comments

TLDR: I added all RPC calls to bitcoin/rpc.py and slightly altered some existing calls to update the API. I also added OP_TRUE and OP_FALSE to script.py.

Changes: I added all RPC calls listed in v0.19.0.1 and reordered all the functions so that their order matches the order provided in bitcoin-cli help. This also sorts all calls roughly by their function. Additionally, I added the ability for calls to accept strings or direct JSON, which I thought made several functions much more flexible. Many comments I made while writing the code remain, but if this is undesirable I can remove them.

Testing: I added a few tests to bitcoin/tests/test_rpc.py, but all calls require a running Core instance and testing many calls would be inconvenient. I manually tested almost every function in rpc.py, with the exception of those which timed out and the mining or PSBT-related calls. I ran all existing unittests and those I created with perfect success (with a running Core instance). Some RPC testing relies on transactions being in the UTXO set, so if they are spent, a new UTXO must be found.

I did my best to ensure every function works in a backwards-compatible way and the previous style was continued to the best of my ability. For this reason, I added duplicate functions for the call sendrawtransaction and fundrawtransaction (named sendrawtransactionv0_19 and fundrawtransactionv0_19). Eventually, these new functions should replace the old.

Future Work:

  • I declined to change the API for sendmany and sendtoaddress because they were substantially different. This should be fixed (I will do this later).

  • Other deprecated calls (such as generate and getinfo) should also be removed in due time.

  • Proxy calls will timeout after 30 seconds, while several Core RPC calls usually take longer. These calls are thus useless for now.

  • The stop call also does not work, so it is commented out for now.

  • New RPC calls should be added to the examples folder, along with more comprehensive testing.

SachinMeier avatar Aug 16 '20 07:08 SachinMeier