Merge branch 'script_fix' into develop
This commit is contained in:
commit
bb6d241633
@ -53,7 +53,6 @@ class Coin(object):
|
|||||||
address = cls.P2PKH_hash168_from_hash160,
|
address = cls.P2PKH_hash168_from_hash160,
|
||||||
script_hash = cls.P2SH_hash168_from_hash160,
|
script_hash = cls.P2SH_hash168_from_hash160,
|
||||||
pubkey = cls.P2PKH_hash168_from_pubkey,
|
pubkey = cls.P2PKH_hash168_from_pubkey,
|
||||||
unknown = lambda x : None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@ -142,8 +142,7 @@ class ScriptPubKey(object):
|
|||||||
TO_P2SH_OPS = [OpCodes.OP_HASH160, -1, OpCodes.OP_EQUAL]
|
TO_P2SH_OPS = [OpCodes.OP_HASH160, -1, OpCodes.OP_EQUAL]
|
||||||
TO_PUBKEY_OPS = [-1, OpCodes.OP_CHECKSIG]
|
TO_PUBKEY_OPS = [-1, OpCodes.OP_CHECKSIG]
|
||||||
|
|
||||||
PayToHandlers = namedtuple('PayToHandlers',
|
PayToHandlers = namedtuple('PayToHandlers', 'address script_hash pubkey')
|
||||||
'address script_hash pubkey unknown')
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def pay_to(cls, script, handlers):
|
def pay_to(cls, script, handlers):
|
||||||
@ -154,9 +153,12 @@ class ScriptPubKey(object):
|
|||||||
handlers.address(hash160)
|
handlers.address(hash160)
|
||||||
handlers.script_hash(hash160)
|
handlers.script_hash(hash160)
|
||||||
handlers.pubkey(pubkey)
|
handlers.pubkey(pubkey)
|
||||||
handlers.unknown(None)
|
or None is returned if the script is invalid or unregonised.
|
||||||
'''
|
'''
|
||||||
ops, datas = Script.get_ops(script)
|
try:
|
||||||
|
ops, datas = Script.get_ops(script)
|
||||||
|
except ScriptError:
|
||||||
|
return None
|
||||||
|
|
||||||
if Script.match_ops(ops, cls.TO_ADDRESS_OPS):
|
if Script.match_ops(ops, cls.TO_ADDRESS_OPS):
|
||||||
return handlers.address(datas[2])
|
return handlers.address(datas[2])
|
||||||
@ -164,7 +166,8 @@ class ScriptPubKey(object):
|
|||||||
return handlers.script_hash(datas[1])
|
return handlers.script_hash(datas[1])
|
||||||
if Script.match_ops(ops, cls.TO_PUBKEY_OPS):
|
if Script.match_ops(ops, cls.TO_PUBKEY_OPS):
|
||||||
return handlers.pubkey(datas[0])
|
return handlers.pubkey(datas[0])
|
||||||
return handlers.unknown(None)
|
|
||||||
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def P2SH_script(cls, hash160):
|
def P2SH_script(cls, hash160):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user