Browse Source

-ac_notarypay

pull/27/head
blackjok3r 5 years ago
parent
commit
2cf2102887
  1. 28
      src/komodo.h
  2. 114
      src/komodo_bitcoind.h
  3. 2
      src/komodo_defs.h
  4. 2
      src/komodo_globals.h
  5. 7
      src/komodo_utils.h
  6. 17
      src/main.cpp
  7. 71
      src/miner.cpp
  8. 4
      src/notaries_staked.cpp

28
src/komodo.h

@ -37,7 +37,7 @@
int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n);
void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height);
void komodo_connectblock(CBlockIndex *pindex,CBlock& block);
int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block);
#include "komodo_structs.h"
#include "komodo_globals.h"
@ -695,6 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
}
else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
else
{
fprintf(stderr, "NOT matched NOTARISATION\n");
return (-2);
}
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
{
sp->NOTARIZED_HEIGHT = *notarizedheightp;
@ -708,10 +713,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
if ( 0 && RemoveOrphanedBlocks(*notarizedheightp))
{
//fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp);
}
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
if ( signedfp == 0 )
@ -798,7 +800,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys
return(-1);
}
void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
// int32_t !
int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block)
{
static int32_t hwmheight;
int32_t staked_era; static int32_t lastStakedEra;
@ -809,7 +812,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
if ( pindex == 0 )
{
fprintf(stderr,"komodo_connectblock null pindex\n");
return;
return -1;
}
memset(&zero,0,sizeof(zero));
komodo_init(pindex->GetHeight());
@ -817,7 +820,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
{
fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL);
return;
return -1;
}
//fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 )
@ -858,6 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0);
}
komodo_currentheight_set(chainActive.LastTip()->GetHeight());
int transaction = 0;
if ( pindex != 0 )
{
height = pindex->GetHeight();
@ -913,6 +917,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
fwrite(&signedmask,1,sizeof(signedmask),signedfp);
fflush(signedfp);
}
transaction = i;
printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
}
notarized = 1;
@ -938,10 +943,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf("%.8f ",dstr(block.vtx[i].vout[j].nValue));
len = block.vtx[i].vout[j].scriptPubKey.size();
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
{
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,&notarizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime());
if ( notaryid == -2 )
return(-1);
if ( 0 && i > 0 )
{
for (k=0; k<len; k++)
@ -999,6 +1007,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
} else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");
//KOMODO_INITDONE = (uint32_t)time(NULL);
//fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->GetHeight());
if (notarized = 1)
return(transaction);
else
return(-1);
}

114
src/komodo_bitcoind.h

