當前位置: 首頁>>代碼示例>>Python>>正文


Python script_interpreter.ScriptInterpreter類代碼示例

本文整理匯總了Python中two1.bitcoin.script_interpreter.ScriptInterpreter的典型用法代碼示例。如果您正苦於以下問題:Python ScriptInterpreter類的具體用法?Python ScriptInterpreter怎麽用?Python ScriptInterpreter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ScriptInterpreter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_disabled_ops

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,代碼行數:7,代碼來源:test_script_interpreter.py

示例2: test_op_return

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例3: test_op_2swap

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例4: test_op_2rot

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例5: test_op_sha256

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例6: test_op_0

def test_op_0():
    s = Script("OP_0")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert si.stack[0] == b''
開發者ID:0xDeX,項目名稱:two1-python,代碼行數:8,代碼來源:test_script_interpreter.py

示例7: test_op_size

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例8: test_op_abs

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例9: test_op_add

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例10: test_op_nip

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例11: test_op_1sub

def test_op_1sub():
    s = Script("OP_3 OP_1SUB")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert list(si.stack) == [2]
開發者ID:0xDeX,項目名稱:two1-python,代碼行數:8,代碼來源:test_script_interpreter.py

示例12: test_op_hash160

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例13: test_op_sha1

def test_op_sha1():
    s = Script("0x01 OP_SHA1")

    si = ScriptInterpreter()
    si.run_script(s)

    assert len(si.stack) == 1
    assert si.stack[0] == b'\xbf\x8bE0\xd8\xd2F\xddt\xacS\xa14q\xbb\xa1yA\xdf\xf7'
開發者ID:0xDeX,項目名稱:two1-python,代碼行數:8,代碼來源:test_script_interpreter.py

示例14: test_op_3dup

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,代碼行數:8,代碼來源:test_script_interpreter.py

示例15: test_op_2over

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,代碼行數:8,代碼來源:test_script_interpreter.py


注:本文中的two1.bitcoin.script_interpreter.ScriptInterpreter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。