From fbc4209b0da192171ab5a94da78bd524451eaec9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 10:27:57 -0300 Subject: [PATCH 001/115] test --- src/komodo_gateway.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3279cfd95..001fb86f4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -191,7 +191,11 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * data[len++] = (pax->vout >> 8) & 0xff; if ( strcmp(symbol,"KMD") != 0 ) PENDING_KOMODO_TX += pax->fiatoshis; - else PENDING_KOMODO_TX += pax->komodoshis; + else + { + //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.78329000,"fiat":"EUR","height":57930,"KMD":0.10000000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5"}] + PENDING_KOMODO_TX += pax->komodoshis; + } //printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); if ( numvouts++ >= 64 ) break; From 73ccdf555c3352ea4db95b4b36f503b383b959ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 10:47:12 -0300 Subject: [PATCH 002/115] test --- src/rpcblockchain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 50175873e..7d87601a1 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -444,7 +444,9 @@ Value paxprice(const Array& params, bool fHelp) ret.push_back(Pair("base", base)); ret.push_back(Pair("rel", rel)); ret.push_back(Pair("height", height)); - ret.push_back(Pair("seed", seed)); + char seedstr[32]; + sprintf(seedstr,"%llu",(long long)seed); + ret.push_back(Pair("seed", seedstr)); if ( height < 0 || height > chainActive.Height() ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else From 121c4c5caa71ee68c01c80c53ec9d85c8740097f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 11:09:20 -0300 Subject: [PATCH 003/115] test --- src/wallet/rpcwallet.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 892cf4fc1..1e8e6c17d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -513,7 +513,7 @@ Value paxdeposit(const Array& params, bool fHelp) Value paxwithdraw(const Array& params, bool fHelp) { extern int32_t KMDHEIGHT,KOMODO_REALTIME; - CWalletTx wtx; std::string dest; int32_t height; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; + CWalletTx wtx; std::string dest; int32_t kmdheight; uint64_t seed,komodoshis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; if ( ASSETCHAINS_SYMBOL[0] == 0 ) return(0); if (!EnsureWalletIsAvailable(fHelp)) @@ -527,20 +527,20 @@ Value paxwithdraw(const Array& params, bool fHelp) if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),KMDHEIGHT,ASSETCHAINS_SYMBOL,fiatoshis); + kmdheight = KMDHEIGHT; + komodoshis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),kmdheight,ASSETCHAINS_SYMBOL,fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); if (!destaddress.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); for (i=0; i<33; i++) printf("%02x",pubkey37[i]); - height = KMDHEIGHT; - printf(" ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),ASSETCHAINS_SYMBOL,(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed); + printf(" kmdheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) komodoshis.%llu seed.%llx\n",kmdheight,(char *)params[0].get_str().c_str(),ASSETCHAINS_SYMBOL,(long long)fiatoshis,destaddr,(long long)komodoshis,(long long)seed); EnsureWalletIsUnlocked(); - uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000; + uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000; if ( fee < 10000 ) fee = 10000; - iguana_rwnum(1,&pubkey37[33],sizeof(height),&height); + iguana_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight); opretlen = komodo_opreturnscript(opretbuf,'W',pubkey37,37); SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis); return wtx.GetHash().GetHex(); From 1fc75a27d37b702dea7eb4abb41f45876530ab75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 11:53:21 -0300 Subject: [PATCH 004/115] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 67 +++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4306548c1..ba53fd1c9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -23,7 +23,7 @@ #include #endif -#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7775",0,(char *)(cmdstr),0) +#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,(char *)(cmdstr),0) struct MemoryStruct { char *memory; size_t size; }; struct return_string { char *ptr; size_t len; }; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 001fb86f4..7aebb0463 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -20,7 +20,7 @@ struct pax_transaction UT_hash_handle hh; uint256 txid; uint64_t komodoshis,fiatoshis; - int32_t marked,height; + int32_t marked,kmdheight; uint16_t vout; char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; } *PAX; @@ -28,27 +28,6 @@ struct pax_transaction uint64_t komodo_paxtotal() { struct pax_transaction *pax,*tmp; uint64_t total = 0; - /*pthread_mutex_lock(&komodo_mutex); - tmp = 0; - if ( PAX != 0 ) - { - pax = (struct pax_transaction *)PAX->hh.next; - while ( pax != 0 && pax != tmp && n++ < 1000000 ) - { - printf("PAX.[%p %p] pax.%p marked.%d fiat %.8f KMD %.8f\n",PAX->hh.next,PAX->hh.prev,pax,pax->marked,dstr(pax->fiatoshis),dstr(pax->komodoshis)); - if ( pax->marked == 0 ) - { - if ( komodo_is_issuer() != 0 ) - total += pax->fiatoshis; - else total += pax->komodoshis; - } - tmp = pax; - pax = (struct pax_transaction *)pax->hh.next; - } - } - pthread_mutex_unlock(&komodo_mutex); - if ( n >= 1000000 ) - printf("komodo_paxtotal n.%d iterations?\n",n);*/ HASH_ITER(hh,PAX,pax,tmp) { if ( pax->marked == 0 ) @@ -97,7 +76,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp return(pax); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height) // assetchain context +void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context { struct pax_transaction *pax; int32_t addflag = 0; pthread_mutex_lock(&komodo_mutex); @@ -108,9 +87,12 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char pax->txid = txid; pax->vout = vout; HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); - //int32_t i; for (i=0; i<32; i++) - // printf("%02x",((uint8_t *)&txid)[i]); - //printf(" v.%d [%s] ht.%d create pax.%p\n",vout,ASSETCHAINS_SYMBOL,height,pax); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + int32_t i; for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" v.%d [%s] kht.%d ht.%d create pax.%p\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax); + } } pthread_mutex_unlock(&komodo_mutex); if ( coinaddr != 0 ) @@ -122,14 +104,15 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char pax->fiatoshis = fiatoshis; memcpy(pax->rmd160,rmd160,20); pax->height = height; + pax->otherheight = otherheight; if ( pax->marked == 0 ) - printf("[%s] %p ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d total %.8f\n",ASSETCHAINS_SYMBOL,pax,symbol,dstr(fiatoshis),coinaddr,height,dstr(komodo_paxtotal())); - else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height); + printf("[%s] %p ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,pax,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); + else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } else { pax->marked = height; - printf("pax.%p MARK DEPOSIT ht.%d\n",pax,height); + printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight); } } @@ -173,7 +156,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%p marked.%d %.8f -> %.8f\n",pax,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); - txNew->vout[numvouts].nValue = pax->fiatoshis; + txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; txNew->vout[numvouts].scriptPubKey.resize(25); script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0]; *script++ = 0x76; @@ -193,7 +176,15 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * PENDING_KOMODO_TX += pax->fiatoshis; else { - //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.78329000,"fiat":"EUR","height":57930,"KMD":0.10000000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5"}] + //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.10000000,"fiat":"EUR","kmdheight":57930,"height":153,"KMD":0.78329000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5","rmd160":"306c507eea639e7220b3069ed9f49f3bc97eaca1"}] + len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis); + len += iguana_rwnum(1,&data[len],sizeof(pax->height),&pax->height); + len += iguana_rwnum(1,&data[len],sizeof(pax->otherheight),&pax->otherheight); + if ( pax->shortflag != 0 ) + data[len++] = '-'; + for (i=0; pax->symbol[i]!=0&&i<3; i++) + data[len++] = pax->symbol[i]; + data[len++] = 0; PENDING_KOMODO_TX += pax->komodoshis; } //printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); @@ -321,7 +312,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( komodo_paxfind(&space,txid,vout) == 0 ) { - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight); + komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight,height); } else printf("duplicate deposit\n"); } } @@ -351,7 +342,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 // printf("%02x",((uint8_t *)&txids[i])[j]); if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 ) { - komodo_gateway_deposit(0,0,0,0,0,0,txids[i],vouts[i],height); + komodo_gateway_deposit(0,0,0,0,0,0,txids[i],vouts[i],height,0); } else { @@ -517,10 +508,9 @@ void komodo_gateway_iteration(char *symbol) void komodo_iteration(char *symbol) { - char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height; uint256 txid; uint8_t rmd160[20],addrtype; + char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height,fiatheight; uint256 txid; uint8_t rmd160[20],addrtype; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.78329000,"fiat":"EUR","height":57930,"KMD":0.10000000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5"}] sprintf(cmd,"{\"agent\":\"dpow\",\"method\":\"pending\",\"fiat\":\"%s\"}",symbol); if ( (retstr= issue_curl(cmd)) != 0 ) { @@ -533,17 +523,18 @@ void komodo_iteration(char *symbol) item = jitem(array,i); coinaddr = jstr(item,(char *)"address"); value = jdouble(item,(char *)"KMD") * COIN; + base = jstr(item,(char *)"fiat"); shortflag = juint(item,(char *)"short"); vout = jint(item,(char *)"prev_vout"); - height = jint(item,(char *)"height"); - base = jstr(item,(char *)"fiat"); + height = jint(item,(char *)"kmdheight"); + fiatheight = jint(item,(char *)"height"); txidstr = jstr(item,(char *)"prev_hash"); if ( coinaddr != 0 && base != 0 && value > 0 && height > 0 ) { fiatoshis = jdouble(item,base) * COIN; decode_hex((uint8_t *)&txid,sizeof(txid),txidstr); bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr); - komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height); + komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,height,fiatheight); } } } From d95563bec0d41c81ac497677426ccac3fe9c53f2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 11:54:29 -0300 Subject: [PATCH 005/115] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 7aebb0463..924c61f76 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -20,7 +20,7 @@ struct pax_transaction UT_hash_handle hh; uint256 txid; uint64_t komodoshis,fiatoshis; - int32_t marked,kmdheight; + int32_t marked,height,otherheight; uint16_t vout; char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; } *PAX; From f55c6d7c80f79bf6cfd4a14242b6a66c633ef4f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:00:58 -0300 Subject: [PATCH 006/115] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 924c61f76..cb148baad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -509,6 +509,7 @@ void komodo_gateway_iteration(char *symbol) void komodo_iteration(char *symbol) { char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height,fiatheight; uint256 txid; uint8_t rmd160[20],addrtype; + return; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { sprintf(cmd,"{\"agent\":\"dpow\",\"method\":\"pending\",\"fiat\":\"%s\"}",symbol); From fba6038cd46b106fb3869279eb0d065050367fa1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:05:41 -0300 Subject: [PATCH 007/115] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ba53fd1c9..cfe438e28 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -23,7 +23,7 @@ #include #endif -#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,(char *)(cmdstr),0) +#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"curl",(char *)"http://127.0.0.1:7776",0,0,(char *)(cmdstr)) struct MemoryStruct { char *memory; size_t size; }; struct return_string { char *ptr; size_t len; }; From a39576b5e2d1dcd37f0532ed16871a578877decc Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:11:36 -0300 Subject: [PATCH 008/115] test --- src/komodo_gateway.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cb148baad..924c61f76 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -509,7 +509,6 @@ void komodo_gateway_iteration(char *symbol) void komodo_iteration(char *symbol) { char *retstr,*base,*coinaddr,*txidstr,cmd[512]; uint64_t value,fiatoshis; cJSON *array,*item; int32_t i,n,vout,shortflag,height,fiatheight; uint256 txid; uint8_t rmd160[20],addrtype; - return; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { sprintf(cmd,"{\"agent\":\"dpow\",\"method\":\"pending\",\"fiat\":\"%s\"}",symbol); From 7961668b7ea7e72d6b3fabaa0420e33ff4609905 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:19:25 -0300 Subject: [PATCH 009/115] test --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 924c61f76..1a2ae19bc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -87,6 +87,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char pax->txid = txid; pax->vout = vout; HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); + addflag = 1; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i; for (i=0; i<32; i++) @@ -106,7 +107,10 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char pax->height = height; pax->otherheight = otherheight; if ( pax->marked == 0 ) - printf("[%s] %p ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,pax,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); + { + if ( addflag != 0 ) + printf("[%s] %p ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,pax,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); + } else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } else @@ -539,7 +543,7 @@ void komodo_iteration(char *symbol) } } } - printf("retstr.(%s)\n",retstr); + //printf("retstr.(%s)\n",retstr); free(retstr); } } From 00cf544ef81489d00bf0f7ab0b353b4510b0bb17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:25:06 -0300 Subject: [PATCH 010/115] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1a2ae19bc..568883b08 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -109,7 +109,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char if ( pax->marked == 0 ) { if ( addflag != 0 ) - printf("[%s] %p ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,pax,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); + printf("[%s] addflag.%d ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); } else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } @@ -190,8 +190,8 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * data[len++] = pax->symbol[i]; data[len++] = 0; PENDING_KOMODO_TX += pax->komodoshis; + printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } - //printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); if ( numvouts++ >= 64 ) break; } @@ -208,7 +208,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * txNew->vout[numvouts].scriptPubKey.resize(opretlen); script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0]; memcpy(script,opret,opretlen); - printf("total numvouts.%d %.8f opretlen.%d\n",numvouts,dstr(PENDING_KOMODO_TX),opretlen); + printf("deposits: total numvouts.%d %.8f opretlen.%d\n",numvouts,dstr(PENDING_KOMODO_TX),opretlen); } } From a8961ee0cced5098d60309ba6435569a55e0eb4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:36:13 -0300 Subject: [PATCH 011/115] test --- src/komodo_gateway.h | 2 ++ src/miner.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 568883b08..5ed928000 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -153,8 +153,10 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * if ( strcmp(symbol,"KMD") != 0 ) opcode = 'I'; else opcode = 'X'; + printf("gateway deposits\n"); HASH_ITER(hh,PAX,pax,tmp) { + printf("pax.%p\n",pax); if ( pax->marked != 0 ) continue; if ( ASSETCHAINS_SYMBOL[0] != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 76c1ae3a0..b692b47d7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -125,7 +125,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) break; sleep(10); } - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); // -regtest only: allow overriding block.nVersion with From 892c45dd2bb6e491f72ca94237c62d29b1ab455b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:47:44 -0300 Subject: [PATCH 012/115] test --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index b692b47d7..af411aea1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -556,14 +556,15 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); } - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - // fprintf(stderr,"%s create new block\n",ASSETCHAINS_SYMBOL); // // Create new block // Mining_start = (uint32_t)time(NULL); unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.Tip(); + Mining_height = pindexPrev->nHeight+1; + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); if (!pblocktemplate.get()) @@ -586,7 +587,6 @@ void static BitcoinMiner(CWallet *pwallet) Mining_start = (uint32_t)time(NULL); fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } else Mining_start = 0; - Mining_height = pindexPrev->nHeight+1; while (true) { //fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); @@ -722,7 +722,7 @@ void static BitcoinMiner(CWallet *pwallet) } if ( pindexPrev != chainActive.Tip() ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("Tip advanced, break\n"); break; } From ec7ad5f6573d9aabb4ace86551979ebafe9d4b26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 12:58:24 -0300 Subject: [PATCH 013/115] test --- src/miner.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index af411aea1..e97b37ec3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -120,7 +120,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { deposits = komodo_paxtotal(); if ( KOMODO_INITDONE == 0 || time(NULL) < KOMODO_INITDONE+60 || KOMODO_REALTIME == 0 ) + { + fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); continue; + } if ( deposits != 0 ) break; sleep(10); From c021b871428d6feb080a8b0bcc4cd890e56f7ff0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 13:03:24 -0300 Subject: [PATCH 014/115] test --- src/komodo.h | 2 +- src/miner.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e2e30224d..3cb5bf2fb 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -366,7 +366,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) sleep(3); } } - KOMODO_INITDONE = (uint32_t)time(NULL); + KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; diff --git a/src/miner.cpp b/src/miner.cpp index e97b37ec3..223573140 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -122,9 +122,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( KOMODO_INITDONE == 0 || time(NULL) < KOMODO_INITDONE+60 || KOMODO_REALTIME == 0 ) { fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); - continue; } - if ( deposits != 0 ) + else if ( deposits != 0 ) break; sleep(10); } From b86d6c98aff5de4943a5d0262d30713e28db283e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 13:08:50 -0300 Subject: [PATCH 015/115] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 223573140..7f69633c9 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -119,7 +119,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( mempool.GetTotalTxSize() <= 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || time(NULL) < KOMODO_INITDONE+60 || KOMODO_REALTIME == 0 ) + if ( KOMODO_INITDONE == 0 || KOMODO_REALTIME == 0 ) { fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); } @@ -566,7 +566,7 @@ void static BitcoinMiner(CWallet *pwallet) CBlockIndex* pindexPrev = chainActive.Tip(); Mining_height = pindexPrev->nHeight+1; //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); + //fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); if (!pblocktemplate.get()) From f5927d73a78f406d4b3648bb1b35f9896ddd2f1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 13:17:53 -0300 Subject: [PATCH 016/115] test --- src/pow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pow.cpp b/src/pow.cpp index 85d88eed2..54959c2b0 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -124,6 +124,12 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in //fprintf(stderr," height.%d special.%d nonz.%d\n",height,special,nonz); if ( nonz == 0 ) return(true); // will come back via different path with pubkey set + else + { + for (i=0; i<33; i++) + fprintf(stderr,"%02x",pubkey33[i]); + fprintf(stderr," special.%d notaryid.%d ht.%d mod.%d\n",special,notaryid,height,(height % 35)); + } if ( special > 0 ) // special notary id == (height % numnotaries) { if (UintToArith256(hash) <= bnTarget) // accept normal diff From a6be357ed34bac799724ba8df92e76f95de5ae7c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 13:19:53 -0300 Subject: [PATCH 017/115] test --- src/komodo_gateway.h | 2 -- src/miner.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5ed928000..568883b08 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -153,10 +153,8 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * if ( strcmp(symbol,"KMD") != 0 ) opcode = 'I'; else opcode = 'X'; - printf("gateway deposits\n"); HASH_ITER(hh,PAX,pax,tmp) { - printf("pax.%p\n",pax); if ( pax->marked != 0 ) continue; if ( ASSETCHAINS_SYMBOL[0] != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 7f69633c9..a72557c65 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -724,7 +724,7 @@ void static BitcoinMiner(CWallet *pwallet) } if ( pindexPrev != chainActive.Tip() ) { - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) printf("Tip advanced, break\n"); break; } From a67020f33336d922835bcfc7315c0a0a10938cb9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 13:51:02 -0300 Subject: [PATCH 018/115] test --- src/pow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pow.cpp b/src/pow.cpp index 54959c2b0..0a8786d74 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -144,6 +144,9 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if (UintToArith256(hash) > bnTarget) { + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" special.%d notaryid.%d ht.%d mod.%d\n",special,notaryid,height,(height % 35)); return error("CheckProofOfWork(): hash doesn't match nBits"); } if ( flag != 0 ) From 359151495ad54a29c1e2a8f83bd4873ebcf1444c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 14:30:34 -0300 Subject: [PATCH 019/115] test --- src/main.cpp | 10 +++++----- src/main.h | 2 +- src/miner.cpp | 4 ++-- src/rpcmining.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9c9d4d21d..78877dd28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3312,12 +3312,12 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned } -bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) +bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) { // Preliminary checks bool checked; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - checked = CheckBlock(komodo_block2height(pblock),0,*pblock, state); + checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state); else checked = CheckBlock(0,0,*pblock, state); { LOCK(cs_main); @@ -3882,7 +3882,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) // process in case the block isn't known yet if (mapBlockIndex.count(hash) == 0 || (mapBlockIndex[hash]->nStatus & BLOCK_HAVE_DATA) == 0) { CValidationState state; - if (ProcessNewBlock(state, NULL, &block, true, dbp)) + if (ProcessNewBlock(0,state, NULL, &block, true, dbp)) nLoaded++; if (state.IsError()) break; @@ -3904,7 +3904,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp) LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(), head.ToString()); CValidationState dummy; - if (ProcessNewBlock(dummy, NULL, &block, true, &it->second)) + if (ProcessNewBlock(0,dummy, NULL, &block, true, &it->second)) { nLoaded++; queue.push_back(block.GetHash()); @@ -4932,7 +4932,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Such an unrequested block may still be processed, subject to the // conditions in AcceptBlock(). bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(); - ProcessNewBlock(state, pfrom, &block, forceProcessing, NULL); + ProcessNewBlock(0,state, pfrom, &block, forceProcessing, NULL); int nDoS; if (state.IsInvalid(nDoS)) { pfrom->PushMessage("reject", strCommand, state.GetRejectCode(), diff --git a/src/main.h b/src/main.h index c768725d6..9e4825c85 100644 --- a/src/main.h +++ b/src/main.h @@ -167,7 +167,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals); * @param[out] dbp If pblock is stored to disk (or already there), this will be set to its location. * @return True if state.IsValid() */ -bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp); +bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp); /** Check whether enough disk space is available for an incoming block */ bool CheckDiskSpace(uint64_t nAdditionalBytes = 0); /** Open a block file (blk?????.dat) */ diff --git a/src/miner.cpp b/src/miner.cpp index a72557c65..fe01410ca 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -468,7 +468,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) { LogPrintf("%s\n", pblock->ToString()); - LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue)); + LogPrintf("generated %s height.%d\n", FormatMoney(pblock->vtx[0].vout[0].nValue),chainActive.Tip()->nHeight+1); // Found a solution { @@ -489,7 +489,7 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese // Process this block the same as if we had received it from another node CValidationState state; - if (!ProcessNewBlock(state, NULL, pblock, true, NULL)) + if (!ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL)) return error("ZcashMiner: ProcessNewBlock, block not accepted"); minedBlocks.increment(); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 3a11eaf0c..e2a6a1430 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -207,7 +207,7 @@ Value generate(const Array& params, bool fHelp) } endloop: CValidationState state; - if (!ProcessNewBlock(state, NULL, pblock, true, NULL)) + if (!ProcessNewBlock(chainActive->Tip()->nHeight+1,state, NULL, pblock, true, NULL)) throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted"); minedBlocks.increment(); ++nHeight; @@ -716,7 +716,7 @@ Value submitblock(const Array& params, bool fHelp) CValidationState state; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); - bool fAccepted = ProcessNewBlock(state, NULL, &block, true, NULL); + bool fAccepted = ProcessNewBlock(chainActive->Tip()->nHeight+1,state, NULL, &block, true, NULL); UnregisterValidationInterface(&sc); if (fBlockPresent) { From 0be151df27ff83ba45db61bb5d9950a2ca649f65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 14:38:38 -0300 Subject: [PATCH 020/115] test --- src/rpcmining.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index e2a6a1430..e92c26ea4 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -207,7 +207,7 @@ Value generate(const Array& params, bool fHelp) } endloop: CValidationState state; - if (!ProcessNewBlock(chainActive->Tip()->nHeight+1,state, NULL, pblock, true, NULL)) + if (!ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, pblock, true, NULL)) throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted"); minedBlocks.increment(); ++nHeight; @@ -716,7 +716,7 @@ Value submitblock(const Array& params, bool fHelp) CValidationState state; submitblock_StateCatcher sc(block.GetHash()); RegisterValidationInterface(&sc); - bool fAccepted = ProcessNewBlock(chainActive->Tip()->nHeight+1,state, NULL, &block, true, NULL); + bool fAccepted = ProcessNewBlock(chainActive.Tip()->nHeight+1,state, NULL, &block, true, NULL); UnregisterValidationInterface(&sc); if (fBlockPresent) { From 1e983efa98ee6b0af87e90706e8183b192d74cfe Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 15:00:31 -0300 Subject: [PATCH 021/115] test --- src/miner.cpp | 7 ++++--- src/pow.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fe01410ca..bae0a2052 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -435,6 +435,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // // Internal miner // +#define ROUNDROBIN_DELAY 10 extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -621,10 +622,10 @@ void static BitcoinMiner(CWallet *pwallet) // printf("missed target\n"); return false; } - if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+20 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY ) { - printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+20-time(NULL))); - sleep(Mining_start+20-time(NULL)); + printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); + sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL)); } // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); diff --git a/src/pow.cpp b/src/pow.cpp index 0a8786d74..8945a590c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -124,7 +124,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in //fprintf(stderr," height.%d special.%d nonz.%d\n",height,special,nonz); if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - else + else if ( 0 ) { for (i=0; i<33; i++) fprintf(stderr,"%02x",pubkey33[i]); @@ -146,7 +146,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in { for (i=0; i<33; i++) printf("%02x",pubkey33[i]); - printf(" special.%d notaryid.%d ht.%d mod.%d\n",special,notaryid,height,(height % 35)); + printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); return error("CheckProofOfWork(): hash doesn't match nBits"); } if ( flag != 0 ) From a3f23ee221ccc6efb2fb7a1bd66e1891a0e87e1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 15:08:46 -0300 Subject: [PATCH 022/115] test --- src/komodo_gateway.h | 8 ++++---- src/miner.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 568883b08..c9a80ab8b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -146,11 +146,11 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin return(n); } -void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol) +void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo) { struct pax_transaction *pax,*tmp; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; PENDING_KOMODO_TX = 0; - if ( strcmp(symbol,"KMD") != 0 ) + if ( tokomodo == 0 ) opcode = 'I'; else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) @@ -176,7 +176,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * } data[len++] = pax->vout & 0xff; data[len++] = (pax->vout >> 8) & 0xff; - if ( strcmp(symbol,"KMD") != 0 ) + if ( tokomodo == 0 ) PENDING_KOMODO_TX += pax->fiatoshis; else { @@ -208,7 +208,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * txNew->vout[numvouts].scriptPubKey.resize(opretlen); script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0]; memcpy(script,opret,opretlen); - printf("deposits: total numvouts.%d %.8f opretlen.%d\n",numvouts,dstr(PENDING_KOMODO_TX),opretlen); + printf("MINER deposits: tokomodo.%d (%s) total numvouts.%d %.8f opretlen.%d\n",tokomodo,ASSETCHAINS_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen); } } diff --git a/src/miner.cpp b/src/miner.cpp index bae0a2052..aaa9028da 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -102,7 +102,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, 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); +void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo); extern int32_t KOMODO_INITDONE,ASSETCHAINS_SHORTFLAG,KOMODO_REALTIME; extern char ASSETCHAINS_SYMBOL[16]; @@ -376,11 +376,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) txNew.vout[1].nValue = 0; //fprintf(stderr,"opretlen.%d\n",opretlen); } - komodo_gateway_deposits(&txNew,0,(char *)"EUR"); + komodo_gateway_deposits(&txNew,0,(char *)"EUR",1); } else if ( komodo_is_issuer() != 0 ) { - komodo_gateway_deposits(&txNew,0,ASSETCHAINS_SYMBOL); + komodo_gateway_deposits(&txNew,0,ASSETCHAINS_SYMBOL,0); fprintf(stderr,"txNew numvouts.%d\n",(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; From 4fe3439ff21c00e776747e16da156c7fca0351e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 15:23:30 -0300 Subject: [PATCH 023/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index aaa9028da..a30877aec 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -127,7 +127,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) break; sleep(10); } - if ( deposits != 0 ) + if ( 0 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); // -regtest only: allow overriding block.nVersion with From 8c22eb466fc9326c824973fc54b6c764f833ce65 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 15:36:44 -0300 Subject: [PATCH 024/115] test --- src/komodo_globals.h | 2 +- src/miner.cpp | 5 ++++- src/pow.cpp | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index e0516aa31..ef503c0e0 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -15,7 +15,7 @@ int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE; std::string NOTARY_PUBKEY; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/miner.cpp b/src/miner.cpp index a30877aec..6cfc35c55 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -436,7 +436,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // Internal miner // #define ROUNDROBIN_DELAY 10 -extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY; +extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; uint32_t Mining_start,Mining_height; @@ -594,6 +594,7 @@ void static BitcoinMiner(CWallet *pwallet) { //fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL); // Hash state + KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; EhInitialiseState(n, k, state); // I = the block header minus nonce and solution. @@ -626,6 +627,7 @@ void static BitcoinMiner(CWallet *pwallet) { printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL))); sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL)); + KOMODO_CHOSEN_ONE = 1; } // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); @@ -636,6 +638,7 @@ void static BitcoinMiner(CWallet *pwallet) std::lock_guard lock{m_cs}; cancelSolver = false; } + KOMODO_CHOSEN_ONE = 0; int32_t i; uint256 hash = pblock->GetHash(); for (i=0; i<32; i++) fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); diff --git a/src/pow.cpp b/src/pow.cpp index 8945a590c..650bfcb7a 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -138,6 +138,14 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in flag = 1; } //else bnTarget /= 8; } + else if ( height == 0 && KOMODO_CHOSEN_ONE != 0 ) + { + bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + memcpy(pubkey33,NOTARY_PUBKEY33,33); + special = 1; + notaryid = -1; + printf("KOMODO_CHOSEN_ONE -> MINDIFF\n"); + } // Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); From ef2f301ca58043288bc228f6d825f4e475e5f44f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 15:37:17 -0300 Subject: [PATCH 025/115] test --- src/pow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pow.cpp b/src/pow.cpp index 650bfcb7a..b652984d3 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -105,6 +105,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param } int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); +extern int32_t KOMODO_CHOSEN_ONE; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { From 05d91eb2ed9c47e7ded253ecd2b6f58f1c87f872 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 15:57:58 -0300 Subject: [PATCH 026/115] test --- src/komodo_gateway.h | 46 ++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c9a80ab8b..c71965c2e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -120,7 +120,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char } } -int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen) +int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uint16_t *vouts,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { int32_t i,n=0,j,len; if ( opretbuf[opretlen-5] == '-' ) @@ -141,6 +141,20 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; //printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + if ( iskomodo != 0 ) + { + uint64_t fiatoshis; int32_t height,otherheight,shortflag; char symbol[16]; + len += iguana_rwnum(0,&opretbuf[len],sizeof(fiatoshis),&fiatoshis); + len += iguana_rwnum(0,&opretbuf[len],sizeof(height),&height); + len += iguana_rwnum(0,&opretbuf[len],sizeof(otherheight),&otherheight); + if ( opretbuf[len] == '-' ) + shortflag = 1, len++; + else shortflag = 0; + for (i=0; opretbuf[len+i]!=0&&i<3; i++) + symbol[i] = opretbuf[len+i]; + symbol[i] = 0; + printf(">>>>>>> iskomodo X: (%s) fiat %.8f kmdheight.%d other.%d short.%d\n",symbol,dstr(fiatoshis),height,otherheight,shortflag); + } } } return(n); @@ -190,7 +204,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * data[len++] = pax->symbol[i]; data[len++] = 0; PENDING_KOMODO_TX += pax->komodoshis; - printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); + printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } if ( numvouts++ >= 64 ) break; @@ -233,7 +247,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) { - if ( (num= komodo_issued_opreturn(&shortflag,base,txids,vouts,&script[offset],opretlen)) > 0 ) + if ( (num= komodo_issued_opreturn(&shortflag,base,txids,vouts,&script[offset],opretlen,opcode == 'X')) > 0 ) { for (i=1; imarked != 0 ) errs++; else matched++; - //printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue)); + if ( opcode == 'X' ) + printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue)); } 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); + if ( opcode == 'X' ) + { + for (j=0; j<32; j++) + printf("%02x",((uint8_t *)&hash)[j]); + printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i); + } } } else { - //for (j=0; j<32; j++) - // printf("%02x",((uint8_t *)&txids[i-1])[j]); - //printf(" cant paxfind txid\n"); + if ( opcode == 'X' ) + { + for (j=0; j<32; j++) + printf("%02x",((uint8_t *)&txids[i-1])[j]); + printf(" cant paxfind txid\n"); + } } komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height); } if ( matched != num ) { - //printf("matched.%d vs num.%d\n",matched,num); + if ( opcode == 'X' ) + printf("matched.%d vs num.%d\n",matched,num); if ( height > 60000 ) return(-1); } @@ -338,7 +360,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase { - if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen)) > 0 && shortflag == ASSETCHAINS_SHORTFLAG ) + if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen,0)) > 0 && shortflag == ASSETCHAINS_SHORTFLAG ) { for (i=0; i Date: Tue, 8 Nov 2016 16:01:13 -0300 Subject: [PATCH 027/115] test --- src/miner.cpp | 4 +--- src/pow.cpp | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6cfc35c55..8c192e3c2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -436,7 +436,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // Internal miner // #define ROUNDROBIN_DELAY 10 -extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE; +extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; uint32_t Mining_start,Mining_height; @@ -511,8 +511,6 @@ void static BitcoinMiner(CWallet *pwallet) unsigned int n = chainparams.EquihashN(); unsigned int k = chainparams.EquihashK(); - extern int32_t ASSETCHAIN_INIT,KOMODO_INITDONE; extern uint8_t NOTARY_PUBKEY33[33]; - int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); int32_t notaryid = -1; while ( ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0 ) { diff --git a/src/pow.cpp b/src/pow.cpp index b652984d3..e76d78749 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -141,6 +141,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } else if ( height == 0 && KOMODO_CHOSEN_ONE != 0 ) { + extern uint8_t NOTARY_PUBKEY33[33]; bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); memcpy(pubkey33,NOTARY_PUBKEY33,33); special = 1; From 23d955d401f7c91eebaaf966a64f59e4c24bd247 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 16:10:58 -0300 Subject: [PATCH 028/115] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c71965c2e..d65837478 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -222,7 +222,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * txNew->vout[numvouts].scriptPubKey.resize(opretlen); script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0]; memcpy(script,opret,opretlen); - printf("MINER deposits: tokomodo.%d (%s) total numvouts.%d %.8f opretlen.%d\n",tokomodo,ASSETCHAINS_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen); + printf("MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,ASSETCHAINS_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen); } } @@ -234,9 +234,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( n <= 2 || script[0] != 0x6a ) return(0); offset += komodo_scriptitemlen(&opretlen,&script[offset]); - //printf("checkdeposit n.%d [%02x] [%c] %d vs %d\n",n,script[0],script[offset],script[offset],'I'); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { + printf("checkdeposit n.%d [%02x] [%c] %d vs %d\n",n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,"KMD"); } From 76aa815e2da861db8fc3891a2ee27e6a80217166 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 16:23:05 -0300 Subject: [PATCH 029/115] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d65837478..fca916b73 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -236,7 +236,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - printf("checkdeposit n.%d [%02x] [%c] %d vs %d\n",n,script[0],script[offset],script[offset],'X'); + for (i=0; i Date: Tue, 8 Nov 2016 16:34:11 -0300 Subject: [PATCH 030/115] test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index fca916b73..ad74d2ca9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -128,7 +128,7 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin else *shortflagp = 0; for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - if ( (strcmp(base,"KMD") == 0 && ASSETCHAINS_SYMBOL[0] == 0) || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag + if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag { opretbuf++, opretlen--; for (n=len=0; n Date: Tue, 8 Nov 2016 16:48:20 -0300 Subject: [PATCH 031/115] test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ad74d2ca9..02f82998b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -291,8 +291,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( opcode == 'X' ) printf("matched.%d vs num.%d\n",matched,num); - if ( height > 60000 ) - return(-1); + //if ( height > 60000 ) + // return(-1); } } //printf("opretlen.%d num.%d\n",opretlen,num); From 0dca8d4c1cd2e98981c661e5fd7a726ee1bd4358 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 16:55:54 -0300 Subject: [PATCH 032/115] test --- src/komodo_gateway.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 02f82998b..f8881c7d8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -111,7 +111,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char if ( addflag != 0 ) printf("[%s] addflag.%d ADD DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,symbol,dstr(fiatoshis),coinaddr,height,otherheight,dstr(komodo_paxtotal())); } - else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); + //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); } else { @@ -289,10 +289,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( matched != num ) { - if ( opcode == 'X' ) - printf("matched.%d vs num.%d\n",matched,num); - //if ( height > 60000 ) - // return(-1); + // can easily happen depending on order of loading } } //printf("opretlen.%d num.%d\n",opretlen,num); From ce94767eb64655f7c1f939a47ddb6ea9aba24416 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:01:50 -0300 Subject: [PATCH 033/115] test --- src/komodo_gateway.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f8881c7d8..3c0c2c8bc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -280,16 +280,20 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( opcode == 'X' ) { + matched++; for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); printf(" cant paxfind txid\n"); - } + } else if ( opcode == 'I' ) + matched++; } komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height); } if ( matched != num ) { // can easily happen depending on order of loading + if ( height > 60000 ) + printf("WARNING: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); } } //printf("opretlen.%d num.%d\n",opretlen,num); From c5d580b26cdf69cbd03730ce668992c607e79780 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:04:05 -0300 Subject: [PATCH 034/115] test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3c0c2c8bc..09906c0b0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -499,7 +499,7 @@ void komodo_gateway_iteration(char *symbol) char *retstr; int32_t i,kmdheight; cJSON *infoobj,*result; uint256 zero; uint16_t port = 7771; if ( KMDHEIGHT <= 0 ) KMDHEIGHT = 1; - KOMODO_REALTIME = 0; + //KOMODO_REALTIME = 0; if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 ) { if ( (infoobj= cJSON_Parse(retstr)) != 0 ) From 610378b40e01c6b4ce98179849257db140e857d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:20:26 -0300 Subject: [PATCH 035/115] test --- src/komodo_gateway.h | 2 ++ src/miner.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 09906c0b0..cd721000c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -273,6 +273,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (j=0; j<32; j++) printf("%02x",((uint8_t *)&hash)[j]); printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i); + // validate amount! } } } @@ -284,6 +285,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); printf(" cant paxfind txid\n"); + // validate amount! } else if ( opcode == 'I' ) matched++; } diff --git a/src/miner.cpp b/src/miner.cpp index 8c192e3c2..b7af64164 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -435,7 +435,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // // Internal miner // -#define ROUNDROBIN_DELAY 10 +#define ROUNDROBIN_DELAY 22 extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; From cf1aa6ab0d519c1fa63919cea7c4dca4b61bc5ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:27:47 -0300 Subject: [PATCH 036/115] test --- src/komodo.h | 6 ++++-- src/miner.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3cb5bf2fb..f1fa4a1ed 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,8 +17,10 @@ #define H_KOMODO_H // Todo: handle reorg: clear all entries above reorged height -// smooth consensus price -// +// error check redeems +// net balance limiter +// REVS and non-fiat chains +// verify: interest payment, ratification #include #include diff --git a/src/miner.cpp b/src/miner.cpp index b7af64164..4f700b514 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); while ( mempool.GetTotalTxSize() <= 0 ) { @@ -127,7 +127,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) break; sleep(10); } - if ( 0 && deposits != 0 ) + //if ( 0 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); // -regtest only: allow overriding block.nVersion with From 79562bf3337806720f25a34f0b2ac47a03ddae9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:33:02 -0300 Subject: [PATCH 037/115] test --- src/miner.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4f700b514..a3a4814f5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,22 +114,23 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); - while ( mempool.GetTotalTxSize() <= 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) { - deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || KOMODO_REALTIME == 0 ) + fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); + while ( mempool.GetTotalTxSize() <= 0 ) { - fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); + deposits = komodo_paxtotal(); + if ( KOMODO_INITDONE == 0 || KOMODO_REALTIME == 0 ) + { + fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); + } + else if ( deposits != 0 ) + break; + sleep(10); } - else if ( deposits != 0 ) - break; - sleep(10); + if ( 0 && deposits != 0 ) + printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); } - //if ( 0 && deposits != 0 ) - printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); - // -regtest only: allow overriding block.nVersion with // -blockversion=N to test forking scenarios if (Params().MineBlocksOnDemand()) From 85de28615c47b1547ad1d2e7a2bdbcf67290c702 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:36:43 -0300 Subject: [PATCH 038/115] test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cd721000c..353dc0624 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -238,9 +238,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - for (i=0; i Date: Tue, 8 Nov 2016 17:41:02 -0300 Subject: [PATCH 039/115] test --- src/assetchains | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/assetchains b/src/assetchains index f030f43d4..6341963fe 100755 --- a/src/assetchains +++ b/src/assetchains @@ -1,35 +1,35 @@ source pubkey.txt echo $pubkey -./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 & +./komodod -pubkey=$pubkey -ac_name=USD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=EUR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=JPY -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=GBP -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=AUD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CAD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CHF -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=NZD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CNY -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=RUB -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MXN -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BRL -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=INR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HKD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=TRY -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=ZAR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=PLN -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=NOK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SEK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=DKK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=CZK -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HUF -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=ILS -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=KRW -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=MYR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=PHP -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=RON -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=SGD -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=THB -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=BGN -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=IDR -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=HRK -addnode=78.47.196.146 $1 & From d9a9d5620c7c00b264b30c395133eb0260a6c218 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 17:49:36 -0300 Subject: [PATCH 040/115] test --- src/komodo_gateway.h | 4 +++- src/miner.cpp | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 353dc0624..2a49991c8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -160,7 +160,7 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin return(n); } -void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo) +int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo) { struct pax_transaction *pax,*tmp; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; PENDING_KOMODO_TX = 0; @@ -225,7 +225,9 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char * script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0]; memcpy(script,opret,opretlen); printf("MINER deposits.%d (%s) vouts.%d %.8f opretlen.%d\n",tokomodo,ASSETCHAINS_SYMBOL,numvouts,dstr(PENDING_KOMODO_TX),opretlen); + return(1); } + return(0); } int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing diff --git a/src/miner.cpp b/src/miner.cpp index a3a4814f5..29d951d45 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -102,7 +102,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, 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,int32_t tokomodo); +int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo); extern int32_t KOMODO_INITDONE,ASSETCHAINS_SHORTFLAG,KOMODO_REALTIME; extern char ASSETCHAINS_SYMBOL[16]; @@ -367,17 +367,19 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; - if ( (opretlen= komodo_pax_opreturn(opret,sizeof(opret))) > 0 ) + if ( komodo_gateway_deposits(&txNew,0,(char *)"EUR",1) == 0 ) { - txNew.vout.resize(2); - txNew.vout[1].scriptPubKey.resize(opretlen); - ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data(); - for (i=0; i 0 ) + { + txNew.vout.resize(2); + txNew.vout[1].scriptPubKey.resize(opretlen); + ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data(); + for (i=0; i Date: Tue, 8 Nov 2016 18:33:56 -0300 Subject: [PATCH 041/115] test --- src/komodo.h | 12 +++++++----- src/komodo_gateway.h | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index f1fa4a1ed..819aefd11 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -16,11 +16,13 @@ #ifndef H_KOMODO_H #define H_KOMODO_H -// Todo: handle reorg: clear all entries above reorged height -// error check redeems -// net balance limiter -// REVS and non-fiat chains -// verify: interest payment, ratification +// Todo: +// 1. error check fiat redeem amounts +// 2. net balance limiter, activate dPoW for all fiats +// 3. REVS and non-fiat chains +// 4. verify: interest payment, ratification, reorgs +// 5. automate notarization fee payouts +// 6. automated distribution of test REVS snapshot #include #include diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2a49991c8..fdb4251f2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -160,9 +160,10 @@ int32_t komodo_issued_opreturn(uint8_t *shortflagp,char *base,uint256 *txids,uin return(n); } -int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *symbol,int32_t tokomodo) +int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; + struct pax_transaction *pax,*tmp; char symbol[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,len=0,opretlen=0,numvouts=1; + strcpy(symbol,base); PENDING_KOMODO_TX = 0; if ( tokomodo == 0 ) opcode = 'I'; @@ -214,7 +215,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,cha if ( shortflag != 0 ) data[len++] = '-'; if ( tokomodo != 0 ) - strcpy(symbol,"KMD"); + strcpy(symbol,(char *)"KMD"); for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; From cf5053b084519119882368fd173458684f564458 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 18:56:19 -0300 Subject: [PATCH 042/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 29d951d45..3937a5e8a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); while ( mempool.GetTotalTxSize() <= 0 ) From 0617dd84de9122fa9747486ada11a85fbfcd5207 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:03:45 -0300 Subject: [PATCH 043/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 3937a5e8a..9798fb36f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -541,7 +541,7 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) + if (chainActive.Tip()->nHeight >= 100 && chainparams.MiningRequiresPeers()) { // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. From 3a9746d294cba902d9171463bb6551e005a10334 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:06:29 -0300 Subject: [PATCH 044/115] test --- src/miner.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9798fb36f..1e74cf432 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,6 +114,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience + printf("create new block %d\n",chainActive.Tip()->nHeight); if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); @@ -567,8 +568,8 @@ void static BitcoinMiner(CWallet *pwallet) unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.Tip(); Mining_height = pindexPrev->nHeight+1; - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) - //fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); if (!pblocktemplate.get()) From 4189bcacf0da9ddf8923f68a1e7cc6c9375d893c Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:06:49 -0300 Subject: [PATCH 045/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 1e74cf432..0bfd29c15 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - printf("create new block %d\n",chainActive.Tip()->nHeight); + fprintf(stderr,"create new block %d\n",chainActive.Tip()->nHeight); if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); From 078f6af1db56ba393260419317ec408fd131062e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:09:28 -0300 Subject: [PATCH 046/115] test --- src/miner.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 0bfd29c15..772244775 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -502,6 +502,8 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese return true; } +int32_t komodo_baseid(char *origbase); + void static BitcoinMiner(CWallet *pwallet) { LogPrintf("ZcashMiner started\n"); @@ -519,6 +521,8 @@ void static BitcoinMiner(CWallet *pwallet) while ( ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0 ) { sleep(1); + if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 ) + break; } komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33); From 2b03a458b92d1af8365cd34dcd58b7605b929177 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:13:41 -0300 Subject: [PATCH 047/115] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 819aefd11..821632e32 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -362,7 +362,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight); // reset komodostate } - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( komodo_is_issuer() != 0 ) { while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME ) { From d90d2be52cc33895499ed14247d1b979749da2ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:18:51 -0300 Subject: [PATCH 048/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 772244775..faa44a4b0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -716,7 +716,7 @@ void static BitcoinMiner(CWallet *pwallet) // Regtest mode doesn't require peers if (vNodes.empty() && chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height < 100 ) printf("no nodes, break\n"); break; } From d90cef0b0c38b7707840256474a6e60523295c40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:20:50 -0300 Subject: [PATCH 049/115] test --- src/miner.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index faa44a4b0..c06fd5d3c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -718,7 +718,8 @@ void static BitcoinMiner(CWallet *pwallet) { if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height < 100 ) printf("no nodes, break\n"); - break; + if ( ASSETCHAINS_SYMBOL[0] != 0 && Mining_height >= 100 ) + break; } if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff) { @@ -728,14 +729,14 @@ void static BitcoinMiner(CWallet *pwallet) } if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("timeout, break\n"); + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + // printf("timeout, break\n"); break; } if ( pindexPrev != chainActive.Tip() ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - printf("Tip advanced, break\n"); + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + // printf("Tip advanced, break\n"); break; } // Update nNonce and nTime From 169b3009eafdc9a04656ff852fb9e19979663ed3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:22:55 -0300 Subject: [PATCH 050/115] test --- src/miner.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c06fd5d3c..6ab4dcdc3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -114,7 +114,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - fprintf(stderr,"create new block %d\n",chainActive.Tip()->nHeight); + //fprintf(stderr,"create new block %d\n",chainActive.Tip()->nHeight); if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) { fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),KOMODO_REALTIME); @@ -716,9 +716,7 @@ void static BitcoinMiner(CWallet *pwallet) // Regtest mode doesn't require peers if (vNodes.empty() && chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height < 100 ) - printf("no nodes, break\n"); - if ( ASSETCHAINS_SYMBOL[0] != 0 && Mining_height >= 100 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 ) break; } if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff) From dc5bef26fa33df0147c92a415da85a03779cd56e Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:27:17 -0300 Subject: [PATCH 051/115] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2d8884a4d..65c2cf3a8 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1379,7 +1379,7 @@ void komodo_args() int32_t komodo_baseid(char *origbase); extern int COINBASE_MATURITY; komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); - if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) + //if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) COINBASE_MATURITY = 1; } } From 7b7049d3c1a23b5eb958ad532ca9283729997f48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:54:08 -0300 Subject: [PATCH 052/115] test --- src/komodo_utils.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 65c2cf3a8..b877f4779 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1354,9 +1354,11 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) printf("ports\n"); } +char *iguanafmtstr = "curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0}"; + void komodo_args() { - std::string name; char *dirname; int32_t i,len; + std::string name; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,len; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); NOTARY_PUBKEY = GetArg("-pubkey", ""); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) @@ -1381,6 +1383,17 @@ void komodo_args() komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); //if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) COINBASE_MATURITY = 1; + iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); + for (i=0; i<4; i++) + sprintf(&magicstr[i<<1],"%02x",magic[i]); + magicstr[8] = 0; + sprintf(fname,"gen%s",ASSETCHAINS_SYMBOL); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1); + fclose(fp); + printf("created (%s)\n",fname); + } else printf("error creating (%s)\n",fname); } } else From 080b37d74e34b2229c8c9a66c49a4ad7483dcac7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 19:55:50 -0300 Subject: [PATCH 053/115] test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b877f4779..b7297331f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1354,7 +1354,7 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) printf("ports\n"); } -char *iguanafmtstr = "curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0}"; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0}"; void komodo_args() { From ea0eb58faa24035d576e5aefc1589163a5eecfda Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 20:12:18 -0300 Subject: [PATCH 054/115] test --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b7297331f..a5cf1b4f0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1354,7 +1354,7 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) printf("ports\n"); } -char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0}"; +char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; void komodo_args() { @@ -1390,7 +1390,7 @@ void komodo_args() sprintf(fname,"gen%s",ASSETCHAINS_SYMBOL); if ( (fp= fopen(fname,"wb")) != 0 ) { - fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1); + fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,"78.47.196.146"); fclose(fp); printf("created (%s)\n",fname); } else printf("error creating (%s)\n",fname); From 6e575e4367ebdf26957d23084883c5f92220efbe Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 8 Nov 2016 21:03:46 -0300 Subject: [PATCH 055/115] test --- src/komodo_utils.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a5cf1b4f0..fdb210028 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1383,18 +1383,18 @@ void komodo_args() komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); //if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) COINBASE_MATURITY = 1; - iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); - for (i=0; i<4; i++) - sprintf(&magicstr[i<<1],"%02x",magic[i]); - magicstr[8] = 0; - sprintf(fname,"gen%s",ASSETCHAINS_SYMBOL); - if ( (fp= fopen(fname,"wb")) != 0 ) - { - fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,"78.47.196.146"); - fclose(fp); - printf("created (%s)\n",fname); - } else printf("error creating (%s)\n",fname); } + iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); + for (i=0; i<4; i++) + sprintf(&magicstr[i<<1],"%02x",magic[i]); + magicstr[8] = 0; + sprintf(fname,"gen%s",ASSETCHAINS_SYMBOL); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,"78.47.196.146"); + fclose(fp); + printf("created (%s)\n",fname); + } else printf("error creating (%s)\n",fname); } else { From cc66cf723056abeccde1ebb111757eefc550c206 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Nov 2016 09:38:46 -0300 Subject: [PATCH 056/115] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 821632e32..3ab36075d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -367,7 +367,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME ) { fprintf(stderr,"komodo_connect.(%s) waiting for realtime RT.%u now.%u\n",ASSETCHAINS_SYMBOL,KOMODO_REALTIME,(uint32_t)time(NULL)); - sleep(3); + sleep(30); } } KOMODO_REALTIME = KOMODO_INITDONE = (uint32_t)time(NULL); From c01add219f4ed876c51296164279fc88292662c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Nov 2016 11:13:57 -0300 Subject: [PATCH 057/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6ab4dcdc3..db8fc6c6e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,7 +439,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // // Internal miner // -#define ROUNDROBIN_DELAY 22 +#define ROUNDROBIN_DELAY 44 extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; From 2b469f431e5114d4cc806eb70f164d7852809a41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Nov 2016 13:06:27 -0300 Subject: [PATCH 058/115] test --- src/bitcoind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 0ea3f12b1..5f47ba352 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -43,7 +43,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // Tell the main threads to shutdown. while (!fShutdown) { - MilliSleep(2000); + MilliSleep(10000); if ( komodo_is_issuer() != 0 ) komodo_gateway_iteration(ASSETCHAINS_SYMBOL); else komodo_iteration((char *)"EUR"); From e37f280f2c7800d38f1e02a20ef4c85c1f8104d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Nov 2016 13:14:45 -0300 Subject: [PATCH 059/115] test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fdb210028..000648752 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -851,11 +851,13 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) { int32_t adjust,i = 0; //printf("decode.(%s)\n",hex); - if ( is_hexstr(hex,n) == 0 ) + if ( is_hexstr(hex,n) < 2 ) { memset(bytes,0,n); return(n); } + if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) + n--; if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) { if ( n > 0 ) From 4f569c795d3700f1a594cfd0020b9831a8aae1b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Nov 2016 14:47:56 -0300 Subject: [PATCH 060/115] test --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 000648752..5045b3cc3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -851,13 +851,13 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex) { int32_t adjust,i = 0; //printf("decode.(%s)\n",hex); - if ( is_hexstr(hex,n) < 2 ) + if ( is_hexstr(hex,n) <= 0 ) { memset(bytes,0,n); return(n); } if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) - n--; + hex[--n] = 0; if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) { if ( n > 0 ) From e2cf55f2c240f078f48f5a5810472b64267b882f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 9 Nov 2016 15:51:24 -0300 Subject: [PATCH 061/115] #!/bin/bash --- src/fiat-cli | 1 + src/fiat/_usd | 2 +- src/fiat/aud | 1 + src/fiat/bgn | 1 + src/fiat/brl | 1 + src/fiat/cad | 1 + src/fiat/chf | 1 + src/fiat/cny | 1 + src/fiat/czk | 1 + src/fiat/dkk | 1 + src/fiat/eur | 1 + src/fiat/gbp | 1 + src/fiat/hkd | 1 + src/fiat/hrk | 1 + src/fiat/huf | 1 + src/fiat/idr | 1 + src/fiat/ils | 1 + src/fiat/inr | 1 + src/fiat/jpy | 1 + src/fiat/krw | 1 + src/fiat/mxn | 1 + src/fiat/myr | 1 + src/fiat/nok | 1 + src/fiat/nzd | 1 + src/fiat/php | 1 + src/fiat/pln | 1 + src/fiat/ron | 1 + src/fiat/rub | 1 + src/fiat/sek | 1 + src/fiat/sgd | 1 + src/fiat/thb | 1 + src/fiat/try | 1 + src/fiat/usd | 1 + src/fiat/zar | 1 + 34 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/fiat-cli b/src/fiat-cli index 5d1469be8..8dd0fc02b 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -1,3 +1,4 @@ +#!/bin/bash echo aud; fiat/aud $1 $2 $3 $4 echo bgn; fiat/bgn $1 $2 $3 $4 echo cad; fiat/cad $1 $2 $3 $4 diff --git a/src/fiat/_usd b/src/fiat/_usd index f5b373730..bdba4ea52 100755 --- a/src/fiat/_usd +++ b/src/fiat/_usd @@ -1,3 +1,3 @@ - +#!/bin/bash ./komodo-cli -ac_name=-USD $1 $2 $3 $4 diff --git a/src/fiat/aud b/src/fiat/aud index 86bb2d56d..bfacdc4e0 100755 --- a/src/fiat/aud +++ b/src/fiat/aud @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=AUD $1 $2 $3 $4 diff --git a/src/fiat/bgn b/src/fiat/bgn index ef57ca52e..dad8778a6 100755 --- a/src/fiat/bgn +++ b/src/fiat/bgn @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=BGN $1 $2 $3 $4 diff --git a/src/fiat/brl b/src/fiat/brl index aa9c8b571..489749d08 100755 --- a/src/fiat/brl +++ b/src/fiat/brl @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=BRL $1 $2 $3 $4 diff --git a/src/fiat/cad b/src/fiat/cad index d1265c9ed..4a199a30a 100755 --- a/src/fiat/cad +++ b/src/fiat/cad @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=CAD $1 $2 $3 $4 diff --git a/src/fiat/chf b/src/fiat/chf index c8a4923a5..fd2a5dbdb 100755 --- a/src/fiat/chf +++ b/src/fiat/chf @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=CHF $1 $2 $3 $4 diff --git a/src/fiat/cny b/src/fiat/cny index 09c16fbd0..f67ccd215 100755 --- a/src/fiat/cny +++ b/src/fiat/cny @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=CNY $1 $2 $3 $4 diff --git a/src/fiat/czk b/src/fiat/czk index a3b735a93..fb3101564 100755 --- a/src/fiat/czk +++ b/src/fiat/czk @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=CZK $1 $2 $3 $4 diff --git a/src/fiat/dkk b/src/fiat/dkk index 370f28087..e8b65848c 100755 --- a/src/fiat/dkk +++ b/src/fiat/dkk @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=DKK $1 $2 $3 $4 diff --git a/src/fiat/eur b/src/fiat/eur index d00e86cf8..60e66af1c 100755 --- a/src/fiat/eur +++ b/src/fiat/eur @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=EUR $1 $2 $3 $4 diff --git a/src/fiat/gbp b/src/fiat/gbp index d4dce3696..fa1263e3f 100755 --- a/src/fiat/gbp +++ b/src/fiat/gbp @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=GBP $1 $2 $3 $4 diff --git a/src/fiat/hkd b/src/fiat/hkd index 74349e2b6..dcb9bf97c 100755 --- a/src/fiat/hkd +++ b/src/fiat/hkd @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=HKD $1 $2 $3 $4 diff --git a/src/fiat/hrk b/src/fiat/hrk index ec421ab58..283794d04 100755 --- a/src/fiat/hrk +++ b/src/fiat/hrk @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=HRK $1 $2 $3 $4 diff --git a/src/fiat/huf b/src/fiat/huf index 98d46721b..336a75bb4 100755 --- a/src/fiat/huf +++ b/src/fiat/huf @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=HUF $1 $2 $3 $4 diff --git a/src/fiat/idr b/src/fiat/idr index aa78918de..34b7a204c 100755 --- a/src/fiat/idr +++ b/src/fiat/idr @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=IDR $1 $2 $3 $4 diff --git a/src/fiat/ils b/src/fiat/ils index efdca0bfc..c06588689 100755 --- a/src/fiat/ils +++ b/src/fiat/ils @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=ILS $1 $2 $3 $4 diff --git a/src/fiat/inr b/src/fiat/inr index e570a267d..b4d230622 100755 --- a/src/fiat/inr +++ b/src/fiat/inr @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=INR $1 $2 $3 $4 diff --git a/src/fiat/jpy b/src/fiat/jpy index 80f6629f0..6d437f02b 100755 --- a/src/fiat/jpy +++ b/src/fiat/jpy @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=JPY $1 $2 $3 $4 diff --git a/src/fiat/krw b/src/fiat/krw index 5e894ae22..51b59dc12 100755 --- a/src/fiat/krw +++ b/src/fiat/krw @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=KRW $1 $2 $3 $4 diff --git a/src/fiat/mxn b/src/fiat/mxn index 12a556c54..a4f119517 100755 --- a/src/fiat/mxn +++ b/src/fiat/mxn @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=MXN $1 $2 $3 $4 diff --git a/src/fiat/myr b/src/fiat/myr index 70af112e2..5de0c80da 100755 --- a/src/fiat/myr +++ b/src/fiat/myr @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=MYR $1 $2 $3 $4 diff --git a/src/fiat/nok b/src/fiat/nok index 39ebd60be..fb1a25430 100755 --- a/src/fiat/nok +++ b/src/fiat/nok @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=NOK $1 $2 $3 $4 diff --git a/src/fiat/nzd b/src/fiat/nzd index 12bcc9b61..af598570a 100755 --- a/src/fiat/nzd +++ b/src/fiat/nzd @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=NZD $1 $2 $3 $4 diff --git a/src/fiat/php b/src/fiat/php index a34f2b737..f333251fd 100755 --- a/src/fiat/php +++ b/src/fiat/php @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=PHP $1 $2 $3 $4 diff --git a/src/fiat/pln b/src/fiat/pln index df55f75a8..5fcc12ba4 100755 --- a/src/fiat/pln +++ b/src/fiat/pln @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=PLN $1 $2 $3 $4 diff --git a/src/fiat/ron b/src/fiat/ron index fbe0de412..3ea339896 100755 --- a/src/fiat/ron +++ b/src/fiat/ron @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=RON $1 $2 $3 $4 diff --git a/src/fiat/rub b/src/fiat/rub index 7419ff31e..367dbf46d 100755 --- a/src/fiat/rub +++ b/src/fiat/rub @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=RUB $1 $2 $3 $4 diff --git a/src/fiat/sek b/src/fiat/sek index f14b8b31c..9fb37e674 100755 --- a/src/fiat/sek +++ b/src/fiat/sek @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=SEK $1 $2 $3 $4 diff --git a/src/fiat/sgd b/src/fiat/sgd index e77f72e02..f9c75ade8 100755 --- a/src/fiat/sgd +++ b/src/fiat/sgd @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=SGD $1 $2 $3 $4 diff --git a/src/fiat/thb b/src/fiat/thb index ca92c4724..a5a7eb017 100755 --- a/src/fiat/thb +++ b/src/fiat/thb @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=THB $1 $2 $3 $4 diff --git a/src/fiat/try b/src/fiat/try index 81602f133..a06a2050d 100755 --- a/src/fiat/try +++ b/src/fiat/try @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=TRY $1 $2 $3 $4 diff --git a/src/fiat/usd b/src/fiat/usd index c72fbc5c3..12eb06e0d 100755 --- a/src/fiat/usd +++ b/src/fiat/usd @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=USD $1 $2 $3 $4 diff --git a/src/fiat/zar b/src/fiat/zar index 92dfaf269..e5fa51785 100755 --- a/src/fiat/zar +++ b/src/fiat/zar @@ -1 +1,2 @@ +#!/bin/bash ./komodo-cli -ac_name=ZAR $1 $2 $3 $4 From 0d2cefb06c6220db79bf852e6c0cd8c10ab5dbec Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Nov 2016 08:57:09 -0300 Subject: [PATCH 062/115] test --- src/main.cpp | 2 +- src/pow.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 78877dd28..8ce789b26 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4896,7 +4896,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int nDoS; if (state.IsInvalid(nDoS)) { if (nDoS > 0) - Misbehaving(pfrom->GetId(), nDoS); + Misbehaving(pfrom->GetId(), nDoS/nDoS); return error("invalid header received"); } } diff --git a/src/pow.cpp b/src/pow.cpp index e76d78749..43c68b322 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -113,6 +113,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in arith_uint256 bnTarget; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); + if ( height == 0 ) + height = chainActive.Tip()->nHeight + 1; if ( height > 34000 ) // 0 -> non-special notary { special = komodo_chosennotary(¬aryid,height,pubkey33); @@ -139,7 +141,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in flag = 1; } //else bnTarget /= 8; } - else if ( height == 0 && KOMODO_CHOSEN_ONE != 0 ) + /*else if ( height == 0 && KOMODO_CHOSEN_ONE != 0 ) { extern uint8_t NOTARY_PUBKEY33[33]; bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); @@ -147,7 +149,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in special = 1; notaryid = -1; printf("KOMODO_CHOSEN_ONE -> MINDIFF\n"); - } + }*/ // Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); From 0dadbebec80deb556bc9629667422b84368a9806 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Nov 2016 09:00:18 -0300 Subject: [PATCH 063/115] test --- src/komodo.h | 1 + src/komodo_globals.h | 2 +- src/pow.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 3ab36075d..7119f9b88 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -362,6 +362,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight); // reset komodostate } + CURRENT_HEIGHT = pindex->nHeight; if ( komodo_is_issuer() != 0 ) { while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME ) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index ef503c0e0..d883e16ce 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -15,7 +15,7 @@ int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,CURRENT_HEIGHT; std::string NOTARY_PUBKEY; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/pow.cpp b/src/pow.cpp index 43c68b322..e08706d5c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -105,7 +105,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param } int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); -extern int32_t KOMODO_CHOSEN_ONE; +extern int32_t KOMODO_CHOSEN_ONE,CURRENT_HEIGHT; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { @@ -114,7 +114,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in bnTarget.SetCompact(nBits, &fNegative, &fOverflow); if ( height == 0 ) - height = chainActive.Tip()->nHeight + 1; + height = CURRENT_HEIGHT + 1; if ( height > 34000 ) // 0 -> non-special notary { special = komodo_chosennotary(¬aryid,height,pubkey33); From ba7babedc4006444ab2cd278b6c4439b037b527c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Nov 2016 09:17:43 -0300 Subject: [PATCH 064/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index db8fc6c6e..c30cd7bc0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -594,7 +594,7 @@ void static BitcoinMiner(CWallet *pwallet) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); Mining_start = (uint32_t)time(NULL); - fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); + //fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } else Mining_start = 0; while (true) { From bbee6596dae7f32b19c9b5351a964ae27d338355 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Nov 2016 11:30:51 -0300 Subject: [PATCH 065/115] test --- src/komodo.h | 2 +- src/main.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 7119f9b88..c1ecde069 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -362,7 +362,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("hwmheight.%d vs pindex->nHeight.%d reorg.%d\n",hwmheight,pindex->nHeight,hwmheight-pindex->nHeight); // reset komodostate } - CURRENT_HEIGHT = pindex->nHeight; + CURRENT_HEIGHT = chainActive.Tip()->nHeight; if ( komodo_is_issuer() != 0 ) { while ( KOMODO_REALTIME == 0 || time(NULL) <= KOMODO_REALTIME ) diff --git a/src/main.cpp b/src/main.cpp index 8ce789b26..899a63c5b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3315,7 +3315,9 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) { // Preliminary checks + extern int32_t CURRENT_HEIGHT; bool checked; + CURRENT_HEIGHT = chainActive.Tip()->nHeight; if ( ASSETCHAINS_SYMBOL[0] == 0 ) checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state); else checked = CheckBlock(0,0,*pblock, state); From 6ae728c777ae66d62f969a0e032e9b367a19ee2a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Nov 2016 16:46:35 -0300 Subject: [PATCH 066/115] test --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 899a63c5b..9460fce28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3317,7 +3317,8 @@ bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBloc // Preliminary checks extern int32_t CURRENT_HEIGHT; bool checked; - CURRENT_HEIGHT = chainActive.Tip()->nHeight; + if ( chainActive.Tip() != 0 ) + CURRENT_HEIGHT = chainActive.Tip()->nHeight; if ( ASSETCHAINS_SYMBOL[0] == 0 ) checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state); else checked = CheckBlock(0,0,*pblock, state); From 94eb04d704d503b347590a7a5cedc3dafb099db4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 09:25:48 -0300 Subject: [PATCH 067/115] osx compatibility --- src/netbase.cpp | 6 ++++++ src/primitives/transaction.cpp | 5 +++++ src/primitives/transaction.h | 5 +++++ src/wallet/asyncrpcoperation_sendmany.cpp | 5 +++++ src/wallet/wallet.h | 4 ++++ 5 files changed, 25 insertions(+) diff --git a/src/netbase.cpp b/src/netbase.cpp index 54d2bef7c..b46fd11e3 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -16,6 +16,12 @@ #include "util.h" #include "utilstrencodings.h" +#ifdef __APPLE__ +#ifdef HAVE_GETADDRINFO_A +#undef HAVE_GETADDRINFO_A +#endif +#endif + #ifdef HAVE_GETADDRINFO_A #include #endif diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 399cd665a..6c3769b01 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -47,8 +47,13 @@ JSDescription JSDescription::Randomized( const uint256& anchor, boost::array& inputs, boost::array& outputs, +#ifdef __APPLE__ + boost::array& inputMap, + boost::array& outputMap, +#else boost::array& inputMap, boost::array& outputMap, +#endif CAmount vpub_old, CAmount vpub_new, bool computeProof, diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 9a0e78ef4..65e7a5896 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -86,8 +86,13 @@ public: const uint256& rt, boost::array& inputs, boost::array& outputs, +#ifdef __APPLE__ + boost::array& inputMap, + boost::array& outputMap, +#else boost::array& inputMap, boost::array& outputMap, +#endif CAmount vpub_old, CAmount vpub_new, bool computeProof = true, // Set to false in some tests diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index f72badc60..a203c4a21 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -873,8 +873,13 @@ Object AsyncRPCOperation_sendmany::perform_joinsplit( {info.vjsin[0], info.vjsin[1]}; boost::array outputs {info.vjsout[0], info.vjsout[1]}; +#ifdef __APPLE__ + boost::array inputMap; + boost::array outputMap; +#else boost::array inputMap; boost::array outputMap; +#endif JSDescription jsdesc = JSDescription::Randomized( *pzcashParams, joinSplitPubKey_, diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index c75f1f54d..404edf4b7 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -160,7 +160,11 @@ public: // Transaction hash uint256 hash; // Index into CTransaction.vjoinsplit +#ifdef __APPLE__ + uint64_t js; +#else size_t js; +#endif // Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS uint8_t n; From 09cd7f3aed96b895d3d226972c87cab6736b1930 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 09:30:38 -0300 Subject: [PATCH 068/115] test --- src/primitives/transaction.h | 1 + src/wallet/asyncrpcoperation_sendmany.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 65e7a5896..035f9af9e 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -12,6 +12,7 @@ #include "serialize.h" #include "uint256.h" #include "consensus/consensus.h" +#include #include diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index a203c4a21..df12ef6a8 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -22,6 +22,8 @@ #include "zcash/IncrementalMerkleTree.hpp" #include "sodium.h" +#include + #include #include #include From ab8ef4502cc3a9da338c1755bbc78f7a6ce97c5f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:29:50 -0300 Subject: [PATCH 069/115] test --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index d883e16ce..94e89aa27 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -16,7 +16,7 @@ int COINBASE_MATURITY = 100; int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,CURRENT_HEIGHT; -std::string NOTARY_PUBKEY; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; int32_t ASSETCHAINS_SHORTFLAG; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5045b3cc3..7a059558e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1358,9 +1358,37 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; +void komodo_assetchain_pubkeys(char *jsonstr) +{ + cJSON *array; int32_t i,n; uint8_t pubkeys[64][33]; char *hexstr; + memset(pubkeys,0,sizeof(pubkeys)); + if ( (array= cJSON_Parse(jsonstr)) != 0 ) + { + if ( (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; i Date: Fri, 11 Nov 2016 11:32:15 -0300 Subject: [PATCH 070/115] test --- src/komodo_notary.h | 27 +++++++++++++++++++++++++++ src/komodo_utils.h | 29 ++--------------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index a106f8503..3c33d41cc 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -244,3 +244,30 @@ void komodo_init(int32_t height) komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0); } } + +void komodo_assetchain_pubkeys(char *jsonstr) +{ + cJSON *array; int32_t i,n; uint8_t pubkeys[64][33]; char *hexstr; + memset(pubkeys,0,sizeof(pubkeys)); + if ( (array= cJSON_Parse(jsonstr)) != 0 ) + { + if ( (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; i 0 ) - { - for (i=0; i Date: Fri, 11 Nov 2016 11:34:30 -0300 Subject: [PATCH 071/115] test --- src/komodo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo.h b/src/komodo.h index c1ecde069..0581d8a26 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -33,6 +33,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar void komodo_init(int32_t height); int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); char *komodo_issuemethod(char *method,char *params,uint16_t port); +void komodo_init(int32_t height); #define GENESIS_NBITS 0x1f00ffff #define KOMODO_MINRATIFY 7 From 2576cfd882e28339feda4ec67cd6b8c41d234bdb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:36:51 -0300 Subject: [PATCH 072/115] test --- src/komodo.h | 1 - src/komodo_utils.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 0581d8a26..f17bcb8d7 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -40,7 +40,6 @@ void komodo_init(int32_t height); #include "komodo_globals.h" #include "komodo_utils.h" -//queue_t DepositsQ,PendingsQ; #include "cJSON.c" #include "komodo_bitcoind.h" diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4dc8f9b7d..5537a8a37 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1359,6 +1359,7 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; void komodo_assetchain_pubkeys(char *jsonstr); +void komodo_init(int32_t height); void komodo_args() { From 9b1a9f08e43589605ffe87b7243a0270c28e5723 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:42:01 -0300 Subject: [PATCH 073/115] test --- src/komodo.h | 1 + src/komodo_utils.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index f17bcb8d7..ba584e50d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -34,6 +34,7 @@ void komodo_init(int32_t height); int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); char *komodo_issuemethod(char *method,char *params,uint16_t port); void komodo_init(int32_t height); +void komodo_assetchain_pubkeys(char *jsonstr); #define GENESIS_NBITS 0x1f00ffff #define KOMODO_MINRATIFY 7 diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5537a8a37..baa266094 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1358,8 +1358,6 @@ void komodo_ports(uint16_t ports[MAX_CURRENCIES]) char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":1,\\\"VALIDATE\\\":1,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\"}\""; -void komodo_assetchain_pubkeys(char *jsonstr); -void komodo_init(int32_t height); void komodo_args() { From 0e2400aad42638743fdafb00d3acd404fe9de53b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:44:53 -0300 Subject: [PATCH 074/115] test --- src/bitcoin-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index b456e5c05..c6f24db07 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -60,6 +60,7 @@ public: #include "arith_uint256.h" #include "komodo_globals.h" #include "komodo_utils.h" +#include "komodo_notary.h" static bool AppInitRPC(int argc, char* argv[]) { From 39eb0ec7936047d7a7143d0f69a1777404feb316 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:46:08 -0300 Subject: [PATCH 075/115] test --- src/bitcoin-cli.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index c6f24db07..a2d116ccf 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -58,8 +58,12 @@ public: #include "uint256.h" #include "arith_uint256.h" + +void komodo_init(int32_t height); +void komodo_assetchain_pubkeys(char *jsonstr); #include "komodo_globals.h" #include "komodo_utils.h" +#include "cJSON.c" #include "komodo_notary.h" static bool AppInitRPC(int argc, char* argv[]) From cf0ace4afa676500cc294711ead1f02b95efce00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:46:49 -0300 Subject: [PATCH 076/115] test --- src/bitcoin-cli.cpp | 2 -- src/komodo.h | 6 ------ src/komodo_globals.h | 7 +++++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index a2d116ccf..c0cd324f5 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -59,8 +59,6 @@ public: #include "uint256.h" #include "arith_uint256.h" -void komodo_init(int32_t height); -void komodo_assetchain_pubkeys(char *jsonstr); #include "komodo_globals.h" #include "komodo_utils.h" #include "cJSON.c" diff --git a/src/komodo.h b/src/komodo.h index ba584e50d..71a9c0e40 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -29,12 +29,6 @@ #include #include -void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout); -void komodo_init(int32_t height); -int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); -char *komodo_issuemethod(char *method,char *params,uint16_t port); -void komodo_init(int32_t height); -void komodo_assetchain_pubkeys(char *jsonstr); #define GENESIS_NBITS 0x1f00ffff #define KOMODO_MINRATIFY 7 diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 94e89aa27..a1a21f442 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -13,6 +13,13 @@ * * ******************************************************************************/ +void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout); +void komodo_init(int32_t height); +int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); +char *komodo_issuemethod(char *method,char *params,uint16_t port); +void komodo_init(int32_t height); +void komodo_assetchain_pubkeys(char *jsonstr); + int COINBASE_MATURITY = 100; int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,CURRENT_HEIGHT; From 725800f9a33a64a446e7f7666947625028cf6e87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 11:50:36 -0300 Subject: [PATCH 077/115] test --- src/bitcoin-cli.cpp | 5 +++++ src/komodo_notary.h | 25 +++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index c0cd324f5..a248d2ae0 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -64,6 +64,11 @@ public: #include "cJSON.c" #include "komodo_notary.h" +void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout) +{ + +} + static bool AppInitRPC(int argc, char* argv[]) { // diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3c33d41cc..6db862392 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -225,24 +225,21 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_init(int32_t height) { static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; - if ( height > didinit ) + if ( didinit == 0 ) { - if ( didinit == 0 ) + pthread_mutex_init(&komodo_mutex,NULL); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; k Date: Fri, 11 Nov 2016 12:06:36 -0300 Subject: [PATCH 078/115] test --- src/komodo_notary.h | 1 + src/komodo_utils.h | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6db862392..5ab3f2f5f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -262,6 +262,7 @@ void komodo_assetchain_pubkeys(char *jsonstr) } if ( i == n ) { + komodo_init(0); komodo_notarysinit(0,pubkeys,n); printf("initialize pubkeys[%d]\n",n); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index baa266094..a39a0e69c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1362,7 +1362,6 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\ void komodo_args() { std::string name; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,len; - komodo_init(0); IS_KOMODO_NOTARY = GetBoolArg("-notary", false); NOTARY_PUBKEY = GetArg("-pubkey", ""); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) @@ -1371,8 +1370,6 @@ void komodo_args() if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); - ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); - komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,&ASSETCHAINS_SHORTFLAG); //fprintf(stderr,"after args: %c%s port.%u magic.%08x supply.%u\n",ASSETCHAINS_SHORTFLAG!=0?'-':'+',ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_MAGIC,(int32_t)ASSETCHAINS_SUPPLY); @@ -1390,6 +1387,8 @@ void komodo_args() //if ( komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 ) COINBASE_MATURITY = 1; } + ASSETCHAINS_NOTARIES = GetArg("-ac_notaries",""); + komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str()); iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC); for (i=0; i<4; i++) sprintf(&magicstr[i<<1],"%02x",magic[i]); From 93f4931eb60ca7b1b90253f7b3bb44aea0faff96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 12:18:59 -0300 Subject: [PATCH 079/115] test --- src/komodo_notary.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5ab3f2f5f..1e2a88aeb 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -266,6 +266,8 @@ void komodo_assetchain_pubkeys(char *jsonstr) komodo_notarysinit(0,pubkeys,n); printf("initialize pubkeys[%d]\n",n); } - } + } else printf("assetchain pubkeys n.%d\n",n); } + else if ( jsonstr != 0 ) + printf("assetchain pubkeys couldnt parse.(%s)\n",jsonstr); } From 6a8e70a959a7a58859722f719ae3b4a25627eba0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 12:36:04 -0300 Subject: [PATCH 080/115] test --- src/komodo_notary.h | 11 +++++++---- src/pow.cpp | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1e2a88aeb..84ae003a8 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -253,10 +253,13 @@ void komodo_assetchain_pubkeys(char *jsonstr) for (i=0; i Date: Fri, 11 Nov 2016 12:37:55 -0300 Subject: [PATCH 081/115] test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 84ae003a8..967b8a61b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -255,7 +255,7 @@ void komodo_assetchain_pubkeys(char *jsonstr) if ( (hexstr= jstri(array,i)) != 0 && is_hexstr(hexstr,0) == 66 ) { decode_hex(pubkeys[i],33,hexstr); - fprintf(stderr,"i.%d of n.%d pubkey.(%s)\n",hexstr); + fprintf(stderr,"i.%d of n.%d pubkey.(%s)\n",i,n,hexstr); } else { From 3a59bdf4ba0f6808173481b5487dc0f1079a9aae Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 12:47:23 -0300 Subject: [PATCH 082/115] test --- src/revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/revs diff --git a/src/revs b/src/revs new file mode 100644 index 000000000..5c8782ae5 --- /dev/null +++ b/src/revs @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=REVS $1 $2 $3 $4 From 4c803a7efb7e9a87e33a635f97c5fa012007be48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 12:48:00 -0300 Subject: [PATCH 083/115] test --- src/revs | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/revs diff --git a/src/revs b/src/revs old mode 100644 new mode 100755 From b6a7cb2ce0a77ad89cb4d5854bf8a34cbe8305ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 13:03:24 -0300 Subject: [PATCH 084/115] test --- src/komodo_globals.h | 2 +- src/komodo_notary.h | 4 ++-- src/komodo_utils.h | 7 +++++-- src/miner.cpp | 6 ++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a1a21f442..8ee8655ca 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -22,7 +22,7 @@ void komodo_assetchain_pubkeys(char *jsonstr); int COINBASE_MATURITY = 100; -int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,CURRENT_HEIGHT; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,CURRENT_HEIGHT,ASSETCHAINS_SEED; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 967b8a61b..777010982 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -271,6 +271,6 @@ void komodo_assetchain_pubkeys(char *jsonstr) } else fprintf(stderr,"komodo_assetchain_pubkeys i.%d vs n.%d\n",i,n); } else fprintf(stderr,"assetchain pubkeys n.%d\n",n); } - else if ( jsonstr != 0 ) - fprintf(stderr,"assetchain pubkeys couldnt parse.(%s)\n",jsonstr); + //else if ( jsonstr != 0 ) + // fprintf(stderr,"assetchain pubkeys couldnt parse.(%s)\n",jsonstr); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index a39a0e69c..ec11d2a2a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1361,7 +1361,7 @@ char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7778\" --data \"{\\\ void komodo_args() { - std::string name; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,len; + std::string name,addn; char *dirname,fname[512],magicstr[9]; uint8_t magic[4]; FILE *fp; int32_t i,len; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); NOTARY_PUBKEY = GetArg("-pubkey", ""); if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) @@ -1370,6 +1370,9 @@ void komodo_args() if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); + addn = GetArg("-addnode",""); + if ( strlen(addn.c_str()) > 6 ) + ASSETCHAINS_SEED = 1; strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,&ASSETCHAINS_SHORTFLAG); //fprintf(stderr,"after args: %c%s port.%u magic.%08x supply.%u\n",ASSETCHAINS_SHORTFLAG!=0?'-':'+',ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_MAGIC,(int32_t)ASSETCHAINS_SUPPLY); @@ -1398,7 +1401,7 @@ void komodo_args() { fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),magicstr,ASSETCHAINS_PORT,ASSETCHAINS_PORT+1,"78.47.196.146"); fclose(fp); - printf("created (%s)\n",fname); + //printf("created (%s)\n",fname); } else printf("error creating (%s)\n",fname); } else diff --git a/src/miner.cpp b/src/miner.cpp index c30cd7bc0..4bbd6f08c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -440,7 +440,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // Internal miner // #define ROUNDROBIN_DELAY 44 -extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; uint32_t Mining_start,Mining_height; @@ -546,8 +546,10 @@ void static BitcoinMiner(CWallet *pwallet) //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainActive.Tip()->nHeight >= 100 && chainparams.MiningRequiresPeers()) + if (chainparams.MiningRequiresPeers()) { + if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) + break; // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. //fprintf(stderr,"Wait for peers...\n"); From 0ef454b7e3f384d94005ce87173cb58b226507a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 13:13:12 -0300 Subject: [PATCH 085/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4bbd6f08c..6a48da1a5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -123,7 +123,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) deposits = komodo_paxtotal(); if ( KOMODO_INITDONE == 0 || KOMODO_REALTIME == 0 ) { - fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); + //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,KOMODO_REALTIME,(double)deposits/COIN); } else if ( deposits != 0 ) break; From 6ed911ff39485deb2cb31d7351ba7efe1967ece4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 14:39:59 -0300 Subject: [PATCH 086/115] test --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ec11d2a2a..195654f49 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1370,8 +1370,8 @@ void komodo_args() if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); - addn = GetArg("-addnode",""); - if ( strlen(addn.c_str()) > 6 ) + addn = GetArg("-seednode",""); + if ( strlen(addn.c_str()) > 0 ) ASSETCHAINS_SEED = 1; strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); ASSETCHAINS_PORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,&ASSETCHAINS_SHORTFLAG); From 4a4e912bbea5e455a11fea7e08f413c142f50b0d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 20:15:05 -0300 Subject: [PATCH 087/115] test --- src/coins.cpp | 3 +++ src/coins.h | 2 ++ src/komodo.h | 13 ++++++++++--- src/komodo_bitcoind.h | 38 ++++++++++++++++++++++++++++++++++++++ src/komodo_notary.h | 19 ++++++++++++------- src/komodo_utils.h | 4 ++-- src/main.cpp | 4 ++-- src/miner.cpp | 7 ++++--- src/pow.cpp | 33 +++++++++------------------------ src/wallet/wallet.cpp | 7 +++++-- 10 files changed, 87 insertions(+), 43 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index bbff5495b..3388f7439 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -400,7 +400,10 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr interest = komodo_interest(nHeight,value,tx.nLockTime,tiptime); #ifdef KOMODO_ENABLE_INTEREST if ( ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 ) + { + printf("nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); nResult += interest; + } #endif (*interestp) += interest; } diff --git a/src/coins.h b/src/coins.h index 123d8b4eb..7d5bc8168 100644 --- a/src/coins.h +++ b/src/coins.h @@ -6,6 +6,8 @@ #ifndef BITCOIN_COINS_H #define BITCOIN_COINS_H +#define KOMODO_ENABLE_INTEREST //enabling this is a hardfork, activate with new RR method + #include "compressor.h" #include "memusage.h" #include "serialize.h" diff --git a/src/komodo.h b/src/komodo.h index 71a9c0e40..94a204b21 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -18,8 +18,8 @@ // Todo: // 1. error check fiat redeem amounts -// 2. net balance limiter, activate dPoW for all fiats -// 3. REVS and non-fiat chains +// 2. net balance limiter +// 3. new RR algo // 4. verify: interest payment, ratification, reorgs // 5. automate notarization fee payouts // 6. automated distribution of test REVS snapshot @@ -33,6 +33,8 @@ #define GENESIS_NBITS 0x1f00ffff #define KOMODO_MINRATIFY 7 +int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks + #include "komodo_globals.h" #include "komodo_utils.h" @@ -348,7 +350,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) static int32_t hwmheight; uint64_t signedmask,voutmask; uint8_t scriptbuf[4096],pubkeys[64][33]; uint256 kmdtxid,btctxid,txhash; - int32_t i,j,k,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; + int32_t i,j,k,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; komodo_init(pindex->nHeight); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; @@ -391,6 +393,11 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) #endif // signedmask is needed here! notaryid = komodo_voutupdate(notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue); + if ( i == 0 && j == 0 && komodo_chosennotary(&nid,height,scriptbuf + 1) >= 0 ) + { + if ( height < sizeof(Minerids)/sizeof(*Minerids) ) + Minerids[height] = nid; + } if ( 0 && i > 0 ) { for (k=0; knHeight); + Minerids[pindex->nHeight] = -2; //hash = block.GetHash(); //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&hash)[i]); @@ -446,6 +447,43 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) } } +int8_t komodo_minerid(int32_t height) +{ + int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33]; + if ( height <= chainActive.Tip()->nHeight ) + { + if ( (pindex= chainActive[height]) != 0 ) + { + komodo_index2pubkey33(pubkey33,pindex,height); + komodo_chosennotary(¬aryid,height,pubkey33); + return(notaryid); + } + } + return(-2); +} + +int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) +{ + int32_t notaryid; + komodo_chosennotary(¬aryid,height,pubkey33); + if ( height >= 34000 && notaryid >= 0 ) + { + for (i=1; i<64; i++) + { + if ( Minerids[height-i] == -2 ) + { + Minerids[height-i] = komodo_minerid(height-i); + if ( Minerids[height - i] == -2 ) + fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,CURRENT_HEIGHT); + } + if ( Minerids[height-i] == notaryid ) + return(-1); + } + return(1); + } + return(0); +} + int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 777010982..564065482 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -229,15 +229,20 @@ void komodo_init(int32_t height) { pthread_mutex_init(&komodo_mutex,NULL); decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); - for (k=0; k= 0 ) { - if ( Notaries_genesis[k][0] == 0 || Notaries_genesis[k][1] == 0 || Notaries_genesis[k][0][0] == 0 || Notaries_genesis[k][1][0] == 0 ) - break; - decode_hex(pubkeys[k],33,(char *)Notaries_genesis[k][1]); + n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis)); + for (k=0; knHeight,&interest,tx,chainActive.Tip()->nTime); - + if ( interest != 0 ) + fprintf(stderr,"add interest %.8f\n",(double)interest/COIN); // we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool view.SetBackend(dummy); } diff --git a/src/miner.cpp b/src/miner.cpp index 6a48da1a5..489ee701f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,12 +439,13 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // // Internal miner // -#define ROUNDROBIN_DELAY 44 +#define ROUNDROBIN_DELAY 30 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; uint32_t Mining_start,Mining_height; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); +int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]); CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) { @@ -589,10 +590,10 @@ void static BitcoinMiner(CWallet *pwallet) // // Search // - int32_t notaryid; uint32_t savebits; int64_t nStart = GetTime(); + uint32_t savebits; int64_t nStart = GetTime(); savebits = pblock->nBits; arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); - if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_chosennotary(¬aryid,pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); Mining_start = (uint32_t)time(NULL); diff --git a/src/pow.cpp b/src/pow.cpp index 1b8ebe18c..9d0548347 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -105,7 +105,9 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param } int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); +int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]); extern int32_t KOMODO_CHOSEN_ONE,CURRENT_HEIGHT; +extern int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { @@ -122,39 +124,22 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in { if ( pubkey33[i] != 0 ) nonz++; - //fprintf(stderr,"%02x",pubkey33[i]); } - //fprintf(stderr," height.%d special.%d nonz.%d\n",height,special,nonz); if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - else if ( 0 ) + if ( notaryid >= 0 ) { - for (i=0; i<33; i++) - fprintf(stderr,"%02x",pubkey33[i]); - fprintf(stderr," special.%d notaryid.%d ht.%d mod.%d\n",special,notaryid,height,(height % 35)); - } - if ( special > 0 ) // special notary id == (height % numnotaries) - { - if (UintToArith256(hash) <= bnTarget) // accept normal diff - return true; - bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - flag = 1; + if ( komodo_is_special(height,pubkey33) > 0 ) + { + bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + flag = 1; + } } //else bnTarget /= 8; } - /*else if ( height == 0 && KOMODO_CHOSEN_ONE != 0 ) - { - extern uint8_t NOTARY_PUBKEY33[33]; - bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); - memcpy(pubkey33,NOTARY_PUBKEY33,33); - special = 1; - notaryid = -1; - printf("KOMODO_CHOSEN_ONE -> MINDIFF\n"); - }*/ - // Check range if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); // Check proof of work matches claimed amount - if (UintToArith256(hash) > bnTarget) + if ( UintToArith256(hash) > bnTarget ) { for (i=0; i<33; i++) printf("%02x",pubkey33[i]); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 881b5256f..15c5bb2eb 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -18,7 +18,7 @@ #include "utilmoneystr.h" #include "zcash/Note.hpp" #include "crypter.h" - +#include "coins.h" #include #include @@ -2402,9 +2402,12 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setnHeight,out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); #ifdef KOMODO_ENABLE_INTEREST if ( ASSETCHAINS_SYMBOL[0] == 0 && txheight >= 60000 ) + { + printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); nValueRet += interest; -#endif + } fprintf(stderr,"interest %llu from %llu lock.%u tip.%u\n",(long long)interest,(long long)out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); +#endif setCoinsRet.insert(make_pair(out.tx, out.i)); } return (nValueRet >= nTargetValue); From e6f6a829c84463a4c5b9c74dd19e6edbfa83991a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 20:19:20 -0300 Subject: [PATCH 088/115] test --- src/komodo_bitcoind.h | 2 +- src/komodo_globals.h | 1 + src/komodo_notary.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dceb2f43b..4561f7563 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -464,7 +464,7 @@ int8_t komodo_minerid(int32_t height) int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { - int32_t notaryid; + int32_t i,notaryid; komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 8ee8655ca..ec5ee6127 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -19,6 +19,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n char *komodo_issuemethod(char *method,char *params,uint16_t port); void komodo_init(int32_t height); void komodo_assetchain_pubkeys(char *jsonstr); +int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); int COINBASE_MATURITY = 100; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 564065482..d99cbfad0 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -224,7 +224,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_init(int32_t height) { - static int didinit; uint256 zero; int32_t k,n; uint8_t pubkeys[64][33]; + static int didinit; uint256 zero; int32_t i,k,n; uint8_t pubkeys[64][33]; if ( didinit == 0 ) { pthread_mutex_init(&komodo_mutex,NULL); From f305836943b79bc1d22675ac6b5cd820932de018 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 20:26:05 -0300 Subject: [PATCH 089/115] test --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 15c5bb2eb..e4075cf8b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2403,7 +2403,7 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, set= 60000 ) { - printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); + printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,txheight,tx->nLockTime,chainActive.Tip()->nTime); nValueRet += interest; } fprintf(stderr,"interest %llu from %llu lock.%u tip.%u\n",(long long)interest,(long long)out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); From 6caf0e0ac3f81877c71600b49f882dc7b34adf3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 20:29:01 -0300 Subject: [PATCH 090/115] test --- src/wallet/wallet.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e4075cf8b..2dc3e7b29 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2399,11 +2399,11 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setvout[out.i].nValue; - interest = komodo_interest(chainActive.Tip()->nHeight,out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); + interest = komodo_interest(chainActive.Tip()->nHeight+1,out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); #ifdef KOMODO_ENABLE_INTEREST - if ( ASSETCHAINS_SYMBOL[0] == 0 && txheight >= 60000 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip()->nHeight+1 >= 60000 ) { - printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,txheight,tx->nLockTime,chainActive.Tip()->nTime); + printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,out.tx->nLockTime,chainActive.Tip()->nTime); nValueRet += interest; } fprintf(stderr,"interest %llu from %llu lock.%u tip.%u\n",(long long)interest,(long long)out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); From 3824fe8c4160878a10cd4459ffd532add2779369 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 20:31:20 -0300 Subject: [PATCH 091/115] test --- src/bitcoin-cli.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index a248d2ae0..e7b0b1476 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -59,6 +59,8 @@ public: #include "uint256.h" #include "arith_uint256.h" +int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks + #include "komodo_globals.h" #include "komodo_utils.h" #include "cJSON.c" From 342421a9bfd9f01b87f1514700857ed845cf5351 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 20:59:39 -0300 Subject: [PATCH 092/115] test --- src/komodo_notary.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d99cbfad0..55c1cba22 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -138,11 +138,11 @@ void komodo_notarysinit(int32_t height,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( height > 10000 ) + //if ( height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); - printf(" notarypubs.[%d]\n",k); + printf(" notarypubs.[%d] ht.%d\n",k,height); } } N.numnotaries = num; From afab46929fd7566f15cb15dc2358b94c6f247a02 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 21:04:28 -0300 Subject: [PATCH 093/115] test --- src/komodo_notary.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 55c1cba22..9064e37d7 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -243,6 +243,7 @@ void komodo_init(int32_t height) memset(&zero,0,sizeof(zero)); for (i=0; i Date: Fri, 11 Nov 2016 21:10:17 -0300 Subject: [PATCH 094/115] test --- src/rpcblockchain.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 7d87601a1..8e46d9c77 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -404,22 +404,24 @@ Value notaries(const Array& params, bool fHelp) { Object item; std::string btcaddress,kmdaddress,hex; - bitcoin_address(btcaddr,0,pubkeys[i],33); - m = (int32_t)strlen(btcaddr); - btcaddress.resize(m); - ptr = (char *)btcaddress.data(); - memcpy(ptr,btcaddr,n); - bitcoin_address(kmdaddr,60,pubkeys[i],33); - m = (int32_t)strlen(kmdaddr); - kmdaddress.resize(m); - ptr = (char *)kmdaddress.data(); - memcpy(ptr,kmdaddr,m); hex.resize(66); hexstr = (char *)hex.data(); for (j=0; j<33; j++) sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]); item.push_back(Pair("pubkey", hex)); + + bitcoin_address(btcaddr,0,pubkeys[i],33); + m = (int32_t)strlen(btcaddr); + btcaddress.resize(m); + ptr = (char *)btcaddress.data(); + memcpy(ptr,btcaddr,n); item.push_back(Pair("BTCaddress", btcaddress)); + + bitcoin_address(kmdaddr,60,pubkeys[i],33); + m = (int32_t)strlen(kmdaddr); + kmdaddress.resize(m); + ptr = (char *)kmdaddress.data(); + memcpy(ptr,kmdaddr,m); item.push_back(Pair("KMDaddress", kmdaddress)); a.push_back(item); } From 6eb6f5f7a1c351599d9baa2bc0a1b682757278e0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 21:12:15 -0300 Subject: [PATCH 095/115] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8e46d9c77..c692b34ae 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -414,7 +414,7 @@ Value notaries(const Array& params, bool fHelp) m = (int32_t)strlen(btcaddr); btcaddress.resize(m); ptr = (char *)btcaddress.data(); - memcpy(ptr,btcaddr,n); + memcpy(ptr,btcaddr,m); item.push_back(Pair("BTCaddress", btcaddress)); bitcoin_address(kmdaddr,60,pubkeys[i],33); From 895f044ae6325cbffc6c967422a723208cf9443a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 21:30:04 -0300 Subject: [PATCH 096/115] test --- src/rpcblockchain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index c692b34ae..05a2907f3 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -394,7 +394,9 @@ Value notaries(const Array& params, bool fHelp) throw runtime_error("notaries height\n"); LOCK(cs_main); int32_t height = atoi(params[0].get_str().c_str()); - if ( height < 0 || height > chainActive.Height()+2000 ) + if ( height < 0 ) + height = 0; + if ( height > chainActive.Height()+20000 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else { From 02286e6339324b605e91abbc9cc9f63f552c819f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 11 Nov 2016 21:33:09 -0300 Subject: [PATCH 097/115] test --- src/rpcblockchain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 05a2907f3..e671c7308 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -396,6 +396,7 @@ Value notaries(const Array& params, bool fHelp) int32_t height = atoi(params[0].get_str().c_str()); if ( height < 0 ) height = 0; + fprintf(stderr,"notaries as of height.%d\n",height); if ( height > chainActive.Height()+20000 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else From 6677fa316c5b3fda6dae4a1dd1c7289d4bd1d17d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 08:44:11 -0300 Subject: [PATCH 098/115] test --- src/komodo_bitcoind.h | 2 +- src/rpcblockchain.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4561f7563..585be4e3e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -450,7 +450,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) int8_t komodo_minerid(int32_t height) { int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33]; - if ( height <= chainActive.Tip()->nHeight ) + if ( height <= CURRENT_HEIGHT )//chainActive.Tip()->nHeight ) { if ( (pindex= chainActive[height]) != 0 ) { diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e671c7308..7373d51c9 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -396,7 +396,7 @@ Value notaries(const Array& params, bool fHelp) int32_t height = atoi(params[0].get_str().c_str()); if ( height < 0 ) height = 0; - fprintf(stderr,"notaries as of height.%d\n",height); + //fprintf(stderr,"notaries as of height.%d\n",height); if ( height > chainActive.Height()+20000 ) throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); else From 6a4abc832deae09e885fef0b49ae44cb05149c37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 09:17:06 -0300 Subject: [PATCH 099/115] test --- src/pow.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 9d0548347..c2433462f 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,14 +127,27 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( notaryid >= 0 ) + if ( height > 65000 ) { - if ( komodo_is_special(height,pubkey33) > 0 ) + if ( notaryid >= 0 ) { + if ( komodo_is_special(height,pubkey33) > 0 ) + { + bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); + flag = 1; + } + } + } + else + { + if ( special > 0 ) // special notary id == (height % numnotaries) + { + if (UintToArith256(hash) <= bnTarget) // accept normal diff + return true; bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; } - } //else bnTarget /= 8; + } } if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); @@ -146,12 +159,6 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); return error("CheckProofOfWork(): hash doesn't match nBits"); } - /*if ( flag != 0 ) - { - for (i=0; i<33; i++) - fprintf(stderr,"%02x",pubkey33[i]); - fprintf(stderr," <- Round Robin ht.%d for notary.%d special.%d\n",height,notaryid,special); - }*/ return true; } From 1698480726e87ac67010b9e6c08bbe20290c4949 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 09:39:35 -0300 Subject: [PATCH 100/115] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 489ee701f..fa8738939 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -439,7 +439,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& // // Internal miner // -#define ROUNDROBIN_DELAY 30 +#define ROUNDROBIN_DELAY 45 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; From ef9a3f7b68f4485de03598e7331077817af3b6c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 10:31:45 -0300 Subject: [PATCH 101/115] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index c2433462f..10fea095d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 65000 ) + if ( height > 6511NwPWSRfsNjUUQB72vzN9omxiQk8iScUJE00 ) { if ( notaryid >= 0 ) { From 6898391df3ccc9ad5b5534aaf305354ff9ffbfe2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 10:36:55 -0300 Subject: [PATCH 102/115] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 10fea095d..f76a88dc2 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 6511NwPWSRfsNjUUQB72vzN9omxiQk8iScUJE00 ) + if ( height > 65100 ) { if ( notaryid >= 0 ) { From a80ba1778bf98916df546ae85e64178a3754f411 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 11:23:29 -0300 Subject: [PATCH 103/115] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index f76a88dc2..e5f024a41 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 65100 ) + if ( height > 65200 ) { if ( notaryid >= 0 ) { From df1fb519c88ee03ffb58dc2122a6eec74eb32e35 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 11:23:47 -0300 Subject: [PATCH 104/115] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index e5f024a41..98f219453 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 65200 ) + if ( height > 65105 ) { if ( notaryid >= 0 ) { From 3959e9f32d40bbda1885dcbc42714af7c68ce3d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 12:10:15 -0300 Subject: [PATCH 105/115] test --- src/coins.cpp | 6 +++++- src/pow.cpp | 2 +- src/wallet/wallet.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 3388f7439..dc3880a2a 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -401,7 +401,11 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr #ifdef KOMODO_ENABLE_INTEREST if ( ASSETCHAINS_SYMBOL[0] == 0 && nHeight >= 60000 ) { - printf("nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); + if ( interest != 0 ) + { + printf("nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); + fprintf(stderr,"nResult %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nResult/COIN,(double)interest/COIN,nHeight,tx.nLockTime,tiptime); + } nResult += interest; } #endif diff --git a/src/pow.cpp b/src/pow.cpp index 98f219453..86118816d 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 65105 ) + if ( height > 65500 ) { if ( notaryid >= 0 ) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2dc3e7b29..5c8ce5a9f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2403,10 +2403,13 @@ bool CWallet::SelectCoins(const CAmount& nTargetValue, setnHeight+1 >= 60000 ) { - printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,out.tx->nLockTime,chainActive.Tip()->nTime); + if ( interest != 0 ) + { + printf("nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,out.tx->nLockTime,chainActive.Tip()->nTime); + fprintf(stderr,"nValueRet %.8f += interest %.8f ht.%d lock.%u tip.%u\n",(double)nValueRet/COIN,(double)interest/COIN,chainActive.Tip()->nHeight+1,out.tx->nLockTime,chainActive.Tip()->nTime); + } nValueRet += interest; } - fprintf(stderr,"interest %llu from %llu lock.%u tip.%u\n",(long long)interest,(long long)out.tx->vout[out.i].nValue,out.tx->nLockTime,chainActive.Tip()->nTime); #endif setCoinsRet.insert(make_pair(out.tx, out.i)); } From e8f5e771e935956ec14467b449bf3a24001221dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 13:07:09 -0300 Subject: [PATCH 106/115] test --- src/komodo_notary.h | 2 +- src/pow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 9064e37d7..8b637db0a 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -52,7 +52,7 @@ const char *Notaries_genesis[][2] = { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, }; -#define KOMODO_ELECTION_GAP 1000 +#define KOMODO_ELECTION_GAP 2000 #define KOMODO_PUBKEYS_HEIGHT(height) ((int32_t)(((((height)+KOMODO_ELECTION_GAP*.5)/KOMODO_ELECTION_GAP) + 1) * KOMODO_ELECTION_GAP)) struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; } *NUTXOS; diff --git a/src/pow.cpp b/src/pow.cpp index 86118816d..c3665fa51 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 65500 ) + if ( height > 65800 ) { if ( notaryid >= 0 ) { From 44eaec67c1dfc19ec831fc2f95a8791226aed846 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 14:01:42 -0300 Subject: [PATCH 107/115] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index c3665fa51..9d714e337 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,7 +127,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 65800 ) + if ( height > 66300 ) { if ( notaryid >= 0 ) { From 6dbfb7fd81acd3bbf457ed87431d78a7a56b8313 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 14:27:45 -0300 Subject: [PATCH 108/115] test --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 9d714e337..7cf20bd83 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -127,11 +127,11 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in } if ( nonz == 0 ) return(true); // will come back via different path with pubkey set - if ( height > 66300 ) + if ( height > 60000 ) { if ( notaryid >= 0 ) { - if ( komodo_is_special(height,pubkey33) > 0 ) + if ( height < 70000 || komodo_is_special(height,pubkey33) > 0 ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From db92d72676d7db3eebad3b7a1c38a2afce4917cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 14:38:02 -0300 Subject: [PATCH 109/115] test --- src/komodo_bitcoind.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 585be4e3e..33b9ff4d4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -474,7 +474,10 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) { Minerids[height-i] = komodo_minerid(height-i); if ( Minerids[height - i] == -2 ) + { fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,CURRENT_HEIGHT); + return(0); + } } if ( Minerids[height-i] == notaryid ) return(-1); From 4940066cd13c2c82ec105302ddc127eb9da7c1c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 15:49:42 -0300 Subject: [PATCH 110/115] test --- src/miner.cpp | 8 +++++--- src/pow.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fa8738939..e90493f23 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -571,10 +571,13 @@ void static BitcoinMiner(CWallet *pwallet) // // Create new block // - Mining_start = (uint32_t)time(NULL); unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); CBlockIndex* pindexPrev = chainActive.Tip(); - Mining_height = pindexPrev->nHeight+1; + if ( Mining_height != pindexPrev->nHeight+1 ) + { + Mining_height = pindexPrev->nHeight+1; + Mining_start = (uint32_t)time(NULL); + } if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); @@ -596,7 +599,6 @@ void static BitcoinMiner(CWallet *pwallet) if ( ASSETCHAINS_SYMBOL[0] == 0 && komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) { hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS); - Mining_start = (uint32_t)time(NULL); //fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); } else Mining_start = 0; while (true) diff --git a/src/pow.cpp b/src/pow.cpp index 7cf20bd83..b7fdb0314 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -131,7 +131,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in { if ( notaryid >= 0 ) { - if ( height < 70000 || komodo_is_special(height,pubkey33) > 0 ) + if ( height < 70000 || special != 0 || komodo_is_special(height,pubkey33) > 0 ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From 27d725c2f586ef9619bfbf9dcd8af5c1d634e7ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 16:16:46 -0300 Subject: [PATCH 111/115] test --- src/pow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index b7fdb0314..667a6e7d0 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -131,7 +131,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in { if ( notaryid >= 0 ) { - if ( height < 70000 || special != 0 || komodo_is_special(height,pubkey33) > 0 ) + if ( (height < 70000 && special != 0) || komodo_is_special(height,pubkey33) > 0 ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; @@ -154,9 +154,9 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) { - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); + //for (i=0; i<33; i++) + // printf("%02x",pubkey33[i]); + //printf(" special.%d notaryid.%d ht.%d mod.%d error\n",special,notaryid,height,(height % 35)); return error("CheckProofOfWork(): hash doesn't match nBits"); } return true; From 25cfa933e9b3313a906c20d4b5c5799bb893a1e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 16:24:55 -0300 Subject: [PATCH 112/115] test --- src/pow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 667a6e7d0..3e1822566 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -131,7 +131,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in { if ( notaryid >= 0 ) { - if ( (height < 70000 && special != 0) || komodo_is_special(height,pubkey33) > 0 ) + if ( (height < 70000 && (special != 0 || komodo_is_special(height,pubkey33) > 0)) || + (height >= 70000 && komodo_is_special(height,pubkey33) > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1; From 5970a0d7472cbc2ac0c7e98b447928ef69b67c56 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 12 Nov 2016 17:04:25 -0300 Subject: [PATCH 113/115] test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c09e956dc..8c65fe825 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5288,7 +5288,7 @@ bool ProcessMessages(CNode* pfrom) } else { - PrintExceptionContinue(&e, "ProcessMessages()"); + //PrintExceptionContinue(&e, "ProcessMessages()"); } } catch (const boost::thread_interrupted&) { From cfbf96d10a86bb9f911785609737b282de69d844 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Nov 2016 07:42:58 -0300 Subject: [PATCH 114/115] test --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 33b9ff4d4..eaf1ee638 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -475,7 +475,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) Minerids[height-i] = komodo_minerid(height-i); if ( Minerids[height - i] == -2 ) { - fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,CURRENT_HEIGHT); + //fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,CURRENT_HEIGHT); return(0); } } From 0a39e8f1ed9633614064228f0fcb52a06c701579 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Nov 2016 07:53:14 -0300 Subject: [PATCH 115/115] test --- src/komodo_bitcoind.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index eaf1ee638..7d13977a7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -449,13 +449,16 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) int8_t komodo_minerid(int32_t height) { + static uint32_t depth; int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33]; - if ( height <= CURRENT_HEIGHT )//chainActive.Tip()->nHeight ) + if ( depth == 0 && height <= CURRENT_HEIGHT )//chainActive.Tip()->nHeight ) { if ( (pindex= chainActive[height]) != 0 ) { + depth++; komodo_index2pubkey33(pubkey33,pindex,height); komodo_chosennotary(¬aryid,height,pubkey33); + depth--; return(notaryid); } }