mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-26 17:52:13 +01:00
test: remove ToHex
helper, use .serialize().hex() instead
This commit is contained in:
parent
2ce7b47958
commit
a79396fe5f
@ -23,7 +23,7 @@ PATH_BASE_TEST_FUNCTIONAL = os.path.abspath(os.path.join(PATH_BASE_CONTRIB_SIGNE
|
||||
sys.path.insert(0, PATH_BASE_TEST_FUNCTIONAL)
|
||||
|
||||
from test_framework.blocktools import WITNESS_COMMITMENT_HEADER, script_BIP34_coinbase_height # noqa: E402
|
||||
from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, FromHex, ToHex, deser_string, hash256, ser_compact_size, ser_string, ser_uint256, tx_from_hex, uint256_from_str # noqa: E402
|
||||
from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, FromHex, deser_string, hash256, ser_compact_size, ser_string, ser_uint256, tx_from_hex, uint256_from_str # noqa: E402
|
||||
from test_framework.script import CScriptOp # noqa: E402
|
||||
|
||||
logging.basicConfig(
|
||||
@ -274,7 +274,7 @@ def do_genpsbt(args):
|
||||
def do_solvepsbt(args):
|
||||
block, signet_solution = do_decode_psbt(sys.stdin.read())
|
||||
block = finish_block(block, signet_solution, args.grind_cmd)
|
||||
print(ToHex(block))
|
||||
print(block.serialize().hex())
|
||||
|
||||
def nbits_to_target(nbits):
|
||||
shift = (nbits >> 24) & 0xff
|
||||
@ -503,7 +503,7 @@ def do_generate(args):
|
||||
block = finish_block(block, signet_solution, args.grind_cmd)
|
||||
|
||||
# submit block
|
||||
r = args.bcli("-stdin", "submitblock", input=ToHex(block).encode('utf8'))
|
||||
r = args.bcli("-stdin", "submitblock", input=block.serialize().hex().encode('utf8'))
|
||||
|
||||
# report
|
||||
bstr = "block" if is_mine else "backup block"
|
||||
|
@ -17,7 +17,6 @@ from test_framework.messages import (
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
ToHex,
|
||||
tx_from_hex,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
@ -101,7 +100,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx1.vin = [CTxIn(COutPoint(int(utxo["txid"], 16), utxo["vout"]), nSequence=sequence_value)]
|
||||
tx1.vout = [CTxOut(value, DUMMY_P2WPKH_SCRIPT)]
|
||||
|
||||
tx1_signed = self.nodes[0].signrawtransactionwithwallet(ToHex(tx1))["hex"]
|
||||
tx1_signed = self.nodes[0].signrawtransactionwithwallet(tx1.serialize().hex())["hex"]
|
||||
tx1_id = self.nodes[0].sendrawtransaction(tx1_signed)
|
||||
tx1_id = int(tx1_id, 16)
|
||||
|
||||
@ -114,13 +113,13 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx2.vout = [CTxOut(int(value - self.relayfee * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx2.rehash()
|
||||
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, self.nodes[0].sendrawtransaction, ToHex(tx2))
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, self.nodes[0].sendrawtransaction, tx2.serialize().hex())
|
||||
|
||||
# Setting the version back down to 1 should disable the sequence lock,
|
||||
# so this should be accepted.
|
||||
tx2.nVersion = 1
|
||||
|
||||
self.nodes[0].sendrawtransaction(ToHex(tx2))
|
||||
self.nodes[0].sendrawtransaction(tx2.serialize().hex())
|
||||
|
||||
# Calculate the median time past of a prior block ("confirmations" before
|
||||
# the current tip).
|
||||
@ -205,9 +204,9 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx.vin.append(CTxIn(COutPoint(int(utxos[j]["txid"], 16), utxos[j]["vout"]), nSequence=sequence_value))
|
||||
value += utxos[j]["amount"]*COIN
|
||||
# Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
|
||||
tx_size = len(ToHex(tx))//2 + 120*num_inputs + 50
|
||||
tx_size = len(tx.serialize().hex())//2 + 120*num_inputs + 50
|
||||
tx.vout.append(CTxOut(int(value-self.relayfee*tx_size*COIN/1000), DUMMY_P2WPKH_SCRIPT))
|
||||
rawtx = self.nodes[0].signrawtransactionwithwallet(ToHex(tx))["hex"]
|
||||
rawtx = self.nodes[0].signrawtransactionwithwallet(tx.serialize().hex())["hex"]
|
||||
|
||||
if (using_sequence_locks and not should_pass):
|
||||
# This transaction should be rejected
|
||||
@ -236,7 +235,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx2.nVersion = 2
|
||||
tx2.vin = [CTxIn(COutPoint(tx1.sha256, 0), nSequence=0)]
|
||||
tx2.vout = [CTxOut(int(tx1.vout[0].nValue - self.relayfee*COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx2_raw = self.nodes[0].signrawtransactionwithwallet(ToHex(tx2))["hex"]
|
||||
tx2_raw = self.nodes[0].signrawtransactionwithwallet(tx2.serialize().hex())["hex"]
|
||||
tx2 = tx_from_hex(tx2_raw)
|
||||
tx2.rehash()
|
||||
|
||||
@ -258,10 +257,10 @@ class BIP68Test(BitcoinTestFramework):
|
||||
|
||||
if (orig_tx.hash in node.getrawmempool()):
|
||||
# sendrawtransaction should fail if the tx is in the mempool
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, node.sendrawtransaction, ToHex(tx))
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, node.sendrawtransaction, tx.serialize().hex())
|
||||
else:
|
||||
# sendrawtransaction should succeed if the tx is not in the mempool
|
||||
node.sendrawtransaction(ToHex(tx))
|
||||
node.sendrawtransaction(tx.serialize().hex())
|
||||
|
||||
return tx
|
||||
|
||||
@ -311,7 +310,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
utxos = self.nodes[0].listunspent()
|
||||
tx5.vin.append(CTxIn(COutPoint(int(utxos[0]["txid"], 16), utxos[0]["vout"]), nSequence=1))
|
||||
tx5.vout[0].nValue += int(utxos[0]["amount"]*COIN)
|
||||
raw_tx5 = self.nodes[0].signrawtransactionwithwallet(ToHex(tx5))["hex"]
|
||||
raw_tx5 = self.nodes[0].signrawtransactionwithwallet(tx5.serialize().hex())["hex"]
|
||||
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, self.nodes[0].sendrawtransaction, raw_tx5)
|
||||
|
||||
@ -337,7 +336,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
block.rehash()
|
||||
block.solve()
|
||||
tip = block.sha256
|
||||
assert_equal(None if i == 1 else 'inconclusive', self.nodes[0].submitblock(ToHex(block)))
|
||||
assert_equal(None if i == 1 else 'inconclusive', self.nodes[0].submitblock(block.serialize().hex()))
|
||||
tmpl = self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
|
||||
tmpl['previousblockhash'] = '%x' % tip
|
||||
tmpl['transactions'] = []
|
||||
@ -370,11 +369,11 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx2.vout = [CTxOut(int(tx1.vout[0].nValue - self.relayfee*COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
|
||||
# sign tx2
|
||||
tx2_raw = self.nodes[0].signrawtransactionwithwallet(ToHex(tx2))["hex"]
|
||||
tx2_raw = self.nodes[0].signrawtransactionwithwallet(tx2.serialize().hex())["hex"]
|
||||
tx2 = tx_from_hex(tx2_raw)
|
||||
tx2.rehash()
|
||||
|
||||
self.nodes[0].sendrawtransaction(ToHex(tx2))
|
||||
self.nodes[0].sendrawtransaction(tx2.serialize().hex())
|
||||
|
||||
# Now make an invalid spend of tx2 according to BIP68
|
||||
sequence_value = 100 # 100 block relative locktime
|
||||
@ -385,7 +384,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
tx3.vout = [CTxOut(int(tx2.vout[0].nValue - self.relayfee * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx3.rehash()
|
||||
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, self.nodes[0].sendrawtransaction, ToHex(tx3))
|
||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, self.nodes[0].sendrawtransaction, tx3.serialize().hex())
|
||||
|
||||
# make a block that violates bip68; ensure that the tip updates
|
||||
block = create_block(tmpl=self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS))
|
||||
@ -418,7 +417,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
rawtxfund = self.nodes[1].fundrawtransaction(rawtx)['hex']
|
||||
tx = tx_from_hex(rawtxfund)
|
||||
tx.nVersion = 2
|
||||
tx_signed = self.nodes[1].signrawtransactionwithwallet(ToHex(tx))["hex"]
|
||||
tx_signed = self.nodes[1].signrawtransactionwithwallet(tx.serialize().hex())["hex"]
|
||||
self.nodes[1].sendrawtransaction(tx_signed)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -22,7 +22,6 @@ from test_framework.messages import (
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
ToHex,
|
||||
)
|
||||
from test_framework.script import (
|
||||
CScript,
|
||||
@ -170,7 +169,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
tx2 = CTransaction()
|
||||
tx2.vin.append(CTxIn(COutPoint(int(tx1_txid, 16), n), b''))
|
||||
tx2.vout.append(CTxOut(int(20.99 * COIN), CScript([OP_RETURN] + [OP_FALSE]*30)))
|
||||
tx2_hex = self.nodes[0].signrawtransactionwithwallet(ToHex(tx2))['hex']
|
||||
tx2_hex = self.nodes[0].signrawtransactionwithwallet(tx2.serialize().hex())['hex']
|
||||
self.nodes[0].sendrawtransaction(tx2_hex)
|
||||
|
||||
# Include both txs in a block
|
||||
@ -207,7 +206,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
block_time = self.nodes[0].getblock(tip)['time'] + 1
|
||||
block = create_block(int(tip, 16), cb, block_time)
|
||||
block.solve()
|
||||
self.nodes[0].submitblock(ToHex(block))
|
||||
self.nodes[0].submitblock(block.serialize().hex())
|
||||
self.sync_all()
|
||||
|
||||
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))
|
||||
|
@ -36,7 +36,6 @@ from test_framework.messages import (
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
ToHex,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
@ -208,7 +207,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||
tx.vout.append(CTxOut(output_amount, hex_str_to_bytes(utxo['scriptPubKey'])))
|
||||
|
||||
# Sign and send the transaction to get into the mempool
|
||||
tx_signed_hex = node.signrawtransactionwithwallet(ToHex(tx))['hex']
|
||||
tx_signed_hex = node.signrawtransactionwithwallet(tx.serialize().hex())['hex']
|
||||
node.sendrawtransaction(tx_signed_hex)
|
||||
num_transactions += 1
|
||||
|
||||
|
@ -6,8 +6,23 @@
|
||||
from decimal import Decimal
|
||||
import random
|
||||
|
||||
from test_framework.messages import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
|
||||
from test_framework.script import CScript, OP_1, OP_DROP, OP_2, OP_HASH160, OP_EQUAL, hash160, OP_TRUE
|
||||
from test_framework.messages import (
|
||||
COIN,
|
||||
COutPoint,
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
)
|
||||
from test_framework.script import (
|
||||
CScript,
|
||||
OP_1,
|
||||
OP_2,
|
||||
OP_DROP,
|
||||
OP_EQUAL,
|
||||
OP_HASH160,
|
||||
OP_TRUE,
|
||||
hash160,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
@ -64,11 +79,11 @@ def small_txpuzzle_randfee(from_node, conflist, unconflist, amount, min_fee, fee
|
||||
# the ScriptSig that will satisfy the ScriptPubKey.
|
||||
for inp in tx.vin:
|
||||
inp.scriptSig = SCRIPT_SIG[inp.prevout.n]
|
||||
txid = from_node.sendrawtransaction(hexstring=ToHex(tx), maxfeerate=0)
|
||||
txid = from_node.sendrawtransaction(hexstring=tx.serialize().hex(), maxfeerate=0)
|
||||
unconflist.append({"txid": txid, "vout": 0, "amount": total_in - amount - fee})
|
||||
unconflist.append({"txid": txid, "vout": 1, "amount": amount})
|
||||
|
||||
return (ToHex(tx), fee)
|
||||
return (tx.serialize().hex(), fee)
|
||||
|
||||
|
||||
def split_inputs(from_node, txins, txouts, initial_split=False):
|
||||
@ -91,10 +106,10 @@ def split_inputs(from_node, txins, txouts, initial_split=False):
|
||||
# If this is the initial split we actually need to sign the transaction
|
||||
# Otherwise we just need to insert the proper ScriptSig
|
||||
if (initial_split):
|
||||
completetx = from_node.signrawtransactionwithwallet(ToHex(tx))["hex"]
|
||||
completetx = from_node.signrawtransactionwithwallet(tx.serialize().hex())["hex"]
|
||||
else:
|
||||
tx.vin[0].scriptSig = SCRIPT_SIG[prevtxout["vout"]]
|
||||
completetx = ToHex(tx)
|
||||
completetx = tx.serialize().hex()
|
||||
txid = from_node.sendrawtransaction(hexstring=completetx, maxfeerate=0)
|
||||
txouts.append({"txid": txid, "vout": 0, "amount": half_change})
|
||||
txouts.append({"txid": txid, "vout": 1, "amount": rem_change})
|
||||
|
@ -11,8 +11,12 @@ This test takes 30 mins or more (up to 2 hours)
|
||||
import os
|
||||
|
||||
from test_framework.blocktools import create_coinbase
|
||||
from test_framework.messages import CBlock, ToHex
|
||||
from test_framework.script import CScript, OP_RETURN, OP_NOP
|
||||
from test_framework.messages import CBlock
|
||||
from test_framework.script import (
|
||||
CScript,
|
||||
OP_NOP,
|
||||
OP_RETURN,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
@ -62,7 +66,7 @@ def mine_large_blocks(node, n):
|
||||
block.solve()
|
||||
|
||||
# Submit to the node
|
||||
node.submitblock(ToHex(block))
|
||||
node.submitblock(block.serialize().hex())
|
||||
|
||||
previousblockhash = block.sha256
|
||||
height += 1
|
||||
|
@ -7,7 +7,14 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, BIP125_SEQUENCE_NUMBER
|
||||
from test_framework.messages import (
|
||||
BIP125_SEQUENCE_NUMBER,
|
||||
COIN,
|
||||
COutPoint,
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
)
|
||||
from test_framework.script import CScript, OP_DROP
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_raises_rpc_error, satoshi_round
|
||||
@ -17,10 +24,6 @@ from test_framework.wallet import MiniWallet
|
||||
MAX_REPLACEMENT_LIMIT = 100
|
||||
|
||||
|
||||
def txToHex(tx):
|
||||
return tx.serialize().hex()
|
||||
|
||||
|
||||
def make_utxo(node, amount, confirmed=True, scriptPubKey=DUMMY_P2WPKH_SCRIPT):
|
||||
"""Create a txout with a given amount and scriptPubKey
|
||||
|
||||
@ -44,7 +47,7 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=DUMMY_P2WPKH_SCRIPT):
|
||||
tx2.vout = [CTxOut(amount, scriptPubKey)]
|
||||
tx2.rehash()
|
||||
|
||||
signed_tx = node.signrawtransactionwithwallet(txToHex(tx2))
|
||||
signed_tx = node.signrawtransactionwithwallet(tx2.serialize().hex())
|
||||
|
||||
txid = node.sendrawtransaction(signed_tx['hex'], 0)
|
||||
|
||||
@ -133,7 +136,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1a = CTransaction()
|
||||
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1a_hex = txToHex(tx1a)
|
||||
tx1a_hex = tx1a.serialize().hex()
|
||||
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, 0)
|
||||
|
||||
self.sync_all()
|
||||
@ -142,7 +145,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1b = CTransaction()
|
||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1b.vout = [CTxOut(1 * COIN, DUMMY_2_P2WPKH_SCRIPT)]
|
||||
tx1b_hex = txToHex(tx1b)
|
||||
tx1b_hex = tx1b.serialize().hex()
|
||||
|
||||
# This will raise an exception due to insufficient fee
|
||||
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
|
||||
@ -151,7 +154,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1b = CTransaction()
|
||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1b.vout = [CTxOut(int(0.9 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1b_hex = txToHex(tx1b)
|
||||
tx1b_hex = tx1b.serialize().hex()
|
||||
# Works when enabled
|
||||
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, 0)
|
||||
|
||||
@ -176,7 +179,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx = CTransaction()
|
||||
tx.vin = [CTxIn(prevout, nSequence=0)]
|
||||
tx.vout = [CTxOut(remaining_value, CScript([1, OP_DROP] * 15 + [1]))]
|
||||
tx_hex = txToHex(tx)
|
||||
tx_hex = tx.serialize().hex()
|
||||
txid = self.nodes[0].sendrawtransaction(tx_hex, 0)
|
||||
chain_txids.append(txid)
|
||||
prevout = COutPoint(int(txid, 16), 0)
|
||||
@ -186,7 +189,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
dbl_tx = CTransaction()
|
||||
dbl_tx.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
dbl_tx.vout = [CTxOut(initial_nValue - 30 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
dbl_tx_hex = txToHex(dbl_tx)
|
||||
dbl_tx_hex = dbl_tx.serialize().hex()
|
||||
|
||||
# This will raise an exception due to insufficient fee
|
||||
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, dbl_tx_hex, 0)
|
||||
@ -195,7 +198,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
dbl_tx = CTransaction()
|
||||
dbl_tx.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
dbl_tx.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
dbl_tx_hex = txToHex(dbl_tx)
|
||||
dbl_tx_hex = dbl_tx.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(dbl_tx_hex, 0)
|
||||
|
||||
mempool = self.nodes[0].getrawmempool()
|
||||
@ -223,7 +226,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx = CTransaction()
|
||||
tx.vin = [CTxIn(prevout, nSequence=0)]
|
||||
tx.vout = vout
|
||||
tx_hex = txToHex(tx)
|
||||
tx_hex = tx.serialize().hex()
|
||||
|
||||
assert len(tx.serialize()) < 100000
|
||||
txid = self.nodes[0].sendrawtransaction(tx_hex, 0)
|
||||
@ -248,7 +251,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
dbl_tx = CTransaction()
|
||||
dbl_tx.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
dbl_tx.vout = [CTxOut(initial_nValue - fee * n, DUMMY_P2WPKH_SCRIPT)]
|
||||
dbl_tx_hex = txToHex(dbl_tx)
|
||||
dbl_tx_hex = dbl_tx.serialize().hex()
|
||||
# This will raise an exception due to insufficient fee
|
||||
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, dbl_tx_hex, 0)
|
||||
|
||||
@ -256,7 +259,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
dbl_tx = CTransaction()
|
||||
dbl_tx.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
dbl_tx.vout = [CTxOut(initial_nValue - fee * n - 1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
dbl_tx_hex = txToHex(dbl_tx)
|
||||
dbl_tx_hex = dbl_tx.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(dbl_tx_hex, 0)
|
||||
|
||||
mempool = self.nodes[0].getrawmempool()
|
||||
@ -276,7 +279,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
dbl_tx = CTransaction()
|
||||
dbl_tx.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
dbl_tx.vout = [CTxOut(initial_nValue - 2 * fee * n, DUMMY_P2WPKH_SCRIPT)]
|
||||
dbl_tx_hex = txToHex(dbl_tx)
|
||||
dbl_tx_hex = dbl_tx.serialize().hex()
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "too many potential replacements", self.nodes[0].sendrawtransaction, dbl_tx_hex, 0)
|
||||
|
||||
@ -291,7 +294,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1a = CTransaction()
|
||||
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1a_hex = txToHex(tx1a)
|
||||
tx1a_hex = tx1a.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(tx1a_hex, 0)
|
||||
|
||||
# Higher fee, but the fee per KB is much lower, so the replacement is
|
||||
@ -299,7 +302,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1b = CTransaction()
|
||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1b.vout = [CTxOut(int(0.001 * COIN), CScript([b'a' * 999000]))]
|
||||
tx1b_hex = txToHex(tx1b)
|
||||
tx1b_hex = tx1b.serialize().hex()
|
||||
|
||||
# This will raise an exception due to insufficient fee
|
||||
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
|
||||
@ -312,7 +315,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1a = CTransaction()
|
||||
tx1a.vin = [CTxIn(utxo1, nSequence=0)]
|
||||
tx1a.vout = [CTxOut(int(1.1 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1a_hex = txToHex(tx1a)
|
||||
tx1a_hex = tx1a.serialize().hex()
|
||||
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, 0)
|
||||
|
||||
tx1a_txid = int(tx1a_txid, 16)
|
||||
@ -322,7 +325,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx2.vin = [CTxIn(utxo1, nSequence=0), CTxIn(utxo2, nSequence=0)]
|
||||
tx2.vin.append(CTxIn(COutPoint(tx1a_txid, 0), nSequence=0))
|
||||
tx2.vout = tx1a.vout
|
||||
tx2_hex = txToHex(tx2)
|
||||
tx2_hex = tx2.serialize().hex()
|
||||
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, tx2_hex, 0)
|
||||
@ -331,7 +334,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1b = CTransaction()
|
||||
tx1b.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0)]
|
||||
tx1b.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1b_hex = txToHex(tx1b)
|
||||
tx1b_hex = tx1b.serialize().hex()
|
||||
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, 0)
|
||||
tx1b_txid = int(tx1b_txid, 16)
|
||||
|
||||
@ -339,7 +342,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx2.vin = [CTxIn(utxo1, nSequence=0), CTxIn(utxo2, nSequence=0),
|
||||
CTxIn(COutPoint(tx1b_txid, 0))]
|
||||
tx2.vout = tx1a.vout
|
||||
tx2_hex = txToHex(tx2)
|
||||
tx2_hex = tx2.serialize().hex()
|
||||
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "bad-txns-spends-conflicting-tx", self.nodes[0].sendrawtransaction, tx2_hex, 0)
|
||||
@ -352,13 +355,13 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1 = CTransaction()
|
||||
tx1.vin = [CTxIn(confirmed_utxo)]
|
||||
tx1.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1_hex = txToHex(tx1)
|
||||
tx1_hex = tx1.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(tx1_hex, 0)
|
||||
|
||||
tx2 = CTransaction()
|
||||
tx2.vin = [CTxIn(confirmed_utxo), CTxIn(unconfirmed_utxo)]
|
||||
tx2.vout = tx1.vout
|
||||
tx2_hex = txToHex(tx2)
|
||||
tx2_hex = tx2.serialize().hex()
|
||||
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "replacement-adds-unconfirmed", self.nodes[0].sendrawtransaction, tx2_hex, 0)
|
||||
@ -381,7 +384,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
splitting_tx = CTransaction()
|
||||
splitting_tx.vin = [CTxIn(utxo, nSequence=0)]
|
||||
splitting_tx.vout = outputs
|
||||
splitting_tx_hex = txToHex(splitting_tx)
|
||||
splitting_tx_hex = splitting_tx.serialize().hex()
|
||||
|
||||
txid = self.nodes[0].sendrawtransaction(splitting_tx_hex, 0)
|
||||
txid = int(txid, 16)
|
||||
@ -391,7 +394,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx_i = CTransaction()
|
||||
tx_i.vin = [CTxIn(COutPoint(txid, i), nSequence=0)]
|
||||
tx_i.vout = [CTxOut(split_value - fee, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx_i_hex = txToHex(tx_i)
|
||||
tx_i_hex = tx_i.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(tx_i_hex, 0)
|
||||
|
||||
# Now create doublespend of the whole lot; should fail.
|
||||
@ -404,7 +407,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
double_tx = CTransaction()
|
||||
double_tx.vin = inputs
|
||||
double_tx.vout = [CTxOut(double_spend_value, CScript([b'a']))]
|
||||
double_tx_hex = txToHex(double_tx)
|
||||
double_tx_hex = double_tx.serialize().hex()
|
||||
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "too many potential replacements", self.nodes[0].sendrawtransaction, double_tx_hex, 0)
|
||||
@ -413,7 +416,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
double_tx = CTransaction()
|
||||
double_tx.vin = inputs[0:-1]
|
||||
double_tx.vout = [CTxOut(double_spend_value, CScript([b'a']))]
|
||||
double_tx_hex = txToHex(double_tx)
|
||||
double_tx_hex = double_tx.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(double_tx_hex, 0)
|
||||
|
||||
def test_opt_in(self):
|
||||
@ -424,7 +427,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1a = CTransaction()
|
||||
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0xffffffff)]
|
||||
tx1a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1a_hex = txToHex(tx1a)
|
||||
tx1a_hex = tx1a.serialize().hex()
|
||||
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, 0)
|
||||
|
||||
# This transaction isn't shown as replaceable
|
||||
@ -434,7 +437,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1b = CTransaction()
|
||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1b.vout = [CTxOut(int(0.9 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1b_hex = txToHex(tx1b)
|
||||
tx1b_hex = tx1b.serialize().hex()
|
||||
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
|
||||
@ -445,14 +448,14 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx2a = CTransaction()
|
||||
tx2a.vin = [CTxIn(tx1_outpoint, nSequence=0xfffffffe)]
|
||||
tx2a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx2a_hex = txToHex(tx2a)
|
||||
tx2a_hex = tx2a.serialize().hex()
|
||||
tx2a_txid = self.nodes[0].sendrawtransaction(tx2a_hex, 0)
|
||||
|
||||
# Still shouldn't be able to double-spend
|
||||
tx2b = CTransaction()
|
||||
tx2b.vin = [CTxIn(tx1_outpoint, nSequence=0)]
|
||||
tx2b.vout = [CTxOut(int(0.9 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx2b_hex = txToHex(tx2b)
|
||||
tx2b_hex = tx2b.serialize().hex()
|
||||
|
||||
# This will raise an exception
|
||||
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, 0)
|
||||
@ -468,7 +471,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx3a.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0xffffffff),
|
||||
CTxIn(COutPoint(tx2a_txid, 0), nSequence=0xfffffffd)]
|
||||
tx3a.vout = [CTxOut(int(0.9 * COIN), CScript([b'c'])), CTxOut(int(0.9 * COIN), CScript([b'd']))]
|
||||
tx3a_hex = txToHex(tx3a)
|
||||
tx3a_hex = tx3a.serialize().hex()
|
||||
|
||||
tx3a_txid = self.nodes[0].sendrawtransaction(tx3a_hex, 0)
|
||||
|
||||
@ -478,12 +481,12 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx3b = CTransaction()
|
||||
tx3b.vin = [CTxIn(COutPoint(tx1a_txid, 0), nSequence=0)]
|
||||
tx3b.vout = [CTxOut(int(0.5 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx3b_hex = txToHex(tx3b)
|
||||
tx3b_hex = tx3b.serialize().hex()
|
||||
|
||||
tx3c = CTransaction()
|
||||
tx3c.vin = [CTxIn(COutPoint(tx2a_txid, 0), nSequence=0)]
|
||||
tx3c.vout = [CTxOut(int(0.5 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx3c_hex = txToHex(tx3c)
|
||||
tx3c_hex = tx3c.serialize().hex()
|
||||
|
||||
self.nodes[0].sendrawtransaction(tx3b_hex, 0)
|
||||
# If tx3b was accepted, tx3c won't look like a replacement,
|
||||
@ -500,14 +503,14 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx1a = CTransaction()
|
||||
tx1a.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx1a_hex = txToHex(tx1a)
|
||||
tx1a_hex = tx1a.serialize().hex()
|
||||
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, 0)
|
||||
|
||||
# Higher fee, but the actual fee per KB is much lower.
|
||||
tx1b = CTransaction()
|
||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||
tx1b.vout = [CTxOut(int(0.001 * COIN), CScript([b'a' * 740000]))]
|
||||
tx1b_hex = txToHex(tx1b)
|
||||
tx1b_hex = tx1b.serialize().hex()
|
||||
|
||||
# Verify tx1b cannot replace tx1a.
|
||||
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
|
||||
@ -526,7 +529,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx2a = CTransaction()
|
||||
tx2a.vin = [CTxIn(tx1_outpoint, nSequence=0)]
|
||||
tx2a.vout = [CTxOut(1 * COIN, DUMMY_P2WPKH_SCRIPT)]
|
||||
tx2a_hex = txToHex(tx2a)
|
||||
tx2a_hex = tx2a.serialize().hex()
|
||||
self.nodes[0].sendrawtransaction(tx2a_hex, 0)
|
||||
|
||||
# Lower fee, but we'll prioritise it
|
||||
@ -534,7 +537,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
||||
tx2b.vin = [CTxIn(tx1_outpoint, nSequence=0)]
|
||||
tx2b.vout = [CTxOut(int(1.01 * COIN), DUMMY_P2WPKH_SCRIPT)]
|
||||
tx2b.rehash()
|
||||
tx2b_hex = txToHex(tx2b)
|
||||
tx2b_hex = tx2b.serialize().hex()
|
||||
|
||||
# Verify tx2b cannot replace tx2a.
|
||||
assert_raises_rpc_error(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx2b_hex, 0)
|
||||
|
@ -23,7 +23,6 @@ from test_framework.messages import (
|
||||
CTransaction,
|
||||
CTxIn,
|
||||
CTxOut,
|
||||
ToHex,
|
||||
sha256,
|
||||
tx_from_hex,
|
||||
)
|
||||
@ -268,7 +267,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
tx = CTransaction()
|
||||
tx.vin.append(CTxIn(COutPoint(int(txid1, 16), 0), b''))
|
||||
tx.vout.append(CTxOut(int(49.99 * COIN), CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE])))
|
||||
tx2_hex = self.nodes[0].signrawtransactionwithwallet(ToHex(tx))['hex']
|
||||
tx2_hex = self.nodes[0].signrawtransactionwithwallet(tx.serialize().hex())['hex']
|
||||
txid2 = self.nodes[0].sendrawtransaction(tx2_hex)
|
||||
tx = tx_from_hex(tx2_hex)
|
||||
assert not tx.wit.is_null()
|
||||
@ -285,7 +284,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||
tx.vin.append(CTxIn(COutPoint(int(txid2, 16), 0), b""))
|
||||
tx.vout.append(CTxOut(int(49.95 * COIN), CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))) # Huge fee
|
||||
tx.calc_sha256()
|
||||
txid3 = self.nodes[0].sendrawtransaction(hexstring=ToHex(tx), maxfeerate=0)
|
||||
txid3 = self.nodes[0].sendrawtransaction(hexstring=tx.serialize().hex(), maxfeerate=0)
|
||||
assert tx.wit.is_null()
|
||||
assert txid3 in self.nodes[0].getrawmempool()
|
||||
|
||||
|
@ -19,7 +19,6 @@ from test_framework.messages import (
|
||||
CTxIn,
|
||||
CTxInWitness,
|
||||
CTxOut,
|
||||
ToHex,
|
||||
)
|
||||
from test_framework.script import (
|
||||
ANNEX_TAG,
|
||||
@ -1306,7 +1305,7 @@ class TaprootTest(BitcoinTestFramework):
|
||||
# Add change
|
||||
fund_tx.vout.append(CTxOut(balance - 10000, random.choice(host_spks)))
|
||||
# Ask the wallet to sign
|
||||
ss = BytesIO(bytes.fromhex(node.signrawtransactionwithwallet(ToHex(fund_tx))["hex"]))
|
||||
ss = BytesIO(bytes.fromhex(node.signrawtransactionwithwallet(fund_tx.serialize().hex())["hex"]))
|
||||
fund_tx.deserialize(ss)
|
||||
# Construct UTXOData entries
|
||||
fund_tx.rehash()
|
||||
|
@ -5,8 +5,15 @@
|
||||
"""Test the ZMQ notification interface."""
|
||||
import struct
|
||||
|
||||
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE, ADDRESS_BCRT1_P2WSH_OP_TRUE
|
||||
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
|
||||
from test_framework.address import (
|
||||
ADDRESS_BCRT1_P2WSH_OP_TRUE,
|
||||
ADDRESS_BCRT1_UNSPENDABLE,
|
||||
)
|
||||
from test_framework.blocktools import (
|
||||
add_witness_commitment,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.messages import (
|
||||
CTransaction,
|
||||
|
@ -34,7 +34,6 @@ from test_framework.messages import (
|
||||
NODE_NETWORK,
|
||||
P2PHeaderAndShortIDs,
|
||||
PrefilledTransaction,
|
||||
ToHex,
|
||||
calculate_shortid,
|
||||
msg_block,
|
||||
msg_blocktxn,
|
||||
@ -62,7 +61,10 @@ from test_framework.script import (
|
||||
OP_TRUE,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, softfork_active
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
softfork_active,
|
||||
)
|
||||
|
||||
# TestP2PConn: A peer we use to send messages to bitcoind, and store responses.
|
||||
class TestP2PConn(P2PInterface):
|
||||
@ -715,9 +717,9 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||
|
||||
[l.clear_block_announcement() for l in listeners]
|
||||
|
||||
# ToHex() won't serialize with witness, but this block has no witnesses
|
||||
# anyway. TODO: repeat this test with witness tx's to a segwit node.
|
||||
node.submitblock(ToHex(block))
|
||||
# serialize without witness (this block has no witnesses anyway).
|
||||
# TODO: repeat this test with witness tx's to a segwit node.
|
||||
node.submitblock(block.serialize().hex())
|
||||
|
||||
for l in listeners:
|
||||
l.wait_until(lambda: "cmpctblock" in l.last_message, timeout=30)
|
||||
|
@ -18,7 +18,6 @@ from decimal import Decimal
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.messages import (
|
||||
CTransaction,
|
||||
ToHex,
|
||||
tx_from_hex,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
@ -451,14 +450,14 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
# As transaction version is unsigned, this should convert to its unsigned equivalent.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = -0x80000000
|
||||
rawtx = ToHex(tx)
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0x80000000)
|
||||
|
||||
# Test the maximum transaction version number that fits in a signed 32-bit integer.
|
||||
tx = CTransaction()
|
||||
tx.nVersion = 0x7fffffff
|
||||
rawtx = ToHex(tx)
|
||||
rawtx = tx.serialize().hex()
|
||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx)
|
||||
assert_equal(decrawtx['version'], 0x7fffffff)
|
||||
|
||||
|
@ -5,9 +5,15 @@
|
||||
"""Test gettxoutproof and verifytxoutproof RPCs."""
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.messages import CMerkleBlock, FromHex, ToHex
|
||||
from test_framework.messages import (
|
||||
CMerkleBlock,
|
||||
FromHex,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal, assert_raises_rpc_error
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
)
|
||||
from test_framework.wallet import MiniWallet
|
||||
|
||||
|
||||
@ -91,7 +97,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
||||
tweaked_proof = FromHex(CMerkleBlock(), proof)
|
||||
|
||||
# Make sure that our serialization/deserialization is working
|
||||
assert txid1 in self.nodes[0].verifytxoutproof(ToHex(tweaked_proof))
|
||||
assert txid1 in self.nodes[0].verifytxoutproof(tweaked_proof.serialize().hex())
|
||||
|
||||
# Check to see if we can go up the merkle tree and pass this off as a
|
||||
# single-transaction block
|
||||
@ -100,7 +106,7 @@ class MerkleBlockTest(BitcoinTestFramework):
|
||||
tweaked_proof.txn.vBits = [True] + [False]*7
|
||||
|
||||
for n in self.nodes:
|
||||
assert not n.verifytxoutproof(ToHex(tweaked_proof))
|
||||
assert not n.verifytxoutproof(tweaked_proof.serialize().hex())
|
||||
|
||||
# TODO: try more variants, eg transactions at different depths, and
|
||||
# verify that the proofs are invalid
|
||||
|
@ -23,7 +23,6 @@ from .messages import (
|
||||
CTxIn,
|
||||
CTxInWitness,
|
||||
CTxOut,
|
||||
ToHex,
|
||||
hash256,
|
||||
hex_str_to_bytes,
|
||||
ser_uint256,
|
||||
@ -250,7 +249,7 @@ def send_to_witness(use_p2wsh, node, utxo, pubkey, encode_p2sh, amount, sign=Tru
|
||||
if (insert_redeem_script):
|
||||
tx = tx_from_hex(tx_to_witness)
|
||||
tx.vin[0].scriptSig += CScript([hex_str_to_bytes(insert_redeem_script)])
|
||||
tx_to_witness = ToHex(tx)
|
||||
tx_to_witness = tx.serialize().hex()
|
||||
|
||||
return node.sendrawtransaction(tx_to_witness)
|
||||
|
||||
|
@ -196,11 +196,6 @@ def FromHex(obj, hex_string):
|
||||
return obj
|
||||
|
||||
|
||||
# Convert a binary-serializable object to hex (eg for submission via RPC)
|
||||
def ToHex(obj):
|
||||
return obj.serialize().hex()
|
||||
|
||||
|
||||
def tx_from_hex(hex_string):
|
||||
"""Deserialize from hex string to a transaction object"""
|
||||
return FromHex(CTransaction(), hex_string)
|
||||
|
@ -7,7 +7,6 @@
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.messages import (
|
||||
ToHex,
|
||||
tx_from_hex,
|
||||
)
|
||||
from test_framework.util import (
|
||||
@ -160,7 +159,7 @@ class WalletGroupTest(BitcoinTestFramework):
|
||||
tx = tx_from_hex(raw_tx)
|
||||
tx.vin = []
|
||||
tx.vout = [tx.vout[0]] * 2000
|
||||
funded_tx = self.nodes[0].fundrawtransaction(ToHex(tx))
|
||||
funded_tx = self.nodes[0].fundrawtransaction(tx.serialize().hex())
|
||||
signed_tx = self.nodes[0].signrawtransactionwithwallet(funded_tx['hex'])
|
||||
self.nodes[0].sendrawtransaction(signed_tx['hex'])
|
||||
self.nodes[0].generate(1)
|
||||
|
@ -5,8 +5,10 @@
|
||||
"""Test that the wallet resends transactions periodically."""
|
||||
import time
|
||||
|
||||
from test_framework.blocktools import create_block, create_coinbase
|
||||
from test_framework.messages import ToHex
|
||||
from test_framework.blocktools import (
|
||||
create_block,
|
||||
create_coinbase,
|
||||
)
|
||||
from test_framework.p2p import P2PTxInvStore
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import assert_equal
|
||||
@ -48,7 +50,7 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
|
||||
block = create_block(int(node.getbestblockhash(), 16), create_coinbase(node.getblockcount() + 1), block_time)
|
||||
block.rehash()
|
||||
block.solve()
|
||||
node.submitblock(ToHex(block))
|
||||
node.submitblock(block.serialize().hex())
|
||||
|
||||
# Set correct m_best_block_time, which is used in ResendWalletTransactions
|
||||
node.syncwithvalidationinterfacequeue()
|
||||
|
Loading…
x
Reference in New Issue
Block a user