Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-mempool-accept-txn.py
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | class FullBlockTest(BitcoinTestFramework): | ||||
def create_and_sign_transaction(self, spend_tx, n, value, script=CScript([OP_TRUE])): | def create_and_sign_transaction(self, spend_tx, n, value, script=CScript([OP_TRUE])): | ||||
tx = self.create_tx(spend_tx, n, value, script) | tx = self.create_tx(spend_tx, n, value, script) | ||||
self.sign_tx(tx, spend_tx, n) | self.sign_tx(tx, spend_tx, n) | ||||
tx.rehash() | tx.rehash() | ||||
return tx | return tx | ||||
def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE])): | def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE])): | ||||
if self.tip == None: | if self.tip is None: | ||||
base_block_hash = self.genesis_hash | base_block_hash = self.genesis_hash | ||||
block_time = int(time.time()) + 1 | block_time = int(time.time()) + 1 | ||||
else: | else: | ||||
base_block_hash = self.tip.sha256 | base_block_hash = self.tip.sha256 | ||||
block_time = self.tip.nTime + 1 | block_time = self.tip.nTime + 1 | ||||
# First create the coinbase | # First create the coinbase | ||||
height = self.block_heights[base_block_hash] + 1 | height = self.block_heights[base_block_hash] + 1 | ||||
coinbase = create_coinbase(height, self.coinbase_pubkey) | coinbase = create_coinbase(height, self.coinbase_pubkey) | ||||
coinbase.vout[0].nValue += additional_coinbase_value | coinbase.vout[0].nValue += additional_coinbase_value | ||||
coinbase.rehash() | coinbase.rehash() | ||||
if spend == None: | if spend is None: | ||||
block = create_block(base_block_hash, coinbase, block_time) | block = create_block(base_block_hash, coinbase, block_time) | ||||
else: | else: | ||||
# all but one satoshi to fees | # all but one satoshi to fees | ||||
coinbase.vout[0].nValue += spend.tx.vout[ | coinbase.vout[0].nValue += spend.tx.vout[ | ||||
spend.n].nValue - 1 | spend.n].nValue - 1 | ||||
coinbase.rehash() | coinbase.rehash() | ||||
block = create_block(base_block_hash, coinbase, block_time) | block = create_block(base_block_hash, coinbase, block_time) | ||||
# spend 1 satoshi | # spend 1 satoshi | ||||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |