diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 738247604..0ea3f12b1 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -35,6 +35,7 @@ static bool fDaemon; extern char ASSETCHAINS_SYMBOL[16]; void komodo_gateway_iteration(char *symbol); void komodo_iteration(char *symbol); +int32_t komodo_is_issuer(); void WaitForShutdown(boost::thread_group* threadGroup) { @@ -43,7 +44,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { MilliSleep(2000); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( komodo_is_issuer() != 0 ) komodo_gateway_iteration(ASSETCHAINS_SYMBOL); else komodo_iteration((char *)"EUR"); @@ -62,6 +63,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,ASSETCHAIN_INIT; extern std::string NOTARY_PUBKEY; +int32_t komodo_is_issuer(); bool AppInit(int argc, char* argv[]) { @@ -104,7 +106,7 @@ bool AppInit(int argc, char* argv[]) fprintf(stderr,"call komodo_args NOTARY_PUBKEY.(%s)\n",NOTARY_PUBKEY.c_str()); while ( ASSETCHAIN_INIT == 0 ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( komodo_is_issuer() != 0 ) komodo_gateway_iteration(ASSETCHAINS_SYMBOL); sleep(1); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d06c49ee3..40a0c6ae0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -44,7 +44,7 @@ uint64_t komodo_paxtotal() { if ( pax->marked == 0 ) { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) + if ( komodo_is_issuer() != 0 ) total += pax->fiatoshis; else total += pax->komodoshis; } @@ -80,9 +80,9 @@ struct pax_transaction *komodo_paxmark(struct pax_transaction *space,uint256 txi if ( pax != 0 ) { pax->marked = mark; - int32_t i; for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" paxmark.ht %d vout%d\n",mark,vout); + //int32_t i; for (i=0; i<32; i++) + // printf("%02x",((uint8_t *)&txid)[i]); + //printf(" paxmark.ht %d vout%d\n",mark,vout); memcpy(space,pax,sizeof(*pax)); } pthread_mutex_unlock(&komodo_mutex); @@ -238,9 +238,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else { hash = block.GetHash(); - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&hash)[j]); - printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i); + //for (j=0; j<32; j++) + // printf("%02x",((uint8_t *)&hash)[j]); + //printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i); komodo_paxmark(&space,txids[i-1],vouts[i-1],height); } } @@ -266,7 +266,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "deposit"; - printf("kmdheight.%d vs height.%d check %.8f vs %.8f\n",kmdheight,height,dstr(checktoshis),dstr(value)); + printf("kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d\n",kmdheight,height,dstr(checktoshis),dstr(value),tokomodo,strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0); if ( kmdheight <= height ) { if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 420d1c228..7465c730e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -802,7 +802,7 @@ int32_t komodo_baseid(char *origbase) int32_t komodo_is_issuer() { - if ( ASSETCHAINS_SYMBOL[0] != 0 && COINBASE_MATURITY < 10 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) return(1); else return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index 5125f3b88..984a9efaf 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,6 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize); uint64_t komodo_paxtotal(); +int32_t komodo_is_issuer(); void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol); extern int32_t KOMODO_INITDONE,ASSETCHAINS_SHORTFLAG; extern char ASSETCHAINS_SYMBOL[16]; @@ -376,7 +377,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) } komodo_gateway_deposits(&txNew,0,(char *)"EUR"); } - else + else if ( komodo_is_issuer() != 0 ) { komodo_gateway_deposits(&txNew,0,(char *)"KMD"); fprintf(stderr,"txNew numvouts.%d\n",(int32_t)txNew.vout.size()); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8060c85f4..7854f2d00 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -476,7 +476,7 @@ Value paxdeposit(const Array& params, bool fHelp) { uint64_t seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; bool fSubtractFeeFromAmount = false; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( komodo_is_issuer() != 0 ) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KMD"); if (!EnsureWalletIsAvailable(fHelp)) return Value::null;