@@ -94,7 +94,8 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
//
|
||||
// Start
|
||||
//
|
||||
extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,ASSETCHAIN_INIT;
|
||||
extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY;
|
||||
extern uint32_t ASSETCHAIN_INIT;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
int32_t komodo_is_issuer();
|
||||
void komodo_passport_iteration();
|
||||
|
||||
@@ -51,11 +51,6 @@ one other technical note is that komodod has the insight-explorer extensions bui
|
||||
#include "../utlist.h"
|
||||
#include "../uthash.h"
|
||||
|
||||
extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
extern char ASSETCHAINS_SYMBOL[];
|
||||
extern std::string CCerror,ASSETCHAINS_CCLIB;
|
||||
extern uint8_t ASSETCHAINS_CCDISABLES[256];
|
||||
|
||||
#define CC_MAXVINS 1024
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> param
|
||||
|
||||
extern struct CCcontract_info CCinfos[0x100];
|
||||
extern std::string MYCCLIBNAME;
|
||||
bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx,unsigned int nIn);
|
||||
bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx,unsigned int nIn);
|
||||
|
||||
bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector<uint8_t> paramsNull,const CTransaction &txTo,unsigned int nIn)
|
||||
{
|
||||
@@ -670,9 +670,9 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector<uint8_t> paramsNull,co
|
||||
CCclearvars(cp);
|
||||
if ( paramsNull.size() != 0 ) // Don't expect params
|
||||
return eval->Invalid("Cannot have params");
|
||||
else if ( CClib_validate(cp,eval,txTo,nIn) != 0 )
|
||||
else if ( CClib_validate(cp,height,eval,txTo,nIn) != 0 )
|
||||
return(true);
|
||||
return eval->Invalid("error in CClib_validate");
|
||||
return(false); //eval->Invalid("error in CClib_validate");
|
||||
}
|
||||
return eval->Invalid("cclib CC must have evalcode between 16 and 127");
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ bool CClibExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction
|
||||
else return(true);
|
||||
}
|
||||
|
||||
bool CClib_validate(struct CCcontract_info *cp,Eval *eval,const CTransaction tx,unsigned int nIn)
|
||||
bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const CTransaction tx,unsigned int nIn)
|
||||
{
|
||||
int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,numblocks; bool retval; uint256 txid; uint8_t hash[32]; char str[65],destaddr[64];
|
||||
std::vector<std::pair<CAddressIndexKey, CAmount> > txids;
|
||||
|
||||
@@ -94,7 +94,7 @@ uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32
|
||||
{
|
||||
return(script[1]);
|
||||
} else fprintf(stderr,"DecodeMaramaraCoinbaseOpRet unmarshal error for %c\n",script[1]);
|
||||
} else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d or 'L' %d\n",script[1],'C','P','L');
|
||||
} //else fprintf(stderr,"script[1] is %d != 'C' %d or 'P' %d or 'L' %d\n",script[1],'C','P','L');
|
||||
} else fprintf(stderr,"vopret.size() is %d\n",(int32_t)vopret.size());
|
||||
return(0);
|
||||
}
|
||||
@@ -255,6 +255,22 @@ int32_t MarmaraValidateCoinbase(int32_t height,CTransaction tx)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx)
|
||||
{
|
||||
CPubKey Marmarapk,pk; int32_t height,unlockht; uint8_t funcid; char coinaddr[64]; struct CCcontract_info *cp,C;
|
||||
//fprintf(stderr,"%s numvins.%d numvouts.%d %.8f opret[%d]\n",staketx.GetHash().ToString().c_str(),(int32_t)staketx.vin.size(),(int32_t)staketx.vout.size(),(double)staketx.vout[0].nValue/COIN,(int32_t)opret.size());
|
||||
if ( staketx.vout.size() == 2 && opret == staketx.vout[1].scriptPubKey )
|
||||
{
|
||||
cp = CCinit(&C,EVAL_MARMARA);
|
||||
funcid = DecodeMaramaraCoinbaseOpRet(opret,pk,height,unlockht);
|
||||
Marmarapk = GetUnspendable(cp,0);
|
||||
GetCCaddress1of2(cp,coinaddr,Marmarapk,pk);
|
||||
//fprintf(stderr,"matched opret! funcid.%c ht.%d unlock.%d %s\n",funcid,height,unlockht,coinaddr);
|
||||
return(strcmp(destaddr,coinaddr) == 0);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn)
|
||||
{
|
||||
std::vector<uint8_t> vopret; CTransaction vinTx; uint256 hashBlock; int32_t numvins,numvouts,i,ht,unlockht,vht,vunlockht; uint8_t funcid,vfuncid,*script; CPubKey pk,vpk;
|
||||
@@ -318,6 +334,10 @@ bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
else if ( funcid == 'C' ) // coinbase
|
||||
{
|
||||
return(true);
|
||||
}
|
||||
// staking only for locked utxo
|
||||
}
|
||||
return eval->Invalid("fall through error");
|
||||
@@ -485,7 +505,34 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height)
|
||||
return(result);
|
||||
}
|
||||
|
||||
// jl777: decide on what unlockht settlement change should have
|
||||
int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &mtx)
|
||||
{
|
||||
uint256 txid,hashBlock; uint8_t *ptr; int32_t i,siglen,vout,numvouts; CTransaction tx; std::string rawtx; CPubKey mypk; std::vector<CPubKey> pubkeys; struct CCcontract_info *cp,C; uint64_t txfee;
|
||||
txfee = 10000;
|
||||
vout = mtx.vin[0].prevout.n;
|
||||
if ( GetTransaction(mtx.vin[0].prevout.hash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 1 && vout < numvouts )
|
||||
{
|
||||
cp = CCinit(&C,EVAL_MARMARA);
|
||||
mypk = pubkey2pk(Mypubkey());
|
||||
pubkeys.push_back(mypk);
|
||||
rawtx = FinalizeCCTx(0,cp,mtx,mypk,txfee,tx.vout[numvouts - 1].scriptPubKey,pubkeys);
|
||||
if ( rawtx.size() > 0 )
|
||||
{
|
||||
siglen = mtx.vin[0].scriptSig.size();
|
||||
ptr = &mtx.vin[0].scriptSig[0];
|
||||
for (i=0; i<siglen; i++)
|
||||
{
|
||||
utxosig[i] = ptr[i];
|
||||
//fprintf(stderr,"%02x",ptr[i]);
|
||||
}
|
||||
//fprintf(stderr," got signed rawtx.%s siglen.%d\n",rawtx.c_str(),siglen);
|
||||
return(siglen);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
// jl777: decide on what unlockht settlement change should have -> from utxo making change
|
||||
|
||||
UniValue MarmaraSettlement(uint64_t txfee,uint256 refbatontxid)
|
||||
{
|
||||
|
||||
@@ -92,11 +92,6 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st
|
||||
void *chainparams_commandline(void *ptr);
|
||||
#include "komodo_defs.h"
|
||||
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC;
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER;
|
||||
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH;
|
||||
|
||||
const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
|
||||
|
||||
|
||||
@@ -557,9 +557,9 @@ uint64_t komodo_seed(int32_t height)
|
||||
return(seed);
|
||||
}
|
||||
|
||||
uint32_t komodo_txtime(uint64_t *valuep,uint256 hash, int32_t n, char *destaddr)
|
||||
uint32_t komodo_txtime(CScript &opret,uint64_t *valuep,uint256 hash, int32_t n, char *destaddr)
|
||||
{
|
||||
CTxDestination address; CTransaction tx; uint256 hashBlock;
|
||||
CTxDestination address; CTransaction tx; uint256 hashBlock; int32_t numvouts;
|
||||
*valuep = 0;
|
||||
if (!GetTransaction(hash, tx,
|
||||
#ifndef KOMODO_ZCASH
|
||||
@@ -570,10 +570,12 @@ uint32_t komodo_txtime(uint64_t *valuep,uint256 hash, int32_t n, char *destaddr)
|
||||
//fprintf(stderr,"ERROR: %s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
|
||||
return(0);
|
||||
}
|
||||
numvouts = tx.vout.size();
|
||||
//fprintf(stderr,"%s/v%d locktime.%u\n",hash.ToString().c_str(),n,(uint32_t)tx.nLockTime);
|
||||
if ( n < tx.vout.size() )
|
||||
if ( n < numvouts )
|
||||
{
|
||||
*valuep = tx.vout[n].nValue;
|
||||
opret = tx.vout[numvouts-1].scriptPubKey;
|
||||
if (ExtractDestination(tx.vout[n].scriptPubKey, address))
|
||||
strcpy(destaddr,CBitcoinAddress(address).ToString().c_str());
|
||||
}
|
||||
@@ -614,12 +616,12 @@ uint32_t komodo_txtime2(uint64_t *valuep,uint256 hash,int32_t n,char *destaddr)
|
||||
|
||||
int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout)
|
||||
{
|
||||
int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid;
|
||||
int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret;
|
||||
if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 )
|
||||
{
|
||||
txid = pblock->vtx[n-1].vin[0].prevout.hash;
|
||||
vout = pblock->vtx[n-1].vin[0].prevout.n;
|
||||
txtime = komodo_txtime(&value,txid,vout,destaddr);
|
||||
txtime = komodo_txtime(opret,&value,txid,vout,destaddr);
|
||||
if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) )
|
||||
{
|
||||
strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str());
|
||||
@@ -634,28 +636,41 @@ int32_t komodo_WhoStaked(CBlock *pblock, CTxDestination &addressout)
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t komodo_isPoS(CBlock *pblock)
|
||||
bool MarmaraPoScheck(char *destaddr,CScript opret,CTransaction staketx);
|
||||
|
||||
int32_t komodo_isPoS(CBlock *pblock,int32_t height)
|
||||
{
|
||||
int32_t n,vout; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid;
|
||||
int32_t n,vout,numvouts; uint32_t txtime; uint64_t value; char voutaddr[64],destaddr[64]; CTxDestination voutaddress; uint256 txid; CScript opret;
|
||||
if ( ASSETCHAINS_STAKED != 0 )
|
||||
{
|
||||
if ( (n= pblock->vtx.size()) > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1 )
|
||||
n = pblock->vtx.size();
|
||||
//fprintf(stderr,"ht.%d check for PoS numtx.%d numvins.%d numvouts.%d\n",height,n,(int32_t)pblock->vtx[n-1].vin.size(),(int32_t)pblock->vtx[n-1].vout.size());
|
||||
if ( n > 1 && pblock->vtx[n-1].vin.size() == 1 && pblock->vtx[n-1].vout.size() == 1+(ASSETCHAINS_MARMARA!=0) )
|
||||
{
|
||||
txid = pblock->vtx[n-1].vin[0].prevout.hash;
|
||||
vout = pblock->vtx[n-1].vin[0].prevout.n;
|
||||
if ( ASSETCHAINS_MARMARA != 0 )
|
||||
{
|
||||
fprintf(stderr,"validate proper signature and unlockht preservation\n");
|
||||
// need to verify it was signed by the non-Marmarapk of the 1of2
|
||||
}
|
||||
txtime = komodo_txtime(&value,txid,vout,destaddr);
|
||||
txtime = komodo_txtime(opret,&value,txid,vout,destaddr);
|
||||
if ( ExtractDestination(pblock->vtx[n-1].vout[0].scriptPubKey,voutaddress) )
|
||||
{
|
||||
strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str());
|
||||
if ( strcmp(destaddr,voutaddr) == 0 && pblock->vtx[n-1].vout[0].nValue == value )
|
||||
//fprintf(stderr,"voutaddr.%s vs destaddr.%s\n",voutaddr,destaddr);
|
||||
if ( pblock->vtx[n-1].vout[0].nValue == value && strcmp(destaddr,voutaddr) == 0 )
|
||||
{
|
||||
//fprintf(stderr,"is PoS block!\n");
|
||||
return(1);
|
||||
if ( ASSETCHAINS_MARMARA == 0 )
|
||||
return(1);
|
||||
else
|
||||
{
|
||||
if ( pblock->vtx[n-1].vout[0].scriptPubKey.IsPayToCryptoCondition() != 0 && (numvouts= pblock->vtx[n-1].vout.size()) == 2 )
|
||||
{
|
||||
//fprintf(stderr,"validate proper %s %s signature and unlockht preservation\n",voutaddr,destaddr);
|
||||
return(MarmaraPoScheck(destaddr,opret,pblock->vtx[n-1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"reject ht.%d PoS block\n",height);
|
||||
return(1); // allow until MTST3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1195,7 +1210,7 @@ uint32_t komodo_segid32(char *coinaddr)
|
||||
|
||||
int8_t komodo_segid(int32_t nocache,int32_t height)
|
||||
{
|
||||
CTxDestination voutaddress; CBlock block; CBlockIndex *pindex; uint64_t value; uint32_t txtime; char voutaddr[64],destaddr[64]; int32_t txn_count,vout; uint256 txid; int8_t segid = -1;
|
||||
CTxDestination voutaddress; CBlock block; CBlockIndex *pindex; uint64_t value; uint32_t txtime; char voutaddr[64],destaddr[64]; int32_t txn_count,vout; uint256 txid; CScript opret; int8_t segid = -1;
|
||||
if ( height > 0 && (pindex= komodo_chainactive(height)) != 0 )
|
||||
{
|
||||
if ( nocache == 0 && pindex->segid >= -1 )
|
||||
@@ -1207,7 +1222,7 @@ int8_t komodo_segid(int32_t nocache,int32_t height)
|
||||
{
|
||||
txid = block.vtx[txn_count-1].vin[0].prevout.hash;
|
||||
vout = block.vtx[txn_count-1].vin[0].prevout.n;
|
||||
txtime = komodo_txtime(&value,txid,vout,destaddr);
|
||||
txtime = komodo_txtime(opret,&value,txid,vout,destaddr);
|
||||
if ( ExtractDestination(block.vtx[txn_count-1].vout[0].scriptPubKey,voutaddress) )
|
||||
{
|
||||
strcpy(voutaddr,CBitcoinAddress(voutaddress).ToString().c_str());
|
||||
@@ -1449,12 +1464,14 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
|
||||
pindex = it != mapBlockIndex.end() ? it->second : NULL;
|
||||
if ( pindex != 0 && pindex->segid >= -1 )
|
||||
{
|
||||
//fprintf(stderr,"isPoSblock segid.%d\n",pindex->segid);
|
||||
if ( pindex->segid == -1 )
|
||||
return(0);
|
||||
else return(1);
|
||||
}
|
||||
txn_count = pblock->vtx.size();
|
||||
if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 )
|
||||
//fprintf(stderr,"checkblock n.%d vins.%d vouts.%d %.8f %.8f\n",txn_count,(int32_t)pblock->vtx[txn_count-1].vin.size(),(int32_t)pblock->vtx[txn_count-1].vout.size(),(double)pblock->vtx[txn_count-1].vout[0].nValue/COIN,(double)pblock->vtx[txn_count-1].vout[1].nValue/COIN);
|
||||
if ( txn_count > 1 && pblock->vtx[txn_count-1].vin.size() == 1 && pblock->vtx[txn_count-1].vout.size() == 1 + (ASSETCHAINS_MARMARA!=0) )
|
||||
{
|
||||
it = mapBlockIndex.find(pblock->hashPrevBlock);
|
||||
if ( it != mapBlockIndex.end() && (previndex = it->second) != NULL )
|
||||
@@ -1464,7 +1481,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
|
||||
vout = pblock->vtx[txn_count-1].vin[0].prevout.n;
|
||||
if ( prevtime != 0 )
|
||||
{
|
||||
if ( komodo_isPoS(pblock) != 0 )
|
||||
if ( komodo_isPoS(pblock,height) != 0 )
|
||||
{
|
||||
eligible = komodo_stake(1,bnTarget,height,txid,vout,pblock->nTime,prevtime+27,(char *)"");
|
||||
}
|
||||
@@ -1500,7 +1517,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_
|
||||
}
|
||||
if ( slowflag == 0 && isPoS == 0 ) // maybe previous block is not seen yet, do the best approx
|
||||
{
|
||||
if ( komodo_isPoS(pblock) != 0 )
|
||||
if ( komodo_isPoS(pblock,height) != 0 )
|
||||
isPoS = 1;
|
||||
}
|
||||
if ( slowflag != 0 && isPoS != 0 )
|
||||
@@ -1813,6 +1830,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
//fprintf(stderr,"ASSETCHAINS_STAKED.%d ht.%d\n",(int32_t)ASSETCHAINS_STAKED,height);
|
||||
if ( ASSETCHAINS_STAKED != 0 && height >= 2 ) // must PoS or have at least 16x better PoW
|
||||
{
|
||||
if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 )
|
||||
@@ -2069,6 +2087,9 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t MarmaraSignature(uint8_t *utxosig,CMutableTransaction &txNew);
|
||||
uint8_t DecodeMaramaraCoinbaseOpRet(const CScript scriptPubKey,CPubKey &pk,int32_t &height,int32_t &unlockht);
|
||||
|
||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
||||
{
|
||||
static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime;
|
||||
@@ -2150,7 +2171,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
}
|
||||
else
|
||||
{
|
||||
struct CCcontract_info *cp,C; uint256 txid; int32_t vout; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk;
|
||||
struct CCcontract_info *cp,C; uint256 txid; int32_t vout,ht,unlockht; CAmount nValue; char coinaddr[64]; CPubKey mypk,Marmarapk,pk;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
cp = CCinit(&C,EVAL_MARMARA);
|
||||
mypk = pubkey2pk(Mypubkey());
|
||||
@@ -2166,8 +2187,11 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
if ( GetTransaction(txid,tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 && myIsutxo_spentinmempool(txid,vout) == 0 )
|
||||
{
|
||||
const CScript &scriptPubKey = tx.vout[vout].scriptPubKey;
|
||||
array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey);
|
||||
fprintf(stderr,"addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp);
|
||||
if ( DecodeMaramaraCoinbaseOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,pk,ht,unlockht) != 0 && pk == mypk )
|
||||
{
|
||||
array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,txid,vout,coinaddr,hashbuf,(CScript)scriptPubKey);
|
||||
}
|
||||
// else fprintf(stderr,"SKIP addutxo %.8f numkp.%d vs max.%d\n",(double)nValue/COIN,numkp,maxkp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2252,22 +2276,23 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
if ( ASSETCHAINS_MARMARA == 0 )
|
||||
{
|
||||
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, *utxovaluep, SIGHASH_ALL), best_scriptPubKey, sigdata, consensusBranchId);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"add opreturn and CCFinalizetx\n");
|
||||
// add opreturn
|
||||
// signSuccess = CCFinalizetx(...)
|
||||
}
|
||||
if (!signSuccess)
|
||||
fprintf(stderr,"failed to create signature\n");
|
||||
else
|
||||
{
|
||||
UpdateTransaction(txNew,0,sigdata);
|
||||
ptr = (uint8_t *)&sigdata.scriptSig[0];
|
||||
siglen = sigdata.scriptSig.size();
|
||||
for (i=0; i<siglen; i++)
|
||||
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
siglen = MarmaraSignature(utxosig,txNew);
|
||||
if ( siglen > 0 )
|
||||
signSuccess = true;
|
||||
else signSuccess = false;
|
||||
}
|
||||
if (!signSuccess)
|
||||
fprintf(stderr,"failed to create signature\n");
|
||||
else
|
||||
{
|
||||
//fprintf(stderr," siglen.%d\n",siglen);
|
||||
//fprintf(stderr,"best %u from %u, gap %d lag.%d\n",earliest,*blocktimep,(int32_t)(earliest - *blocktimep),(int32_t)(time(NULL) - *blocktimep));
|
||||
*blocktimep = earliest;
|
||||
|
||||
@@ -36,5 +36,43 @@
|
||||
|
||||
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
||||
int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC;
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER;
|
||||
extern uint64_t ASSETCHAINS_SUPPLY;
|
||||
|
||||
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE;
|
||||
|
||||
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,KOMODO_ON_DEMAND,KOMODO_PASSPORT_INITDONE;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED;
|
||||
extern bool VERUS_MINTBLOCKS;
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[];
|
||||
extern const char *ASSETCHAINS_ALGORITHMS[];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
extern uint32_t ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB;
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
|
||||
|
||||
extern char ASSETCHAINS_SYMBOL[65];
|
||||
extern int32_t VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD;
|
||||
|
||||
|
||||
extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
extern char ASSETCHAINS_SYMBOL[];
|
||||
extern std::string CCerror,ASSETCHAINS_CCLIB;
|
||||
extern uint8_t ASSETCHAINS_CCDISABLES[256];
|
||||
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern int32_t KOMODO_EXCHANGEWALLET;
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
extern std::string DONATION_PUBKEY;
|
||||
extern uint8_t ASSETCHAINS_PRIVATE;
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3806,7 +3806,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
CValidationState stateDummy;
|
||||
|
||||
// don't keep staking or invalid transactions
|
||||
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||
if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight()) != 0)) || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
||||
{
|
||||
mempool.remove(tx, removed, true);
|
||||
}
|
||||
@@ -3837,7 +3837,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
|
||||
{
|
||||
CTransaction &tx = block.vtx[i];
|
||||
//if ((i == (block.vtx.size() - 1)) && ((ASSETCHAINS_LWMAPOS && block.IsVerusPOSBlock()) || (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0))))
|
||||
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block) != 0)))
|
||||
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight()) != 0)))
|
||||
{
|
||||
EraseFromWallets(tx.GetHash());
|
||||
}
|
||||
@@ -4734,7 +4734,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
||||
CValidationState state;
|
||||
CTransaction Tx;
|
||||
const CTransaction &tx = (CTransaction)block.vtx[i];
|
||||
if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0)))
|
||||
if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block,height) != 0)))
|
||||
continue;
|
||||
Tx = tx;
|
||||
if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH;
|
||||
#include "komodo_defs.h"
|
||||
int64_t komodo_block_unlocktime(uint32_t nHeight);
|
||||
|
||||
void AtomicTimer::start()
|
||||
|
||||
@@ -132,17 +132,8 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
||||
#include "komodo_defs.h"
|
||||
|
||||
extern CCriticalSection cs_metrics;
|
||||
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION, ASSETCHAINS_STAKED;
|
||||
extern bool VERUS_MINTBLOCKS;
|
||||
extern uint64_t ASSETCHAINS_REWARD[ASSETCHAINS_MAX_ERAS], ASSETCHAINS_TIMELOCKGTE, ASSETCHAINS_NONCEMASK[];
|
||||
extern const char *ASSETCHAINS_ALGORITHMS[];
|
||||
extern int32_t VERUS_MIN_STAKEAGE, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH, ASSETCHAINS_LASTERA, ASSETCHAINS_LWMAPOS, ASSETCHAINS_NONCESHIFT[], ASSETCHAINS_HASHESPERROUND[];
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB;
|
||||
void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len);
|
||||
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
|
||||
uint32_t Mining_start,Mining_height;
|
||||
int32_t My_notaryid = -1;
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
@@ -487,7 +478,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
{
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr;
|
||||
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[512],*ptr;
|
||||
CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight);
|
||||
|
||||
if (ASSETCHAINS_LWMAPOS != 0)
|
||||
@@ -521,7 +512,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
pblocktemplate->vTxSigOps.push_back(GetLegacySigOpCount(txStaked));
|
||||
nFees += txfees;
|
||||
pblock->nTime = blocktime;
|
||||
//printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13)));
|
||||
printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13)));
|
||||
} else return(0); //fprintf(stderr,"no utxos eligible for staking\n");
|
||||
}
|
||||
// Create coinbase tx
|
||||
|
||||
@@ -37,9 +37,8 @@
|
||||
#endif // ENABLE_RUST
|
||||
uint32_t komodo_chainactive_timestamp();
|
||||
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_STAKED;
|
||||
extern char ASSETCHAINS_SYMBOL[65];
|
||||
extern int32_t ASSETCHAINS_LWMAPOS,VERUS_BLOCK_POSUNITS, VERUS_CONSECUTIVE_POS_THRESHOLD, VERUS_NOPOS_THRESHHOLD;
|
||||
#include "komodo_defs.h"
|
||||
|
||||
unsigned int lwmaGetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params);
|
||||
unsigned int lwmaCalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "crypto/common.h"
|
||||
#include "komodo_defs.h"
|
||||
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH;
|
||||
|
||||
// default hash algorithm for block
|
||||
uint256 (CBlockHeader::*CBlockHeader::hashFunction)() const = &CBlockHeader::GetSHA256DHash;
|
||||
|
||||
@@ -48,10 +48,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern int32_t ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_LWMAPOS;
|
||||
extern uint64_t ASSETCHAINS_STAKED;
|
||||
extern int32_t KOMODO_MININGTHREADS;
|
||||
extern bool VERUS_MINTBLOCKS;
|
||||
#include "komodo_defs.h"
|
||||
|
||||
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,7 +77,8 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
extern uint32_t ASSETCHAINS_MAGIC;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY,ASSETCHAINS_LASTERA;
|
||||
extern uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY;
|
||||
extern uint32_t ASSETCHAINS_LASTERA;
|
||||
extern int32_t ASSETCHAINS_LWMAPOS,ASSETCHAINS_SAPLING;
|
||||
extern uint64_t ASSETCHAINS_ENDSUBSIDY[],ASSETCHAINS_REWARD[],ASSETCHAINS_HALVING[],ASSETCHAINS_DECAY[];
|
||||
extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[];
|
||||
@@ -224,7 +225,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
if (ASSETCHAINS_LASTERA > 0)
|
||||
obj.push_back(Pair("eras", ASSETCHAINS_LASTERA + 1));
|
||||
obj.push_back(Pair("eras", (int64_t)(ASSETCHAINS_LASTERA + 1)));
|
||||
obj.push_back(Pair("reward", acReward));
|
||||
obj.push_back(Pair("halving", acHalving));
|
||||
obj.push_back(Pair("decay", acDecay));
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#include "komodo_defs.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -67,8 +68,6 @@ const std::string ADDR_TYPE_SPROUT = "sprout";
|
||||
const std::string ADDR_TYPE_SAPLING = "sapling";
|
||||
|
||||
extern UniValue TxJoinSplitToJSON(const CTransaction& tx);
|
||||
extern uint8_t ASSETCHAINS_PRIVATE;
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
uint32_t komodo_segid32(char *coinaddr);
|
||||
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
||||
int32_t komodo_isnotaryvout(char *coinaddr); // from ac_private chains only
|
||||
@@ -5172,7 +5171,6 @@ int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits
|
||||
|
||||
int32_t ensure_CCrequirements()
|
||||
{
|
||||
extern uint8_t NOTARY_PUBKEY33[];
|
||||
CCerror = "";
|
||||
if ( NOTARY_PUBKEY33[0] == 0 )
|
||||
return(-1);
|
||||
@@ -5262,8 +5260,6 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
||||
|
||||
char Raddress[18];
|
||||
uint8_t pubkey33[33];
|
||||
extern uint8_t NOTARY_PUBKEY33[];
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
if ( NOTARY_PUBKEY33[0] == 0 ) {
|
||||
if (strlen(params[0].get_str().c_str()) == 66) {
|
||||
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
|
||||
|
||||
@@ -59,13 +59,7 @@ bool fSendFreeTransactions = false;
|
||||
bool fPayAtLeastCustomFee = true;
|
||||
#include "komodo_defs.h"
|
||||
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern int32_t KOMODO_EXCHANGEWALLET;
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
CBlockIndex *komodo_chainactive(int32_t height);
|
||||
extern std::string DONATION_PUBKEY;
|
||||
|
||||
/**
|
||||
* Fees smaller than this (in satoshi) are considered zero fee (for transaction creation)
|
||||
|
||||
Reference in New Issue
Block a user