|
@ -90,7 +90,7 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi |
|
|
{ |
|
|
{ |
|
|
if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) |
|
|
if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) |
|
|
{ |
|
|
{ |
|
|
fprintf(stderr,"ht.%d couldnt get txid.%s !\n",height,txid.GetHex().c_str()); |
|
|
LogPrint("dpow","ht.%d couldnt get txid.%s !\n",height,txid.GetHex().c_str()); |
|
|
return(-1); |
|
|
return(-1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -98,7 +98,7 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi |
|
|
{ |
|
|
{ |
|
|
if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) |
|
|
if ( GetTransaction(txid,tx,hashBlock,true) == 0 ) |
|
|
{ |
|
|
{ |
|
|
fprintf(stderr,"ht.%d couldnt get txid.%s !\n",height,txid.GetHex().c_str()); |
|
|
LogPrint("dpow","ht.%d couldnt get txid.%s !\n",height,txid.GetHex().c_str()); |
|
|
return(-1); |
|
|
return(-1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -111,11 +111,11 @@ int32_t gettxout_scriptPubKey(int32_t height,uint8_t *scriptPubKey,int32_t maxsi |
|
|
for (i=0; i<maxsize&&i<m; i++) { |
|
|
for (i=0; i<maxsize&&i<m; i++) { |
|
|
scriptPubKey[i] = ptr[i]; |
|
|
scriptPubKey[i] = ptr[i]; |
|
|
} |
|
|
} |
|
|
fprintf(stderr,"got scriptPubKey[%d] via rawtransaction ht.%d %s\n",m,height,txid.GetHex().c_str()); |
|
|
LogPrint("dpow","got scriptPubKey[%d] via rawtransaction ht.%d %s\n",m,height,txid.GetHex().c_str()); |
|
|
return(i); |
|
|
return(i); |
|
|
} |
|
|
} |
|
|
else if ( !tx.IsNull() ) |
|
|
else if ( !tx.IsNull() ) |
|
|
fprintf(stderr,"gettxout_scriptPubKey ht.%d n.%d > voutsize.%d\n",height,n,(int32_t)tx.vout.size()); |
|
|
LogPrint("dpow","gettxout_scriptPubKey ht.%d n.%d > voutsize.%d\n",height,n,(int32_t)tx.vout.size()); |
|
|
|
|
|
|
|
|
return(-1); |
|
|
return(-1); |
|
|
} |
|
|
} |
|
@ -572,9 +572,9 @@ CBlockIndex *komodo_chainactive(int32_t height) |
|
|
{ |
|
|
{ |
|
|
if ( height <= tipindex->nHeight ) |
|
|
if ( height <= tipindex->nHeight ) |
|
|
return(chainActive[height]); |
|
|
return(chainActive[height]); |
|
|
else fprintf(stderr,"komodo_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight); |
|
|
else LogPrint("dpow","komodo_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight); |
|
|
} |
|
|
} |
|
|
fprintf(stderr,"komodo_chainactive null chainActive.Tip() height %d\n",height); |
|
|
LogPrint("dpow","komodo_chainactive null chainActive.Tip() height %d\n",height); |
|
|
return(0); |
|
|
return(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -583,7 +583,7 @@ uint32_t komodo_heightstamp(int32_t height) |
|
|
CBlockIndex *ptr; |
|
|
CBlockIndex *ptr; |
|
|
if ( height > 0 && (ptr= komodo_chainactive(height)) != 0 ) |
|
|
if ( height > 0 && (ptr= komodo_chainactive(height)) != 0 ) |
|
|
return(ptr->nTime); |
|
|
return(ptr->nTime); |
|
|
else fprintf(stderr,"komodo_heightstamp null ptr for block.%d\n",height); |
|
|
else LogPrint("dpow","komodo_heightstamp null ptr for block.%d\n",height); |
|
|
return(0); |
|
|
return(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -760,7 +760,7 @@ void komodo_importpubkeys() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if ( dispflag != 0 ) |
|
|
if ( dispflag != 0 ) |
|
|
fprintf(stderr,"%d Notary pubkeys imported\n",dispflag); |
|
|
LogPrint("dpow","%d Notary pubkeys imported\n",dispflag); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int32_t komodo_init() |
|
|
int32_t komodo_init() |
|
@ -841,7 +841,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam |
|
|
} |
|
|
} |
|
|
memcpy(pubkeys,elected_pubkeys0,n0 * 33); |
|
|
memcpy(pubkeys,elected_pubkeys0,n0 * 33); |
|
|
if ( ASSETCHAINS_SYMBOL[0] != 0 ) |
|
|
if ( ASSETCHAINS_SYMBOL[0] != 0 ) |
|
|
fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n0); |
|
|
LogPrint("dpow","%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n0); |
|
|
return(n0); |
|
|
return(n0); |
|
|
} |
|
|
} |
|
|
else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 )
|
|
|
else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 )
|
|
@ -852,7 +852,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam |
|
|
for (i=0; i<n1; i++) |
|
|
for (i=0; i<n1; i++) |
|
|
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); |
|
|
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); |
|
|
if ( ASSETCHAINS_SYMBOL[0] != 0 ) |
|
|
if ( ASSETCHAINS_SYMBOL[0] != 0 ) |
|
|
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1); |
|
|
LogPrint("dpow","%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1); |
|
|
did1 = 1; |
|
|
did1 = 1; |
|
|
} |
|
|
} |
|
|
memcpy(pubkeys,elected_pubkeys1,n1 * 33); |
|
|
memcpy(pubkeys,elected_pubkeys1,n1 * 33); |
|
@ -878,7 +878,7 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock *block) |
|
|
{ |
|
|
{ |
|
|
if ( (int32_t)pindex->nHeight <= NOTARIZED_HEIGHT ) |
|
|
if ( (int32_t)pindex->nHeight <= NOTARIZED_HEIGHT ) |
|
|
{ |
|
|
{ |
|
|
fprintf(stderr,"komodo_disconnect unexpected reorg pindex->nHeight.%d vs %d\n",(int32_t)pindex->nHeight,NOTARIZED_HEIGHT); |
|
|
LogPrint("dpow","komodo_disconnect unexpected reorg pindex->nHeight.%d vs %d\n",(int32_t)pindex->nHeight,NOTARIZED_HEIGHT); |
|
|
komodo_clearstate(); // bruteforce shortcut. on any reorg, no active notarization until next one is seen
|
|
|
komodo_clearstate(); // bruteforce shortcut. on any reorg, no active notarization until next one is seen
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -981,7 +981,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n |
|
|
if ( np != 0 ) |
|
|
if ( np != 0 ) |
|
|
{ |
|
|
{ |
|
|
if ( np->nHeight >= nHeight || (i < NUM_NPOINTS && np[1].nHeight < nHeight) ) |
|
|
if ( np->nHeight >= nHeight || (i < NUM_NPOINTS && np[1].nHeight < nHeight) ) |
|
|
fprintf(stderr,"warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); |
|
|
LogPrint("dpow","warning: flag.%d i.%d np->ht %d [1].ht %d >= nHeight.%d\n",flag,i,np->nHeight,np[1].nHeight,nHeight); |
|
|
*notarized_hashp = np->notarized_hash; |
|
|
*notarized_hashp = np->notarized_hash; |
|
|
*notarized_desttxidp = np->notarized_desttxid; |
|
|
*notarized_desttxidp = np->notarized_desttxid; |
|
|
return(np->notarized_height); |
|
|
return(np->notarized_height); |
|
@ -1097,17 +1097,17 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has |
|
|
{ |
|
|
{ |
|
|
if ( nHeight < notarized_height ) |
|
|
if ( nHeight < notarized_height ) |
|
|
{ |
|
|
{ |
|
|
fprintf(stderr,"nHeight.%d < NOTARIZED_HEIGHT.%d\n",nHeight,notarized_height); |
|
|
LogPrint("dpow","nHeight.%d < NOTARIZED_HEIGHT.%d\n",nHeight,notarized_height); |
|
|
return(-1); |
|
|
return(-1); |
|
|
} |
|
|
} |
|
|
else if ( nHeight == notarized_height && memcmp(&hash,¬arized_hash,sizeof(hash)) != 0 ) |
|
|
else if ( nHeight == notarized_height && memcmp(&hash,¬arized_hash,sizeof(hash)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
fprintf(stderr,"nHeight.%d == NOTARIZED_HEIGHT.%d, diff hash\n",nHeight,notarized_height); |
|
|
LogPrint("dpow","nHeight.%d == NOTARIZED_HEIGHT.%d, diff hash\n",nHeight,notarized_height); |
|
|
return(-1); |
|
|
return(-1); |
|
|
} |
|
|
} |
|
|
} else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); |
|
|
} else LogPrint("dpow","unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); |
|
|
} else if ( notarized_height > 0 ) |
|
|
} else if ( notarized_height > 0 ) |
|
|
fprintf(stderr,"%s couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight); |
|
|
LogPrint("dpow","%s couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight); |
|
|
return(0); |
|
|
return(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1218,7 +1218,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) |
|
|
} |
|
|
} |
|
|
} else if ( block.vtx[i].vin[j].prevout.hash != zero ) { |
|
|
} else if ( block.vtx[i].vin[j].prevout.hash != zero ) { |
|
|
//if (IS_NOTARY)
|
|
|
//if (IS_NOTARY)
|
|
|
// fprintf(stderr,"%s cant get scriptPubKey for ht.%d txi.%d vin.%d\n",ASSETCHAINS_SYMBOL,height,i,j);
|
|
|
// LogPrint("dpow","%s cant get scriptPubKey for ht.%d txi.%d vin.%d\n",ASSETCHAINS_SYMBOL,height,i,j);
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
numvalid = bitweight(signedmask); |
|
|
numvalid = bitweight(signedmask); |
|
@ -1243,6 +1243,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) |
|
|
printf("%s ht.%d\n",ASSETCHAINS_SYMBOL,height); |
|
|
printf("%s ht.%d\n",ASSETCHAINS_SYMBOL,height); |
|
|
LogPrintf("dpow: [%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx); |
|
|
LogPrintf("dpow: [%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx); |
|
|
} |
|
|
} |
|
|
} else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); |
|
|
} else LogPrint("dpow","komodo_connectblock: unexpected null pindex\n"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|