Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
13e979b
Merge pull request #38 from CityOfZion/development
jseagrave21 Oct 10, 2018
e41e950
Merge pull request #40 from CityOfZion/development
jseagrave21 Oct 11, 2018
7db54f4
Merge pull request #41 from CityOfZion/development
jseagrave21 Oct 11, 2018
54a4f3f
Fix ExtendedJsonRpcApi (#662)
jseagrave21 Oct 11, 2018
0f96dc3
Mute expected test stacktrace and clearly identify why an exception i…
ixje Oct 12, 2018
1e5b4dc
Add guideline for adding tests to the neo-privnet-unittest image (#661)
dauTT Oct 12, 2018
8febcf1
Update CHANGELOG.rst
jseagrave21 Oct 18, 2018
c7a790f
Update CHANGELOG.rst
jseagrave21 Oct 18, 2018
c51390e
Merge CoZ Development into jseagrave21 Development (#49)
jseagrave21 Oct 18, 2018
32a16e3
Merge pull request #50 from CityOfZion/development
jseagrave21 Oct 18, 2018
3c8232d
Merge pull request #53 from CityOfZion/development
jseagrave21 Oct 25, 2018
1b00db8
Merge pull request #54 from CityOfZion/development
jseagrave21 Oct 26, 2018
eb495bf
Merge pull request #58 from CityOfZion/development
jseagrave21 Oct 28, 2018
4df642e
Merge pull request #63 from CityOfZion/development
jseagrave21 Nov 1, 2018
e12e746
Update test_extended_json_rpc_api.py
jseagrave21 Nov 1, 2018
0f55903
Update test_extended_json_rpc_api.py
jseagrave21 Nov 1, 2018
7eb4a1e
Merge pull request #64 from CityOfZion/development
jseagrave21 Nov 8, 2018
1f40685
Merge pull request #66 from CityOfZion/development
jseagrave21 Nov 10, 2018
16f5163
Merge pull request #74 from CityOfZion/development
jseagrave21 Nov 20, 2018
ff49beb
Merge pull request #81 from CityOfZion/development
jseagrave21 Dec 8, 2018
05ce2e7
Merge pull request #82 from CityOfZion/development
jseagrave21 Dec 11, 2018
19dce4f
Merge pull request #92 from CityOfZion/development
jseagrave21 Jan 10, 2019
08cd57f
Merge pull request #95 from CityOfZion/development
jseagrave21 Jan 11, 2019
e085410
Merge pull request #97 from CityOfZion/development
jseagrave21 Jan 19, 2019
84c8478
Merge pull request #102 from CityOfZion/development
jseagrave21 Feb 17, 2019
cb920ce
Merge branch 'development' of https://github.com/CityOfZion/neo-pytho…
Mar 7, 2019
557af22
implement changes in neocore
Mar 7, 2019
daf251a
Merge branch 'development' of https://github.com/CityOfZion/neo-pytho…
Mar 12, 2019
6088b30
update CHANGELOG.rst
Mar 12, 2019
4ad60f6
implement feedback from https://github.com/CityOfZion/neo-python/pull…
Mar 14, 2019
4225e36
Merge branch 'development' of https://github.com/CityOfZion/neo-pytho…
Mar 18, 2019
d1261a1
edit travis.yml for testing
Mar 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ install:
- pip install coveralls
- yes | pip uninstall neo-boa neocore
- pip install -e git+https://github.com/CityOfZion/neo-boa@development#egg=neo-boa
- pip install -e git+https://github.com/CityOfZion/neo-python-core@master#egg=neocore
- pip install -e git+https://github.com/CityOfZion/neo-python-core@development#egg=neocore

env:
- NEOPYTHON_UNITTEST=1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project are documented in this file.
- Support cancelling actions with ``KeyboardInterrupt``
- Enhance output of `wallet` cli command
- Fixed size calculation for `RegisterTransaction`
- Support updating np-core to throw exceptions instead of logging errors `#888 <https://github.com/CityOfZion/neo-python/issues/888>`_


[0.8.4] 2019-02-14
Expand Down
2 changes: 1 addition & 1 deletion neo/Core/BlockBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def Deserialize(self, reader):
"""
self.__hash = None
self.DeserializeUnsigned(reader)
byt = reader.ReadByte()
byt = ord(reader.ReadByte())
if int(byt) != 1:
raise Exception('Incorrect format')

Expand Down
2 changes: 1 addition & 1 deletion neo/Core/FunctionCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def Deserialize(self, reader):
"""
self.Script = reader.ReadVarBytes()
self.ParameterList = reader.ReadVarBytes()
self.ReturnType = reader.ReadByte()
self.ReturnType = ord(reader.ReadByte())

def Serialize(self, writer):
"""
Expand Down
2 changes: 1 addition & 1 deletion neo/Core/Header.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def Deserialize(self, reader):
reader (neo.IO.BinaryReader):
"""
super(Header, self).Deserialize(reader)
if reader.ReadByte() != 0:
if ord(reader.ReadByte()) != 0:
raise Exception('Incorrect Header Format')

def Equals(self, other):
Expand Down
6 changes: 3 additions & 3 deletions neo/Core/State/AssetState.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,19 @@ def Deserialize(self, reader):
"""
super(AssetState, self).Deserialize(reader)
self.AssetId = reader.ReadUInt256()
self.AssetType = reader.ReadByte()
self.AssetType = ord(reader.ReadByte())
self.Name = reader.ReadVarString()

position = reader.stream.tell()

try:
self.Amount = reader.ReadFixed8()
except Exception as e:
except Exception:
reader.stream.seek(position)
self.Amount = reader.ReadFixed8()

self.Available = reader.ReadFixed8()
self.Precision = reader.ReadByte()
self.Precision = ord(reader.ReadByte())

# fee mode
reader.ReadByte()
Expand Down
2 changes: 1 addition & 1 deletion neo/Core/State/StateBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def Deserialize(self, reader):
Raises:
Exception: if the state version is incorrect.
"""
sv = reader.ReadByte()
sv = ord(reader.ReadByte())
if sv != self.StateVersion:
raise Exception("Incorrect State format")

Expand Down
2 changes: 1 addition & 1 deletion neo/Core/State/StateDescriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def Deserialize(self, reader: BinaryReader):
reader (neocore.IO.BinaryReader):
"""

self.Type = StateType(reader.ReadByte())
self.Type = StateType(ord(reader.ReadByte()))

self.Key = reader.ReadVarBytes(max=100)
self.Field = reader.ReadVarString(max=32).decode('utf-8')
Expand Down
2 changes: 1 addition & 1 deletion neo/Core/State/UnspentCoinState.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def Deserialize(self, reader):
blen = reader.ReadVarInt()
self.Items = [0] * blen
for i in range(0, blen):
self.Items[i] = int.from_bytes(reader.ReadByte(do_ord=False), 'little')
self.Items[i] = int.from_bytes(reader.ReadByte(), 'little')

@staticmethod
def DeserializeFromDB(buffer):
Expand Down
4 changes: 2 additions & 2 deletions neo/Core/TX/RegisterTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ def DeserializeExclusiveData(self, reader):
reader (neo.IO.BinaryReader):
"""
self.Type = TransactionType.RegisterTransaction
self.AssetType = reader.ReadByte()
self.AssetType = ord(reader.ReadByte())
self.Name = reader.ReadVarString()
self.Amount = reader.ReadFixed8()
self.Precision = reader.ReadByte()
self.Precision = ord(reader.ReadByte())
self.Owner = ECDSA.Deserialize_Secp256r1(reader)
# self.Owner = ecdsa.G
self.Admin = reader.ReadUInt160()
Expand Down
6 changes: 3 additions & 3 deletions neo/Core/TX/Transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def DeserializeFrom(reader):
Returns:
Transaction:
"""
ttype = reader.ReadByte()
ttype = ord(reader.ReadByte())
tx = None

from neo.Core.TX.RegisterTransaction import RegisterTransaction
Expand Down Expand Up @@ -499,7 +499,7 @@ def DeserializeUnsigned(self, reader):
Raises:
Exception: if transaction type is incorrect.
"""
txtype = reader.ReadByte()
txtype = ord(reader.ReadByte())
if txtype != int.from_bytes(self.Type, 'little'):
raise Exception('incorrect type {}, wanted {}'.format(txtype, int.from_bytes(self.Type, 'little')))
self.DeserializeUnsignedWithoutType(reader)
Expand All @@ -511,7 +511,7 @@ def DeserializeUnsignedWithoutType(self, reader):
Args:
reader (neo.IO.BinaryReader):
"""
self.Version = reader.ReadByte()
self.Version = ord(reader.ReadByte())
self.DeserializeExclusiveData(reader)
self.Attributes = reader.ReadSerializableArray('neo.Core.TX.TransactionAttribute.TransactionAttribute',
max=self.MAX_TX_ATTRIBUTES)
Expand Down
4 changes: 2 additions & 2 deletions neo/Core/TX/TransactionAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def Deserialize(self, reader):
Args:
reader (neo.IO.BinaryReader):
"""
usage = reader.ReadByte()
usage = ord(reader.ReadByte())
self.Usage = usage

if usage == TransactionAttributeUsage.ContractHash or usage == TransactionAttributeUsage.Vote or \
Expand All @@ -99,7 +99,7 @@ def Deserialize(self, reader):

elif usage == TransactionAttributeUsage.DescriptionUrl:

self.Data = reader.ReadBytes(reader.ReadByte())
self.Data = reader.ReadBytes(ord(reader.ReadByte()))

elif usage == TransactionAttributeUsage.Description or usage >= TransactionAttributeUsage.Remark:
self.Data = reader.ReadVarBytes(max=self.MAX_ATTR_DATA_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion neo/Network/Payloads/InvPayload.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def Deserialize(self, reader):
Args:
reader (neo.IO.BinaryReader):
"""
self.Type = reader.ReadByte()
self.Type = ord(reader.ReadByte())
self.Hashes = reader.ReadHashes()

def Serialize(self, writer):
Expand Down
4 changes: 4 additions & 0 deletions neo/Prompt/Commands/Invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ def gather_signatures(context, itx, owners):
else:
print("Public Key does not match address %s " % next_addr)

except ValueError:
# expected from ECDSA if public key is invalid
print(f"Invalid public key: {items[0]}")
do_exit = True
except EOFError:
# Control-D pressed: quit
do_exit = True
Expand Down
5 changes: 4 additions & 1 deletion neo/Prompt/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ def gather_param(index, param_type, do_continue=True):
elif ptype == ContractParameterType.Boolean:
return bool(result), False
elif ptype == ContractParameterType.PublicKey:
return ECDSA.decode_secp256r1(result).G, False
try:
return ECDSA.decode_secp256r1(result).G, False
except ValueError:
return None, True
elif ptype == ContractParameterType.ByteArray:
if isinstance(result, str) and len(result) == 34 and result[0] == 'A':
return Helper.AddrStrToScriptHash(result).Data, False
Expand Down
7 changes: 7 additions & 0 deletions neo/Prompt/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ def test_gather_param(self):
wallet = None
os.remove(WalletFixtureTestCase.wallet_1_dest())

# test ContractParameterType.PublicKey with bad public key
with mock.patch('neo.Prompt.Utils.get_input_prompt', return_value="blah") as fake_prompt:

result, abort = Utils.gather_param(0, ContractParameterType.PublicKey)
self.assertIsNone(result)
self.assertTrue(abort)

# test unknown ContractParameterType
with mock.patch('neo.Prompt.Utils.get_input_prompt', return_value="9698b1cac6ce9cbe8517e490778525b929e01903") as fake_prompt:

Expand Down
12 changes: 8 additions & 4 deletions neo/SmartContract/ContractParameterContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ def AddSignature(self, contract, pubkey, signature):
ms = MemoryStream(binascii.unhexlify(contract.Script))
reader = BinaryReader(ms)
numr = reader.ReadUInt8()
while reader.ReadUInt8() == 33:
ecpoint = ecdsa.ec.decode_from_hex(binascii.hexlify(reader.ReadBytes(33)).decode())
points.append(ecpoint)
ms.close()
try:
while reader.ReadUInt8() == 33:
ecpoint = ecdsa.ec.decode_from_hex(binascii.hexlify(reader.ReadBytes(33)).decode())
points.append(ecpoint)
except ValueError:
return False
finally:
ms.close()

if pubkey not in points:
return False
Expand Down
5 changes: 4 additions & 1 deletion neo/SmartContract/StateMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def Asset_Create(self, engine: ExecutionEngine):

ownerData = engine.CurrentContext.EvaluationStack.Pop().GetByteArray()

owner = ECDSA.decode_secp256r1(ownerData, unhex=False).G
try:
owner = ECDSA.decode_secp256r1(ownerData, unhex=False).G
except ValueError:
return False

if owner.IsInfinity:
return False
Expand Down
5 changes: 4 additions & 1 deletion neo/SmartContract/StateReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ def Runtime_CheckWitness(self, engine: ExecutionEngine):
result = self.CheckWitnessHash(engine, UInt160(data=hashOrPubkey))

elif len(hashOrPubkey) == 33:
point = ECDSA.decode_secp256r1(hashOrPubkey, unhex=False).G
try:
point = ECDSA.decode_secp256r1(hashOrPubkey, unhex=False).G
except ValueError:
return False
result = self.CheckWitnessPubkey(engine, point)
else:
return False
Expand Down
12 changes: 6 additions & 6 deletions neo/VM/ExecutionEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def ExecuteOp(self, opcode, context: ExecutionContext):
estack.PushT(bytearray(0))

elif opcode == PUSHDATA1:
lenngth = context.OpReader.ReadByte()
lenngth = ord(context.OpReader.ReadByte())
estack.PushT(bytearray(context.OpReader.SafeReadBytes(lenngth)))
elif opcode == PUSHDATA2:
estack.PushT(context.OpReader.SafeReadBytes(context.OpReader.ReadUInt16()))
Expand Down Expand Up @@ -887,8 +887,8 @@ def ExecuteOp(self, opcode, context: ExecutionContext):

# stack isolation
elif opcode == CALL_I:
rvcount = context.OpReader.ReadByte()
pcount = context.OpReader.ReadByte()
rvcount = ord(context.OpReader.ReadByte())
pcount = ord(context.OpReader.ReadByte())

if estack.Count < pcount:
return self.VM_FAULT_and_report(VMFault.UNKNOWN_STACKISOLATION)
Expand All @@ -906,8 +906,8 @@ def ExecuteOp(self, opcode, context: ExecutionContext):
if self._Table is None:
return self.VM_FAULT_and_report(VMFault.UNKNOWN_STACKISOLATION2)

rvcount = context.OpReader.ReadByte()
pcount = context.OpReader.ReadByte()
rvcount = ord(context.OpReader.ReadByte())
pcount = ord(context.OpReader.ReadByte())

if estack.Count < pcount:
return self.VM_FAULT_and_report(VMFault.UNKNOWN_STACKISOLATION)
Expand Down Expand Up @@ -998,7 +998,7 @@ def StepInto(self):
if self.CurrentContext.InstructionPointer >= len(self.CurrentContext.Script):
op = RET
else:
op = self.CurrentContext.OpReader.ReadByte(do_ord=False)
op = self.CurrentContext.OpReader.ReadByte()

self.ops_processed += 1

Expand Down
2 changes: 1 addition & 1 deletion neo/VM/InteropService.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def DeserializeStackItem(reader):
if stype == StackItemType.ByteArray:
return ByteArray(reader.ReadVarBytes())
elif stype == StackItemType.Boolean:
return Boolean(reader.ReadByte())
return Boolean(ord(reader.ReadByte()))
elif stype == StackItemType.Integer:
return Integer(BigInteger.FromBytes(reader.ReadVarBytes(), signed=True))
elif stype == StackItemType.Array:
Expand Down