Skip to content

Commit

Permalink
disable vSolutions > 1 in Solver and ExtractDestination after June 20…
Browse files Browse the repository at this point in the history
…21 HF to prevent index breaking
  • Loading branch information
dimxy committed May 12, 2021
1 parent b48dc3a commit c7b4229
Showing 2 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/komodo_utils.h
Original file line number Diff line number Diff line change
@@ -2497,3 +2497,8 @@ void komodo_prefetch(FILE *fp)
}
fseek(fp,fpos,SEEK_SET);
}

bool komodo_Is2021JuneHFActive()
{
return GetLatestTimestamp(komodo_currentheight()) < JUNE2021_NNELECTION_HARDFORK;
}
19 changes: 13 additions & 6 deletions src/script/standard.cpp
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ typedef vector<unsigned char> valtype;

unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY;

bool komodo_Is2021JuneHFActive(); // didn't want to bring komodo headers here, it's a special case to bypass bad code in Solver() and ExtractDestination()

COptCCParams::COptCCParams(std::vector<unsigned char> &vch)
{
CScript inScr = CScript(vch.begin(), vch.end());
@@ -244,14 +246,19 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::v
for (i=0; i<20; i++)
ptr[i] = hash20[i];
vSolutionsRet.push_back(hashBytes);
if (vParams.size())

if (!komodo_Is2021JuneHFActive())
{
COptCCParams cp = COptCCParams(vParams[0]);
if (cp.IsValid())
// allow this code before the hardfork if anyone might accidentally try it
if (vParams.size())
{
for (auto k : cp.vKeys)
COptCCParams cp = COptCCParams(vParams[0]);
if (cp.IsValid())
{
vSolutionsRet.push_back(std::vector<unsigned char>(k.begin(), k.end()));
for (auto k : cp.vKeys)
{
vSolutionsRet.push_back(std::vector<unsigned char>(k.begin(), k.end())); // we do not need opdrop pubkeys in vSolution as it breaks indexes
}
}
}
}
@@ -385,7 +392,7 @@ bool ExtractDestination(const CScript& _scriptPubKey, CTxDestination& addressRet

else if (IsCryptoConditionsEnabled() != 0 && whichType == TX_CRYPTOCONDITION)
{
if (vSolutions.size() > 1)
if (vSolutions.size() > 1 && !komodo_Is2021JuneHFActive()) // allow this temporarily before the HF; actually this is incorrect to use opdrop's pubkey as the address
{
CPubKey pk = CPubKey((vSolutions[1]));
addressRet = pk;

0 comments on commit c7b4229

Please sign in to comment.