本文整理汇总了Python中two1.bitcoin.script_interpreter.ScriptInterpreter.restore_stack方法的典型用法代码示例。如果您正苦于以下问题:Python ScriptInterpreter.restore_stack方法的具体用法?Python ScriptInterpreter.restore_stack怎么用?Python ScriptInterpreter.restore_stack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类two1.bitcoin.script_interpreter.ScriptInterpreter
的用法示例。
在下文中一共展示了ScriptInterpreter.restore_stack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _verify_input
# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import restore_stack [as 别名]
def _verify_input(self, input_index, sub_script, partial_multisig=False):
p2sh = sub_script.is_p2sh()
sig_script = self.inputs[input_index].script
si = ScriptInterpreter(txn=self,
input_index=input_index,
sub_script=sub_script)
try:
si.run_script(sig_script)
except ScriptInterpreterError:
return False
# This copy_stack and the restore_stack emulate the behavior
# found in bitcoin core for evaluating P2SH scripts. See:
# https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L1170
if p2sh:
si.copy_stack()
try:
si.run_script(sub_script)
except ScriptInterpreterError:
return False
rv = si.valid
if p2sh:
si.restore_stack()
redeem_script = Script(si.stack.pop())
si._sub_script = redeem_script
try:
if sig_script.is_multisig_sig() and partial_multisig:
# This is a hack for partial verification
partial_script = copy.deepcopy(redeem_script)
partial_script.ast[-1] = 'OP_CHECKPARTIALMULTISIG'
sig_info = sig_script.extract_multisig_sig_info()
si.run_script(partial_script)
rv &= si.match_count > 0 and si.match_count <= len(sig_info['signatures'])
else:
si.run_script(redeem_script)
rv &= si.valid
except:
rv = False
return rv