Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spark/sparkwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ CWalletTx CSparkWallet::CreateSparkSpendTransaction(
nHeight = chainActive.Height();
}

if (vOut > consensusParams.GetMaxValueSparkSpendPerBlock(nHeight))
if (vOut > consensusParams.GetMaxValueSparkSpendPerTransaction(nHeight))
throw std::runtime_error(_("Spend to transparent address limit exceeded."));

std::vector<CWalletTx> result;
Expand Down
16 changes: 2 additions & 14 deletions src/test/spark_mintspend_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,10 @@ BOOST_AUTO_TEST_CASE(spark_limit_test)
BOOST_CHECK_EQUAL(chainActive.Height(), prevHeight);
mempool.clear();

auto spend5 = GenerateSparkSpend({1100 * COIN}, {}, nullptr);
BOOST_CHECK_THROW(GenerateSparkSpend({1100 * COIN}, {}, nullptr), std::runtime_error);
// Check that the spend of 1100 FIRO has not made it into the mempool
BOOST_CHECK_MESSAGE(mempool.size() == 0, "1100 FIRO SparkSpend should not be added to mempool");

// Try to process a block with the 1100 FIRO spend and ensure it is rejected
prevHeight = chainActive.Height();
CBlock block3 = CreateBlock({CMutableTransaction(spend5)}, script);
BOOST_CHECK_MESSAGE(!ProcessNewBlock(chainparams, std::make_shared<const CBlock>(block3), true, NULL), "Block with 1100 FIRO SparkSpend should not be processed");
BOOST_CHECK_EQUAL(chainActive.Height(), prevHeight);

// advance to block 1500 so new limits are applied
GenerateBlocks(1500 - chainActive.Height());
// After block 1500, limits should be updated, so try spending 800 + 800 again
Expand All @@ -191,13 +185,7 @@ BOOST_AUTO_TEST_CASE(spark_limit_test)
BOOST_CHECK_MESSAGE(ProcessNewBlock(chainparams, std::make_shared<const CBlock>(block4), true, NULL), "Block with two 800 FIRO spends after limit update failed to process");
BOOST_CHECK_EQUAL(chainActive.Height(), postLimitHeight + 1);

// single spend of 1100 FIRO should now be allowed
prevHeight = chainActive.Height();
CBlock block5 = CreateBlock({CMutableTransaction(spend5)}, script);
BOOST_CHECK_MESSAGE(ProcessNewBlock(chainparams, std::make_shared<const CBlock>(block5), true, NULL), "Block with 1100 FIRO SparkSpend after limit update failed to process");
BOOST_CHECK_EQUAL(chainActive.Height(), prevHeight + 1);

auto spend6 = GenerateSparkSpend({3100 * COIN}, {}, nullptr);
BOOST_CHECK_THROW(GenerateSparkSpend({3100 * COIN}, {}, nullptr), std::runtime_error);
// Check that the spend of 3100 FIRO has not made it into the mempool
BOOST_CHECK_MESSAGE(mempool.size() == 0, "3100 FIRO SparkSpend should not be added to mempool");

Expand Down
Loading