Closed meevee98 closed 4 years ago
The hexdigest() function from hashlib was generating a reversed hash string
I'm going to guess this has todo with C# calling ToScriptHash()
which returns a UInt160
. The problem is that they reverse the actual bytes before turning it into a string here
public override string ToString()
{
return "0x" + this.ToArray().ToHexString(reverse: true);
}
I've historically tried to convince them to remove it because it makes no sense to change a byte array order when printing, but no luck. I gave up
What current issue(s) from Github does this address? Fix #132
What problem does this PR solve? Fixes the incorrect hash in abi generation
How did you solve this problem? Changed the algorithm used to hash the file.
How did you make sure your solution works? Compared with the hash output from neo-cli when deploying the contracts and included unit tests.
Are there any special changes in the code that we should be aware of? The
hexdigest()
function fromhashlib
was generating a reversed hash string. That's why we need to reverse the bytes before getting the string representation