CityOfZion / neo-python

Python Node and SDK for the NEO 2.x blockchain. For NEO 3.x go to our successor project neo-mamba
https://neo-python.readthedocs.io/en/latest/
MIT License
313 stars 189 forks source link

build_raw_transactions.py relies on an active blockchain node #717

Closed jseagrave21 closed 5 years ago

jseagrave21 commented 5 years ago

Current behavior

NOTE: This issue is carried over from an unresolved issue from #dev-general on Discord

User @amir reported receiving this error while trying to build a raw transaction per the example:

Traceback (most recent call last):
  File "./neophone.py", line 229, in <module>
    NeoPhone()
  File "./neophone.py", line 52, in init
    getattr(self, parsed_args.command)(leftover_args)
  File "./neophone.py", line 157, in transfer
    neolib.transfer()
  File "/Users/amirbaer/Home/code/curv/repos/research/neo/python/neolib.py", line 124, in transfer
    context = ContractParametersContext(contract_tx)
  File "/usr/local/lib/python3.6/site-packages/neo/SmartContract/ContractParameterContext.py", line 83, in init
    self.ScriptHashes = verifiable.GetScriptHashesForVerifying()
  File "/usr/local/lib/python3.6/site-packages/neo/Core/TX/Transaction.py", line 721, in GetScriptHashesForVerifying
    raise Exception("Invalid operation")
Exception: Invalid operation

After investigating, I found the problem here: https://github.com/CityOfZion/neo-python/blob/f003f0a66cdd10cef91f30a6cda5549844ebd013/neo/Core/TX/Transaction.py#L719-L721

Expected behavior

Building a raw transaction to relay via RPC method sendrawtransaction should not rely on an active blockchain instance.

How to reproduce

Run example1 or example2 without a blockchain db activate in the environment.

Your environment

jseagrave21 commented 5 years ago

This issue has been addressed! :tada:

senhanxiao commented 5 years ago

asset = GetBlockchain().GetAssetState(key.ToBytes()) if asset is None: raise Exception("Invalid operation")

I also met this situation.Using Local Private NET。s ettings.setup_privnet(host="192.168.0.106")

but ......