Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 committed Oct 7, 2024
1 parent d9a3276 commit dc29f5b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ class CRegTestParams : public CChainParams {
consensus.nLelantusStartBlock = 400;
consensus.nLelantusFixesStartBlock = 400;
consensus.nSparkStartBlock = 1000;
consensus.nSparkCoinbase = 1300;
consensus.nSparkCoinbase = consensus.nSparkStartBlock;
consensus.nExchangeAddressStartBlock = 1000;
consensus.nLelantusGracefulPeriod = 1500;
consensus.nZerocoinV2MintMempoolGracefulPeriod = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/libspark/coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Coin {
if (ser_action.ForRead()) {
this->params = spark::Params::get_default();
}
if ((type == COIN_TYPE_MINT || COIN_TYPE_COINBASE) && r_.ciphertext.size() != (1 + AES_BLOCKSIZE) + SCALAR_ENCODING + (1 + params->get_memo_bytes() + 1)) {
if ((type == COIN_TYPE_MINT || type == COIN_TYPE_COINBASE) && r_.ciphertext.size() != (1 + AES_BLOCKSIZE) + SCALAR_ENCODING + (1 + params->get_memo_bytes() + 1)) {
throw std::invalid_argument("Cannot deserialize mint coin due to bad encrypted data");
}
if (type == COIN_TYPE_SPEND && r_.ciphertext.size() != 8 + (1 + AES_BLOCKSIZE) + SCALAR_ENCODING + (1 + params->get_memo_bytes() + 1)) {
Expand Down
21 changes: 19 additions & 2 deletions src/spark/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool IsPayToSparkAddress(const CScript& script)
}

bool IsPayToSparkAddress(const CScript& script, spark::Address& addr)
{ if (script[script.size()-1] != OP_SPARKMINT)
{ if (script.empty() || script[script.size()-1] != OP_SPARKMINT)
return false;
unsigned char network = spark::GetNetworkType();
unsigned char coinNetwork;
Expand All @@ -102,6 +102,9 @@ bool IsPayToSparkAddress(const CScript& script, spark::Address& addr)
}

std::string ToStringSparkAddress(const CScript script) {
if (script.empty())
return "";

std::vector<unsigned char> vch(script.begin() + 2, script.end() - 1);
try {
const spark::Params* params = spark::Params::get_default();
Expand Down Expand Up @@ -893,7 +896,21 @@ std::vector<unsigned char> getSerialContext(const CTransaction &tx) {
return std::vector<unsigned char>();
}
} else if (tx.IsCoinBase()) {
std::vector<spark::Coin> coins = GetSparkMintCoins(tx);
std::vector<spark::Coin> coins;

for (const auto& vout : tx.vout) {
const auto& script = vout.scriptPubKey;
if (script.IsSparkMint()) {
try {
spark::Coin coin(Params::get_default());
ParseSparkMintCoin(script, coin);
coins.push_back(coin);
} catch (const std::exception &) {
//Continue
}
}
}

if (coins.empty())
return std::vector<unsigned char>();

Expand Down

0 comments on commit dc29f5b

Please sign in to comment.