def getTxStateLockScript(T: int, delta: int, pubkey_pay_right: PublicKey, pubkey_mulsig_left: PublicKey, pubkey_mulsig_right: PublicKey) -> Script: """ tx_state lock script encodes possibilities to either refund locked coins to left or pay to right :param T: locked funds can pe paid after this time wherever right user wants :param delta: upper bound on time for transaction to be confirmed by the network :param pubkey_pay_right: public key owned by right user for payment after time T :param pubkey_mulsig_left: public key owned by left user for refund if enable-refund tx is published :param pubkey_mulsig_right: public key owned by right user for refund if enable-refund tx is published :return: tx_state lock script """ # signature script: # - for refund (with enable-refund tx + ∆): "OP_0 <left_signature> <right_signature>" # - for payment (time() >= T): "<signature_right> <pubkey_right> OP_0 OP_0 OP_0 OP_0 OP_0 OP_0" lock_script = Script([ 'OP_2', pubkey_mulsig_left.to_hex(), pubkey_mulsig_right.to_hex(), 'OP_2', 'OP_CHECKMULTISIG', 'OP_IF', delta, 'OP_CHECKSEQUENCEVERIFY', 'OP_DROP', 'OP_TRUE', # check if refund and lock for ∆ 'OP_ELSE', T, 'OP_CHECKLOCKTIMEVERIFY', 'OP_DROP', 'OP_DUP', 'OP_HASH160', pubkey_pay_right.to_hash160(), 'OP_EQUALVERIFY', 'OP_CHECKSIG', # check if payment 'OP_ENDIF' ]) return lock_script
def test_pubkey_uncompressed(self): pub = PublicKey(self.public_key_hex) self.assertEqual(pub.to_hex(compressed=False), self.public_key_hex)