Changeset View
Changeset View
Standalone View
Standalone View
test/functional/bip65-cltv-p2p.py
Show All 38 Lines | if(height > 0): | ||||
tx.vin[0].nSequence = 0 | tx.vin[0].nSequence = 0 | ||||
tx.nLockTime = height | tx.nLockTime = height | ||||
height_op = CScriptNum(height) | height_op = CScriptNum(height) | ||||
tx.vout[0].scriptPubKey = CScript( | tx.vout[0].scriptPubKey = CScript( | ||||
[height_op, OP_CHECKLOCKTIMEVERIFY, OP_DROP, OP_TRUE]) | [height_op, OP_CHECKLOCKTIMEVERIFY, OP_DROP, OP_TRUE]) | ||||
tx.rehash() | tx.rehash() | ||||
signed_result = node.signrawtransaction(ToHex(tx)) | signed_result = node.signrawtransactionwithwallet(ToHex(tx)) | ||||
new_tx = FromHex(CTransaction(), signed_result['hex']) | new_tx = FromHex(CTransaction(), signed_result['hex']) | ||||
pad_tx(new_tx) | pad_tx(new_tx) | ||||
new_tx.rehash() | new_tx.rehash() | ||||
return new_tx | return new_tx | ||||
def spend_from_coinbase(node, coinbase, to_address, amount): | def spend_from_coinbase(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 = 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 = [ | ||||
['-promiscuousmempoolflags=1', '-whitelist=127.0.0.1', "-deprecatedrpc=signrawtransaction"]] | ['-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): | ||||
node0 = NodeConnCB() | node0 = NodeConnCB() | ||||
connections = [] | connections = [] | ||||
connections.append( | connections.append( | ||||
NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], node0)) | NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], node0)) | ||||
node0.add_connection(connections[0]) | node0.add_connection(connections[0]) | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
rawspendtx = self.nodes[0].decoderawtransaction(ToHex(spendtx)) | rawspendtx = self.nodes[0].decoderawtransaction(ToHex(spendtx)) | ||||
inputs = [{ | inputs = [{ | ||||
"txid": rawspendtx['txid'], | "txid": rawspendtx['txid'], | ||||
"vout": rawspendtx['vout'][0]['n'] | "vout": rawspendtx['vout'][0]['n'] | ||||
}] | }] | ||||
output = {self.nodeaddress: 49.98} | output = {self.nodeaddress: 49.98} | ||||
rejectedtx_raw = self.nodes[0].createrawtransaction(inputs, output) | rejectedtx_raw = self.nodes[0].createrawtransaction(inputs, output) | ||||
rejectedtx_signed = self.nodes[0].signrawtransaction(rejectedtx_raw) | rejectedtx_signed = self.nodes[0].signrawtransactionwithwallet( | ||||
rejectedtx_raw) | |||||
#!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') | ||||
rejectedtx = FromHex(CTransaction(), rejectedtx_signed['hex']) | rejectedtx = FromHex(CTransaction(), rejectedtx_signed['hex']) | ||||
pad_tx(rejectedtx) | pad_tx(rejectedtx) | ||||
rejectedtx.rehash() | rejectedtx.rehash() | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |