Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-replay-protection.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Copyright (c) 2017 The Bitcoin developers | # Copyright (c) 2017 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
""" | """ | ||||
This test checks activation of UAHF and the different consensus | This test checks activation of UAHF and the different consensus | ||||
related to this activation. | related to this activation. | ||||
It is derived from the much more complex p2p-fullblocktest. | It is derived from the much more complex p2p-fullblocktest. | ||||
""" | """ | ||||
import time | import time | ||||
from test_framework.blocktools import ( | from test_framework.blocktools import ( | ||||
create_block, | create_block, | ||||
create_coinbase, | create_coinbase, | ||||
create_transaction, | create_tx_with_script, | ||||
make_conform_to_ctor, | make_conform_to_ctor, | ||||
) | ) | ||||
from test_framework.key import CECKey | from test_framework.key import CECKey | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
COIN, | COIN, | ||||
COutPoint, | COutPoint, | ||||
CTransaction, | CTransaction, | ||||
CTxIn, | CTxIn, | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
private_key = CECKey() | private_key = CECKey() | ||||
private_key.set_secretbytes(b"replayprotection") | private_key.set_secretbytes(b"replayprotection") | ||||
public_key = private_key.get_pubkey() | public_key = private_key.get_pubkey() | ||||
# This is a little handier to use than the version in blocktools.py | # This is a little handier to use than the version in blocktools.py | ||||
def create_fund_and_spend_tx(spend, forkvalue=0): | def create_fund_and_spend_tx(spend, forkvalue=0): | ||||
# Fund transaction | # Fund transaction | ||||
script = CScript([public_key, OP_CHECKSIG]) | script = CScript([public_key, OP_CHECKSIG]) | ||||
txfund = create_transaction( | txfund = create_tx_with_script( | ||||
spend.tx, spend.n, b'', 50 * COIN - 1000, script) | spend.tx, spend.n, b'', 50 * COIN - 1000, script) | ||||
txfund.rehash() | txfund.rehash() | ||||
# Spend transaction | # Spend transaction | ||||
txspend = CTransaction() | txspend = CTransaction() | ||||
txspend.vout.append(CTxOut(50 * COIN - 2000, CScript([OP_TRUE]))) | txspend.vout.append(CTxOut(50 * COIN - 2000, CScript([OP_TRUE]))) | ||||
txspend.vin.append(CTxIn(COutPoint(txfund.sha256, 0), b'')) | txspend.vin.append(CTxIn(COutPoint(txfund.sha256, 0), b'')) | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |