16 #include <boost/test/unit_test.hpp> 25 return m_orphans.size();
30 std::map<uint256, OrphanTx>::iterator it;
32 if (it == m_orphans.end())
33 it = m_orphans.begin();
40 std::vector<unsigned char> keydata;
42 key.
Set(keydata.data(), keydata.data() + keydata.size(),
true);
65 for (
int i = 0; i < 50; i++)
69 tx.
vin[0].prevout.n = 0;
80 for (
int i = 0; i < 50; i++)
86 tx.
vin[0].prevout.n = 0;
87 tx.
vin[0].prevout.hash = txPrev->GetHash();
97 for (
int i = 0; i < 10; i++)
106 for (
unsigned int j = 0; j < tx.
vin.size(); j++)
108 tx.
vin[j].prevout.n = j;
109 tx.
vin[j].prevout.hash = txPrev->GetHash();
114 for (
unsigned int j = 1; j < tx.
vin.size(); j++)
115 tx.
vin[j].scriptSig = tx.
vin[0].scriptSig;
121 for (
NodeId i = 0; i < 3; i++)
std::shared_ptr< const CTransaction > CTransactionRef
RecursiveMutex g_cs_orphans
Guards orphan transactions and extra txs for compact blocks.
bool AddTx(const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Add a new orphan transaction.
CPubKey GetPubKey() const
Compute the public key from a private key.
A class to track orphan transactions (failed on TX_MISSING_INPUTS) Since we cannot distinguish orphan...
void EraseForPeer(NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Erase all orphans announced by a peer (eg, after that peer disconnects)
size_t CountOrphans() const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
void EraseForBlock(const CBlock &block) LOCKS_EXCLUDED(void LimitOrphans(unsigned int max_orphans) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
Erase all orphans included in or invalidated by a new block.
FastRandomContext g_insecure_rand_ctx
This global and the helpers that use it are not thread-safe.
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.
BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
CTransactionRef RandomOrphan() EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
BOOST_AUTO_TEST_SUITE_END()
Fillable signing provider that keeps keys in an address->secret map.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::vector< CTxOut > vout
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
static void MakeNewKeyWithFastRandomContext(CKey &key)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
A mutable version of CTransaction.
static constexpr CAmount CENT
An encapsulated private key.
static uint256 InsecureRand256()
Testing setup that configures a complete environment.
std::vector< unsigned char > randbytes(size_t len)
Generate random bytes.
virtual bool AddKey(const CKey &key)
bool IsValid() const
Check whether this private key is valid.
#define BOOST_CHECK(expr)