From 910405ceed0a3d10c828713915a7c045048d51bd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:12:25 +0200 Subject: [PATCH 01/38] test --- src/komodo.h | 4 +--- src/komodo_notary.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 5b45126a5..20755a257 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -19,9 +19,7 @@ // Todo: // verify: reorgs -// non komodod (non-hardfork) todo: -// a. automate notarization fee payouts -// b. automated distribution of test REVS snapshot +#define KOMODO_MAINNET_START 156720 #define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index b6de38df8..259a5aee5 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -52,6 +52,12 @@ const char *Notaries_genesis[][2] = { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, }; +const char *Notaries_elected[][2] = +{ + { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, + { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, +}; + int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask) { int32_t htind,numnotaries,i,wt = 0; @@ -246,6 +252,18 @@ void komodo_init(int32_t height) // Minerids[i] = -2; didinit = 1; } + else if ( height == KOMODO_MAINNET_START ) + { + n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected)); + for (k=0; k Date: Mon, 16 Jan 2017 11:14:34 +0200 Subject: [PATCH 02/38] test --- src/komodo_notary.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 259a5aee5..843776512 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,6 +13,8 @@ * * ******************************************************************************/ +#define KOMODO_MAINNET_START 156720 + const char *Notaries_genesis[][2] = { { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, From f4bc5a9ae9198fd3dc484e0fcfa86870030b9bc3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:21:15 +0200 Subject: [PATCH 03/38] test --- src/komodo_notary.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 843776512..0322ca50c 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,7 +13,7 @@ * * ******************************************************************************/ -#define KOMODO_MAINNET_START 156720 +#define KOMODO_MAINNET_START 156730 const char *Notaries_genesis[][2] = { @@ -116,7 +116,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 0 && height > 10000 ) + if ( 1 && height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); @@ -234,6 +234,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_init(int32_t height) { static int didinit; uint256 zero; int32_t i,k,n; uint8_t pubkeys[64][33]; + printf("komodo_init ht.%d didinit.%d mainnet.%d\n",height,didinit,KOMODO_MAINNET_START); if ( didinit == 0 ) { pthread_mutex_init(&komodo_mutex,NULL); From 1ba18c2d213dbbc76eda3d72365ca0aab203bd04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:22:09 +0200 Subject: [PATCH 04/38] test --- src/komodo.h | 2 +- src/komodo_notary.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 20755a257..cf0226633 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -19,7 +19,7 @@ // Todo: // verify: reorgs -#define KOMODO_MAINNET_START 156720 +#define KOMODO_MAINNET_START 156730 #define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 0322ca50c..3a5a6e142 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,7 +13,6 @@ * * ******************************************************************************/ -#define KOMODO_MAINNET_START 156730 const char *Notaries_genesis[][2] = { From c9e772875833c6bf47819146c72381367f159463 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:24:42 +0200 Subject: [PATCH 05/38] test --- src/komodo_notary.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 3a5a6e142..971d2a823 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -233,7 +233,8 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_init(int32_t height) { static int didinit; uint256 zero; int32_t i,k,n; uint8_t pubkeys[64][33]; - printf("komodo_init ht.%d didinit.%d mainnet.%d\n",height,didinit,KOMODO_MAINNET_START); + if ( height != 0 ) + printf("komodo_init ht.%d didinit.%d\n",height,didinit); if ( didinit == 0 ) { pthread_mutex_init(&komodo_mutex,NULL); From 1d3c302743d216ef23e326b479262e600e60f5b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:26:33 +0200 Subject: [PATCH 06/38] test --- src/komodo.h | 1 - src/komodo_notary.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index cf0226633..482c00012 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -19,7 +19,6 @@ // Todo: // verify: reorgs -#define KOMODO_MAINNET_START 156730 #define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 971d2a823..876bc88ce 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,6 +13,7 @@ * * ******************************************************************************/ +#define KOMODO_MAINNET_START 156735 const char *Notaries_genesis[][2] = { From 483c56f8bdad7704068c6d0f2d17891c4eeda6ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:31:50 +0200 Subject: [PATCH 07/38] test --- src/komodo_notary.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 876bc88ce..1aeea0137 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,7 +13,7 @@ * * ******************************************************************************/ -#define KOMODO_MAINNET_START 156735 +#define KOMODO_MAINNET_START 156742 const char *Notaries_genesis[][2] = { @@ -266,7 +266,7 @@ void komodo_init(int32_t height) decode_hex(pubkeys[k],33,(char *)Notaries_elected[k][1]); } printf("set MAINNET notaries.%d\n",k); - komodo_notarysinit(0,pubkeys,k); + komodo_notarysinit(KOMODO_MAINNET_START,pubkeys,k); } komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); } From 35dd11f0c188bc1137363b29b3d294688670dff8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 11:38:29 +0200 Subject: [PATCH 08/38] support hardcoded elected notaries --- src/komodo_notary.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 1aeea0137..c4acbb44b 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,7 +13,7 @@ * * ******************************************************************************/ -#define KOMODO_MAINNET_START 156742 +#define KOMODO_MAINNET_START 156999 const char *Notaries_genesis[][2] = { @@ -54,7 +54,7 @@ const char *Notaries_genesis[][2] = { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, }; -const char *Notaries_elected[][2] = +const char *Notaries_elected[][2] = // update with all elected notaries { { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" }, { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" }, @@ -116,7 +116,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( 1 && height > 10000 ) + if ( 0 && height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); @@ -234,7 +234,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n void komodo_init(int32_t height) { static int didinit; uint256 zero; int32_t i,k,n; uint8_t pubkeys[64][33]; - if ( height != 0 ) + if ( 0 && height != 0 ) printf("komodo_init ht.%d didinit.%d\n",height,didinit); if ( didinit == 0 ) { From b55c23673678cd8385a180228618f305b6a85da1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 12:30:34 +0200 Subject: [PATCH 09/38] test --- src/komodo.h | 3 +-- src/komodo_bitcoind.h | 50 +++++++++++++++++++++++++++++++++++++++ src/komodo_globals.h | 2 +- src/komodo_utils.h | 55 ++++++++++++++++++++++++++++++------------- 4 files changed, 91 insertions(+), 19 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 482c00012..39a40ca02 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -19,7 +19,6 @@ // Todo: // verify: reorgs - #define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) @@ -303,7 +302,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar else if ( height != 0 ) { //printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs); - if ( sp != 0 ) + if ( sp != 0 && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(symbol,dest,height,sp->NOTARIZED_HEIGHT,sp->NOTARIZED_HASH,sp->NOTARIZED_DESTTXID) == 0) ) { fputc('N',fp); if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dbb887963..c304bcae2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -346,6 +346,56 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } +int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) +{ + int32_t i; uint256 hash; char params[256]; + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&NOTARIZED_HASH)[i]); + printf(" notarized, "); + for (i=0; i<32; i++) + { + ((uint8_t *)&hash)[i] = script[31+2-i]; + printf("%02x",script[31+2-i]); + } + printf(" <- opreturn?\n"); + if ( hash == NOTARIZED_HASH ) + return(0); + else return(-1); +} + +int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) +{ + char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; + sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); + if ( strcmp(dest,"KMD") == 0 ) + jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771); + else if ( strcmp(dest,"BTC") == 0 ) + jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); + else return(-1); + if ( jsonstr != 0 ) + { + if ( (txjson= cJSON_Parse(jsonstr)) != 0 ) + { + if ( (vouts= jarray(&n,txjson,"vout")) > 0 ) + { + vout = jitem(vouts,n-1); + if ( (skey= jobj(vout,"scriptPubKey")) != 0 ) + { + if ( (hexstr= jstr(skey,"hex")) != 0 ) + { + len = strlen(hexstr) >> 1; + decode_hex(script,len,hexstr); + retval = komodo_verifynotarizedscript(script,len,NOTARIZED_HASH); + } + } + } + free_json(txjson); + } + free(jsonstr); + } + return(retval); +} + uint256 komodo_getblockhash(int32_t height) { uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; int32_t i; uint8_t revbuf[32]; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 1e985da6b..08c80ff79 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,5 +47,5 @@ uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t ASSETCHAINS_SUPPLY = 10; uint32_t KOMODO_INITDONE; -char KMDUSERPASS[1024]; uint16_t BITCOIND_PORT = 7771; +char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t BITCOIND_PORT = 7771; uint64_t PENDING_KOMODO_TX; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 198caccd8..0f7392e56 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1347,7 +1347,11 @@ void komodo_configfile(char *symbol,uint16_t port) #else while ( fname[strlen(fname)-1] != '/' ) fname[strlen(fname)-1] = 0; +#ifdef __APPLE__ + strcat(fname,"Komodo.conf"); +#else strcat(fname,"komodo.conf"); +#endif #endif if ( (fp= fopen(fname,"rb")) != 0 ) { @@ -1363,7 +1367,13 @@ int32_t komodo_userpass(char *userpass,char *symbol) FILE *fp; char fname[512],username[512],password[512],confname[16]; userpass[0] = 0; if ( strcmp("KMD",symbol) == 0 ) + { +#ifdef __APPLE__ + sprintf(confname,"Komodo.conf"); +#else sprintf(confname,"komodo.conf"); +#endif + } else sprintf(confname,"%s.conf",symbol); komodo_statefname(fname,symbol,confname); if ( (fp= fopen(fname,"rb")) != 0 ) @@ -1494,23 +1504,36 @@ void komodo_args() { char fname[512],username[512],password[4096]; FILE *fp; ASSETCHAINS_PORT = 8777; - strcpy(fname,GetDataDir().string().c_str()); -#ifdef WIN32 - while ( fname[strlen(fname)-1] != '\\' ) - fname[strlen(fname)-1] = 0; - strcat(fname,".komodo/komodo.conf"); -#else - while ( fname[strlen(fname)-1] != '/' ) - fname[strlen(fname)-1] = 0; - strcat(fname,".komodo/komodo.conf"); -#endif - if ( (fp= fopen(fname,"rb")) != 0 ) + for (iter=0; iter<2; iter++) { - komodo_userpass(username,password,fp); - sprintf(KMDUSERPASS,"%s:%s",username,password); - fclose(fp); - //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); - } else printf("couldnt open.(%s)\n",fname); + strcpy(fname,GetDataDir().string().c_str()); +#ifdef WIN32 + while ( fname[strlen(fname)-1] != '\\' ) + fname[strlen(fname)-1] = 0; + if ( iter == 0 ) + strcat(fname,".komodo\\komodo.conf"); + else strcat(fname,".bitcoin\\bitcoin.conf"); +#else + while ( fname[strlen(fname)-1] != '/' ) + fname[strlen(fname)-1] = 0; +#ifdef __APPLE__ + if ( iter == 0 ) + strcat(fname,"Komodo/Komodo.conf"); + else strcat(fname,"Bitcoin/Bitcoin.conf"); +#else + if ( iter == 0 ) + strcat(fname,".komodo/komodo.conf"); + else strcat(fname,".bitcoin/bitcoin.conf"); +#endif +#endif + if ( (fp= fopen(fname,"rb")) != 0 ) + { + komodo_userpass(username,password,fp); + sprintf(iter == 0 ? KMDUSERPASS : BTCUSERPASS,"%s:%s",username,password); + fclose(fp); + //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); + } else printf("couldnt open.(%s)\n",fname); + } } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); } From 523a5dc7e09a6c87a658b5a107cca505b2afd453 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 12:32:20 +0200 Subject: [PATCH 10/38] test --- src/komodo_bitcoind.h | 6 +++--- src/komodo_utils.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c304bcae2..165cc0657 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -376,12 +376,12 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t { if ( (txjson= cJSON_Parse(jsonstr)) != 0 ) { - if ( (vouts= jarray(&n,txjson,"vout")) > 0 ) + if ( (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); - if ( (skey= jobj(vout,"scriptPubKey")) != 0 ) + if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 ) { - if ( (hexstr= jstr(skey,"hex")) != 0 ) + if ( (hexstr= jstr(skey,(char *)"hex")) != 0 ) { len = strlen(hexstr) >> 1; decode_hex(script,len,hexstr); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0f7392e56..81a116eda 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1502,7 +1502,7 @@ void komodo_args() } else { - char fname[512],username[512],password[4096]; FILE *fp; + char fname[512],username[512],password[4096]; int32_t iter; FILE *fp; ASSETCHAINS_PORT = 8777; for (iter=0; iter<2; iter++) { From b148643e801300b19740e69ab5f2f09a41a7c972 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 12:46:04 +0200 Subject: [PATCH 11/38] test --- src/komodo.h | 4 ++-- src/komodo_bitcoind.h | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 39a40ca02..29f7ecb26 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -302,7 +302,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar else if ( height != 0 ) { //printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs); - if ( sp != 0 && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(symbol,dest,height,sp->NOTARIZED_HEIGHT,sp->NOTARIZED_HASH,sp->NOTARIZED_DESTTXID) == 0) ) + if ( sp != 0 ) { fputc('N',fp); if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) ) @@ -376,7 +376,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(symbol,dest,height,*notarizedheightp,kmdtxid,desttxid) == 0) ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 165cc0657..9031d89c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -368,9 +368,17 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); if ( strcmp(dest,"KMD") == 0 ) - jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771); + { + if ( KMDUSERPASS[0] != 0 ) + jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771); + //else jsonstr = _dex_getrawtransaction(); + } else if ( strcmp(dest,"BTC") == 0 ) - jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); + { + if ( BTCUSERPASS[0] != 0 ) + jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); + //else jsonstr = _dex_getrawtransaction(); + } else return(-1); if ( jsonstr != 0 ) { From 48d0e5df77b54a8db1c202ea820399d76c54e4bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:16:19 +0200 Subject: [PATCH 12/38] test --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 9 +++++++++ src/komodo_utils.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 29f7ecb26..0036299e2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -409,7 +409,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j); } } - } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); + } else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d prev.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,sp->NOTARIZED_HEIGHT,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) { diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 9031d89c1..7334ab154 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -367,30 +367,39 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t { char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); + printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",src,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771); //else jsonstr = _dex_getrawtransaction(); + else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok } else if ( strcmp(dest,"BTC") == 0 ) { if ( BTCUSERPASS[0] != 0 ) + { + printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); + } //else jsonstr = _dex_getrawtransaction(); + else return(0); } else return(-1); if ( jsonstr != 0 ) { + printf("GOT.(%s)\n",jsonstr); if ( (txjson= cJSON_Parse(jsonstr)) != 0 ) { if ( (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); + printf("vout.(%s)\n",jprint(vout,0)); if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 ) { if ( (hexstr= jstr(skey,(char *)"hex")) != 0 ) { + printf("HEX.(%s)\n",hexstr); len = strlen(hexstr) >> 1; decode_hex(script,len,hexstr); retval = komodo_verifynotarizedscript(script,len,NOTARIZED_HASH); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 81a116eda..0364dcbf6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1534,6 +1534,7 @@ void komodo_args() //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } + printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); } From de28264f07de6c3514c0aec5326c19ea25c1dc26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:17:18 +0200 Subject: [PATCH 13/38] 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 7334ab154..d0eed2afe 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -367,7 +367,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t { char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",src,dest,params,height,NOTARIZED_HEIGHT); + printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) From eee286628f26d3e5ab67323900dd7df6164141bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:34:40 +0200 Subject: [PATCH 14/38] test --- src/komodo.h | 2 ++ src/komodo_bitcoind.h | 9 +++++++-- src/komodo_utils.h | 1 - 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0036299e2..5956ae9f0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,6 +99,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( 0 && sp != 0 ) printf("%s load[%s.%d] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp + if ( komodo_verifynotarization(symbol,dest,height,notarized_height,notarized_hash,notarized_desttxid) != 0 ) + printf("error validating notarization\n"); komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } else if ( func == 'U' ) // deprecated diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index d0eed2afe..93fe2f05d 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -366,7 +366,12 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; - sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); + params[0] = '['; + params[1] = '"'; + for (i=0; i<32; i++) + sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[i]); + strcat(params,"\", 1]"); + //sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { @@ -379,7 +384,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t { if ( BTCUSERPASS[0] != 0 ) { - printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); + //printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); jsonstr = komodo_issuemethod(BTCUSERPASS,(char *)"getrawtransaction",params,8332); } //else jsonstr = _dex_getrawtransaction(); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0364dcbf6..81a116eda 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1534,7 +1534,6 @@ void komodo_args() //printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS); } else printf("couldnt open.(%s)\n",fname); } - printf("BTCUSERPASS.(%s)\n",BTCUSERPASS); } //fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL); } From 88432f13d49c8d79a7f31e09d4d09c715ee9c593 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:36:00 +0200 Subject: [PATCH 15/38] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 5956ae9f0..df9e68727 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,7 +99,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( 0 && sp != 0 ) printf("%s load[%s.%d] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp - if ( komodo_verifynotarization(symbol,dest,height,notarized_height,notarized_hash,notarized_desttxid) != 0 ) + if ( komodo_verifynotarization(symbol,dest,ht,notarized_height,notarized_hash,notarized_desttxid) != 0 ) printf("error validating notarization\n"); komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } From 731f2c845012fd9586c24ca38e3f3b1aa7958e1c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:36:22 +0200 Subject: [PATCH 16/38] 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 93fe2f05d..af2560837 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -365,7 +365,7 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { - char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; + char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t i,n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; params[0] = '['; params[1] = '"'; for (i=0; i<32; i++) From 13b64fd60662cd3dbb1cb90291072025c289629c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:40:20 +0200 Subject: [PATCH 17/38] test --- src/komodo.h | 2 -- src/komodo_bitcoind.h | 7 +++---- src/komodo_events.h | 21 +++++++++++++-------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index df9e68727..0036299e2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -99,8 +99,6 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char if ( 0 && sp != 0 ) printf("%s load[%s.%d] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,symbol,sp->NUM_NPOINTS,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp - if ( komodo_verifynotarization(symbol,dest,ht,notarized_height,notarized_hash,notarized_desttxid) != 0 ) - printf("error validating notarization\n"); komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } else if ( func == 'U' ) // deprecated diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index af2560837..dbbc5a178 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -365,7 +365,7 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { - char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t i,n,len,retval = -1; cJSON *txjson,*vouts,*vout,*skey; + char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t i,n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey; params[0] = '['; params[1] = '"'; for (i=0; i<32; i++) @@ -393,10 +393,9 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t else return(-1); if ( jsonstr != 0 ) { - printf("GOT.(%s)\n",jsonstr); - if ( (txjson= cJSON_Parse(jsonstr)) != 0 ) + if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - if ( (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) + if ( (txjson= jobj(json,"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); printf("vout.(%s)\n",jprint(vout,0)); diff --git a/src/komodo_events.h b/src/komodo_events.h index cb7861107..60fb6ad2c 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,14 +39,19 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight) { struct komodo_event_notarized N; - memset(&N,0,sizeof(N)); - N.blockhash = notarized_hash; - N.desttxid = notarized_desttxid; - N.notarizedheight = notarizedheight; - strcpy(N.dest,dest); - komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); - if ( sp != 0 ) - komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid); + if ( komodo_verifynotarization(symbol,dest,ht,notarized_height,notarized_hash,notarized_desttxid) != 0 ) + printf("error validating notarization\n"); + else + { + memset(&N,0,sizeof(N)); + N.blockhash = notarized_hash; + N.desttxid = notarized_desttxid; + N.notarizedheight = notarizedheight; + strcpy(N.dest,dest); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); + if ( sp != 0 ) + komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid); + } } void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33]) From 4a6c805b0d280cb3d609878de1e734f274b42364 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:41:35 +0200 Subject: [PATCH 18/38] test --- src/komodo_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index 60fb6ad2c..0e600f32e 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,7 +39,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight) { struct komodo_event_notarized N; - if ( komodo_verifynotarization(symbol,dest,ht,notarized_height,notarized_hash,notarized_desttxid) != 0 ) + if ( komodo_verifynotarization(symbol,dest,height,notarized_height,notarized_hash,notarized_desttxid) != 0 ) printf("error validating notarization\n"); else { From fa73aa673ed507b6896632246e79d14dc70c049d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:42:48 +0200 Subject: [PATCH 19/38] test --- src/komodo_bitcoind.h | 2 +- src/komodo_events.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dbbc5a178..241e453b2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -395,7 +395,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t { if ( (json= cJSON_Parse(jsonstr)) != 0 ) { - if ( (txjson= jobj(json,"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) + if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); printf("vout.(%s)\n",jprint(vout,0)); diff --git a/src/komodo_events.h b/src/komodo_events.h index 0e600f32e..aeb038f99 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,7 +39,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight) { struct komodo_event_notarized N; - if ( komodo_verifynotarization(symbol,dest,height,notarized_height,notarized_hash,notarized_desttxid) != 0 ) + if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) printf("error validating notarization\n"); else { From c315390018481a600154e810e0488f12d5ed5216 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:45:57 +0200 Subject: [PATCH 20/38] test --- src/komodo_bitcoind.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 241e453b2..f3d589c29 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -365,13 +365,13 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) { - char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t i,n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey; - params[0] = '['; + char params[256],*jsonstr,*hexstr; uint8_t script[8192]; int32_t n,len,retval = -1; cJSON *json,*txjson,*vouts,*vout,*skey; + /*params[0] = '['; params[1] = '"'; for (i=0; i<32; i++) - sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[i]); - strcat(params,"\", 1]"); - //sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); + sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); + strcat(params,"\", 1]");*/ + sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { From ebd189442f629a8e451c2ae4aec682b0f70642e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:50:42 +0200 Subject: [PATCH 21/38] 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 f3d589c29..7314557ad 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -354,8 +354,8 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ printf(" notarized, "); for (i=0; i<32; i++) { - ((uint8_t *)&hash)[i] = script[31+2-i]; - printf("%02x",script[31+2-i]); + ((uint8_t *)&hash)[i] = script[2+i]; + printf("%02x",script[2+i]); } printf(" <- opreturn?\n"); if ( hash == NOTARIZED_HASH ) @@ -398,12 +398,12 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); - printf("vout.(%s)\n",jprint(vout,0)); + //printf("vout.(%s)\n",jprint(vout,0)); if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 ) { if ( (hexstr= jstr(skey,(char *)"hex")) != 0 ) { - printf("HEX.(%s)\n",hexstr); + //printf("HEX.(%s)\n",hexstr); len = strlen(hexstr) >> 1; decode_hex(script,len,hexstr); retval = komodo_verifynotarizedscript(script,len,NOTARIZED_HASH); From b556919ac5595058662d68ea6de9f4a98b1555dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:53:52 +0200 Subject: [PATCH 22/38] test --- src/komodo_bitcoind.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7314557ad..6927de309 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -349,18 +349,17 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) { int32_t i; uint256 hash; char params[256]; + for (i=0; i<32; i++) + ((uint8_t *)&hash)[i] = script[2+i]; + if ( hash == NOTARIZED_HASH ) + return(0); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&NOTARIZED_HASH)[i]); printf(" notarized, "); for (i=0; i<32; i++) - { - ((uint8_t *)&hash)[i] = script[2+i]; - printf("%02x",script[2+i]); - } - printf(" <- opreturn?\n"); - if ( hash == NOTARIZED_HASH ) - return(0); - else return(-1); + printf("%02x",((uint8_t *)&hash)[i]); + printf(" opreturn\n"); + return(-1); } int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t NOTARIZED_HEIGHT,uint256 NOTARIZED_HASH,uint256 NOTARIZED_DESTTXID) @@ -372,7 +371,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); + //printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) From 1bb3eff053ebcdb9c7eb12b611a7c4834d01e51a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 13:59:14 +0200 Subject: [PATCH 23/38] 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 6927de309..bda5b47b1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -351,14 +351,14 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ int32_t i; uint256 hash; char params[256]; for (i=0; i<32; i++) ((uint8_t *)&hash)[i] = script[2+i]; - if ( hash == NOTARIZED_HASH ) - return(0); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&NOTARIZED_HASH)[i]); printf(" notarized, "); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); printf(" opreturn\n"); + if ( hash == NOTARIZED_HASH ) + return(0); return(-1); } From d56e594584182cd76002984b6f992106c33f0664 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:02:43 +0200 Subject: [PATCH 24/38] 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 bda5b47b1..6927de309 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -351,14 +351,14 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ int32_t i; uint256 hash; char params[256]; for (i=0; i<32; i++) ((uint8_t *)&hash)[i] = script[2+i]; + if ( hash == NOTARIZED_HASH ) + return(0); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&NOTARIZED_HASH)[i]); printf(" notarized, "); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); printf(" opreturn\n"); - if ( hash == NOTARIZED_HASH ) - return(0); return(-1); } From 9674c671d081ada9b19f18090e94cc5e7823a9ff Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:13:12 +0200 Subject: [PATCH 25/38] test --- src/komodo_bitcoind.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6927de309..0a8cac099 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -358,7 +358,7 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ printf(" notarized, "); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); - printf(" opreturn\n"); + printf(" opreturn from [%s]\n",ASSETCHAINS_SYMBOL); return(-1); } @@ -389,7 +389,11 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t //else jsonstr = _dex_getrawtransaction(); else return(0); } - else return(-1); + else + { + printf("[%s] verifynotarization error unexpected dest.(%s)\n",ASSETCHAINS_SYMBOL,dest); + return(-1); + } if ( jsonstr != 0 ) { if ( (json= cJSON_Parse(jsonstr)) != 0 ) From 20a5cb84d97d278f8cd615545b9c2a6d66516d9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:19:34 +0200 Subject: [PATCH 26/38] test --- src/komodo_bitcoind.h | 10 +++++----- src/komodo_events.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0a8cac099..1a8dd56a4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -346,7 +346,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port) return(retstr2); } -int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) +int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH) { int32_t i; uint256 hash; char params[256]; for (i=0; i<32; i++) @@ -358,7 +358,7 @@ int32_t komodo_verifynotarizedscript(uint8_t *script,int32_t len,uint256 NOTARIZ printf(" notarized, "); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&hash)[i]); - printf(" opreturn from [%s]\n",ASSETCHAINS_SYMBOL); + printf(" opreturn from [%s] ht.%d\n",ASSETCHAINS_SYMBOL,height); return(-1); } @@ -371,7 +371,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - //printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); + printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) @@ -401,7 +401,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); - //printf("vout.(%s)\n",jprint(vout,0)); + printf("vout.(%s)\n",jprint(vout,0)); if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 ) { if ( (hexstr= jstr(skey,(char *)"hex")) != 0 ) @@ -409,7 +409,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t //printf("HEX.(%s)\n",hexstr); len = strlen(hexstr) >> 1; decode_hex(script,len,hexstr); - retval = komodo_verifynotarizedscript(script,len,NOTARIZED_HASH); + retval = komodo_verifynotarizedscript(height,script,len,NOTARIZED_HASH); } } } diff --git a/src/komodo_events.h b/src/komodo_events.h index aeb038f99..d8aafb333 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -40,7 +40,7 @@ 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("error validating notarization\n"); + printf("%s error validating notarization\n",ASSETCHAINS_SYMBOL); else { memset(&N,0,sizeof(N)); From 5697258b95fffc07ef253f728e33e484000352e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:28:09 +0200 Subject: [PATCH 27/38] test --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1a8dd56a4..2af89b864 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -370,8 +370,10 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t for (i=0; i<32; i++) sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ + if ( strcmp(ASSETCHAINS_SYMBOL,symbol) != 0 ) + return(0); sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - printf("src.%s dest.%s params.[%s] ht.%d notarized.%d\n",symbol,dest,params,height,NOTARIZED_HEIGHT); + printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) From 51ecd3f99f51c108c6a584eedb2c0f8b8a6b413e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:33:06 +0200 Subject: [PATCH 28/38] 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 2af89b864..70c363b29 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -373,7 +373,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t if ( strcmp(ASSETCHAINS_SYMBOL,symbol) != 0 ) return(0); sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); + //printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) @@ -403,7 +403,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); - printf("vout.(%s)\n",jprint(vout,0)); + //printf("vout.(%s)\n",jprint(vout,0)); if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 ) { if ( (hexstr= jstr(skey,(char *)"hex")) != 0 ) From 447744dc8bcef41c278bcbd8dc4e531b70ac498e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:42:50 +0200 Subject: [PATCH 29/38] test --- src/komodo.h | 2 +- src/komodo_bitcoind.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0036299e2..ed0d44f50 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -376,7 +376,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(symbol,dest,height,*notarizedheightp,kmdtxid,desttxid) == 0) ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD",height,*notarizedheightp,kmdtxid,desttxid) == 0) ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 70c363b29..3e5d3727e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -370,10 +370,10 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t for (i=0; i<32; i++) sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ + printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(ASSETCHAINS_SYMBOL,symbol) != 0 ) return(0); sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); - //printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) From 42af20bb9b86c6a723131c3c0ec6c2a198d2d7b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:44:36 +0200 Subject: [PATCH 30/38] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index ed0d44f50..9fe331708 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -376,7 +376,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD",height,*notarizedheightp,kmdtxid,desttxid) == 0) ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height && (height < sp->CURRENT_HEIGHT-1000 || komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD"),height,*notarizedheightp,kmdtxid,desttxid) == 0) ) { sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; From 67c0495a9dce1c143839a9637440f40c66df5e4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:47:16 +0200 Subject: [PATCH 31/38] test --- src/komodo_bitcoind.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 3e5d3727e..f4e44e862 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -370,10 +370,8 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t for (i=0; i<32; i++) sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ - printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); - if ( strcmp(ASSETCHAINS_SYMBOL,symbol) != 0 ) - return(0); sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); + printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) From 81e91b43c1f35d000390dd4e10aff9c73ecd7b1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:49:56 +0200 Subject: [PATCH 32/38] test --- src/komodo_events.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index d8aafb333..e9c34576a 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,7 +39,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight) { struct komodo_event_notarized N; - if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) + if ( komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD"),height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) printf("%s error validating notarization\n",ASSETCHAINS_SYMBOL); else { @@ -48,7 +48,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig N.desttxid = notarized_desttxid; N.notarizedheight = notarizedheight; strcpy(N.dest,dest); - komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); + komodo_eventadd(sp,height,ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); if ( sp != 0 ) komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid); } From ed9376455790481b7c07779dbcb4a562d31b9f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 14:53:36 +0200 Subject: [PATCH 33/38] test --- src/komodo_bitcoind.h | 3 +++ src/komodo_events.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f4e44e862..7b1435fa8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -371,7 +371,10 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t sprintf(¶ms[i*2 + 2],"%02x",((uint8_t *)&NOTARIZED_DESTTXID)[31-i]); strcat(params,"\", 1]");*/ sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); + if ( strcmp(symbol,ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL) != 0 ) + return(0); printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); + if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) diff --git a/src/komodo_events.h b/src/komodo_events.h index e9c34576a..d8aafb333 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -39,7 +39,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight) { struct komodo_event_notarized N; - if ( komodo_verifynotarization(ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "BTC" : "KMD"),height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) + if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 ) printf("%s error validating notarization\n",ASSETCHAINS_SYMBOL); else { @@ -48,7 +48,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig N.desttxid = notarized_desttxid; N.notarizedheight = notarizedheight; strcpy(N.dest,dest); - komodo_eventadd(sp,height,ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); + komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N)); if ( sp != 0 ) komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid); } From dff9ec91d792ec6c17d865cecf797fe07f4424db Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 15:06:43 +0200 Subject: [PATCH 34/38] 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 e00357ee7..a327ca08a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -763,7 +763,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( kmdheight > 91800 ) + else if ( kmdheight > 91800 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD\n",base,dstr(fiatoshis),kmdheight,dstr(value)); } } @@ -965,7 +965,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->redeemed += value; pax->didstats = 1; - //if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) printf("ht.%d %.8f ########### %p redeemed %s += %.8f %.8f kht.%d ht.%d\n",height,dstr(value),basesp,CURRENCIES[baseids[i]],dstr(value),dstr(srcvalues[i]),kmdheights[i],otherheights[i]); } } From a82f9da16e6da87a5059fec92da6f7a9304c563a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 15:07:37 +0200 Subject: [PATCH 35/38] test --- src/komodo_bitcoind.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7b1435fa8..5af538d9b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -373,8 +373,7 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); if ( strcmp(symbol,ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL) != 0 ) return(0); - printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); - + //printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) From 7641baed4d398793f268374ade92eb4a81253a1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 15:16:56 +0200 Subject: [PATCH 36/38] test --- src/komodo_notary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index c4acbb44b..fc77d1222 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -13,7 +13,7 @@ * * ******************************************************************************/ -#define KOMODO_MAINNET_START 156999 +#define KOMODO_MAINNET_START 178999 const char *Notaries_genesis[][2] = { From 73678c97f56d61c78aa63d05e2e31f1a5923cf2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 16 Jan 2017 18:08:50 +0200 Subject: [PATCH 37/38] 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 a327ca08a..cef75d663 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -819,11 +819,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 ) { - if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 ) + if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp("KMD",(char *)&opretbuf[opretlen-4]) != 0 ) { for (i=0; i Date: Mon, 16 Jan 2017 18:12:35 +0200 Subject: [PATCH 38/38] 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 cef75d663..007b16b0b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -823,7 +823,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i