Changeset View
Changeset View
Standalone View
Standalone View
test/functional/bip65-cltv-p2p.py
Show All 37 Lines | |||||
def cltv_validate(node, tx, height): | def cltv_validate(node, tx, height): | ||||
'''Modify the signature in vin 0 of the tx to pass CLTV | '''Modify the signature in vin 0 of the tx to pass CLTV | ||||
Prepends <height> CLTV DROP in the scriptSig, and sets | Prepends <height> CLTV DROP in the scriptSig, and sets | ||||
the locktime to height''' | the locktime to height''' | ||||
tx.vin[0].nSequence = 0 | tx.vin[0].nSequence = 0 | ||||
tx.nLockTime = height | tx.nLockTime = height | ||||
# Need to re-sign, since nSequence and nLockTime changed | # Need to re-sign, since nSequence and nLockTime changed | ||||
signed_result = node.signrawtransaction(ToHex(tx)) | signed_result = node.signrawtransactionwithwallet(ToHex(tx)) | ||||
new_tx = CTransaction() | new_tx = CTransaction() | ||||
new_tx.deserialize(BytesIO(hex_str_to_bytes(signed_result['hex']))) | new_tx.deserialize(BytesIO(hex_str_to_bytes(signed_result['hex']))) | ||||
new_tx.vin[0].scriptSig = CScript([CScriptNum(height), OP_CHECKLOCKTIMEVERIFY, OP_DROP] + | new_tx.vin[0].scriptSig = CScript([CScriptNum(height), OP_CHECKLOCKTIMEVERIFY, OP_DROP] + | ||||
list(CScript(new_tx.vin[0].scriptSig))) | list(CScript(new_tx.vin[0].scriptSig))) | ||||
return new_tx | return new_tx | ||||
def create_transaction(node, coinbase, to_address, amount): | def create_transaction(node, coinbase, to_address, amount): | ||||
from_txid = node.getblock(coinbase)['tx'][0] | from_txid = node.getblock(coinbase)['tx'][0] | ||||
inputs = [{"txid": from_txid, "vout": 0}] | inputs = [{"txid": from_txid, "vout": 0}] | ||||
outputs = {to_address: amount} | outputs = {to_address: amount} | ||||
rawtx = node.createrawtransaction(inputs, outputs) | rawtx = node.createrawtransaction(inputs, outputs) | ||||
signresult = node.signrawtransaction(rawtx) | signresult = node.signrawtransactionwithwallet(rawtx) | ||||
tx = CTransaction() | tx = CTransaction() | ||||
tx.deserialize(BytesIO(hex_str_to_bytes(signresult['hex']))) | tx.deserialize(BytesIO(hex_str_to_bytes(signresult['hex']))) | ||||
return tx | return tx | ||||
class BIP65Test(BitcoinTestFramework): | class BIP65Test(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |