Skip to content

Commit

Permalink
Merge pull request #412 from KomodoPlatform/dev
Browse files Browse the repository at this point in the history
sync beta
  • Loading branch information
ca333 authored Apr 22, 2021
2 parents 778ebc1 + efc9756 commit 4aef1a5
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 28 deletions.
12 changes: 6 additions & 6 deletions src/komodo.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
sp->NOTARIZED_HASH = block.GetHash();
sp->NOTARIZED_DESTTXID = txhash;
}
if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf("(tx.%d: ",i);
//if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
// printf("(tx.%d: ",i);
for (j=0; j<numvouts; j++)
{
/*if ( i == 0 && j == 0 )
Expand All @@ -955,8 +955,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
}
}
}*/
if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf("%.8f ",dstr(block.vtx[i].vout[j].nValue));
//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) )
Expand All @@ -976,8 +976,8 @@ int32_t komodo_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
}
}
}
if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf(") ");
//if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
// printf(") ");
if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 )
printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification);
if ( !fJustCheck && (notarized != 0 && (notarizedheight != 0 || specialtx != 0)) )
Expand Down
44 changes: 31 additions & 13 deletions src/komodo_bitcoind.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,11 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
{
sprintf(url,(char *)"http://127.0.0.1:%u",port);
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
//printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS);
// printf("[%s] (%s) postdata.(%s) params.(%s) USERPASS.(%s)\n",ASSETCHAINS_SYMBOL,url,postdata,params,KMDUSERPASS);
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,method,params);
//retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
}
// fprintf(stderr, "RPC RESP: %s\n", retstr2);
return(retstr2);
}

Expand All @@ -394,27 +395,45 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig
port = KMD_PORT;
userpass = KMDUSERPASS;
}
else if ( strcmp(dest,"BTC") == 0 )
else if ( strcmp(dest,"BTC") == 0 ) // this is no longer strictly BTC; depends on -notary= path
{
port = 8332;
port = DEST_PORT;
userpass = BTCUSERPASS;
}
else return(0);
if ( userpass[0] != 0 )
{
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 )
if ( strcmp("BTC",dest) != 0 )
{
//printf("(%s)\n",jsonstr);
if ( (json= cJSON_Parse(jsonstr)) != 0 )
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 )
{
if ( (item= jobj(json,(char *)"result")) != 0 )
//printf("(%s)\n",jsonstr);
if ( (json= cJSON_Parse(jsonstr)) != 0 )
{
height = jint(item,(char *)"blocks");
*kmdnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height;
if ( (item= jobj(json,(char *)"result")) != 0 )
{
height = jint(item,(char *)"blocks");
*kmdnotarized_heightp = height;
}
free_json(json);
}
free_json(json);
free(jsonstr);
}
} else {
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getblockchaininfo",params,port)) != 0 )
{
//printf("(%s)\n",jsonstr);
if ( (json= cJSON_Parse(jsonstr)) != 0 )
{
if ( (item= jobj(json,(char *)"result")) != 0 )
{
height = jint(item,(char *)"blocks");
*kmdnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height;
}
free_json(json);
}
free(jsonstr);
}
free(jsonstr);
}
sprintf(params,"[\"%s\", 1]",txidstr);
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 )
Expand Down Expand Up @@ -496,8 +515,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t
{
if ( BTCUSERPASS[0] != 0 )
{
//printf("BTCUSERPASS.(%s)\n",BTCUSERPASS);
jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332);
jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,DEST_PORT);
}
//else jsonstr = _dex_getrawtransaction();
else return(0);
Expand Down
2 changes: 1 addition & 1 deletion src/komodo_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int32_t ASSETCHAINS_STAKED;
uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,ASSETCHAINS_FOUNDERS_REWARD;

uint32_t KOMODO_INITDONE;
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771, DEST_PORT;
uint64_t PENDING_KOMODO_TX;
extern int32_t KOMODO_LOADINGBLOCKS;
unsigned int MAX_BLOCK_SIGOPS = 20000;
Expand Down
20 changes: 12 additions & 8 deletions src/komodo_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1698,9 +1698,13 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k)
void komodo_args(char *argv0)
{
std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0;
FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512] = {0}; CTransaction earlytx; uint256 hashBlock;
FILE *fp; uint64_t val; uint16_t port, dest_rpc_port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512] = {0}; CTransaction earlytx; uint256 hashBlock;

std::string ntz_dest_path;
ntz_dest_path = GetArg("-notary", "");
IS_KOMODO_NOTARY = ntz_dest_path == "" ? 0 : 1;


IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
IS_STAKED_NOTARY = GetArg("-stakednotary", -1);
KOMODO_NSPV = GetArg("-nSPV",0);
memset(ccenables,0,sizeof(ccenables));
Expand Down Expand Up @@ -2333,27 +2337,27 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
fname[strlen(fname)-1] = 0;
if ( iter == 0 )
strcat(fname,"Komodo\\komodo.conf");
else strcat(fname,"Bitcoin\\bitcoin.conf");
else strcat(fname,ntz_dest_path.c_str());
#else
while ( fname[strlen(fname)-1] != '/' )
fname[strlen(fname)-1] = 0;
#ifdef __APPLE__
if ( iter == 0 )
strcat(fname,"Komodo/Komodo.conf");
else strcat(fname,"Bitcoin/Bitcoin.conf");
else strcat(fname,ntz_dest_path.c_str());
#else
if ( iter == 0 )
strcat(fname,".komodo/komodo.conf");
else strcat(fname,".bitcoin/bitcoin.conf");
else strcat(fname,ntz_dest_path.c_str());
#endif
#endif
if ( (fp= fopen(fname,"rb")) != 0 )
{
_komodo_userpass(username,password,fp);
dest_rpc_port = _komodo_userpass(username,password,fp);
DEST_PORT = iter == 1 ? dest_rpc_port : 0;
sprintf(iter == 0 ? KMDUSERPASS : BTCUSERPASS,"%s:%s",username,password);
fclose(fp);
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
} //else printf("couldnt open.(%s)\n",fname);
} else printf("couldnt open.(%s) will not validate dest notarizations\n",fname);
if ( IS_KOMODO_NOTARY == 0 )
break;
}
Expand Down

0 comments on commit 4aef1a5

Please sign in to comment.