question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

deserialize fails

See original GitHub issue

Hi,

the deserialize cmd does not seem to work for me. I started an electron-cash daemon as well as an electrum one. Electrum 3.1.2. can decode the BCH txn, though electron-cash can’t. Here’s my console interaction to try to decode a recent coinbase txn:

awemany@bitcoinunlimited:~/Electron Cash-3.1.6$ ./electron-cash gettransaction 147f8cff3bb64a78bd97a947cb90734c9ee4aed9002aa026f98fb39379797bfa{
    "complete": true,
    "final": true,
    "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2503020608184d696e656420627920416e74506f6f6c343505205ad1f03ede83000063f70100ffffffff0209e9954a000000001976a9141fefe863a7e0ddc767780ce3bedc564cf5cbda6388acfcc80200000000001976a914000000000000000000000000000000000000000088ac00000000"
}
awemany@bitcoinunlimited:~/Electron Cash-3.1.6$ ./electron-cash deserialize 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2503020608184d696e656420627920416e74506f6f6c343505205ad1f03ede83000063f70100ffffffff0209e9954a000000001976a9141fefe863a7e0ddc767780ce3bedc564cf5cbda6388acfcc80200000000001976a914000000000000000000000000000000000000000088ac00000000
Server-side error: <Fault -32603: Server error: File "/usr/lib/python3.6/json/encoder.py", line 180, in default | TypeError: Object of type 'bytes' is not JSON serializable
>
Traceback (most recent call last):
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/SimpleJSONRPCServer.py", line 447, in do_POST
    data, getattr(self, '_dispatch', None), self.path)
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/SimpleJSONRPCServer.py", line 268, in _marshaled_dispatch
    return jsonrpclib.jdumps(response, self.encoding)
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/jsonrpc.py", line 160, in jdumps
    return json.dumps(obj)
  File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable
Traceback (most recent call last):
  File "./electron-cash", line 435, in <module>
    result = server.run_cmdline(config_options)
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/jsonrpc.py", line 650, in __call__
    return self.__send(self.__name, args)
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/jsonrpc.py", line 531, in _request
    response = self._run_request(request)
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/jsonrpc.py", line 564, in _run_request
    verbose=self.__verbose
  File "/usr/lib/python3.6/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/home/awemany/Electron Cash-3.1.6/packages/jsonrpclib/jsonrpc.py", line 387, in single_request
    response.msg)
jsonrpclib.jsonrpc.ProtocolError: ('user:XXX@127.0.0.1:34825/', 500, 'Internal Server Error', <http.client.HTTPMessage object at 0x7f650ead0048>)
awemany@bitcoinunlimited:~/Electron Cash-3.1.6$ electrum deserialize 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2503020608184d696e656420627920416e74506f6f6c343505205ad1f03ede83000063f70100ffffffff0209e9954a000000001976a9141fefe863a7e0ddc767780ce3bedc564cf5cbda6388acfcc80200000000001976a914000000000000000000000000000000000000000088ac00000000
{
    "inputs": [
        {
            "address": null,
            "num_sig": 0,
            "prevout_hash": "0000000000000000000000000000000000000000000000000000000000000000",
            "prevout_n": 4294967295,
            "pubkeys": [],
            "scriptSig": "03020608184d696e656420627920416e74506f6f6c343505205ad1f03ede83000063f70100",
            "sequence": 4294967295,
            "signatures": {},
            "type": "coinbase",
            "x_pubkeys": []
        }
    ],
    "lockTime": 0,
    "outputs": [
        {
            "address": "13usM2ns3f466LP65EY1h8hnTBLFiJV6rD",
            "prevout_n": 0,
            "scriptPubKey": "76a9141fefe863a7e0ddc767780ce3bedc564cf5cbda6388ac",
            "type": 0,
            "value": 1251338505
        },
        {
            "address": "1111111111111111111114oLvT2",
            "prevout_n": 1,
            "scriptPubKey": "76a914000000000000000000000000000000000000000088ac",
            "type": 0,
            "value": 182524
        }
    ],
    "version": 1
}```

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17

github_iconTop GitHub Comments

1reaction
qr1qr1commented, Aug 24, 2018

Thank you cculianu. It works now. You are a ninja!

1reaction
cculianucommented, Aug 24, 2018

Ah! Didn’t realize you were doing RPC. I should have form the stack trace tho. LOL. Sorry! My bad!

Yes. It’s broken. Same errors you got. Let me investigate this…

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Json deserialization fails - Stack Overflow
I tried removing the spaces and \r\n from the string but still it throws exception and fails to deserialize. Can anyone help to...
Read more >
Serialization Error Handling - Json.NET
The Error event is an event handler found on JsonSerializer. The error event is raised whenever an exception is thrown while serializing or...
Read more >
System.Text.Json fails to deserialize into a model ... - GitHub
Json fails to deserialize into a model with an ImmutableList property. #69417 ... Serialize and deserialize it with the System.Text.
Read more >
Regarding the case where Deserialize fails without the ...
This is a problem related to Serialize and Deserialize of XmlSerializer. For a certain XML file, save it with [Code Flagment 1] and...
Read more >
Error handling - Serde
Deserializer can fail, especially if the input data is syntactically invalid. Deserialize can fail, usually because the input is the wrong type for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found