@ -142,7 +142,7 @@ int32_t komodo_importaddress(std::string addr)
return ( 1 ) ;
return ( 1 ) ;
}
}
}
}
printf ( " %s -> komodo_importaddress failed valid.%d \n " , addr . c_str ( ) , address . IsValid ( ) ) ;
LogPrint ( " dpow " , " %s -> komodo_importaddress failed valid.%d \n " , addr . c_str ( ) , address . IsValid ( ) ) ;
}
}
return ( - 1 ) ;
return ( - 1 ) ;
}
}
@ -514,7 +514,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
if ( n > 0 )
if ( n > 0 )
{
{
bytes [ 0 ] = unhex ( hex [ 0 ] ) ;
bytes [ 0 ] = unhex ( hex [ 0 ] ) ;
printf ( " decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld \n " , n , hex [ 0 ] , bytes [ 0 ] , hex , hex [ n * 2 + 1 ] , hex [ n * 2 ] , hex [ n * 2 ] , ( long ) strlen ( hex ) ) ;
LogPrint ( " dpow " , " decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld \n " , n , hex [ 0 ] , bytes [ 0 ] , hex , hex [ n * 2 + 1 ] , hex [ n * 2 ] , hex [ n * 2 ] , ( long ) strlen ( hex ) ) ;
}
}
bytes + + ;
bytes + + ;
hex + + ;
hex + + ;
@ -754,7 +754,7 @@ void komodo_importpubkeys()
//fprintf(stderr,"pubkey=%s, addr=%s\n", pubkey, addr.c_str() );
//fprintf(stderr,"pubkey=%s, addr=%s\n", pubkey, addr.c_str() );
if ( ( val = komodo_importaddress ( addr ) ) < 0 )
if ( ( val = komodo_importaddress ( addr ) ) < 0 )
LogPrintf ( " dpow: error importing (%s) \n " , addr . c_str ( ) ) ;
LogPrint ( " dpow " , " dpow: error importing (%s) \n " , addr . c_str ( ) ) ;
else if ( val = = 0 )
else if ( val = = 0 )
dispflag + + ;
dispflag + + ;
}
}
@ -954,7 +954,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n
{
{
if ( NPOINTS [ i ] . nHeight > = nHeight )
if ( NPOINTS [ i ] . nHeight > = nHeight )
{
{
LogPrintf ( " dpow: flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d \n " , i , np - > nHeight , i , NPOINTS [ i ] . nHeight , nHeight , last_NPOINTSi , NUM_NPOINTS ) ;
LogPrint ( " dpow " , " dpow: flag.1 i.%d np->ht %d [%d].ht %d >= nHeight.%d, last.%d num.%d \n " , i , np - > nHeight , i , NPOINTS [ i ] . nHeight , nHeight , last_NPOINTSi , NUM_NPOINTS ) ;
flag = 1 ;
flag = 1 ;
break ;
break ;
}
}
@ -1006,8 +1006,8 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
# else
# else
sep = " / " ;
sep = " / " ;
# endif
# endif
sprintf ( fname , " %s%snotarizations%s " , GetDefaultD ataDir ( ) . string ( ) . c_str ( ) , sep . c_str ( ) , suffix . c_str ( ) ) ;
sprintf ( fname , " %s%snotarizations%s " , GetDataDir ( ) . string ( ) . c_str ( ) , sep . c_str ( ) , suffix . c_str ( ) ) ;
LogPrintf ( " dpow: fname.(%s) \n " , fname ) ;
LogPrint ( " dpow " , " dpow: fname.(%s) \n " , fname ) ;
if ( ( fp = fopen ( fname , " rb+ " ) ) = = 0 )
if ( ( fp = fopen ( fname , " rb+ " ) ) = = 0 )
fp = fopen ( fname , " wb+ " ) ;
fp = fopen ( fname , " wb+ " ) ;
else
else
@ -1030,12 +1030,12 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
NOTARIZED_MOMDEPTH = np - > MoMdepth ;
NOTARIZED_MOMDEPTH = np - > MoMdepth ;
//fprintf(stderr,"%d ",np->notarized_height);
//fprintf(stderr,"%d ",np->notarized_height);
fpos = ftell ( fp ) ;
fpos = ftell ( fp ) ;
} else LogPrintf ( " dpow: %s error with notarization ht.%d %s \n " , ASSETCHAINS_SYMBOL , N . notarized_height , pindex - > GetBlockHash ( ) . ToString ( ) . c_str ( ) ) ;
} else LogPrint ( " dpow " , " dpow: %s error with notarization ht.%d %s \n " , ASSETCHAINS_SYMBOL , N . notarized_height , pindex ? pindex - > GetBlockHash ( ) . ToString ( ) . c_str ( ) : " " ) ;
}
}
if ( ftell ( fp ) ! = fpos )
if ( ftell ( fp ) ! = fpos )
fseek ( fp , fpos , SEEK_SET ) ;
fseek ( fp , fpos , SEEK_SET ) ;
}
}
LogPrintf ( " dpow: finished loading %s [pubkey %s] \n " , fname , NOTARY_PUBKEY . c_str ( ) ) ;
LogPrint ( " dpow " , " dpow: finished loading %s [pubkey %s] \n " , fname , NOTARY_PUBKEY . c_str ( ) ) ;
didinit = 1 ;
didinit = 1 ;
}
}
if ( notarized_height = = 0 )
if ( notarized_height = = 0 )
@ -1045,16 +1045,16 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
}
}
if ( notarized_height > = nHeight )
if ( notarized_height > = nHeight )
{
{
LogPrintf ( " dpow: komodo_notarized_update REJECT notarized_height %d > %d nHeight \n " , notarized_height , nHeight ) ;
LogPrint ( " dpow " , " dpow: komodo_notarized_update REJECT notarized_height %d > %d nHeight \n " , notarized_height , nHeight ) ;
return ;
return ;
}
}
pindex = komodo_chainactive ( notarized_height ) ;
pindex = komodo_chainactive ( notarized_height ) ;
if ( pindex = = 0 | | pindex - > GetBlockHash ( ) ! = notarized_hash | | notarized_height ! = pindex - > nHeight )
if ( pindex = = 0 | | pindex - > GetBlockHash ( ) ! = notarized_hash | | notarized_height ! = pindex - > nHeight )
{
{
LogPrintf ( " dpow: komodo_notarized_update reject nHeight.%d notarized_height.%d:%d \n " , nHeight , notarized_height , ( int32_t ) pindex - > nHeight ) ;
LogPrint ( " dpow " , " dpow: komodo_notarized_update reject nHeight.%d notarized_height.%d:%d \n " , nHeight , notarized_height , ( int32_t ) pindex - > nHeight ) ;
return ;
return ;
}
}
LogPrintf ( " dpow: komodo_notarized_update nHeight.%d notarized_height.%d prev.%d \n " , nHeight , notarized_height , NPOINTS ! = 0 ? NPOINTS [ NUM_NPOINTS - 1 ] . notarized_height : - 1 ) ;
LogPrint ( " dpow " , " dpow: komodo_notarized_update nHeight.%d notarized_height.%d prev.%d \n " , nHeight , notarized_height , NPOINTS ! = 0 ? NPOINTS [ NUM_NPOINTS - 1 ] . notarized_height : - 1 ) ;
portable_mutex_lock ( & komodo_mutex ) ;
portable_mutex_lock ( & komodo_mutex ) ;
NPOINTS = ( struct notarized_checkpoint * ) realloc ( NPOINTS , ( NUM_NPOINTS + 1 ) * sizeof ( * NPOINTS ) ) ;
NPOINTS = ( struct notarized_checkpoint * ) realloc ( NPOINTS , ( NUM_NPOINTS + 1 ) * sizeof ( * NPOINTS ) ) ;
np = & NPOINTS [ NUM_NPOINTS + + ] ;
np = & NPOINTS [ NUM_NPOINTS + + ] ;
@ -1073,7 +1073,7 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no
{
{
if ( fwrite ( np , 1 , sizeof ( * np ) , fp ) = = sizeof ( * np ) )
if ( fwrite ( np , 1 , sizeof ( * np ) , fp ) = = sizeof ( * np ) )
fflush ( fp ) ;
fflush ( fp ) ;
else LogPrintf ( " dpow: error writing notarization to %d \n " , ( int32_t ) ftell ( fp ) ) ;
else LogPrint ( " dpow " , " dpow: error writing notarization to %d \n " , ( int32_t ) ftell ( fp ) ) ;
}
}
// add to stored notarizations
// add to stored notarizations
portable_mutex_unlock ( & komodo_mutex ) ;
portable_mutex_unlock ( & komodo_mutex ) ;
@ -1092,7 +1092,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has
{
{
notary = mapBlockIndex [ notarized_hash ] ;
notary = mapBlockIndex [ notarized_hash ] ;
if ( IS_NOTARY )
if ( IS_NOTARY )
printf ( " nHeight.%d -> (%d %s) \n " , pindex - > nHeight , notarized_height , notarized_hash . ToString ( ) . c_str ( ) ) ;
LogPrint ( " dpow " , " nHeight.%d -> (%d %s) \n " , pindex - > nHeight , notarized_height , notarized_hash . ToString ( ) . c_str ( ) ) ;
if ( notary - > nHeight = = notarized_height ) // if notarized_hash not in chain, reorg
if ( notary - > nHeight = = notarized_height ) // if notarized_hash not in chain, reorg
{
{
if ( nHeight < notarized_height )
if ( nHeight < notarized_height )
@ -1132,7 +1132,7 @@ void komodo_voutupdate(int32_t txi,int32_t vout,uint8_t *scriptbuf,int32_t scrip
opretlen = scriptbuf [ len + + ] ;
opretlen = scriptbuf [ len + + ] ;
opretlen + = ( scriptbuf [ len + + ] < < 8 ) ;
opretlen + = ( scriptbuf [ len + + ] < < 8 ) ;
}
}
printf ( " opretlen.%d vout.%d [%s].(%s) \n " , opretlen , vout , ( char * ) & scriptbuf [ len + 32 * 2 + 4 ] , ASSETCHAINS_SYMBOL ) ;
LogPrint ( " dpow " , " opretlen.%d vout.%d [%s].(%s) \n " , opretlen , vout , ( char * ) & scriptbuf [ len + 32 * 2 + 4 ] , ASSETCHAINS_SYMBOL ) ;
if ( vout = = 1 & & opretlen - 3 > = 32 * 2 + 4 & & strcmp ( ASSETCHAINS_SYMBOL , ( char * ) & scriptbuf [ len + 32 * 2 + 4 ] ) = = 0 )
if ( vout = = 1 & & opretlen - 3 > = 32 * 2 + 4 & & strcmp ( ASSETCHAINS_SYMBOL , ( char * ) & scriptbuf [ len + 32 * 2 + 4 ] ) = = 0 )
{
{
len + = iguana_rwbignum ( 0 , & scriptbuf [ len ] , 32 , ( uint8_t * ) & hash ) ;
len + = iguana_rwbignum ( 0 , & scriptbuf [ len ] , 32 , ( uint8_t * ) & hash ) ;
@ -1158,12 +1158,12 @@ void komodo_voutupdate(int32_t txi,int32_t vout,uint8_t *scriptbuf,int32_t scrip
}
}
else
else
{
{
LogPrintf ( " dpow: VALID %s MoM.%s [%d] \n " , ASSETCHAINS_SYMBOL , MoM . ToString ( ) . c_str ( ) , MoMdepth ) ;
LogPrint ( " dpow " , " dpow: VALID %s MoM.%s [%d] \n " , ASSETCHAINS_SYMBOL , MoM . ToString ( ) . c_str ( ) , MoMdepth ) ;
}
}
}
}
komodo_notarized_update ( height , * notarizedheightp , hash , desttxid , MoM , MoMdepth ) ;
komodo_notarized_update ( height , * notarizedheightp , hash , desttxid , MoM , MoMdepth ) ;
LogPrintf ( " dpow: %s ht.%d NOTARIZED.%d %s %sTXID.%s lens.(%d %d) \n " , ASSETCHAINS_SYMBOL , height , * notarizedheightp , hash . ToString ( ) . c_str ( ) , " KMD " , desttxid . ToString ( ) . c_str ( ) , opretlen , len ) ;
LogPrint ( " dpow " , " dpow: %s ht.%d NOTARIZED.%d %s %sTXID.%s lens.(%d %d) \n " , ASSETCHAINS_SYMBOL , height , * notarizedheightp , hash . ToString ( ) . c_str ( ) , " KMD " , desttxid . ToString ( ) . c_str ( ) , opretlen , len ) ;
} else LogPrintf ( " dpow: notarized.%d ht %d vs prev %d vs height.%d \n " , notarized , * notarizedheightp , NOTARIZED_HEIGHT , height ) ;
} else LogPrint ( " dpow " , " dpow: notarized.%d ht %d vs prev %d vs height.%d \n " , notarized , * notarizedheightp , NOTARIZED_HEIGHT , height ) ;
}
}
}
}
}
}
@ -1172,6 +1172,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
{
{
static int32_t hwmheight ;
static int32_t hwmheight ;
uint64_t signedmask ; uint8_t scriptbuf [ 4096 ] , pubkeys [ 64 ] [ 33 ] , scriptPubKey [ 35 ] ; uint256 zero ; int32_t i , j , k , m , numnotaries , notarized , scriptlen , numvalid , specialtx , notarizedheight , len , numvouts , numvins , height , txn_count ;
uint64_t signedmask ; uint8_t scriptbuf [ 4096 ] , pubkeys [ 64 ] [ 33 ] , scriptPubKey [ 35 ] ; uint256 zero ; int32_t i , j , k , m , numnotaries , notarized , scriptlen , numvalid , specialtx , notarizedheight , len , numvouts , numvins , height , txn_count ;
uint256 txhash ;
if ( KOMODO_NEEDPUBKEYS ! = 0 )
if ( KOMODO_NEEDPUBKEYS ! = 0 )
{
{
@ -1187,7 +1188,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
else
else
{
{
if ( pindex - > nHeight ! = hwmheight )
if ( pindex - > nHeight ! = hwmheight )
LogPrintf ( " dpow: %s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d \n " , ASSETCHAINS_SYMBOL , hwmheight , pindex - > nHeight , ( uint32_t ) pindex - > nTime , hwmheight - pindex - > nHeight ) ;
LogPrint ( " dpow " , " dpow: %s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d \n " , ASSETCHAINS_SYMBOL , hwmheight , pindex - > nHeight , ( uint32_t ) pindex - > nTime , hwmheight - pindex - > nHeight ) ;
}
}
if ( pindex ! = 0 )
if ( pindex ! = 0 )
@ -1197,7 +1198,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
//fprintf(stderr, "txn_count=%d\n", txn_count);
//fprintf(stderr, "txn_count=%d\n", txn_count);
for ( i = 0 ; i < txn_count ; i + + )
for ( i = 0 ; i < txn_count ; i + + )
{
{
//txhash = block.vtx[i]->GetHash();
txhash = block . vtx [ i ] . GetHash ( ) ;
numvouts = block . vtx [ i ] . vout . size ( ) ;
numvouts = block . vtx [ i ] . vout . size ( ) ;
specialtx = notarizedheight = notarized = 0 ;
specialtx = notarizedheight = notarized = 0 ;
signedmask = 0 ;
signedmask = 0 ;
@ -1224,12 +1225,18 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
numvalid = bitweight ( signedmask ) ;
numvalid = bitweight ( signedmask ) ;
if ( numvalid > = KOMODO_MINRATIFY )
if ( numvalid > = KOMODO_MINRATIFY )
notarized = 1 ;
notarized = 1 ;
if ( Params ( ) . NetworkIDString ( ) = = " regtest " & & ( height % 7 = = 0 ) ) {
notarized = 1 ;
NOTARIZED_HEIGHT = height ;
NOTARIZED_HASH = block . GetHash ( ) ;
NOTARIZED_DESTTXID = txhash ;
}
if ( IS_NOTARY )
if ( IS_NOTARY )
printf ( " (tx.%d: " , i ) ;
LogPrint ( " dpow " , " (tx.%d: " , i ) ;
for ( j = 0 ; j < numvouts ; j + + )
for ( j = 0 ; j < numvouts ; j + + )
{
{
if ( IS_NOTARY )
if ( IS_NOTARY )
printf ( " %.8f " , dstr ( block . vtx [ i ] . vout [ j ] . nValue ) ) ;
LogPrint ( " dpow " , " %.8f " , dstr ( block . vtx [ i ] . vout [ j ] . nValue ) ) ;
len = block . vtx [ i ] . vout [ j ] . scriptPubKey . size ( ) ;
len = block . vtx [ i ] . vout [ j ] . scriptPubKey . size ( ) ;
if ( len > = ( int32_t ) sizeof ( uint32_t ) & & len < = ( int32_t ) sizeof ( scriptbuf ) )
if ( len > = ( int32_t ) sizeof ( uint32_t ) & & len < = ( int32_t ) sizeof ( scriptbuf ) )
{
{
@ -1238,10 +1245,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
}
}
}
if ( NOTARY_PUBKEY33 [ 0 ] ! = 0 )
if ( NOTARY_PUBKEY33 [ 0 ] ! = 0 )
printf ( " ) " ) ;
LogPrint ( " dpow " , " ) " ) ;
if ( NOTARY_PUBKEY33 [ 0 ] ! = 0 )
if ( NOTARY_PUBKEY33 [ 0 ] ! = 0 )
printf ( " %s ht.%d \n " , ASSETCHAINS_SYMBOL , height ) ;
LogPrint ( " dpow " , " %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 ) ;
LogPrint ( " dpow " , " 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 LogPrint ( " dpow " , " komodo_connectblock: unexpected null pindex \n " ) ;
} else LogPrint ( " dpow " , " komodo_connectblock: unexpected null pindex \n " ) ;