Skip to content

Suggested changes in the komodod code for Marmara

dimxy edited this page Jun 28, 2020 · 2 revisions

Suggested changes in komodod basic code needed for Marmara to work

Working on Marmara I had to make some changes in komodod basic code to enable some features for Marmara.

New CCtxidaddr_tweak function

This function is like the existing CCtxidaddr function but the new one also tweaks the last byte of the pubkey created from a txid, to make the created pubkey valid that is checked with secp256k1_ec_pubkey_parse function. Without this validation, a cryptocondition deserialization from JSON function (secp256k1FromJSON) fails. I suggest to use this function in all contracts to enable all tx be serializable to JSON correctly used in marmara

Adding pubkeys to CC opret

Here is how MakeCC1vout now looks like:

CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue, CPubKey pk, std::vector<std::vector<unsigned char>>* vData)
{
    CTxOut vout;
    CC *payoutCond = MakeCCcond1(evalcode,pk);
    vout = CTxOut(nValue,CCPubKey(payoutCond));
    if ( vData )
    {
        //std::vector<std::vector<unsigned char>> vtmpData = std::vector<std::vector<unsigned char>>(vData->begin(), vData->end());
        std::vector<CPubKey> vPubKeys = std::vector<CPubKey>();
        //vPubKeys.push_back(pk);
        COptCCParams ccp = COptCCParams(COptCCParams::VERSION, evalcode, 1, 1, vPubKeys, ( * vData));
        vout.scriptPubKey << ccp.AsVector() << OP_DROP;
    }
    cc_free(payoutCond);
    return(vout);
}

Why is addition the pubkey to COptCCParams commented out? It is important for Marmara and Tokens CC to identify their cc vouts. For this, vPubkeys vector is extremely useful. Can we still add it back to COptCCParams? Yet another reason for this is the the cc opret parsing function COptCCParams(std::vector<unsigned char> &vch) does not work now because it expects to find the pubkey in the vch array.

(The same considerations are for MakeCC1of2vout function where adding 2 pubkeys is currently commented out.

in marmara

Changes in ExtractDestination function

Remove the code that added the M-of-N pubkey as vSolution[1] done in the codebase in May 2020

Clone this wiki locally