@ -1772,6 +1772,96 @@ bool verusCheckPOSBlock(int32_t slowflag, CBlock *pblock, int32_t height)
return(isPOS);
}
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarisationNotaries, uint32_t timestamp)
{
// fetch notary pubkey array.
uint64_t total = 0;
int32_t staked_era; int8_t numSN;
uint8_t staked_pubkeys[64][33];
staked_era = STAKED_era(timestamp);
numSN = numStakedNotaries(staked_pubkeys,staked_era);
// resize coinbase vouts to number of notary nodes +1 for coinbase itself.
txNew.vout.resize(NotarisationNotaries.size()+1);
// loop over notarisation vins and add transaction to coinbase.
for (int8_t n = 0; n < NotarisationNotaries.size(); n++)
{
uint8_t *ptr;
txNew.vout[n+1].scriptPubKey.resize(35);
ptr = (uint8_t *)&txNew.vout[n+1].scriptPubKey[0];
ptr[0] = 33;
for (int8_t i=0; i<33; i++)
{
ptr[i+1] = staked_pubkeys[NotarisationNotaries[n]][i];
//fprintf(stderr,"%02x",ptr[i+1]);
}
ptr[34] = OP_CHECKSIG;
//fprintf(stderr," set notary %i PUBKEY33 into vout[%i]\n",NotarisationNotaries[n],n+1);
txNew.vout[n+1].nValue = ASSETCHAINS_NOTARY_PAY; // ASSETCHAINS_NOTARY_PAY
total += txNew.vout[n+1].nValue;
}
return(total);
}
uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
{
std::vector<int8_t> NotarisationNotaries;
uint32_t timestamp = pblock->nTime;
int32_t staked_era; int8_t numSN;
uint8_t staked_pubkeys[64][33];
staked_era = STAKED_era(timestamp);
numSN = numStakedNotaries(staked_pubkeys,staked_era);
uint8_t *script; int32_t scriptlen;
// loop over notaries array and extract index of signers.
BOOST_FOREACH(const CTxIn& txin, pblock->vtx[1].vin)
{
uint256 hash; CTransaction tx1;
if ( GetTransaction(txin.prevout.hash,tx1,hash,false) )
{
for (int8_t i = 0; i < numSN; i++)
{
//tx1.vout[txin.prevout.n].scriptPubKey
script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0];
scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size();
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 )
NotarisationNotaries.push_back(i);
}
}
}
const CChainParams& chainparams = Params();
const Consensus::Params &consensusParams = chainparams.GetConsensus();
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, height);
uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime);
int8_t n = 0, i = 0, matches = 0;
uint64_t total = 0;
//fprintf(stderr, "txNew.vout size = %li\n",txNew.vout.size());
BOOST_FOREACH(const CTxOut& txout, txNew.vout)
{
if ( n == 0 )
{
n++;
continue;
}
script = (uint8_t *)&txout.scriptPubKey[0];
scriptlen = (int32_t)txout.scriptPubKey.size();
// ASSETCHAINS_NOTARY_PAY = nValue!
if ( txout.nValue == ASSETCHAINS_NOTARY_PAY && scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[NotarisationNotaries[n-1]],33) == 0 )
{
matches++;
total += txout.nValue;
fprintf(stderr, "matched.%i\n", NotarisationNotaries[n-1]);
}
n++;
}
if ( matches = n && matches != 0 && total == totalsats )
{
fprintf(stderr, "VALIDATED.\n" );
return(totalsats);
}
return(-1);
}
int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
{
int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0;
@ -1952,6 +2042,30 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
return(-1);
}
}
if( failed == 0 && ASSETCHAINS_NOTARY_PAY != 0 && pblock->vtx[0].vout.size() != 1 )
{
if ( slowflag != 0 && komodo_checknotarypay(pblock,height) < 0 )
{
fprintf(stderr, "Komodo notary pay validation failed.%i\n",height);
return(0);
}
else
{
// Check the notarisation tx is to the crypto address and meets min sigs.
if ( !komodo_is_notarytx(pblock->vtx[1]) == 1 )
{
fprintf(stderr, "notarisation is not to crypto address.%i\n",height);
return(0);
}
// Check min sigs.
if ( pblock->vtx[1].vin.size() < num_notaries_STAKED[STAKED_era(pblock->nTime)] )
{
fprintf(stderr, "block does not meet minsigs .%i\n",height);
return(0);
}
}
}
//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
if ( failed != 0 && possible == 0 && notaryid < 0 )
return(-1);

2
src/komodo_defs.h

@ -40,7 +40,7 @@ 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_FOUNDERS_REWARD;
extern uint64_t ASSETCHAINS_SUPPLY, ASSETCHAINS_FOUNDERS_REWARD, ASSETCHAINS_NOTARY_PAY;
extern uint64_t ASSETCHAINS_TIMELOCKGTE;
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH,ASSETCHAINS_EQUIHASH,KOMODO_INITDONE;

2
src/komodo_globals.h

@ -97,7 +97,7 @@ int32_t ASSETCHAINS_OVERWINTER = -1;
uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
int32_t ASSETCHAINS_STAKED;
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD;
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,MIN_RECV_SATS,ASSETCHAINS_FOUNDERS_REWARD,ASSETCHAINS_NOTARY_PAY;
uint32_t KOMODO_INITDONE;
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;

7
src/komodo_utils.h

