From 66294e69b2f04d6e60e85aaf491ba9373a6f7854 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Mar 2017 19:32:17 +0200 Subject: [PATCH 01/60] Remove prints --- src/komodo_bitcoind.h | 2 +- src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 05893328f..84bf54dd3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -818,7 +818,7 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ { if ( tx.nLockTime != 1477258935 || dispflag != 0 ) { - fprintf(stderr,"komodo_validate_interest.%d reject.%d [%d] locktime %u cmp2.%u\n",dispflag,txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,cmptime); + //fprintf(stderr,"komodo_validate_interest.%d reject.%d [%d] locktime %u cmp2.%u\n",dispflag,txheight,(int32_t)(tx.nLockTime - (cmptime-3600)),(uint32_t)tx.nLockTime,cmptime); } return(-1); } diff --git a/src/main.cpp b/src/main.cpp index 1599b2fe1..43794cb94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1113,7 +1113,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa auto verifier = libzcash::ProofVerifier::Strict(); if ( komodo_validate_interest(tx,chainActive.Tip()->nHeight+1,chainActive.Tip()->GetMedianTimePast() + 777,0) < 0 ) { - fprintf(stderr,"AcceptToMemoryPool komodo_validate_interest failure\n"); + //fprintf(stderr,"AcceptToMemoryPool komodo_validate_interest failure\n"); return error("AcceptToMemoryPool: komodo_validate_interest failed"); } if (!CheckTransaction(tx, state, verifier)) From 23bf71d1f6f6beddbc8c24c4ef06f3f9176ffcf6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Mar 2017 20:36:39 +0200 Subject: [PATCH 02/60] Test --- src/komodo_gateway.h | 38 -------------------------------------- src/miner.cpp | 2 +- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a79537ee3..e91c30f1f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -721,17 +721,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - /*extern int32_t KOMODO_REWIND; - if ( KOMODO_REWIND < 0 ) - { - fprintf(stderr,">>>>>>> rewind.%d will pause here for a minute. issue command and stop\n",KOMODO_REWIND); - sleep(60); - KOMODO_REWIND = 0; - }*/ - // 6a35506c65617365206d616b6520796f75722047697420636f6d6d6974206d65737361676573206d6f726520696e74657265737469 height.241778 checkdeposit n.4 [6a] [P] 80 vs 88 - //for (i=0; i= 235300 ) return(-1); @@ -993,33 +982,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } else { - /*int64_t val,prevtotal = 0; int32_t overflow = 0; - total = 0; - for (i=1; i= MAX_MONEY ) - { - overflow = 1; - break; - } - total += val; - if ( total < prevtotal || (val != 0 && total == prevtotal) ) - { - overflow = 1; - break; - } - prevtotal = total; - } - if ( overflow != 0 || total > COIN/10 ) - { - for (i=0; i Date: Sat, 25 Mar 2017 23:05:17 +0200 Subject: [PATCH 03/60] Test --- src/miner.cpp | 2 +- src/pow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0f7d829b7..07d29cd6c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -650,7 +650,7 @@ void static BitcoinMiner(CWallet *pwallet) CBlock *pblock = &pblocktemplate->block; if ( ASSETCHAINS_SYMBOL[0] != 0 ) { - if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( pblock->vtx.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { static uint32_t counter; if ( counter++ < 10 ) diff --git a/src/pow.cpp b/src/pow.cpp index e0957ab75..0a62f46ee 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -175,7 +175,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in fprintf(stderr,"pow error height.%d loading.%d notaryid.%d\n",height,KOMODO_LOADINGBLOCKS,notaryid); return error("CheckProofOfWork(): hash doesn't match nBits"); } else fprintf(stderr,"skip return error height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS); - } else fprintf(stderr,"skip height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS); + } //else fprintf(stderr,"skip height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS); } if ( 0 && height > 248000 ) { From b000fa04a6cd3e91eac1396f64b51b23900ce75a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 12:53:24 +0300 Subject: [PATCH 04/60] Test --- src/komodo_bitcoind.h | 33 +++++++++++++++++++++++++++++++++ src/miner.cpp | 4 ++-- src/rpcmisc.cpp | 15 ++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 84bf54dd3..3513a3adf 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -346,6 +346,39 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } +int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) +{ + char *jsonstr,params[256]; int32_t height = 0,txid_height = 0,confirmations = 0; + params[0] = 0; + *kmdnotarized_heightp = 0; + if ( KMDUSERPASS[0] != 0 ) + { + if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getinfo",params,7771)) != 0 ) + { + if ( (json= cJSON_Parse(jsonstr)) != 0 ) + { + *kmdnotarized_heightp = jint(json,"notarized"); + height = jint(json,"blocks"); + free_json(json); + } + free(jsonstr); + } + sprintf(params,"[\"%s\", 1]",txidstr); + if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771)) != 0 ) + { + if ( (json= cJSON_Parse(jsonstr)) != 0 ) + { + confirmations = jint(json,"confirmations"); + if ( confirmations > 0 && height > confirmations ) + txid_height = height - txid_confirmations; + free_json(json); + } + free(jsonstr); + } + } + return(txid_height); +} + int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) { int32_t i; uint256 hash; char params[256]; diff --git a/src/miner.cpp b/src/miner.cpp index 07d29cd6c..7f7bb5a74 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -703,11 +703,11 @@ void static BitcoinMiner(CWallet *pwallet) if ( mids[j] == -1 ) gpucount++; } - if ( gpucount > j/3 ) + if ( gpucount > j/2 ) { double delta; i = ((Mining_height + notaryid) % 64); - delta = sqrt((double)gpucount - j/3) / 2.; + delta = sqrt((double)gpucount - j/2) / 2.; roundrobin_delay += ((delta * i) / 64) - delta; //fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64); } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 841a5fb4f..1e2e1c704 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -46,6 +46,9 @@ int32_t komodo_longestchain(); int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); int32_t komodo_whoami(char *pubkeystr,int32_t height); extern int32_t KOMODO_LASTMINED; +extern char ASSETCHAINS_SYMBOL[]; +int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp); +#define KOMODO_VERSION "0.1.0" Value getinfo(const Array& params, bool fHelp) { @@ -92,14 +95,24 @@ Value getinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("version", CLIENT_VERSION)); obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); + obj.push_back(Pair("KMDversion", KOMODO_VERSION)); obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + int32_t kmdnotarized_height,txid_height; + txid_height = notarizedtxid_height(notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + obj.push_back(Pair("notarizedtxid_height", txid_height)); + obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", kmdnotarized_height)); + } #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); - obj.push_back(Pair("interest", ValueFromAmount(komodo_interestsum()))); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + obj.push_back(Pair("interest", ValueFromAmount(komodo_interestsum()))); } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); From 5de55e14aa776b0018af8c8818eb1e43aeab3acc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:10:23 +0300 Subject: [PATCH 05/60] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3513a3adf..a6699eba7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,7 +348,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) { - char *jsonstr,params[256]; int32_t height = 0,txid_height = 0,confirmations = 0; + char *jsonstr,params[256]; cJSON *json; int32_t height = 0,txid_height = 0,txid_confirmations = 0; params[0] = 0; *kmdnotarized_heightp = 0; if ( KMDUSERPASS[0] != 0 ) @@ -368,7 +368,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) { if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - confirmations = jint(json,"confirmations"); + txid_confirmations = jint(json,"confirmations"); if ( confirmations > 0 && height > confirmations ) txid_height = height - txid_confirmations; free_json(json); From 7ed958da81a34c234cc8c9f746c1f7984f4c5acf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:20:00 +0300 Subject: [PATCH 06/60] Test --- src/komodo_bitcoind.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a6699eba7..4c36d7c73 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -357,8 +357,8 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) { if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - *kmdnotarized_heightp = jint(json,"notarized"); - height = jint(json,"blocks"); + *kmdnotarized_heightp = jint(json,(char *)"notarized"); + height = jint(json,(char *)"blocks"); free_json(json); } free(jsonstr); @@ -368,8 +368,8 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) { if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - txid_confirmations = jint(json,"confirmations"); - if ( confirmations > 0 && height > confirmations ) + txid_confirmations = jint(json,(char *)"confirmations"); + if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; free_json(json); } From f1024f06acdd33633d1b8c7440e59752983962b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:25:55 +0300 Subject: [PATCH 07/60] Test --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1e2e1c704..3b96a2f7c 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -102,7 +102,7 @@ Value getinfo(const Array& params, bool fHelp) if ( ASSETCHAINS_SYMBOL[0] != 0 ) { int32_t kmdnotarized_height,txid_height; - txid_height = notarizedtxid_height(notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + txid_height = notarizedtxid_height((char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); obj.push_back(Pair("notarizedtxid_height", txid_height)); obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); obj.push_back(Pair("notarized_confirms", kmdnotarized_height)); From 9e1bde7e240a626f4dea91a346748c48889b000b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:30:23 +0300 Subject: [PATCH 08/60] Test --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 2 +- src/rpcmisc.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4c36d7c73..5fb9f223f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -375,7 +375,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) } free(jsonstr); } - } + } else printf("no KMDUSERPASS\n"); return(txid_height); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7c99aa4b2..418eb7226 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1355,7 +1355,7 @@ void komodo_configfile(char *symbol,uint16_t port) komodo_userpass(username,password,fp); sprintf(KMDUSERPASS,"%s:%s",username,password); fclose(fp); - //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); +printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 3b96a2f7c..40380d3cb 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -111,7 +111,7 @@ Value getinfo(const Array& params, bool fHelp) if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) obj.push_back(Pair("interest", ValueFromAmount(komodo_interestsum()))); } #endif From 1e2a41f6c1b204792adc7efd876dc722acec97a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:35:37 +0300 Subject: [PATCH 09/60] Test --- src/komodo_bitcoind.h | 3 +++ src/rpcmisc.cpp | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5fb9f223f..11e9e8823 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -355,6 +355,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) { if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getinfo",params,7771)) != 0 ) { + printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { *kmdnotarized_heightp = jint(json,(char *)"notarized"); @@ -366,9 +367,11 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) sprintf(params,"[\"%s\", 1]",txidstr); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771)) != 0 ) { + printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { txid_confirmations = jint(json,(char *)"confirmations"); + printf("height.%d tconfs.%d\n",height,txid_confirmations); if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; free_json(json); diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 40380d3cb..1d20e8f22 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -139,11 +139,13 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); { char pubkeystr[65]; int32_t notaryid; - notaryid = komodo_whoami(pubkeystr,(int32_t)chainActive.Tip()->nHeight); - obj.push_back(Pair("notaryid", notaryid)); - obj.push_back(Pair("pubkey", pubkeystr)); - if ( KOMODO_LASTMINED != 0 ) - obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + if ( (notaryid= komodo_whoami(pubkeystr,(int32_t)chainActive.Tip()->nHeight)) >= 0 ) + { + obj.push_back(Pair("notaryid", notaryid)); + obj.push_back(Pair("pubkey", pubkeystr)); + if ( KOMODO_LASTMINED != 0 ) + obj.push_back(Pair("lastmined", KOMODO_LASTMINED)); + } } return obj; } From 033f496dbe4265d72cb00a69560a4337ef4ef388 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:41:31 +0300 Subject: [PATCH 10/60] Test --- src/komodo_bitcoind.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 11e9e8823..1d07d26cf 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -348,18 +348,21 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) { - char *jsonstr,params[256]; cJSON *json; int32_t height = 0,txid_height = 0,txid_confirmations = 0; + char *jsonstr,params[256]; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0; params[0] = 0; *kmdnotarized_heightp = 0; if ( KMDUSERPASS[0] != 0 ) { if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getinfo",params,7771)) != 0 ) { - printf("(%s)\n",jsonstr); + //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - *kmdnotarized_heightp = jint(json,(char *)"notarized"); - height = jint(json,(char *)"blocks"); + if ( (item= jobj(json,"result")) != 0 ) + { + *kmdnotarized_heightp = jint(item,(char *)"notarized"); + height = jint(item,(char *)"blocks"); + } free_json(json); } free(jsonstr); @@ -367,13 +370,16 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) sprintf(params,"[\"%s\", 1]",txidstr); if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771)) != 0 ) { - printf("(%s)\n",jsonstr); + //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - txid_confirmations = jint(json,(char *)"confirmations"); - printf("height.%d tconfs.%d\n",height,txid_confirmations); - if ( txid_confirmations > 0 && height > txid_confirmations ) - txid_height = height - txid_confirmations; + if ( (item= jobj(json,"result")) != 0 ) + { + txid_confirmations = jint(item,(char *)"confirmations"); + printf("height.%d tconfs.%d\n",height,txid_confirmations); + if ( txid_confirmations > 0 && height > txid_confirmations ) + txid_height = height - txid_confirmations; + } free_json(json); } free(jsonstr); From 978ca7951298b40ae467d04b81926375583b0841 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:46:07 +0300 Subject: [PATCH 11/60] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1d07d26cf..b6edcd2fa 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -358,7 +358,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - if ( (item= jobj(json,"result")) != 0 ) + if ( (item= jobj(json,(char *)"result")) != 0 ) { *kmdnotarized_heightp = jint(item,(char *)"notarized"); height = jint(item,(char *)"blocks"); @@ -373,7 +373,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - if ( (item= jobj(json,"result")) != 0 ) + if ( (item= jobj(json,(char *)"result")) != 0 ) { txid_confirmations = jint(item,(char *)"confirmations"); printf("height.%d tconfs.%d\n",height,txid_confirmations); From 43cc3df6572d135b3a196fac6f58882e10a76a3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 13:53:22 +0300 Subject: [PATCH 12/60] Test --- src/komodo_bitcoind.h | 4 ++-- src/komodo_utils.h | 2 +- src/rpcmisc.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b6edcd2fa..e7d53313b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -376,15 +376,15 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) if ( (item= jobj(json,(char *)"result")) != 0 ) { txid_confirmations = jint(item,(char *)"confirmations"); - printf("height.%d tconfs.%d\n",height,txid_confirmations); if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; + printf("height.%d tconfs.%d txid_height.%d\n",height,txid_confirmations,txid_height); } free_json(json); } free(jsonstr); } - } else printf("no KMDUSERPASS\n"); + } return(txid_height); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 418eb7226..1131302df 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1355,7 +1355,7 @@ void komodo_configfile(char *symbol,uint16_t port) komodo_userpass(username,password,fp); sprintf(KMDUSERPASS,"%s:%s",username,password); fclose(fp); -printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); +//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 1d20e8f22..adbc27449 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -105,7 +105,7 @@ Value getinfo(const Array& params, bool fHelp) txid_height = notarizedtxid_height((char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); obj.push_back(Pair("notarizedtxid_height", txid_height)); obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", kmdnotarized_height > txid_height ? (txid_height - txid_height) : 0)); } #ifdef ENABLE_WALLET if (pwalletMain) { From 094b401e3d69a001db5b73229f7930a9a329f74a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 14:16:03 +0300 Subject: [PATCH 13/60] Test --- src/komodo_bitcoind.h | 2 +- src/rpcmisc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e7d53313b..4a1ca28dc 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -378,7 +378,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) txid_confirmations = jint(item,(char *)"confirmations"); if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; - printf("height.%d tconfs.%d txid_height.%d\n",height,txid_confirmations,txid_height); + //printf("height.%d tconfs.%d txid_height.%d\n",height,txid_confirmations,txid_height); } free_json(json); } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index adbc27449..025b73254 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -105,7 +105,7 @@ Value getinfo(const Array& params, bool fHelp) txid_height = notarizedtxid_height((char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); obj.push_back(Pair("notarizedtxid_height", txid_height)); obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", kmdnotarized_height > txid_height ? (txid_height - txid_height) : 0)); + obj.push_back(Pair("notarized_confirms", txid_height > kmdnotarized_height ? (txid_height - kmdnotarized_height) : 0)); } #ifdef ENABLE_WALLET if (pwalletMain) { From e9c40f1f8fb223178ad1d92d7f346197d6a48b41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 14:20:04 +0300 Subject: [PATCH 14/60] Test --- src/rpcmisc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 025b73254..a2660f958 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -105,7 +105,7 @@ Value getinfo(const Array& params, bool fHelp) txid_height = notarizedtxid_height((char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); obj.push_back(Pair("notarizedtxid_height", txid_height)); obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", txid_height > kmdnotarized_height ? (txid_height - kmdnotarized_height) : 0)); + obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height) : 0)); } #ifdef ENABLE_WALLET if (pwalletMain) { From 0cb025c1817767567bd08b2f66c72f82c2436740 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 14:26:03 +0300 Subject: [PATCH 15/60] Test --- src/komodo_bitcoind.h | 21 ++++++++++++++++----- src/rpcmisc.cpp | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4a1ca28dc..a3526bdcc 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -346,14 +346,25 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } -int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) +int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp) { - char *jsonstr,params[256]; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0; + char *jsonstr,params[256],*userpass; uint16_t port; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0; params[0] = 0; *kmdnotarized_heightp = 0; - if ( KMDUSERPASS[0] != 0 ) + if ( strcmp(dest,"KMD") == 0 ) { - if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getinfo",params,7771)) != 0 ) + port = 7771; + userpass = KMDUSERPASS; + } + else if ( strcmp(dest,"BTC") == 0 ) + { + port = 8332; + userpass = BTCUSERPASS; + } + else return(0); + if ( userpass[0] != 0 ) + { + if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 ) { //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) @@ -368,7 +379,7 @@ int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp) free(jsonstr); } sprintf(params,"[\"%s\", 1]",txidstr); - if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771)) != 0 ) + if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 ) { //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index a2660f958..766ba125f 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -47,7 +47,7 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp); int32_t komodo_whoami(char *pubkeystr,int32_t height); extern int32_t KOMODO_LASTMINED; extern char ASSETCHAINS_SYMBOL[]; -int32_t notarizedtxid_height(char *txidstr,int32_t *kmdnotarized_heightp); +int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); #define KOMODO_VERSION "0.1.0" Value getinfo(const Array& params, bool fHelp) @@ -102,7 +102,7 @@ Value getinfo(const Array& params, bool fHelp) if ( ASSETCHAINS_SYMBOL[0] != 0 ) { int32_t kmdnotarized_height,txid_height; - txid_height = notarizedtxid_height((char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); obj.push_back(Pair("notarizedtxid_height", txid_height)); obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height) : 0)); From 0036398537bdd57d4dbc61a58503dcf06d73c1ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 14:55:44 +0300 Subject: [PATCH 16/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 96ba7923e..a122a50db 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -123,7 +123,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From 40f7f7e7f8374f526e677eac97a08b8ff71326b5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 15:16:27 +0300 Subject: [PATCH 17/60] Test --- src/komodo_interest.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index a122a50db..a962a8efe 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -80,7 +80,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! - if ( nValue > 25000LL*COIN ) + if ( nValue > 25000LL*COIN || txheight >= 250000 ) { exception = 0; if ( txheight <= 155949 ) @@ -108,7 +108,12 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue / 20); // assumes 5%! if ( txheight < 250000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + else + { + if ( nValue < 100000LL*COIN ) + interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + else interest = (numerator / denominator); + } } else { From e0f32abae56d67630b9c8d9258c2f17deaa132ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 15:23:39 +0300 Subject: [PATCH 18/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index a962a8efe..9ec58bde0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } return(interest); From ab97f718e52566c2d3e0d7a1a006ee8af47dfcb7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 15:31:36 +0300 Subject: [PATCH 19/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 9ec58bde0..44ea535a3 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); + fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } return(interest); From e89758bde21eaef5657a796b350a6482ed383b60 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 15:39:47 +0300 Subject: [PATCH 20/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 44ea535a3..4b00b0602 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -80,7 +80,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! - if ( nValue > 25000LL*COIN || txheight >= 250000 ) + if ( nValue > 25000LL*COIN || tiptime >= 1490531630 ) { exception = 0; if ( txheight <= 155949 ) From 170bc39eb109f07227c6399bf3cafe9552ccbee7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 15:44:12 +0300 Subject: [PATCH 21/60] Test --- src/komodo_interest.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 4b00b0602..0df7489d1 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -111,8 +111,15 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { if ( nValue < 100000LL*COIN ) + { + printf("post 250K, < 100000 KMD path\n"); interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - else interest = (numerator / denominator); + } + else + { + printf("post 250K, > 100000 KMD path\n"); + interest = (numerator / denominator); + } } } else From f592eadc016e8bc744478a26dcd04bc29fb6aa69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 15:59:27 +0300 Subject: [PATCH 22/60] Test --- src/komodo_interest.h | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 0df7489d1..bf05f0dd0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -80,7 +80,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! - if ( nValue > 25000LL*COIN || tiptime >= 1490531630 ) + if ( nValue > 25000LL*COIN ) { exception = 0; if ( txheight <= 155949 ) @@ -106,21 +106,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 250000 ) - interest = (numerator / denominator); - else - { - if ( nValue < 100000LL*COIN ) - { - printf("post 250K, < 100000 KMD path\n"); - interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - } - else - { - printf("post 250K, > 100000 KMD path\n"); - interest = (numerator / denominator); - } - } + interest = (numerator / denominator); } else { @@ -130,10 +116,26 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin } else { - numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) + { + numerator = (nValue * KOMODO_INTEREST); + if ( txheight >= 250000 ) + printf("numerator * minutes < 365 * 24 * 60\n"); interest = (numerator / denominator) / COIN; - else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + } + else + { + if ( tiptime < 1490531630 ) // 1491350400 5th April + { + numerator = (nValue * KOMODO_INTEREST); + interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + } + else + { + numerator = (nValue / 20); // assumes 5%! + interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); + } + } } fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } From d8e548cb971e31d0f5d8abb49e83c74a708e8557 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 16:09:32 +0300 Subject: [PATCH 23/60] Test --- src/komodo_interest.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index bf05f0dd0..de7f9750e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -66,7 +66,8 @@ uint64_t komodo_moneysupply(int32_t height) uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { - int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; + int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation; + activation = 1490531630; // 1491350400 5th April if ( ASSETCHAINS_SYMBOL[0] != 0 ) return(0); if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) @@ -106,7 +107,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - interest = (numerator / denominator); + if ( txheight < 250000 ) + interest = (numerator / denominator); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -116,20 +119,19 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin } else { - if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) - { + /* 250000 algo numerator = (nValue * KOMODO_INTEREST); - if ( txheight >= 250000 ) - printf("numerator * minutes < 365 * 24 * 60\n"); + if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) + interest = (numerator / denominator) / COIN; + else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + */ + numerator = (nValue * KOMODO_INTEREST); + if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; - } else { - if ( tiptime < 1490531630 ) // 1491350400 5th April - { - numerator = (nValue * KOMODO_INTEREST); + if ( tiptime < activation ) interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; - } else { numerator = (nValue / 20); // assumes 5%! From 2af45c1f384477f44f3e4ca6d869b7193200a983 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 16:21:30 +0300 Subject: [PATCH 24/60] Test --- src/komodo_interest.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index de7f9750e..aa5b79dc8 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -136,10 +136,12 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); + fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } } + if ( numerator == (nValue * KOMODO_INTEREST) ) + fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } - fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } return(interest); From 3a7753af9c8a0920e37d6f09fea5008f48cf91f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 16:26:44 +0300 Subject: [PATCH 25/60] Test --- src/komodo_interest.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index aa5b79dc8..47d2a4bc8 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -110,11 +110,13 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( txheight < 250000 ) interest = (numerator / denominator); else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + fprintf(stderr,">25000 KMD\n"); } else { numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; + fprintf(stderr,"exception\n"); } } else @@ -126,12 +128,18 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; */ numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) + if ( (txheight < 250000 && tiptime < activation) || numerator * minutes < 365 * 24 * 60 ) + { interest = (numerator / denominator) / COIN; + fprintf(stderr,"txheight < 250000 || numerator * minutes < 365 * 24 * 60\n"); + } else { if ( tiptime < activation ) + { interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + fprintf(stderr,"tiptime < activation\n"); + } else { numerator = (nValue / 20); // assumes 5%! From cf99cfc1eb298a498600e7607100e824f6e9f4ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 16:32:59 +0300 Subject: [PATCH 26/60] Test --- src/komodo_interest.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 47d2a4bc8..b16233608 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -67,7 +67,7 @@ uint64_t komodo_moneysupply(int32_t height) uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation; - activation = 1490531630; // 1491350400 5th April + activation = 1491350400; // 1491350400 5th April if ( ASSETCHAINS_SYMBOL[0] != 0 ) return(0); if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) @@ -110,13 +110,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( txheight < 250000 ) interest = (numerator / denominator); else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - fprintf(stderr,">25000 KMD\n"); } else { numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; - fprintf(stderr,"exception\n"); } } else @@ -129,17 +127,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin */ numerator = (nValue * KOMODO_INTEREST); if ( (txheight < 250000 && tiptime < activation) || numerator * minutes < 365 * 24 * 60 ) - { interest = (numerator / denominator) / COIN; - fprintf(stderr,"txheight < 250000 || numerator * minutes < 365 * 24 * 60\n"); - } else { if ( tiptime < activation ) - { interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; - fprintf(stderr,"tiptime < activation\n"); - } else { numerator = (nValue / 20); // assumes 5%! @@ -147,7 +139,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } } - if ( numerator == (nValue * KOMODO_INTEREST) ) + if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } From 9eb7ea3abd92bda9740f60a4d6d01fd665392772 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 16:56:20 +0300 Subject: [PATCH 27/60] Test --- src/komodo_interest.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index b16233608..12e415404 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -67,7 +67,7 @@ uint64_t komodo_moneysupply(int32_t height) uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation; - activation = 1491350400; // 1491350400 5th April + activation = 149135040; // 1491350400 5th April if ( ASSETCHAINS_SYMBOL[0] != 0 ) return(0); if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) @@ -126,18 +126,17 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; */ numerator = (nValue * KOMODO_INTEREST); - if ( (txheight < 250000 && tiptime < activation) || numerator * minutes < 365 * 24 * 60 ) - interest = (numerator / denominator) / COIN; + if ( txheight < 250000 || tiptime < activation ) + { + if ( numerator * minutes < 365 * 24 * 60 ) + interest = (numerator / denominator) / COIN; + else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + } else { - if ( tiptime < activation ) - interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; - else - { - numerator = (nValue / 20); // assumes 5%! - interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); - fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); - } + numerator = (nValue / 20); // assumes 5%! + interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); + fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); From 73de636086b39b167b89366acb53057a97f3522b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:01:32 +0300 Subject: [PATCH 28/60] Test --- src/komodo_interest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 12e415404..43f2568b0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -126,7 +126,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; */ numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 250000 || tiptime < activation ) + if ( txheight < 250000 && tiptime < activation ) { if ( numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; @@ -138,7 +138,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } - if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) + if ( 1 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } From ea3666c63061cd860b592f3a063f1124d5d770f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:07:28 +0300 Subject: [PATCH 29/60] April 5th activation --- src/komodo_interest.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 43f2568b0..e0c9a9a58 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -67,7 +67,7 @@ uint64_t komodo_moneysupply(int32_t height) uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime) { int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation; - activation = 149135040; // 1491350400 5th April + activation = 1491350400; // 1491350400 5th April if ( ASSETCHAINS_SYMBOL[0] != 0 ) return(0); if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN ) @@ -136,9 +136,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); - fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); + //fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } - if ( 1 && numerator == (nValue * KOMODO_INTEREST) ) + if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } From 715bda82cf8c710559432f72947ab68cbe1ee593 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:18:20 +0300 Subject: [PATCH 30/60] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a3526bdcc..84b476b09 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -366,7 +366,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig { if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 ) { - //printf("(%s)\n",jsonstr); + printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { if ( (item= jobj(json,(char *)"result")) != 0 ) @@ -381,7 +381,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig sprintf(params,"[\"%s\", 1]",txidstr); if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 ) { - //printf("(%s)\n",jsonstr); + printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { if ( (item= jobj(json,(char *)"result")) != 0 ) From 7ea5a37187894f2f56de97c438207d04b198ca11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:22:49 +0300 Subject: [PATCH 31/60] Test --- src/rpcmisc.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index 766ba125f..b6208ba47 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -52,8 +52,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig Value getinfo(const Array& params, bool fHelp) { - uint256 notarized_hash,notarized_desttxid; - int32_t notarized_height,longestchain; + uint256 notarized_hash,notarized_desttxid; int32_t notarized_height,longestchain,kmdnotarized_height,txid_height; if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" @@ -99,14 +98,10 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - int32_t kmdnotarized_height,txid_height; - txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); - obj.push_back(Pair("notarizedtxid_height", txid_height)); - obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height) : 0)); - } + txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); + obj.push_back(Pair("notarizedtxid_height", txid_height)); + obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height) : 0)); #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); From 66c5b6ae4d85ff5cde7b30746d0a4d346ee5a04d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:31:57 +0300 Subject: [PATCH 32/60] Test --- src/komodo_bitcoind.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 84b476b09..ef75f8e2a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -389,6 +389,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig txid_confirmations = jint(item,(char *)"confirmations"); if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; + else txid_height = height+1; //printf("height.%d tconfs.%d txid_height.%d\n",height,txid_confirmations,txid_height); } free_json(json); From 70d8393432ba487d46e47cedcad37500a1e398b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:36:57 +0300 Subject: [PATCH 33/60] Test --- src/komodo_bitcoind.h | 4 ++-- src/rpcmisc.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ef75f8e2a..9c212f50a 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -366,7 +366,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig { if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 ) { - printf("(%s)\n",jsonstr); + //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { if ( (item= jobj(json,(char *)"result")) != 0 ) @@ -381,7 +381,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig sprintf(params,"[\"%s\", 1]",txidstr); if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 ) { - printf("(%s)\n",jsonstr); + //printf("(%s)\n",jsonstr); if ( (json= cJSON_Parse(jsonstr)) != 0 ) { if ( (item= jobj(json,(char *)"result")) != 0 ) diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index b6208ba47..e23a0bf1a 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -99,8 +99,10 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); - obj.push_back(Pair("notarizedtxid_height", txid_height)); - obj.push_back(Pair("kmdnotarized_height", kmdnotarized_height)); + if ( txid_height > 0 ) + obj.push_back(Pair("notarizedtxid_height", txid_height)); + else obj.push_back(Pair("notarizedtxid_height", "mempool")); + obj.push_back(Pair(ASSETCHAINS_SYMBOL[0] == 0 ? "BTCnotarized_height" :"KMDnotarized_height", kmdnotarized_height)); obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height) : 0)); #ifdef ENABLE_WALLET if (pwalletMain) { From 198571952beb32b9a9648206d837f78196a5668e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:42:34 +0300 Subject: [PATCH 34/60] 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 9c212f50a..b94f87260 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -389,7 +389,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig txid_confirmations = jint(item,(char *)"confirmations"); if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; - else txid_height = height+1; + else txid_height = height; //printf("height.%d tconfs.%d txid_height.%d\n",height,txid_confirmations,txid_height); } free_json(json); From 57dd4adae0f46e069f4236ca37897d4e1510ca8b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 17:50:05 +0300 Subject: [PATCH 35/60] Test --- src/komodo_bitcoind.h | 2 +- src/rpcmisc.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b94f87260..72eac6305 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -371,8 +371,8 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig { if ( (item= jobj(json,(char *)"result")) != 0 ) { - *kmdnotarized_heightp = jint(item,(char *)"notarized"); height = jint(item,(char *)"blocks"); + *kmdnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height; } free_json(json); } diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index e23a0bf1a..9135cd812 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -102,8 +102,9 @@ Value getinfo(const Array& params, bool fHelp) if ( txid_height > 0 ) obj.push_back(Pair("notarizedtxid_height", txid_height)); else obj.push_back(Pair("notarizedtxid_height", "mempool")); - obj.push_back(Pair(ASSETCHAINS_SYMBOL[0] == 0 ? "BTCnotarized_height" :"KMDnotarized_height", kmdnotarized_height)); - obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height) : 0)); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + obj.push_back(Pair("KMDnotarized_height", kmdnotarized_height)); + obj.push_back(Pair("notarized_confirms", txid_height < kmdnotarized_height ? (kmdnotarized_height - txid_height + 1) : 0)); #ifdef ENABLE_WALLET if (pwalletMain) { obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); From ddbc321c54136a2e694674df2d2c3f0d09ed7e97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 18:53:42 +0300 Subject: [PATCH 36/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index e0c9a9a58..40e0ef2be 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 && tiptime < activation ) { - if ( numerator * minutes < 365 * 24 * 60 ) + if ( txheight >= 250000 && numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } From c95550ebe57650b5cee3144e06875ef4b3f9a58b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 18:54:52 +0300 Subject: [PATCH 37/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index e0c9a9a58..40e0ef2be 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 && tiptime < activation ) { - if ( numerator * minutes < 365 * 24 * 60 ) + if ( txheight >= 250000 && numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } From 8cfe68a169a4ddbdba010e2ff49c08c38cbdd678 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 18:55:25 +0300 Subject: [PATCH 38/60] Revert "Test" This reverts commit ddbc321c54136a2e694674df2d2c3f0d09ed7e97. --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 40e0ef2be..e0c9a9a58 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 && tiptime < activation ) { - if ( txheight >= 250000 && numerator * minutes < 365 * 24 * 60 ) + if ( numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } From 82c67a009a920b75006ba5bf7f299935e03bcac5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 18:56:51 +0300 Subject: [PATCH 39/60] April 5th --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index e0c9a9a58..40e0ef2be 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 && tiptime < activation ) { - if ( numerator * minutes < 365 * 24 * 60 ) + if ( txheight >= 250000 && numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } From 1ce44fb757cd0b6bf000995f902d205b3975538b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 19:01:39 +0300 Subject: [PATCH 40/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 40e0ef2be..11bbd55d5 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 && tiptime < activation ) { - if ( txheight >= 250000 && numerator * minutes < 365 * 24 * 60 ) + if ( txheight < 250000 && numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } From ddf7c583aa0a417fb30e39bc9d8cc788222cd32d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 19:03:11 +0300 Subject: [PATCH 41/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 11bbd55d5..8fb1cb5ac 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -128,7 +128,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); if ( txheight < 250000 && tiptime < activation ) { - if ( txheight < 250000 && numerator * minutes < 365 * 24 * 60 ) + if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } From 17914f3e595be633e8d1680dc289db9c9db5b812 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 19:15:56 +0300 Subject: [PATCH 42/60] Test --- src/komodo_events.h | 5 ++++- src/komodo_interest.h | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 2652aaa58..110c1f757 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -40,7 +40,10 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig { struct komodo_event_notarized N; if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) - printf("[%s] error validating notarization ht.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,height,notarizedheight); + { + if ( height > 50000 ) + printf("[%s] error validating notarization ht.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,height,notarizedheight); + } else { memset(&N,0,sizeof(N)); diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 8fb1cb5ac..00c4e95eb 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -136,11 +136,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); - //fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); + fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } - if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) - fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } + if ( 1 && numerator == (nValue * KOMODO_INTEREST) ) + fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } return(interest); From fb3715334a9f90be1b2d5557260165cb235e0422 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 19:25:18 +0300 Subject: [PATCH 43/60] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 00c4e95eb..0b4561320 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -126,7 +126,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; */ numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 250000 && tiptime < activation ) + if ( txheight < 250000 || tiptime < activation ) { if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; From 71ac621458171a6917d6d3abc33c51ce6a97f8da Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 19:34:55 +0300 Subject: [PATCH 44/60] Test --- src/komodo_interest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 0b4561320..6355173d8 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -136,10 +136,10 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { numerator = (nValue / 20); // assumes 5%! interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)); - fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); + //fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes); } } - if ( 1 && numerator == (nValue * KOMODO_INTEREST) ) + if ( 0 && numerator == (nValue * KOMODO_INTEREST) ) fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes)); } } From ab0442fc5c0893ae49ea92458510d26c1e0acbaa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 19:41:52 +0300 Subject: [PATCH 45/60] Test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e91c30f1f..09ac4ed4d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -652,7 +652,8 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); memset(baseids,0xff,sizeof(baseids)); @@ -706,7 +707,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( overflow != 0 || total > COIN/10 ) { //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); - if ( height >= 235300 ) + if ( height >= activation ) return(-1); } } @@ -985,7 +986,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (i=0; i= activation ) + return(-1); } //printf("opretlen.%d num.%d\n",opretlen,num); } @@ -995,7 +997,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("%02x",script[i]); printf(" height.%d checkdeposit n.%d [%02x] [%c] %d len.%d ",height,n,script[0],script[offset],script[offset],opretlen); printf("not proper vout with opreturn format %s ht.%d\n",ASSETCHAINS_SYMBOL,height); -exit(-1); return(-1); } return(0); From 88908338cac52289c3e4e99f7a7d770072f4400f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 20:27:00 +0300 Subject: [PATCH 46/60] Test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 09ac4ed4d..3fe31b7b8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -956,7 +956,8 @@ 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(" kht.%d ht.%d %.8f %.8f blockhash couldnt find vout.[%d] ht.%d %s for [%s]\n",kmdheights[i-1],otherheights[i-1],dstr(values[i-1]),dstr(srcvalues[i]),i,height,ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]); - return(-1); + if ( ASSETCHAINS_SYMBOL[0] != 0 || height >= activation ) + return(-1); } } if ( ASSETCHAINS_SYMBOL[0] == 0 ) @@ -986,7 +987,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (i=0; i= activation ) + if ( ASSETCHAINS_SYMBOL[0] != 0 || height >= activation ) return(-1); } //printf("opretlen.%d num.%d\n",opretlen,num); From 04e91f213ed3b6fbabb1a9fd0f0c03b1c7a84963 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 20:47:07 +0300 Subject: [PATCH 47/60] 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 3fe31b7b8..51c745e86 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -962,7 +962,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) + /*if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) { printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); // can easily happen depending on order of loading @@ -971,7 +971,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); } - } + }*/ // disabled 'X' path } else { From 45c6eef80cde18d8971a197b96c712d9132d26fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:19:29 +0300 Subject: [PATCH 48/60] Test --- src/komodo_gateway.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51c745e86..924a22aae 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -584,7 +584,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 64 ) + if ( numvouts++ >= 1 ) break; } if ( numvouts > 1 ) @@ -939,7 +939,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { } if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) + { + //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,block.vtx[0].vout[i].nValue,0) == 0 ) + printf("paxcmp PASS "); + else printf("paxcmp FAIL "); + printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { From 9866121b28e844a6e30c21b6ecb3397ff9f68031 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:30:17 +0300 Subject: [PATCH 49/60] Test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 924a22aae..3f08753da 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -652,7 +652,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -941,7 +941,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,block.vtx[0].vout[i].nValue,0) == 0 ) + checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)values[i-1]); + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,checktoshis,0) == 0 ) printf("paxcmp PASS "); else printf("paxcmp FAIL "); From 0c780ec8fa421461c83cddf085abd143b975dda9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:32:18 +0300 Subject: [PATCH 50/60] 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 3f08753da..98228d585 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1100,7 +1100,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 1 && strcmp(base,"USD") == 0 ) + if ( 0 && strcmp(base,"USD") == 0 ) printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d [%d]\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,height); } } From 9bd8223b2c3a3ff8a6d1d35d75d43162f204cc33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:36:03 +0300 Subject: [PATCH 51/60] 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 98228d585..6956314e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -941,7 +941,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)values[i-1]); + checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,checktoshis,0) == 0 ) printf("paxcmp PASS "); else printf("paxcmp FAIL "); From c83e66e128a9136d4ac8e52f3be05bd82f5c9b37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:42:20 +0300 Subject: [PATCH 52/60] Test --- src/komodo_gateway.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6956314e3..9de8bb545 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -941,8 +941,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,checktoshis,0) == 0 ) + char destaddr[64],coinaddr[64]; uint8_t pubkey33[33]; + checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis); + //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,0) == 0 ) printf("paxcmp PASS "); else printf("paxcmp FAIL "); From a2a15c59f87d1b1f016aeb1a3e7480803c36c022 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:46:49 +0300 Subject: [PATCH 53/60] Test --- src/komodo_gateway.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9de8bb545..7669bc061 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -944,11 +944,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above char destaddr[64],coinaddr[64]; uint8_t pubkey33[33]; checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis); //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,0) == 0 ) - printf("paxcmp PASS "); - else printf("paxcmp FAIL "); - - printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 ) + { + printf("paxcmp FAIL "); + printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + return(-1); + } } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) From e86de02591269aa03473f5dbfb23e3b721cf4175 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:49:19 +0300 Subject: [PATCH 54/60] 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 7669bc061..17828c41e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -949,7 +949,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("paxcmp FAIL "); printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); return(-1); - } + } else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) From 38fb23568e2c8164cd90121c9360137cd5e6c2f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:52:55 +0300 Subject: [PATCH 55/60] Test --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 17828c41e..ce5586f86 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -281,6 +281,8 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che } else if ( checkvalue != 0 ) { + if ( checkvalue != value ) + fprintf(stderr,"(%.8f != %.8f) ",(double)value/COIN,(double)checkvalue/COIN); ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); From 548befdc629e7c9e9f50d039d0711a795855067c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:55:20 +0300 Subject: [PATCH 56/60] Test --- src/komodo_gateway.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ce5586f86..17828c41e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -281,8 +281,6 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che } else if ( checkvalue != 0 ) { - if ( checkvalue != value ) - fprintf(stderr,"(%.8f != %.8f) ",(double)value/COIN,(double)checkvalue/COIN); ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); From ba2a8aa714eed85ef6a24971f2f7202a658df415 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 22:05:42 +0300 Subject: [PATCH 57/60] Test --- src/komodo_gateway.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 17828c41e..371d2174d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -946,10 +946,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 ) { - printf("paxcmp FAIL "); - printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + printf("paxcmp FAIL when check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); return(-1); - } else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + } //else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) From d31a8037828591f9abed8efb0406d9aff5ff435e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 22:23:06 +0300 Subject: [PATCH 58/60] 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 371d2174d..1cdce2c29 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -584,7 +584,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 1 ) + if ( numvouts++ >= 64 || sum > COIN ) break; } if ( numvouts > 1 ) From d965945bdab837668808ee207de05930b74db94f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 22:45:46 +0300 Subject: [PATCH 59/60] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7f7bb5a74..7c14b8d4e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -657,7 +657,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); From e41cf01052208f8d6d1e144eafd3a11b47a27ede Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 27 Mar 2017 10:11:48 +0300 Subject: [PATCH 60/60] WLC --- src/assetchains | 3 ++- src/dpowassets | 2 +- src/fiat-cli | 2 +- src/fiat/wireless | 2 -- src/fiat/wlc | 2 ++ src/wallet/wallet.cpp | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) delete mode 100755 src/fiat/wireless create mode 100755 src/fiat/wlc diff --git a/src/assetchains b/src/assetchains index ead749ec7..2239048fa 100755 --- a/src/assetchains +++ b/src/assetchains @@ -16,7 +16,8 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=999999 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MVP -ac_supply=1000000 -addnode=78.47.196.146 $1 & -./komodod -pubkey=$pubkey -ac_name=WIRELESS -ac_supply=21000000 -addnode=78.47.196.146 $1 & +#./komodod -pubkey=$pubkey -ac_name=WIRELESS -ac_supply=21000000 -addnode=78.47.196.146 $1 & +./komodod -pubkey=$pubkey -ac_name=WLC -ac_supply=210000000 -addnode=148.251.190.89 $1 & ./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 & ./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000000 -addnode=78.47.196.146 $1 & diff --git a/src/dpowassets b/src/dpowassets index 2e0790639..8115fdd27 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -17,7 +17,7 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGW\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MVP\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WIRELESS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WLC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KV\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CEAL\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MESH\",\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat-cli b/src/fiat-cli index 3150fa3b7..aa29a3095 100755 --- a/src/fiat-cli +++ b/src/fiat-cli @@ -44,7 +44,7 @@ echo shark; fiat/shark $1 $2 $3 $4 echo bots; fiat/bots $1 $2 $3 $4 echo mgw; fiat/mgw $1 $2 $3 $4 echo mvp; fiat/mvp $1 $2 $3 $4 -echo wireless; fiat/wireless $1 $2 $3 $4 +echo wlc; fiat/wlc $1 $2 $3 $4 echo kv; fiat/kv $1 $2 $3 $4 echo ceal; fiat/ceal $1 $2 $3 $4 echo mesh; fiat/mesh $1 $2 $3 $4 diff --git a/src/fiat/wireless b/src/fiat/wireless deleted file mode 100755 index c6e092a41..000000000 --- a/src/fiat/wireless +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=WIRELESS $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/wlc b/src/fiat/wlc new file mode 100755 index 000000000..ef7c47b90 --- /dev/null +++ b/src/fiat/wlc @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6 diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 091fb5e22..7fbdb237f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2384,7 +2384,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int //fprintf(stderr,"count.%d %.8f\n",count,(double)pcoin->vout[i].interest/COIN); interests[count++] = pcoin->vout[i].interest; } - if ( nTotalLower > 2*nTargetValue + CENT ) + if ( count >= sizeof(interests)/sizeof(*interests) && nTotalLower > 2*nTargetValue + CENT ) { //fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n"); break;