Browse Source

Test

pull/4/head
jl777 6 years ago
parent
commit
ce5dd5473e
  1. 5
      src/komodo_bitcoind.h
  2. 11
      src/komodo_gateway.h
  3. 2
      src/komodo_globals.h
  4. 2
      src/komodo_kv.h
  5. 6
      src/komodo_utils.h
  6. 5
      src/main.cpp
  7. 12
      src/pow.cpp
  8. 1
      src/rpcblockchain.cpp

5
src/komodo_bitcoind.h

@ -557,10 +557,11 @@ uint64_t komodo_seed(int32_t height)
return(seed);
}
uint32_t komodo_txtime(uint256 hash)
uint32_t komodo_txtime(uint64_t *valuep,uint256 hash,int32_t n)
{
CTransaction tx;
uint256 hashBlock;
*valuep = 0;
if (!GetTransaction(hash, tx,
#ifndef KOMODO_ZCASH
Params().GetConsensus(),
@ -568,6 +569,8 @@ uint32_t komodo_txtime(uint256 hash)
hashBlock, true))
{
//printf("null GetTransaction\n");
if ( n < tx.vout.size() )
*valuep = tx.vout[n].nValue;
return(tx.nLockTime);
}
return(0);

11
src/komodo_gateway.h

@ -670,7 +670,7 @@ uint64_t komodo_commission(const CBlock &block)
return((total * ASSETCHAINS_COMMISSION) / COIN);
}
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing
{
static uint256 array[64]; static int32_t numbanned,indallvouts;
int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[KOMODO_ASSETCHAIN_MAXLEN],base[KOMODO_ASSETCHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp;
@ -740,6 +740,13 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
}
else
{
if ( ASSETCHAINS_STAKED != 0 )
{
uint32_t txtime,minutes; uint64_t value;
txtime = komodo_txtime(&value,block.vtx[txn_count-1].vin[0].prevout.hash,block.vtx[txn_count-1].vin[0].prevout.n);
minutes = (block.nTime - txtime) / 60;
fprintf(stderr,"txn_count.%d txtime.%u blocktime.%u prev.%u gap.%d minutes.%d %.8f\n",txn_count,txtime,block.nTime,prevtime,(int32_t)(block.nTime-prevtime),minutes,dstr(value));
}
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && block.vtx[0].vout.size() > 1 )
{
script = (uint8_t *)block.vtx[0].vout[1].scriptPubKey.data();
@ -747,7 +754,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
return(-1);
if ( (checktoshis = komodo_commission(block)) != 0 )
{
if ( block.vtx[0].vout.size() < 2 || block.vtx[0].vout[1].nValue != checktoshis )
if ( block.vtx[0].vout[1].nValue != checktoshis )
{
fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue));
return(-1);

2
src/komodo_globals.h

@ -54,7 +54,7 @@ char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
uint16_t ASSETCHAINS_PORT;
uint32_t ASSETCHAIN_INIT;
uint32_t ASSETCHAINS_MAGIC = 2387029918;
uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10;
uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10;
uint32_t KOMODO_INITDONE;
char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t KMD_PORT = 7771,BITCOIND_PORT = 7771;

2
src/komodo_kv.h

@ -171,7 +171,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
memcpy(ptr->key,key,keylen);
newflag = 1;
HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr);
printf("KV add.(%s) (%s)\n",ptr->key,valueptr);
//printf("KV add.(%s) (%s)\n",ptr->key,valueptr);
}
if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 )
{

6
src/komodo_utils.h

@ -1501,7 +1501,7 @@ char *argv0names[] =
void komodo_args(char *argv0)
{
extern int64_t MAX_MONEY;
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; int32_t i,baseid,len,n,extralen = 0;
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; int32_t i,baseid,len,n,extralen = 0;
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 )
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
@ -1540,6 +1540,7 @@ void komodo_args(char *argv0)
ASSETCHAINS_DECAY = GetArg("-ac_decay",0);
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
ASSETCHAINS_STAKED = GetArg("-ac_staked",0);
if ( ASSETCHAINS_HALVING != 0 && ASSETCHAINS_HALVING < 1440 )
{
ASSETCHAINS_HALVING = 1440;
@ -1571,7 +1572,8 @@ void komodo_args(char *argv0)
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD),(void *)&ASSETCHAINS_REWARD);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING),(void *)&ASSETCHAINS_HALVING);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY),(void *)&ASSETCHAINS_DECAY);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_COMMISSION),(void *)&ASSETCHAINS_COMMISSION);
val = ASSETCHAINS_COMMISSION | ((ASSETCHAINS_STAKED & 0xffff) << 32);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
}
addn = GetArg("-seednode","");
if ( strlen(addn.c_str()) > 0 )

5
src/main.cpp

@ -3506,7 +3506,8 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
return true;
}
int32_t komodo_check_deposit(int32_t height,const CBlock& block);
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime);
bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
libzcash::ProofVerifier& verifier,
bool fCheckPOW, bool fCheckMerkleRoot)
@ -3568,7 +3569,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
if (nSigOps > MAX_BLOCK_SIGOPS)
return state.DoS(100, error("CheckBlock(): out-of-bounds SigOpCount"),
REJECT_INVALID, "bad-blk-sigops", true);
if ( komodo_check_deposit(ASSETCHAINS_SYMBOL[0] == 0 ? height : pindex != 0 ? (int32_t)pindex->nHeight : chainActive.Tip()->nHeight+1,block) < 0 )
if ( komodo_check_deposit(ASSETCHAINS_SYMBOL[0] == 0 ? height : pindex != 0 ? (int32_t)pindex->nHeight : chainActive.Tip()->nHeight+1,block,pindex==0||pindex->pprev==0?0:pindex->pprev->nTime) < 0 )
{
static uint32_t counter;
if ( counter++ < 100 )

12
src/pow.cpp

@ -190,18 +190,6 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
} else fprintf(stderr,"skip return error height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS);
} //else fprintf(stderr,"skip height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS);
}
if ( 0 && height > 248000 )
{
for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," hash vs ");
for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&bnTarget)[i]);
fprintf(stderr," POW ok for ht.%d notaryid.%d: ",height,notaryid);
for (i=0; i<33; i++)
fprintf(stderr,"%02x",pubkey33[i]);
fprintf(stderr,"\n");
}
return true;
}

1
src/rpcblockchain.cpp

@ -544,7 +544,6 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp)
#define KOMODO_KVBINARY 2
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime);
uint32_t komodo_txtime(uint256 hash);
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume);
int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel);
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);

Loading…
Cancel
Save