|
|
@ -56,9 +56,9 @@ def add_signatures_from_file(file, sigs={}): |
|
|
|
|
|
|
|
|
|
|
|
class Signatures(object): |
|
|
|
class Signatures(object): |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, enable_online_lookkup=True): |
|
|
|
def __init__(self, enable_online_lookup=True): |
|
|
|
self.signatures = {} # signatures in-mem cache |
|
|
|
self.signatures = {} # signatures in-mem cache |
|
|
|
self.enable_online_lookup =enable_online_lookkup # enable online funcsig resolving |
|
|
|
self.enable_online_lookup =enable_online_lookup # enable online funcsig resolving |
|
|
|
|
|
|
|
|
|
|
|
def open(self, path=None): |
|
|
|
def open(self, path=None): |
|
|
|
if not path: |
|
|
|
if not path: |
|
|
@ -91,14 +91,17 @@ class Signatures(object): |
|
|
|
:return: list of function signatures |
|
|
|
:return: list of function signatures |
|
|
|
""" |
|
|
|
""" |
|
|
|
if not self.signatures.get(sighash) and self.enable_online_lookup: |
|
|
|
if not self.signatures.get(sighash) and self.enable_online_lookup: |
|
|
|
self.signatures[sighash] = Signatures.lookup_online(sighash) # might return multiple sigs |
|
|
|
funcsigs = Signatures.lookup_online(sighash) # might return multiple sigs |
|
|
|
return self.signatures.get(sighash) |
|
|
|
if funcsigs: |
|
|
|
|
|
|
|
# only store if we get at least one result |
|
|
|
|
|
|
|
self.signatures[sighash] = funcsigs |
|
|
|
|
|
|
|
return self.signatures[sighash] # raise keyerror |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
@staticmethod |
|
|
|
def lookup_online(sighash): |
|
|
|
def lookup_online(sighash): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Lookup function signatures from 4bytes.directory. |
|
|
|
Lookup function signatures from 4byte.directory. |
|
|
|
//tintinweb: the smart-contract-sanctuary project dumps contracts from etherscan.io and feeds them into |
|
|
|
//tintinweb: the smart-contract-sanctuary project dumps contracts from etherscan.io and feeds them into |
|
|
|
4bytes.directory. |
|
|
|
4bytes.directory. |
|
|
|
https://github.com/tintinweb/smart-contract-sanctuary |
|
|
|
https://github.com/tintinweb/smart-contract-sanctuary |
|
|
|