@ -1895,6 +1895,9 @@ void komodo_args(char *argv0)
}
else
{
ASSETCHAINS_NOTARY_PAY = GetArg("-ac_notarypay",0);
if ( ASSETCHAINS_NOTARY_PAY != 0 )
printf("Assetchains NOTARY PAY set to %lu sats per notarisation per notary. Cannot work with ac_script or ac_pubkey!\n",ASSETCHAINS_NOTARY_PAY);
if ( ASSETCHAINS_COMMISSION != 0 )
{
ASSETCHAINS_COMMISSION = 0;
@ -1911,7 +1914,7 @@ void komodo_args(char *argv0)
fprintf(stderr,"-ac_script and -ac_marmara are mutually exclusive\n");
exit(0);
}
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 )
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 || ASSETCHAINS_MARMARA != 0 || nonz > 0 || ASSETCHAINS_CCLIB.size() > 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 || ASSETCHAINS_NOTARY_PAY != 0 )
{
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size());
extraptr = extrabuf;
@ -2006,6 +2009,8 @@ void komodo_args(char *argv0)
}
fprintf(stderr," <- CCLIB name\n");
}
if ( ASSETCHAINS_NOTARY_PAY != 0 )
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY),(void *)&ASSETCHAINS_NOTARY_PAY);
}
addn = GetArg("-seednode","");

17
src/main.cpp

@ -3572,6 +3572,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
fprintf(stderr,"checktoshis %.8f vs %.8f numvouts %d\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue),(int32_t)block.vtx[0].vout.size());
}
}
if ( ASSETCHAINS_NOTARY_PAY != 0 && block.vtx[0].vout.size() > 1 )
{
uint64_t notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight());
if ( notarypaycheque > 0 )
blockReward += notarypaycheque;
else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 4 && IS_STAKED_NOTARY > 0 )
blockReward += 999999999999999; // Notaries can validate any block for now.
else
return state.DoS(100, error("ConnectBlock(): Notary Pay exceeds coinbase (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward),
REJECT_INVALID, "bad-cb-amount");
}
if (ASSETCHAINS_SYMBOL[0] != 0 && pindex->GetHeight() == 1 && block.vtx[0].GetValueOut() != blockReward)
{
return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward),
@ -3684,7 +3695,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001);
//FlushStateToDisk();
komodo_connectblock(pindex,*(CBlock *)&block);
int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000;
if ( tmp > 0 )
{
printf("VALID NOTARISATION connect block.%i tx.%i\n NOT VALIDATING HERE YET!",pindex->GetHeight(),tmp);
}
return true;
}

71
src/miner.cpp

@ -55,6 +55,8 @@
#include "sodium.h"
#include "notaries_staked.h"
#include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp>
#ifdef ENABLE_MINING
@ -151,6 +153,7 @@ int32_t komodo_is_notarytx(const CTransaction& tx);
CScript Marmara_scriptPubKey(int32_t height,CPubKey pk);
CScript MarmaraCoinbaseOpret(uint8_t funcid,int32_t height,CPubKey pk);
int32_t komodo_is_notarytx(const CTransaction& tx);
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarisationNotaries, uint32_t timestamp);
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
{
@ -170,6 +173,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
} else pk = _pk;
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
//fprintf(stderr,"create new block\n");
// Create new block
if ( gpucount < 0 )
@ -239,6 +244,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
}
}
pblock->nTime = GetAdjustedTime();
// Now we have the block time, we can get the active notaries.
int32_t staked_era; int8_t numSN;
uint8_t staked_pubkeys[64][33];
staked_era = STAKED_era(pblock->nTime);
numSN = numStakedNotaries(staked_pubkeys,staked_era);
CCoinsViewCache view(pcoinsTip);
uint32_t expired; uint64_t commission;
@ -249,13 +259,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
// Priority order to process transactions
list<COrphan> vOrphan; // list memory doesn't move
map<uint256, vector<COrphan*> > mapDependers;
bool fPrintPriority = GetBoolArg("-printpriority", false);
bool fPrintPriority = GetBoolArg("-printpriority", true);
// This vector will be sorted into a priority queue:
vector<TxPriority> vecPriority;
vecPriority.reserve(mempool.mapTx.size() + 1);
// now add transactions from the mem pool
int32_t Notarisations = 0;
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
mi != mempool.mapTx.end(); ++mi)
{
@ -329,22 +340,33 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
nTotalIn += nValueIn;
int nConf = nHeight - coins->nHeight;
// This is to test is a tx is a notarisation and assign it max priotity.
if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 )
uint8_t *script; int32_t scriptlen; uint256 hash; CTransaction tx1;
// loop over notaries array and extract index of signers.
if ( fToCryptoAddress && staked_pubkeys[0][0] != 0 && GetTransaction(txin.prevout.hash,tx1,hash,false) )
{
uint256 hash; CTransaction tx1; CTxDestination address;
if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) )
for (int8_t i = 0; i < numSN; i++)
{
for (int i = 0; i < NUM_NOTARIES; i++)
if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 )
numNotaryVins++;
script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0];
scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size();
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,staked_pubkeys[i],33) == 0 )
{
numNotaryVins++;
if ( Notarisations == 0 )
{
// Until we get a valid notarization this will always be 0.
// We can add the index of each notary to vector, and clear it if this notarisation is not valid later on.
NotarisationNotaries.push_back(i);
}
}
}
}
dPriority += (double)nValueIn * nConf;
}
if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 )
if ( numSN != 0 && numNotaryVins >= numSN / 5 )
fNotarisation = true;
else
NotarisationNotaries.clear();
nTotalIn += tx.GetShieldedValueIn();
}
@ -360,16 +382,27 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
if (fNotarisation) {
if (fNotarisation)
{
dPriority = 1e16;
//fprintf(stderr, "Notarisation.%s set to maximum priority.\n",hash.ToString().c_str());
Notarisations++;
fNotarisationBlock = true;
fprintf(stderr, "Notarisation[%i] %s set to maximum priority\n",Notarisations,hash.ToString().c_str());
}
else if ( dPriority == 1e16 )
{
dPriority -= 10;
// make sure notarisation is tx[1] in block.
// Need to check this? Tried sapling tx and it was not set to max priotity, maybe missing something.
}
if (porphan)
{
porphan->dPriority = dPriority;
porphan->feeRate = feeRate;
}
else
else if ( fNotarisation && Notarisations != 1 && is_STAKED(ASSETCHAINS_SYMBOL) != 0)
continue; // If we have added a notarisation already skip the next one. There can only be one per block.
else
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
}
@ -637,7 +670,17 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
txNew.vout[0].scriptPubKey = CScriptExt().PayToScriptHash(CScriptID(opretScript));
txNew.vout[1].scriptPubKey = CScriptExt().OpReturnScript(opretScript, OPRETTYPE_TIMELOCK);
txNew.vout[1].nValue = 0;
} // timelocks and commissions are currently incompatible due to validation complexity of the combination
// timelocks and commissions are currently incompatible due to validation complexity of the combination
}
else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY != 0 )
{
// This block contains a valid notarisation as best as we can know. We cant check this 100% until we try to connect block.
// This assumes notaries are not going to collude to create invalid notarisations.
// If they did this, then the block would be invalid, and all kinds of werid things will happen.
// We can test this, and see what happens, if its unreliable, we will need to create a CC contract.
uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime);
fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats);
}
pblock->vtx[0] = txNew;
pblocktemplate->vTxFees[0] = -nFees;

4
src/notaries_staked.cpp

@ -21,7 +21,9 @@ int8_t is_STAKED(const char *chain_name) {
else if ( (strncmp(chain_name, "LABS", 4) == 0) )
STAKED = 2;
else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) )
STAKED = 3;
STAKED = 3;
else if ( (strcmp(chain_name, "NOTARYTEST") == 0) )
STAKED = 4;
else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) )
STAKED = 255; // This means that all notarisations for chains that are in 255 group are invalid.
doneinit = 1;

Loading…
Cancel
Save