示例#1
0
def expiring_tip_locking_script(locktime, claim_pubkey, refund_pubkey):
    assert (locktime < 0x100000000)
    assert isinstance(claim_pubkey, PublicKey)
    assert isinstance(refund_pubkey, PublicKey)
    assert (claim_pubkey.is_compressed()
            & refund_pubkey.is_compressed()), "public keys must be compressed"
    return (bytes([OP_IF]) + push_data(claim_pubkey.to_ser()) +
            bytes([OP_ELSE]) + push_data(script_number(locktime)) +
            bytes([OP_CHECKLOCKTIMEVERIFY, OP_DROP]) +
            push_data(refund_pubkey.to_ser()) + bytes([OP_ENDIF, OP_CHECKSIG]))
示例#2
0
def nulldata_script(data):
    ''' Data (temporary: int, bytes and str) '''

    script = bytes([OP_RETURN])
    for d in data:
        if isinstance(d, int):
            script += push_data(script_number(d))
        elif isinstance(d, bytes):
            script += push_data(d)
        elif isinstance(d, str):
            script += push_data(d.encode('utf-8'))
        else:
            NullDataError("cannot serialize nulldata script")

    return script
示例#3
0
def nulldata_script(data):
    ''' Data (temporary: int, bytes and str) '''

    for i, d in enumerate(data):
        if isinstance(d, Address):
            data[i] = d.h
        elif isinstance(d, PublicKey):
            data[i] = d.to_ser(strtype=False)

    script = bytes([OP_RETURN])
    for d in data:
        if isinstance(d, int):
            script += push_data(script_number(d))
        elif isinstance(d, bytes):
            script += push_data(d)
        elif isinstance(d, str):
            script += push_data(d.encode('utf-8'))
        else:
            ScriptError("cannot serialize nulldata script")

    return script
示例#4
0
def simple_sequence_locking_script(sequence):
    ''' Simple anyone-can-spend CHECKSEQUENCEVERIFY locking script. '''
    assert not (sequence & Constants.SEQUENCE_LOCKTIME_DISABLE_FLAG)
    return (push_data(script_number(sequence)) +
            bytes([OP_CHECKSEQUENCEVERIFY, OP_DROP]))
示例#5
0
def simple_locktime_locking_script(locktime):
    ''' Simple anyone-can-spend CHECKLOCKTIMEVERIFY locking script. '''
    return (push_data(script_number(locktime)) +
            bytes([OP_CHECKLOCKTIMEVERIFY, OP_DROP]))