Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.cpp
Show First 20 Lines • Show All 321 Lines • ▼ Show 20 Lines | CBlock TestChain100Setup::CreateAndProcessBlock( | ||||
Assert(m_node.chainman) | Assert(m_node.chainman) | ||||
->ProcessNewBlock(config, shared_pblock, true, nullptr); | ->ProcessNewBlock(config, shared_pblock, true, nullptr); | ||||
return block; | return block; | ||||
} | } | ||||
CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction( | CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction( | ||||
CTransactionRef input_transaction, int input_vout, int input_height, | CTransactionRef input_transaction, int input_vout, int input_height, | ||||
CKey input_signing_key, CScript output_destination, Amount output_amount) { | CKey input_signing_key, CScript output_destination, Amount output_amount, | ||||
bool submit) { | |||||
// Transaction we will submit to the mempool | // Transaction we will submit to the mempool | ||||
CMutableTransaction mempool_txn; | CMutableTransaction mempool_txn; | ||||
// Create an input | // Create an input | ||||
COutPoint outpoint_to_spend(input_transaction->GetId(), input_vout); | COutPoint outpoint_to_spend(input_transaction->GetId(), input_vout); | ||||
CTxIn input(outpoint_to_spend); | CTxIn input(outpoint_to_spend); | ||||
mempool_txn.vin.push_back(input); | mempool_txn.vin.push_back(input); | ||||
Show All 16 Lines | CMutableTransaction TestChain100Setup::CreateValidMempoolTransaction( | ||||
std::map<COutPoint, Coin> input_coins; | std::map<COutPoint, Coin> input_coins; | ||||
input_coins.insert({outpoint_to_spend, utxo_to_spend}); | input_coins.insert({outpoint_to_spend, utxo_to_spend}); | ||||
// - Default signature hashing type | // - Default signature hashing type | ||||
SigHashType nHashType{SIGHASH_ALL}; | SigHashType nHashType{SIGHASH_ALL}; | ||||
std::map<int, std::string> input_errors; | std::map<int, std::string> input_errors; | ||||
assert(SignTransaction(mempool_txn, &keystore, input_coins, nHashType, | assert(SignTransaction(mempool_txn, &keystore, input_coins, nHashType, | ||||
input_errors)); | input_errors)); | ||||
// Add transaction to the mempool | // If submit=true, add transaction to the mempool. | ||||
{ | if (submit) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
const MempoolAcceptResult result = AcceptToMemoryPool( | const MempoolAcceptResult result = AcceptToMemoryPool( | ||||
m_node.chainman->ActiveChainstate(), GetConfig(), | m_node.chainman->ActiveChainstate(), GetConfig(), | ||||
*m_node.mempool.get(), MakeTransactionRef(mempool_txn), | *m_node.mempool.get(), MakeTransactionRef(mempool_txn), | ||||
/* bypass_limits */ false); | /* bypass_limits */ false); | ||||
assert(result.m_result_type == MempoolAcceptResult::ResultType::VALID); | assert(result.m_result_type == MempoolAcceptResult::ResultType::VALID); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |