mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
skip balance checks when assumevalid is active
This commit is contained in:
parent
93cabbf1e9
commit
2ccbf87b04
4 changed files with 12 additions and 10 deletions
|
|
@ -102,7 +102,7 @@ BOOST_AUTO_TEST_CASE(witness_valid)
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
CCoinsView coinsDummy;
|
CCoinsView coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
BOOST_CHECK(Consensus::CheckTxInputs(tx, state, coins, 0, setPeginsSpent, nullptr, false));
|
BOOST_CHECK(Consensus::CheckTxInputs(tx, state, coins, 0, setPeginsSpent, nullptr, false, true));
|
||||||
BOOST_CHECK(setPeginsSpent.size() == 1);
|
BOOST_CHECK(setPeginsSpent.size() == 1);
|
||||||
setPeginsSpent.clear();
|
setPeginsSpent.clear();
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(witness_valid)
|
||||||
CMutableTransaction mtxn(tx);
|
CMutableTransaction mtxn(tx);
|
||||||
mtxn.wit.vtxinwit[0].m_pegin_witness.SetNull();
|
mtxn.wit.vtxinwit[0].m_pegin_witness.SetNull();
|
||||||
CTransaction tx2(mtxn);
|
CTransaction tx2(mtxn);
|
||||||
BOOST_CHECK(!Consensus::CheckTxInputs(tx2, state, coins, 0, setPeginsSpent, nullptr, false));
|
BOOST_CHECK(!Consensus::CheckTxInputs(tx2, state, coins, 0, setPeginsSpent, nullptr, false, true));
|
||||||
BOOST_CHECK(setPeginsSpent.empty());
|
BOOST_CHECK(setPeginsSpent.empty());
|
||||||
|
|
||||||
// Invalidate peg-in (and spending) authorization by pegin marker.
|
// Invalidate peg-in (and spending) authorization by pegin marker.
|
||||||
|
|
@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(witness_valid)
|
||||||
CMutableTransaction mtxn2(tx);
|
CMutableTransaction mtxn2(tx);
|
||||||
mtxn2.vin[0].m_is_pegin = false;
|
mtxn2.vin[0].m_is_pegin = false;
|
||||||
CTransaction tx3(mtxn2);
|
CTransaction tx3(mtxn2);
|
||||||
BOOST_CHECK(!Consensus::CheckTxInputs(tx3, state, coins, 0, setPeginsSpent, nullptr, false));
|
BOOST_CHECK(!Consensus::CheckTxInputs(tx3, state, coins, 0, setPeginsSpent, nullptr, false, true));
|
||||||
BOOST_CHECK(setPeginsSpent.empty());
|
BOOST_CHECK(setPeginsSpent.empty());
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -764,7 +764,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
|
std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
|
||||||
bool fCheckResult = tx.IsCoinBase() ||
|
bool fCheckResult = tx.IsCoinBase() ||
|
||||||
Consensus::CheckTxInputs(tx, state, mempoolDuplicate, nSpendHeight, setPeginsSpent, NULL, false);
|
Consensus::CheckTxInputs(tx, state, mempoolDuplicate, nSpendHeight, setPeginsSpent, NULL, false, true);
|
||||||
assert(fCheckResult);
|
assert(fCheckResult);
|
||||||
UpdateCoins(tx, mempoolDuplicate, 1000000);
|
UpdateCoins(tx, mempoolDuplicate, 1000000);
|
||||||
assert(setPeginsSpent == it->setPeginsSpent);
|
assert(setPeginsSpent == it->setPeginsSpent);
|
||||||
|
|
@ -785,7 +785,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||||
} else {
|
} else {
|
||||||
std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
|
std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
|
||||||
bool fCheckResult = entry->GetTx().IsCoinBase() ||
|
bool fCheckResult = entry->GetTx().IsCoinBase() ||
|
||||||
Consensus::CheckTxInputs(entry->GetTx(), state, mempoolDuplicate, nSpendHeight, setPeginsSpent, NULL, false);
|
Consensus::CheckTxInputs(entry->GetTx(), state, mempoolDuplicate, nSpendHeight, setPeginsSpent, NULL, false, true);
|
||||||
assert(fCheckResult);
|
assert(fCheckResult);
|
||||||
UpdateCoins(entry->GetTx(), mempoolDuplicate, 1000000);
|
UpdateCoins(entry->GetTx(), mempoolDuplicate, 1000000);
|
||||||
assert(setPeginsSpent == entry->setPeginsSpent);
|
assert(setPeginsSpent == entry->setPeginsSpent);
|
||||||
|
|
|
||||||
|
|
@ -1844,7 +1844,7 @@ int GetSpendHeight(const CCoinsViewCache& inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Consensus {
|
namespace Consensus {
|
||||||
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, std::set<std::pair<uint256, COutPoint> >& setPeginsSpent, std::vector<CCheck*> *pvChecks, const bool cacheStore)
|
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, std::set<std::pair<uint256, COutPoint> >& setPeginsSpent, std::vector<CCheck*> *pvChecks, const bool cacheStore, bool fScriptChecks)
|
||||||
{
|
{
|
||||||
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
||||||
// for an attacker to attempt to split the network.
|
// for an attacker to attempt to split the network.
|
||||||
|
|
@ -1893,11 +1893,13 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tally transaction fees
|
// Tally transaction fees
|
||||||
if (!tx.HasValidFee())
|
if (!tx.HasValidFee()) {
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-fee-outofrange");
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-fee-outofrange");
|
||||||
if (!VerifyAmounts(inputs, tx, pvChecks, cacheStore))
|
}
|
||||||
|
if (fScriptChecks && !VerifyAmounts(inputs, tx, pvChecks, cacheStore)) {
|
||||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-ne-out", false,
|
return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-ne-out", false,
|
||||||
strprintf("value in (%s) != value out", FormatMoney(nValueIn)));
|
strprintf("value in (%s) != value out", FormatMoney(nValueIn)));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1907,7 +1909,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
|
||||||
{
|
{
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
{
|
{
|
||||||
if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs), setPeginsSpent, pvChecks, cacheStore))
|
if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs), setPeginsSpent, pvChecks, cacheStore, fScriptChecks))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pvChecks)
|
if (pvChecks)
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ namespace Consensus {
|
||||||
* This does not modify the UTXO set. This does not check scripts and sigs.
|
* This does not modify the UTXO set. This does not check scripts and sigs.
|
||||||
* Preconditions: tx.IsCoinBase() is false.
|
* Preconditions: tx.IsCoinBase() is false.
|
||||||
*/
|
*/
|
||||||
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, std::set<std::pair<uint256, COutPoint> >& setPeginsSpent, std::vector<CCheck*> *pvChecks, const bool cacheStore);
|
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, std::set<std::pair<uint256, COutPoint> >& setPeginsSpent, std::vector<CCheck*> *pvChecks, const bool cacheStore, bool fScriptChecks);
|
||||||
|
|
||||||
} // namespace Consensus
|
} // namespace Consensus
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue