Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_cltv.py
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | def spend_from_coinbase(node, coinbase, to_address, amount): | ||||
signresult = node.signrawtransactionwithwallet(rawtx) | signresult = node.signrawtransactionwithwallet(rawtx) | ||||
tx = FromHex(CTransaction(), signresult['hex']) | tx = FromHex(CTransaction(), 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 | ||||
self.extra_args = [ | self.extra_args = [['-whitelist=127.0.0.1']] | ||||
['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1']] | |||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
def run_test(self): | def run_test(self): | ||||
self.nodes[0].add_p2p_connection(P2PInterface()) | self.nodes[0].add_p2p_connection(P2PInterface()) | ||||
network_thread_start() | network_thread_start() | ||||
# wait_for_verack ensures that the P2P connection is fully up. | # wait_for_verack ensures that the P2P connection is fully up. | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
block.vtx.append(fundtx) | block.vtx.append(fundtx) | ||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.solve() | block.solve() | ||||
self.nodes[0].p2p.send_and_ping(msg_block(block)) | self.nodes[0].p2p.send_and_ping(msg_block(block)) | ||||
# This block is valid | # This block is valid | ||||
assert_equal(self.nodes[0].getbestblockhash(), block.hash) | assert_equal(self.nodes[0].getbestblockhash(), block.hash) | ||||
# We show that this tx is valid except for CLTV by getting it | # We show that this tx is invalid due to CLTV by getting it | ||||
# accepted to the mempool (which we can achieve with | # rejected from the mempool for exactly that reason. | ||||
# -promiscuousmempoolflags). | assert_equal( | ||||
self.nodes[0].p2p.send_and_ping(msg_tx(spendtx)) | [{'txid': spendtx.hash, 'allowed': False, | ||||
assert spendtx.hash in self.nodes[0].getrawmempool() | 'reject-reason': '64: non-mandatory-script-verify-flag (Negative locktime)'}], | ||||
self.nodes[0].testmempoolaccept( | |||||
rawtxs=[spendtx.serialize().hex()], allowhighfees=True) | |||||
) | |||||
rejectedtx_signed = self.nodes[0].signrawtransactionwithwallet( | rejectedtx_signed = self.nodes[0].signrawtransactionwithwallet( | ||||
ToHex(spendtx)) | ToHex(spendtx)) | ||||
# Couldn't complete signature due to CLTV | # Couldn't complete signature due to CLTV | ||||
assert(rejectedtx_signed['errors'][0]['error'] == 'Negative locktime') | assert(rejectedtx_signed['errors'][0]['error'] == 'Negative locktime') | ||||
tip = block.hash | tip = block.hash | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |