From 83f1c673bfc94233ff1838e350431469d9566dc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Mar 2017 23:05:17 +0200 Subject: [PATCH 01/27] 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 02/27] 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 03/27] 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 04/27] 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 05/27] 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 06/27] 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 07/27] 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 08/27] 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 09/27] 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 10/27] 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 11/27] 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 12/27] 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 13/27] 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 14/27] 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 15/27] 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 16/27] 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 17/27] 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 18/27] 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 19/27] 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 20/27] 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 21/27] 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 22/27] 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 23/27] 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 24/27] 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 25/27] 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 26/27] 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 27/27] 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)); } }