Skip to content

Commit

Permalink
Merge pull request jl777#429 from dimxy/dev-komodo-vsolution-fix
Browse files Browse the repository at this point in the history
ExtractDestination is disabled to have vsolutions size > 1
ca333 authored May 15, 2021
2 parents 1b06dc8 + 1f46d47 commit caba74c
Showing 4 changed files with 32 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/komodo-tx.cpp
Original file line number Diff line number Diff line change
@@ -200,6 +200,12 @@ int32_t komodo_nextheight()
return(100000000);
}

// function stub to allow build komodo-tx
bool komodo_is_vSolutionsFixActive()
{
return true;
}


// Set default values of new CMutableTransaction based on consensus rules at given height.
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight)
7 changes: 7 additions & 0 deletions src/komodo_utils.h
Original file line number Diff line number Diff line change
@@ -2497,3 +2497,10 @@ void komodo_prefetch(FILE *fp)
}
fseek(fp,fpos,SEEK_SET);
}

// check if block timestamp is more than S5 activation time
// this function is to activate the ExtractDestination fix
bool komodo_is_vSolutionsFixActive()
{
return GetLatestTimestamp(komodo_currentheight()) > nS5Timestamp;
}
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_is_vSolutionsFixActive(); // 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_is_vSolutionsFixActive())
{
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_is_vSolutionsFixActive()) // 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;
6 changes: 6 additions & 0 deletions src/wallet-utility.cpp
Original file line number Diff line number Diff line change
@@ -356,3 +356,9 @@ int main(int argc, char* argv[])
else
return -1;
}

// function stub to allow build wallet-utility
bool komodo_is_vSolutionsFixActive()
{
return true;
}

0 comments on commit caba74c

Please sign in to comment.