当前位置: 首页>>代码示例>>Python>>正文


Python ScriptInterpreter.run_script方法代码示例

本文整理汇总了Python中two1.bitcoin.script_interpreter.ScriptInterpreter.run_script方法的典型用法代码示例。如果您正苦于以下问题:Python ScriptInterpreter.run_script方法的具体用法?Python ScriptInterpreter.run_script怎么用?Python ScriptInterpreter.run_script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在two1.bitcoin.script_interpreter.ScriptInterpreter的用法示例。


在下文中一共展示了ScriptInterpreter.run_script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_op_checklocktimeverify

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_checklocktimeverify():
    prev_txn_hash = Hash('6eae1e03964799c4e29039db459ea4fad4df57c2b06f730b60032a48fb075620')
    txn_input = TransactionInput(prev_txn_hash, 0, Script(""), 1)

    addr = "1HJiL6AYYmtkbJzC9bxAorznWijwNK5Z8E"
    out_script_pub_key = Script.build_p2pkh(
        utils.address_to_key_hash(addr)[1])
    txn_output = TransactionOutput(9000, out_script_pub_key)

    # Create the txn
    txn = Transaction(Transaction.DEFAULT_TRANSACTION_VERSION,
                      [txn_input],
                      [txn_output],
                      367987)

    # This is one more (367988) so it should fail
    s = Script("0x749d05 OP_CHECKLOCKTIMEVERIFY")

    si = ScriptInterpreter(txn=txn,
                           input_index=0,
                           sub_script=out_script_pub_key)
    si.run_script(s)

    assert not si.valid

    # This is negative, so it should fail
    s = Script("0xfff74d05 OP_CHECKLOCKTIMEVERIFY")

    si = ScriptInterpreter(txn=txn,
                           input_index=0,
                           sub_script=out_script_pub_key)
    si.run_script(s)

    assert not si.valid

    # This is one less (367986) so it should pass
    s = Script("0x729d05 OP_CHECKLOCKTIMEVERIFY")

    si = ScriptInterpreter(txn=txn,
                           input_index=0,
                           sub_script=out_script_pub_key)
    si.run_script(s)

    assert not si.stop

    # Now reformulate the txn so that the input is finalized
    txn_input.sequence_num = 0xffffffff
    si.run_script(s)

    assert not si.valid

    # The last check is if there are mismatching notions of locktime
    txn_input.sequence_num = 1
    txn.lock_time = 500000001
    si = ScriptInterpreter(txn=txn,
                           input_index=0,
                           sub_script=out_script_pub_key)
    si.run_script(s)

    assert not si.valid
开发者ID:0xDeX,项目名称:two1-python,代码行数:62,代码来源:test_script_interpreter.py

示例2: test_disabled_ops

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_disabled_ops():
    for opcode in ScriptInterpreter.DISABLED_OPS:
        si = ScriptInterpreter()
        si.run_script(Script("OP_1 " + opcode + " OP_2"))

        assert not si.valid
        assert list(si.stack) == [1]
开发者ID:0xDeX,项目名称:two1-python,代码行数:9,代码来源:test_script_interpreter.py

示例3: test_op_depth

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_depth():
    s = Script("OP_1 OP_IFDUP OP_DEPTH")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 3
    assert list(si.stack) == [1, 1, 2]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例4: test_op_size

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_size():
    s = Script("OP_1 OP_2 OP_3 OP_4 OP_5 0x010203 OP_SIZE")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 7
    assert list(si.stack) == [1, 2, 3, 4, 5, b'\x01\x02\x03', 3]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例5: test_op_return

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_return():
    s = Script("OP_RETURN 0x010203")

    si = ScriptInterpreter()
    si.run_script(s)

    assert si.stop
    assert len(si.stack) == 0
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例6: test_op_sha256

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_sha256():
    s = Script("0x01 OP_SHA256")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert si.stack[0] == b'K\xf5\x12/4ET\xc5;\xde.\xbb\x8c\xd2\xb7\xe3\xd1`\n\xd61\xc3\x85\xa5\xd7\xcc\xe2<w\x85E\x9a'
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例7: test_op_add

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_add():
    s = Script("OP_1 OP_2 OP_ADD")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert list(si.stack) == [3]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例8: test_op_drop

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_drop():
    s = Script("OP_1 OP_IFDUP OP_DROP")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert list(si.stack) == [1]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例9: test_op_abs

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_abs():
    s = Script("OP_3 OP_NEGATE OP_ABS")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert list(si.stack) == [3]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例10: test_op_hash160

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_hash160():
    s = Script("0x01 OP_HASH160")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert si.stack[0] == b'\xc5\x1bf\xbc\xed^D\x91\x00\x1b\xd7\x02f\x97p\xdc\xcfD\t\x82'
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例11: test_op_nip

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_nip():
    s = Script("OP_1 OP_2 OP_3 OP_NIP")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 2
    assert list(si.stack) == [1, 3]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例12: test_op_2rot

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_2rot():
    s = Script("OP_1 OP_2 OP_3 OP_4 OP_5 OP_6 OP_2ROT")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 6
    assert list(si.stack) == [3, 4, 5, 6, 1, 2]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例13: test_op_2swap

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_2swap():
    s = Script("OP_1 OP_2 OP_3 OP_4 OP_5 OP_6 OP_2SWAP")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 6
    assert list(si.stack) == [1, 2, 5, 6, 3, 4]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例14: test_op_3dup

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_3dup():
    s = Script("OP_1 OP_2 OP_3 OP_4 OP_5 OP_3DUP")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 8
    assert list(si.stack) == [1, 2, 3, 4, 5, 3, 4, 5]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py

示例15: test_op_2over

# 需要导入模块: from two1.bitcoin.script_interpreter import ScriptInterpreter [as 别名]
# 或者: from two1.bitcoin.script_interpreter.ScriptInterpreter import run_script [as 别名]
def test_op_2over():
    s = Script("OP_1 OP_2 OP_3 OP_4 OP_5 OP_2OVER")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 7
    assert list(si.stack) == [1, 2, 3, 4, 5, 2, 3]
开发者ID:0xDeX,项目名称:two1-python,代码行数:10,代码来源:test_script_interpreter.py


注:本文中的two1.bitcoin.script_interpreter.ScriptInterpreter.run_script方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。