Short script which support JSON-RPC protocol and return fixed JSON file should do the job. I'm not web developer, but i'll share the script if i managed to create it within 1 hour.
It's much easier than expected. After read a tutorial[1] and library GitHub page[2], i managed to create one in less than 10 minutes. The fake data is based on testnet data with changed median time, but it can be changed to any JSON data.
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer
import jsonrpclib
jsonrpclib.config.version = 1.0
def getblockchaininfo(*args):
return {
"result": {
"chain": "test",
"blocks": 2377252,
"headers": 2377252,
"bestblockhash": "000000000000001116b19fd67c291a7fdf87810b2ff47b7d313940ee42f5c1b5",
"difficulty": 67108864,
"time": 1666169543,
# fake mediantime
"mediantime": 9999999999,
"verificationprogress": 0.9999993333482174,
"initialblockdownload": False,
"chainwork": "0000000000000000000000000000000000000000000007d7c718524bc0ba7e52",
"size_on_disk": 31445472022,
"pruned": False,
"warnings": "Unknown new rules activated (versionbit 28)"
},
"error": None,
"id": "curltest"
}
server = SimpleJSONRPCServer(('localhost', 8332))
server.register_function(getblockchaininfo)
server.serve_forever()
I tested it with
curl and it works properly. FYI, the user and password could be any string.
$ curl --user random_text --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockchaininfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
Enter host password for user 'random_text':
{"result": {"result": {"chain": "test", "blocks": 2377252, "headers": 2377252, "bestblockhash": "000000000000001116b19fd67c291a7fdf87810b2ff47b7d313940ee42f5c1b5", "difficulty": 67108864, "time": 1666169543, "mediantime": 9999999999, "verificationprogress": 0.9999993333482174, "initialblockdownload": false, "chainwork": "0000000000000000000000000000000000000000000007d7c718524bc0ba7e52", "size_on_disk": 31445472022, "pruned": false, "warnings": "Unknown new rules activated (versionbit 28)"}, "error": null, "id": "curltest"}, "id": "curltest", "error": null}
[1]
https://www.tutorialspoint.com/python_network_programming/python_rpc_json_server.htm[2]
https://github.com/joshmarshall/jsonrpclibI am trying to hack my program with your code. It’s displaying some odd behavior, but I’m unable to view the private keys.
If I run the code by itself and open BTCapsule, I get this message in the console:
127.0.0.1 - - [19/Oct/2022 13:35:47] "POST / HTTP/1.1" 200 -
BTCapsule opens and says “Please Open Bitcoin Core and Restart BTCapsule”. So I open Bitcoin Core while your code is still running, and when I restart BTCapsule, it continues to alert me that I need to open Bitcoin Core. Every time I open BTCapsule, a new message is printed to the console like the one above.
So I started Bitcoin Core first, and then ran your code. If I do that, I get an error:
Permission Error: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
So BTCapsule is definitely talking to your program, but it’s not recognizing it as a valid Bitcoin Core implementation. I have tried this with and without internet enabled.