Bitcoin Core 22.99.0
P2P Digital Currency
denialofservice_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2011-2020 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5// Unit tests for denial-of-service detection/prevention code
6
7#include <arith_uint256.h>
8#include <banman.h>
9#include <chainparams.h>
10#include <net.h>
11#include <net_processing.h>
12#include <pubkey.h>
13#include <script/sign.h>
15#include <script/standard.h>
16#include <serialize.h>
17#include <test/util/net.h>
19#include <txorphanage.h>
20#include <util/string.h>
21#include <util/system.h>
22#include <util/time.h>
23#include <validation.h>
24
25#include <array>
26#include <stdint.h>
27
28#include <boost/test/unit_test.hpp>
29
30static CService ip(uint32_t i)
31{
32 struct in_addr s;
33 s.s_addr = i;
34 return CService(CNetAddr(s), Params().GetDefaultPort());
35}
36
37static NodeId id = 0;
38
39void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds);
40
41BOOST_FIXTURE_TEST_SUITE(denialofservice_tests, TestingSetup)
42
43// Test eviction of an outbound peer whose chain never advances
44// Mock a node connection, and use mocktime to simulate a peer
45// which never sends any headers messages. PeerLogic should
46// decide to evict that outbound peer, after the appropriate timeouts.
47// Note that we protect 4 outbound nodes from being subject to
48// this logic; this test takes advantage of that protection only
49// being applied to nodes which send headers with sufficient
50// work.
51BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
52{
53 const CChainParams& chainparams = Params();
54 auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
55 // Disable inactivity checks for this test to avoid interference
56 static_cast<ConnmanTestMsg*>(connman.get())->SetPeerConnectTimeout(99999);
57 auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr,
58 *m_node.chainman, *m_node.mempool, false);
59
60 // Mock an outbound peer
61 CAddress addr1(ip(0xa0b0c001), NODE_NONE);
62 CNode dummyNode1(id++, ServiceFlags(NODE_NETWORK | NODE_WITNESS), INVALID_SOCKET, addr1, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress(), /* pszDest */ "", ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false);
64
65 peerLogic->InitializeNode(&dummyNode1);
66 dummyNode1.fSuccessfullyConnected = true;
67
68 // This test requires that we have a chain with non-zero work.
69 {
71 BOOST_CHECK(m_node.chainman->ActiveChain().Tip() != nullptr);
72 BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->nChainWork > 0);
73 }
74
75 // Test starts here
76 {
77 LOCK(dummyNode1.cs_sendProcessing);
78 BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in getheaders
79 }
80 {
81 LOCK(dummyNode1.cs_vSend);
82 BOOST_CHECK(dummyNode1.vSendMsg.size() > 0);
83 dummyNode1.vSendMsg.clear();
84 }
85
86 int64_t nStartTime = GetTime();
87 // Wait 21 minutes
88 SetMockTime(nStartTime+21*60);
89 {
90 LOCK(dummyNode1.cs_sendProcessing);
91 BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in getheaders
92 }
93 {
94 LOCK(dummyNode1.cs_vSend);
95 BOOST_CHECK(dummyNode1.vSendMsg.size() > 0);
96 }
97 // Wait 3 more minutes
98 SetMockTime(nStartTime+24*60);
99 {
100 LOCK(dummyNode1.cs_sendProcessing);
101 BOOST_CHECK(peerLogic->SendMessages(&dummyNode1)); // should result in disconnect
102 }
103 BOOST_CHECK(dummyNode1.fDisconnect == true);
104
105 peerLogic->FinalizeNode(dummyNode1);
106}
107
108static void AddRandomOutboundPeer(std::vector<CNode*>& vNodes, PeerManager& peerLogic, ConnmanTestMsg& connman)
109{
111 vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK | NODE_WITNESS), INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 0, /* nLocalHostNonceIn */ 0, CAddress(), /* pszDest */ "", ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false));
112 CNode &node = *vNodes.back();
113 node.SetCommonVersion(PROTOCOL_VERSION);
114
115 peerLogic.InitializeNode(&node);
116 node.fSuccessfullyConnected = true;
117
118 connman.AddTestNode(node);
119}
120
121BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
122{
123 const CChainParams& chainparams = Params();
124 auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman);
125 auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr,
126 *m_node.chainman, *m_node.mempool, false);
127
128 constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS;
129 CConnman::Options options;
131 options.m_max_outbound_full_relay = max_outbound_full_relay;
133
134 connman->Init(options);
135 std::vector<CNode *> vNodes;
136
137 // Mock some outbound peers
138 for (int i = 0; i < max_outbound_full_relay; ++i) {
139 AddRandomOutboundPeer(vNodes, *peerLogic, *connman);
140 }
141
142 peerLogic->CheckForStaleTipAndEvictPeers();
143
144 // No nodes should be marked for disconnection while we have no extra peers
145 for (const CNode *node : vNodes) {
146 BOOST_CHECK(node->fDisconnect == false);
147 }
148
149 SetMockTime(GetTime() + 3 * chainparams.GetConsensus().nPowTargetSpacing + 1);
150
151 // Now tip should definitely be stale, and we should look for an extra
152 // outbound peer
153 peerLogic->CheckForStaleTipAndEvictPeers();
154 BOOST_CHECK(connman->GetTryNewOutboundPeer());
155
156 // Still no peers should be marked for disconnection
157 for (const CNode *node : vNodes) {
158 BOOST_CHECK(node->fDisconnect == false);
159 }
160
161 // If we add one more peer, something should get marked for eviction
162 // on the next check (since we're mocking the time to be in the future, the
163 // required time connected check should be satisfied).
164 AddRandomOutboundPeer(vNodes, *peerLogic, *connman);
165
166 peerLogic->CheckForStaleTipAndEvictPeers();
167 for (int i = 0; i < max_outbound_full_relay; ++i) {
168 BOOST_CHECK(vNodes[i]->fDisconnect == false);
169 }
170 // Last added node should get marked for eviction
171 BOOST_CHECK(vNodes.back()->fDisconnect == true);
172
173 vNodes.back()->fDisconnect = false;
174
175 // Update the last announced block time for the last
176 // peer, and check that the next newest node gets evicted.
177 UpdateLastBlockAnnounceTime(vNodes.back()->GetId(), GetTime());
178
179 peerLogic->CheckForStaleTipAndEvictPeers();
180 for (int i = 0; i < max_outbound_full_relay - 1; ++i) {
181 BOOST_CHECK(vNodes[i]->fDisconnect == false);
182 }
183 BOOST_CHECK(vNodes[max_outbound_full_relay-1]->fDisconnect == true);
184 BOOST_CHECK(vNodes.back()->fDisconnect == false);
185
186 for (const CNode *node : vNodes) {
187 peerLogic->FinalizeNode(*node);
188 }
189
190 connman->ClearTestNodes();
191}
192
193BOOST_AUTO_TEST_CASE(peer_discouragement)
194{
195 const CChainParams& chainparams = Params();
196 auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
197 auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman);
198 auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(),
199 *m_node.chainman, *m_node.mempool, false);
200
201 CNetAddr tor_netaddr;
202 BOOST_REQUIRE(
203 tor_netaddr.SetSpecial("pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion"));
204 const CService tor_service{tor_netaddr, Params().GetDefaultPort()};
205
206 const std::array<CAddress, 3> addr{CAddress{ip(0xa0b0c001), NODE_NONE},
207 CAddress{ip(0xa0b0c002), NODE_NONE},
208 CAddress{tor_service, NODE_NONE}};
209
210 const CNetAddr other_addr{ip(0xa0b0ff01)}; // Not any of addr[].
211
212 std::array<CNode*, 3> nodes;
213
214 banman->ClearBanned();
215 nodes[0] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[0], /* nKeyedNetGroupIn */ 0,
216 /* nLocalHostNonceIn */ 0, CAddress(), /* pszDest */ "",
217 ConnectionType::INBOUND, /* inbound_onion */ false};
218 nodes[0]->SetCommonVersion(PROTOCOL_VERSION);
219 peerLogic->InitializeNode(nodes[0]);
220 nodes[0]->fSuccessfullyConnected = true;
221 connman->AddTestNode(*nodes[0]);
222 peerLogic->Misbehaving(nodes[0]->GetId(), DISCOURAGEMENT_THRESHOLD, /* message */ ""); // Should be discouraged
223 {
224 LOCK(nodes[0]->cs_sendProcessing);
225 BOOST_CHECK(peerLogic->SendMessages(nodes[0]));
226 }
227 BOOST_CHECK(banman->IsDiscouraged(addr[0]));
228 BOOST_CHECK(nodes[0]->fDisconnect);
229 BOOST_CHECK(!banman->IsDiscouraged(other_addr)); // Different address, not discouraged
230
231 nodes[1] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[1], /* nKeyedNetGroupIn */ 1,
232 /* nLocalHostNonceIn */ 1, CAddress(), /* pszDest */ "",
233 ConnectionType::INBOUND, /* inbound_onion */ false};
234 nodes[1]->SetCommonVersion(PROTOCOL_VERSION);
235 peerLogic->InitializeNode(nodes[1]);
236 nodes[1]->fSuccessfullyConnected = true;
237 connman->AddTestNode(*nodes[1]);
238 peerLogic->Misbehaving(nodes[1]->GetId(), DISCOURAGEMENT_THRESHOLD - 1, /* message */ "");
239 {
240 LOCK(nodes[1]->cs_sendProcessing);
241 BOOST_CHECK(peerLogic->SendMessages(nodes[1]));
242 }
243 // [0] is still discouraged/disconnected.
244 BOOST_CHECK(banman->IsDiscouraged(addr[0]));
245 BOOST_CHECK(nodes[0]->fDisconnect);
246 // [1] is not discouraged/disconnected yet.
247 BOOST_CHECK(!banman->IsDiscouraged(addr[1]));
248 BOOST_CHECK(!nodes[1]->fDisconnect);
249 peerLogic->Misbehaving(nodes[1]->GetId(), 1, /* message */ ""); // [1] reaches discouragement threshold
250 {
251 LOCK(nodes[1]->cs_sendProcessing);
252 BOOST_CHECK(peerLogic->SendMessages(nodes[1]));
253 }
254 // Expect both [0] and [1] to be discouraged/disconnected now.
255 BOOST_CHECK(banman->IsDiscouraged(addr[0]));
256 BOOST_CHECK(nodes[0]->fDisconnect);
257 BOOST_CHECK(banman->IsDiscouraged(addr[1]));
258 BOOST_CHECK(nodes[1]->fDisconnect);
259
260 // Make sure non-IP peers are discouraged and disconnected properly.
261
262 nodes[2] = new CNode{id++, NODE_NETWORK, INVALID_SOCKET, addr[2], /* nKeyedNetGroupIn */ 1,
263 /* nLocalHostNonceIn */ 1, CAddress(), /* pszDest */ "",
264 ConnectionType::OUTBOUND_FULL_RELAY, /* inbound_onion */ false};
265 nodes[2]->SetCommonVersion(PROTOCOL_VERSION);
266 peerLogic->InitializeNode(nodes[2]);
267 nodes[2]->fSuccessfullyConnected = true;
268 connman->AddTestNode(*nodes[2]);
269 peerLogic->Misbehaving(nodes[2]->GetId(), DISCOURAGEMENT_THRESHOLD, /* message */ "");
270 {
271 LOCK(nodes[2]->cs_sendProcessing);
272 BOOST_CHECK(peerLogic->SendMessages(nodes[2]));
273 }
274 BOOST_CHECK(banman->IsDiscouraged(addr[0]));
275 BOOST_CHECK(banman->IsDiscouraged(addr[1]));
276 BOOST_CHECK(banman->IsDiscouraged(addr[2]));
277 BOOST_CHECK(nodes[0]->fDisconnect);
278 BOOST_CHECK(nodes[1]->fDisconnect);
279 BOOST_CHECK(nodes[2]->fDisconnect);
280
281 for (CNode* node : nodes) {
282 peerLogic->FinalizeNode(*node);
283 }
284 connman->ClearTestNodes();
285}
286
288{
289 const CChainParams& chainparams = Params();
290 auto banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
291 auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
292 auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(),
293 *m_node.chainman, *m_node.mempool, false);
294
295 banman->ClearBanned();
296 int64_t nStartTime = GetTime();
297 SetMockTime(nStartTime); // Overrides future calls to GetTime()
298
299 CAddress addr(ip(0xa0b0c001), NODE_NONE);
300 CNode dummyNode(id++, NODE_NETWORK, INVALID_SOCKET, addr, /* nKeyedNetGroupIn */ 4, /* nLocalHostNonceIn */ 4, CAddress(), /* pszDest */ "", ConnectionType::INBOUND, /* inbound_onion */ false);
302 peerLogic->InitializeNode(&dummyNode);
303 dummyNode.fSuccessfullyConnected = true;
304
305 peerLogic->Misbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD, /* message */ "");
306 {
307 LOCK(dummyNode.cs_sendProcessing);
308 BOOST_CHECK(peerLogic->SendMessages(&dummyNode));
309 }
310 BOOST_CHECK(banman->IsDiscouraged(addr));
311
312 peerLogic->FinalizeNode(dummyNode);
313}
314
316{
317public:
319 {
320 return m_orphans.size();
321 }
322
324 {
325 std::map<uint256, OrphanTx>::iterator it;
326 it = m_orphans.lower_bound(InsecureRand256());
327 if (it == m_orphans.end())
328 it = m_orphans.begin();
329 return it->second.tx;
330 }
331};
332
334{
335 std::vector<unsigned char> keydata;
336 keydata = g_insecure_rand_ctx.randbytes(32);
337 key.Set(keydata.data(), keydata.data() + keydata.size(), /*fCompressedIn*/ true);
338 assert(key.IsValid());
339}
340
341BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
342{
343 // This test had non-deterministic coverage due to
344 // randomly selected seeds.
345 // This seed is chosen so that all branches of the function
346 // ecdsa_signature_parse_der_lax are executed during this test.
347 // Specifically branches that run only when an ECDSA
348 // signature's R and S values have leading zeros.
350
351 TxOrphanageTest orphanage;
352 CKey key;
355 BOOST_CHECK(keystore.AddKey(key));
356
358
359 // 50 orphan transactions:
360 for (int i = 0; i < 50; i++)
361 {
363 tx.vin.resize(1);
364 tx.vin[0].prevout.n = 0;
365 tx.vin[0].prevout.hash = InsecureRand256();
366 tx.vin[0].scriptSig << OP_1;
367 tx.vout.resize(1);
368 tx.vout[0].nValue = 1*CENT;
369 tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
370
371 orphanage.AddTx(MakeTransactionRef(tx), i);
372 }
373
374 // ... and 50 that depend on other orphans:
375 for (int i = 0; i < 50; i++)
376 {
377 CTransactionRef txPrev = orphanage.RandomOrphan();
378
380 tx.vin.resize(1);
381 tx.vin[0].prevout.n = 0;
382 tx.vin[0].prevout.hash = txPrev->GetHash();
383 tx.vout.resize(1);
384 tx.vout[0].nValue = 1*CENT;
385 tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
386 BOOST_CHECK(SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL));
387
388 orphanage.AddTx(MakeTransactionRef(tx), i);
389 }
390
391 // This really-big orphan should be ignored:
392 for (int i = 0; i < 10; i++)
393 {
394 CTransactionRef txPrev = orphanage.RandomOrphan();
395
397 tx.vout.resize(1);
398 tx.vout[0].nValue = 1*CENT;
399 tx.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
400 tx.vin.resize(2777);
401 for (unsigned int j = 0; j < tx.vin.size(); j++)
402 {
403 tx.vin[j].prevout.n = j;
404 tx.vin[j].prevout.hash = txPrev->GetHash();
405 }
406 BOOST_CHECK(SignSignature(keystore, *txPrev, tx, 0, SIGHASH_ALL));
407 // Re-use same signature for other inputs
408 // (they don't have to be valid for this test)
409 for (unsigned int j = 1; j < tx.vin.size(); j++)
410 tx.vin[j].scriptSig = tx.vin[0].scriptSig;
411
412 BOOST_CHECK(!orphanage.AddTx(MakeTransactionRef(tx), i));
413 }
414
415 // Test EraseOrphansFor:
416 for (NodeId i = 0; i < 3; i++)
417 {
418 size_t sizeBefore = orphanage.CountOrphans();
419 orphanage.EraseForPeer(i);
420 BOOST_CHECK(orphanage.CountOrphans() < sizeBefore);
421 }
422
423 // Test LimitOrphanTxSize() function:
424 orphanage.LimitOrphans(40);
425 BOOST_CHECK(orphanage.CountOrphans() <= 40);
426 orphanage.LimitOrphans(10);
427 BOOST_CHECK(orphanage.CountOrphans() <= 10);
428 orphanage.LimitOrphans(0);
429 BOOST_CHECK(orphanage.CountOrphans() == 0);
430}
431
uint256 ArithToUint256(const arith_uint256 &a)
static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME
Definition: banman.h:19
NodeContext m_node
Definition: bitcoin-gui.cpp:36
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:118
const CChainParams & Params()
Return the currently selected parameters.
A CService with information about it as peer.
Definition: protocol.h:359
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Definition: chainparams.h:70
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:82
uint16_t GetDefaultPort() const
Definition: chainparams.h:84
An encapsulated private key.
Definition: key.h:27
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:93
CPubKey GetPubKey() const
Compute the public key from a private key.
Definition: key.cpp:187
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition: key.h:73
Network address.
Definition: netaddress.h:119
bool SetSpecial(const std::string &addr)
Parse a Tor or I2P address and set this object to it.
Definition: netaddress.cpp:212
Information about a peer.
Definition: net.h:394
NodeId GetId() const
Definition: net.h:585
RecursiveMutex cs_sendProcessing
Definition: net.h:419
void SetCommonVersion(int greatest_common_version)
Definition: net.h:610
std::atomic_bool fSuccessfullyConnected
fSuccessfullyConnected is set to true on receiving VERACK from the peer.
Definition: net.h:449
Mutex cs_vSend
Definition: net.h:411
std::atomic_bool fDisconnect
Definition: net.h:452
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:523
Fast randomness source.
Definition: random.h:120
std::vector< unsigned char > randbytes(size_t len)
Generate random bytes.
Definition: random.cpp:626
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
Definition: random.h:172
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddKey(const CKey &key)
virtual void InitializeNode(CNode *pnode)=0
Initialize a peer (setup state, queue any initial messages)
static std::unique_ptr< PeerManager > make(const CChainParams &chainparams, CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, bool ignore_incoming_txs)
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphan...
Definition: txorphanage.h:21
void EraseForPeer(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Erase all orphans announced by a peer (eg, after that peer disconnects)
Definition: txorphanage.cpp:88
bool AddTx(const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Add a new orphan transaction.
Definition: txorphanage.cpp:20
void EraseForBlock(const CBlock &block) LOCKS_EXCLUDED(unsigned int LimitOrphans(unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Erase all orphans included in or invalidated by a new block.
Definition: txorphanage.h:44
CTransactionRef RandomOrphan() EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
size_t CountOrphans() const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
256-bit unsigned big integer.
#define INVALID_SOCKET
Definition: compat.h:53
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
static void AddRandomOutboundPeer(std::vector< CNode * > &vNodes, PeerManager &peerLogic, ConnmanTestMsg &connman)
static void MakeNewKeyWithFastRandomContext(CKey &key)
void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
static CService ip(uint32_t i)
@ SIGHASH_ALL
Definition: interpreter.h:27
static const std::string addr1
Definition: key_tests.cpp:24
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS
The maximum number of peer connections to maintain.
Definition: net.h:71
@ OUTBOUND_FULL_RELAY
These are the default connections that we use to connect with the network.
@ INBOUND
Inbound connections are those initiated by a peer.
int64_t NodeId
Definition: net.h:87
static const int MAX_FEELER_CONNECTIONS
Maximum number of feeler connections.
Definition: net.h:67
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS
Maximum number of automatic outgoing nodes over which we'll relay everything (blocks,...
Definition: net.h:61
static const int DISCOURAGEMENT_THRESHOLD
Threshold for marking a node to be discouraged, e.g.
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_CHECK(expr)
Definition: object.cpp:17
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:387
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
ServiceFlags
nServices flags
Definition: protocol.h:271
@ NODE_NONE
Definition: protocol.h:274
@ NODE_WITNESS
Definition: protocol.h:284
@ NODE_NETWORK
Definition: protocol.h:277
@ OP_1
Definition: script.h:76
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
static constexpr CAmount CENT
Definition: setup_common.h:71
static uint256 InsecureRand256()
Definition: setup_common.h:66
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType)
Produce a script signature for a transaction.
Definition: sign.cpp:514
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:310
int m_max_outbound_full_relay
Definition: net.h:748
int nMaxFeeler
Definition: net.h:751
int nMaxConnections
Definition: net.h:747
A mutable version of CTransaction.
Definition: transaction.h:345
std::vector< CTxOut > vout
Definition: transaction.h:347
std::vector< CTxIn > vin
Definition: transaction.h:346
void AddTestNode(CNode &node)
Definition: net.h:26
int64_t nPowTargetSpacing
Definition: params.h:103
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:47
std::unique_ptr< AddrMan > addrman
Definition: context.h:42
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:44
Testing setup that configures a complete environment.
Definition: setup_common.h:99
#define LOCK(cs)
Definition: sync.h:226
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:101
int64_t GetTime()
DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
Definition: time.cpp:26
RecursiveMutex g_cs_orphans
Guards orphan transactions and extra txs for compact blocks.
Definition: txorphanage.cpp:18
assert(!tx.IsCoinBase())
static const int PROTOCOL_VERSION
network protocol versioning
Definition: version.h:12