Explorer-Error "AttributeError: 'NoneType' object has no attribute 'startswith'"

+2 votes
Can u help me to solve this error?

 

...

block 469 already in chain 1
commit
block 470 already in chain 1
commit
block 471 already in chain 1
commit
block 472 already in chain 1
commit
block 473 already in chain 1
commit
Exception at 174123
Failed to catch up {'blkfile_offset': 173281, 'blkfile_number': 100000, 'chain_id': 1, 'loader': u'default', 'conf': None, 'dirname': u'/home/Admin/.multichain/chain1', 'id': 16}
Traceback (most recent call last):
  File "Mce/DataStore.py", line 2903, in catch_up
    store.catch_up_dir(dircfg)
  File "Mce/DataStore.py", line 3215, in catch_up_dir
    store.import_blkdat(dircfg, ds, blkfile['name'])
  File "Mce/DataStore.py", line 3347, in import_blkdat
    store.import_block(b, chain = chain)
  File "Mce/DataStore.py", line 1199, in import_block
    tx['tx_id'] = store.import_and_commit_tx(tx, pos == 0, chain)
  File "Mce/DataStore.py", line 2221, in import_and_commit_tx
    tx_id = store.import_tx(tx, is_coinbase, chain)
  File "Mce/DataStore.py", line 1961, in import_tx
    pubkey_id = store.script_to_pubkey_id(chain, txout['scriptPubKey'])
  File "Mce/DataStore.py", line 2819, in script_to_pubkey_id
    script_type, data = chain.parse_txout_script(script)
  File "Mce/Chain/__init__.py", line 247, in parse_txout_script
    return chain.parse_decoded_txout_script(decoded)
  File "Mce/Chain/__init__.py", line 270, in parse_decoded_txout_script
    if len(decoded) >= 6 and decoded[2][1].startswith("spkk"):
AttributeError: 'NoneType' object has no attribute 'startswith'
Abe initialized.
Listening on http://0.0.0.0:2750
Launched background thread to catch up tx every 60.0 seconds
asked Dec 6, 2019 by JoToTheHannes

1 Answer

+1 vote

Can you please try making the following replacement in line 270 of the file __init__.py:

if len(decoded) >= 6 and decoded[2][1].startswith("spkk"):

... to replace with ...

if len(decoded) >= 6 and decoded[2][1] and decoded[2][1].startswith("spkk"):

And then let me know if that fixes the problem?

answered Dec 8, 2019 by MultiChain
Thank you already for your help.

After adjusting line 270 the following error appears:


sudo python -m Mce.abe --config chain1.conf
block_tx 493 543
block_tx 493 544
block_tx 493 564
commit
block_tx 494 565
commit
block_tx 495 566
commit
block_tx 496 567
commit
block_tx 497 568
commit
block_tx 498 569
commit
block_tx 499 570
commit
block_tx 500 571
commit
block_tx 501 572
commit
block_tx 502 573
commit
block_tx 503 574
commit
Failed to catch up {'blkfile_offset': 0, 'blkfile_number': 1, 'chain_id': 1, 'loader': u'default', 'conf': None, 'dirname': u'/home/Admin/.multichain/chain1', 'id': 22}
Traceback (most recent call last):
  File "Mce/DataStore.py", line 2899, in catch_up
    if not store.catch_up_rpc(dircfg):
  File "Mce/DataStore.py", line 3132, in catch_up_rpc
    store.import_block(block, chain = chain)
  File "Mce/DataStore.py", line 1199, in import_block
    tx['tx_id'] = store.import_and_commit_tx(tx, pos == 0, chain)
  File "Mce/DataStore.py", line 2221, in import_and_commit_tx
    tx_id = store.import_tx(tx, is_coinbase, chain)
  File "Mce/DataStore.py", line 1961, in import_tx
    pubkey_id = store.script_to_pubkey_id(chain, txout['scriptPubKey'])
  File "Mce/DataStore.py", line 2819, in script_to_pubkey_id
    script_type, data = chain.parse_txout_script(script)
  File "Mce/Chain/__init__.py", line 247, in parse_txout_script
    return chain.parse_decoded_txout_script(decoded)
  File "Mce/Chain/__init__.py", line 267, in parse_decoded_txout_script
    if len(pubkey_hash) == PUBKEY_HASH_LENGTH:
TypeError: object of type 'NoneType' has no len()
Abe initialized.
Listening on http://0.0.0.0:2750
Launched background thread to catch up tx every 60.0 seconds
OK, here's another change to please add in line 267 of __init__.py:

if len(decoded) >= 3 and decoded[-2][1] and decoded[-2][1].startswith("spkq"):

...change to...

if len(decoded) >= 3 and decoded[-2][1] and decoded[-2][1].startswith("spkq") and decoded[2][1]:
Thank you! That worked for me :-)
Thanks, we've rolled these changes into the Github repository for the Explorer.
...