Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-schnorr.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2019 The Bitcoin developers | # Copyright (c) 2019 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 tests the treatment of Schnorr transaction signatures: | This tests the treatment of Schnorr transaction signatures: | ||||
- acceptance both in mempool and blocks. | - acceptance both in mempool and blocks. | ||||
- check banning for peers who send txns with 64 byte ECDSA DER sigs. | - check banning for peers who send txns with 64 byte ECDSA DER sigs. | ||||
Derived from a variety of functional tests. | Derived from a variety of functional tests. | ||||
""" | """ | ||||
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 ( | ||||
CBlock, | CBlock, | ||||
COutPoint, | COutPoint, | ||||
CTransaction, | CTransaction, | ||||
CTxIn, | CTxIn, | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
if multi: | if multi: | ||||
script = CScript([OP_1, public_key, OP_1, OP_CHECKMULTISIG]) | script = CScript([OP_1, public_key, OP_1, OP_CHECKMULTISIG]) | ||||
else: | else: | ||||
script = CScript([public_key, OP_CHECKSIG]) | script = CScript([public_key, OP_CHECKSIG]) | ||||
value = spendfrom.vout[0].nValue | value = spendfrom.vout[0].nValue | ||||
# Fund transaction | # Fund transaction | ||||
txfund = create_transaction(spendfrom, 0, b'', value, script) | txfund = create_tx_with_script(spendfrom, 0, b'', value, script) | ||||
txfund.rehash() | txfund.rehash() | ||||
fundings.append(txfund) | fundings.append(txfund) | ||||
# Spend transaction | # Spend transaction | ||||
txspend = CTransaction() | txspend = CTransaction() | ||||
txspend.vout.append( | txspend.vout.append( | ||||
CTxOut(value - 1000, CScript([OP_TRUE]))) | CTxOut(value - 1000, CScript([OP_TRUE]))) | ||||
txspend.vin.append( | txspend.vin.append( | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |