From d7227bf643b24781d4d8bcbdbf7bc19572fe34c4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 13:52:57 -0300 Subject: [PATCH 01/24] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 967386695..0cf6d5324 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -444,6 +444,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; memset(&zero,0,sizeof(zero)); komodo_init(pindex->nHeight); + KOMODO_INITDONE = (uint32_t)time(NULL); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) return; numnotaries = komodo_notaries(pubkeys,pindex->nHeight); @@ -465,7 +466,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) sleep(3); } } - //KOMODO_INITDONE = (uint32_t)time(NULL); if ( pindex != 0 ) { height = pindex->nHeight; From 0f99d3c46980d532dac1aab6b48d84578f22e209 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:07:46 -0300 Subject: [PATCH 02/24] 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 1cc0bb9cb..cfe40710f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -392,7 +392,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value == checktoshis )//value >= checktoshis || (seed == 0 && diff < .01) ) + if ( value >= checktoshis-(checktoshis >> 10) ) { if ( komodo_paxfind(&space,txid,vout) == 0 ) { @@ -412,7 +412,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); - if ( checktoshis == komodoshis ) + if ( checktoshis <= komodoshis+(komodoshis >> 10) ) { if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) { From d90509ae2addb9177ecef3f78641c3ab82819ae1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:23:26 -0300 Subject: [PATCH 03/24] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0cf6d5324..a4a396cb5 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -458,14 +458,14 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + /*if ( ASSETCHAINS_SYMBOL[0] != 0 ) { while ( KOMODO_PASSPORT_INITDONE == 0 ) { fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); sleep(3); } - } + }*/ if ( pindex != 0 ) { height = pindex->nHeight; From a96fd7b542c48662c1abc571792ac2d70eb1d143 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:30:02 -0300 Subject: [PATCH 04/24] test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index fffbee299..7f290770e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -550,8 +550,8 @@ void static BitcoinMiner(CWallet *pwallet) { if (chainparams.MiningRequiresPeers()) { - if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) - break; + //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) + // break; // Busy-wait for the network to come online so we don't waste time mining // on an obsolete chain. In regtest mode we expect to fly solo. //fprintf(stderr,"Wait for peers...\n"); From 8fc7222dcdcb048df58bb014c49d26b077d81247 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 14:35:39 -0300 Subject: [PATCH 05/24] test --- src/miner.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 7f290770e..e2a0ca6a3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -569,6 +569,11 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); } + while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) + { + fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight); + sleep(3); + } // // Create new block // From d82623d257c7846d160511691987c69b12713549 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:14:16 -0300 Subject: [PATCH 06/24] test --- src/komodo_bitcoind.h | 16 +++++++++------- src/miner.cpp | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6878114b6..27d88d9b5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -550,12 +550,14 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash) { - int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; - notarized_height = komodo_notarizeddata(chainActive.Tip()->nHeight,¬arized_hash,¬arized_desttxid); + int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; CBlockIndex *pindex; + if ( (pindex= chainActive.Tip()) == 0 ) + return(-1); + notarized_height = komodo_notarizeddata(pindex->nHeight,¬arized_hash,¬arized_desttxid); *notarized_heightp = notarized_height; - if ( notarized_height >= 0 && notarized_height <= chainActive.Tip()->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) + if ( notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 ) { - //printf("nHeight.%d -> (%d %s)\n",chainActive.Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); + //printf("nHeight.%d -> (%d %s)\n",pindex->Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str()); if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg { if ( nHeight < notarized_height ) @@ -570,7 +572,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has } } else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight); } else if ( notarized_height > 0 && notarized_height != 73880 ) - fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,chainActive.Tip()->nHeight); + fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight); return(0); } @@ -611,11 +613,11 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 int32_t komodo_isrealtime(int32_t *kmdheightp) { - struct komodo_state *sp; + struct komodo_state *sp; CBlockIndex *pindex; if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; - if ( chainActive.Tip()->nHeight == (int32_t)komodo_longestchain() ) + if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight == (int32_t)komodo_longestchain() ) return(1); else return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index e2a0ca6a3..6a5fda4d1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -569,11 +569,11 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); //fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL); } - while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) + /*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 ) { fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight); sleep(3); - } + }*/ // // Create new block // From ef1a963671edf2d4fb3eea4f893bb202359a53b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:29:55 -0300 Subject: [PATCH 07/24] test --- src/komodo.h | 2 +- src/komodo_events.h | 2 +- src/komodo_gateway.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a4a396cb5..7e5e7aec0 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -139,7 +139,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char } else if ( func == 'R' ) { - uint16_t olen,v; uint64_t ovalue; uint256 txid; uint8_t opret[10000]; + uint16_t olen,v; uint64_t ovalue; uint256 txid; uint8_t opret[16384]; if ( fread(&txid,1,sizeof(txid),fp) != sizeof(txid) ) errs++; if ( fread(&v,1,sizeof(v),fp) != sizeof(v) ) diff --git a/src/komodo_events.h b/src/komodo_events.h index 0a5034a73..e38708918 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -74,7 +74,7 @@ void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t heig void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t height,uint256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen) { - struct komodo_event_opreturn O; uint8_t opret[10000]; + struct komodo_event_opreturn O; uint8_t opret[16384]; memset(&O,0,sizeof(O)); O.txid = txid; O.value = value; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cfe40710f..2d95d9ea0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -182,7 +182,7 @@ uint64_t komodo_paxtotal() int32_t komodo_pending_withdraws(char *opretstr) { - struct pax_transaction *pax,*tmp; uint8_t opretbuf[10000]; int32_t ht,len=0; uint64_t total = 0; + struct pax_transaction *pax,*tmp; uint8_t opretbuf[16384]; int32_t ht,len=0; uint64_t total = 0; if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 ) return(0); HASH_ITER(hh,PAX,pax,tmp) @@ -204,7 +204,7 @@ int32_t komodo_pending_withdraws(char *opretstr) int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; From c29e766f504b1ffb65557b9d69e970f84c8d2042 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:44:34 -0300 Subject: [PATCH 08/24] test --- src/rpcblockchain.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 8bfb19629..b79c2e90c 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -398,9 +398,9 @@ Value notaries(const Array& params, bool fHelp) if ( height < 0 ) height = 0; //fprintf(stderr,"notaries as of height.%d\n",height); - if ( height > chainActive.Height()+20000 ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - else + //if ( height > chainActive.Height()+20000 ) + // throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + //else { if ( (n= komodo_notaries(pubkeys,height)) > 0 ) { From 7ba6b48d571f832a5afadc417d5120bc5bbf2815 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 15:59:30 -0300 Subject: [PATCH 09/24] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 7e5e7aec0..350b1a486 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -177,7 +177,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); } - else printf("illegal func.(%d %c)\n",func,func); + else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func); return(func); } else return(-1); } From ede04b12fbad664ec4ef6972af35ee48d2dcf64f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:06:38 -0300 Subject: [PATCH 10/24] test --- src/komodo_gateway.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2d95d9ea0..b340954cc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -163,17 +163,21 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0; + struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; uint64_t total = 0; if ( komodo_isrealtime(&ht) == 0 ) return(0); + komodo_stateptr(symbol,dest); HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( pax->marked == 0 ) + if ( strcmp(symbol,pax->symbol) == 0 ) { - if ( komodo_is_issuer() != 0 ) - total += pax->fiatoshis; - else total += pax->komodoshis; + if ( pax->marked == 0 ) + { + if ( komodo_is_issuer() != 0 ) + total += pax->fiatoshis; + else total += pax->komodoshis; + } } } //printf("paxtotal %.8f\n",dstr(total)); From a8aa4375611ca13634e929b35c2ba7c790ce6077 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 16:24:34 -0300 Subject: [PATCH 11/24] test --- src/miner.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6a5fda4d1..749e31ce0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -657,10 +657,6 @@ void static BitcoinMiner(CWallet *pwallet) cancelSolver = false; } KOMODO_CHOSEN_ONE = 0; - int32_t i; uint256 hash = pblock->GetHash(); - for (i=0; i<32; i++) - fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); - fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); SetThreadPriority(THREAD_PRIORITY_LOWEST); // In regression test mode, stop mining after a block is found. if (chainparams.MineBlocksOnDemand()) { @@ -714,6 +710,10 @@ void static BitcoinMiner(CWallet *pwallet) bool found = EhOptimisedSolve(n, k, curr_state, validBlock, cancelled); ehSolverRuns.increment(); if (found) { + int32_t i; uint256 hash = pblock->GetHash(); + for (i=0; i<32; i++) + fprintf(stderr,"%02x",((uint8_t *)&hash)[i]); + fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height); break; } } catch (EhSolverCancelledException&) { From 97b426a8cdb341ce69aaed8ee6eca90fbc3ea053 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:36:49 -0300 Subject: [PATCH 12/24] test --- src/assetfunds | 33 +++++++++++++++++++++++++++++++++ src/script/standard.cpp | 1 + 2 files changed, 34 insertions(+) create mode 100755 src/assetfunds diff --git a/src/assetfunds b/src/assetfunds new file mode 100755 index 000000000..b2bee93c1 --- /dev/null +++ b/src/assetfunds @@ -0,0 +1,33 @@ +#!/bin/bash +./komodo-cli paxdeposit $1 aud 0.01 +./komodo-cli paxdeposit $1 bgn 0.01 +./komodo-cli paxdeposit $1 cad 0.01 +./komodo-cli paxdeposit $1 chf 0.01 +./komodo-cli paxdeposit $1 cny 0.01 +./komodo-cli paxdeposit $1 czk 0.01 +./komodo-cli paxdeposit $1 dkk 0.01 +./komodo-cli paxdeposit $1 eur 0.01 +./komodo-cli paxdeposit $1 gbp 0.01 +./komodo-cli paxdeposit $1 hkd 0.01 +./komodo-cli paxdeposit $1 hrk 0.01 +./komodo-cli paxdeposit $1 huf 0.01 +./komodo-cli paxdeposit $1 idr 0.01 +./komodo-cli paxdeposit $1 ils 0.01 +./komodo-cli paxdeposit $1 inr 0.01 +./komodo-cli paxdeposit $1 jpy 0.01 +./komodo-cli paxdeposit $1 krw 0.01 +./komodo-cli paxdeposit $1 mxn 0.01 +./komodo-cli paxdeposit $1 myr 0.01 +./komodo-cli paxdeposit $1 nok 0.01 +./komodo-cli paxdeposit $1 nzd 0.01 +./komodo-cli paxdeposit $1 php 0.01 +./komodo-cli paxdeposit $1 pln 0.01 +./komodo-cli paxdeposit $1 brl 0.01 +./komodo-cli paxdeposit $1 ron 0.01 +./komodo-cli paxdeposit $1 rub 0.01 +./komodo-cli paxdeposit $1 sek 0.01 +./komodo-cli paxdeposit $1 sgd 0.01 +./komodo-cli paxdeposit $1 thb 0.01 +./komodo-cli paxdeposit $1 try 0.01 +./komodo-cli paxdeposit $1 usd 0.01 +./komodo-cli paxdeposit $1 zar 0.01 diff --git a/src/script/standard.cpp b/src/script/standard.cpp index e4f9fc1c1..6c2cfbfbb 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,6 +143,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector nMaxDatacarrier.%d\n",vch1.size(),nMaxDatacarrierBytes); if (vch1.size() > nMaxDatacarrierBytes) break; } From a2829a0c4558a6fcc51b1224dd7c727e79938a7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:38:24 -0300 Subject: [PATCH 13/24] test --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 6c2cfbfbb..91c45c93e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,7 +143,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector nMaxDatacarrier.%d\n",vch1.size(),nMaxDatacarrierBytes); + fprintf(stderr,"size.%d > nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes); if (vch1.size() > nMaxDatacarrierBytes) break; } From cc0f93da2e920e4d8692868a453227e67483b2ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:47:23 -0300 Subject: [PATCH 14/24] test --- src/main.cpp | 10 +++++++--- src/script/standard.cpp | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0e1b84341..840ab46f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -676,14 +676,18 @@ bool IsStandardTx(const CTransaction& tx, string& reason) txnouttype whichType; BOOST_FOREACH(const CTxOut& txout, tx.vout) { - if (!::IsStandard(txout.scriptPubKey, whichType)) { - reason = "scriptpubkey"; - fprintf(stderr,"vout.%d nDataout.%d\n",v,nDataOut); + if (!::IsStandard(txout.scriptPubKey, whichType)) + { + reason = "scriptpubkeyA"; + fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut); return false; } if (whichType == TX_NULL_DATA) + { nDataOut++; + fprintf(stderr,"is OP_RETURN\n"); + } else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; return false; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 91c45c93e..0fb38fb95 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -143,9 +143,11 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes); if (vch1.size() > nMaxDatacarrierBytes) + { + fprintf(stderr,"size.%d > nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes); break; + } } else if (opcode1 != opcode2 || vch1 != vch2) { @@ -203,7 +205,8 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) if (m < 1 || m > n) return false; } - + if ( whichtype == TX_NONSTANDARD ) + fprintf(stderr,"IsStandard nonstandard tx\n"); return whichType != TX_NONSTANDARD; } From ce71f7729c9bca3e8d6eff765acd3b3ce95c8c86 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 17:48:52 -0300 Subject: [PATCH 15/24] test --- src/script/standard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 0fb38fb95..d0ec61632 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -205,7 +205,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) if (m < 1 || m > n) return false; } - if ( whichtype == TX_NONSTANDARD ) + if ( whichType == TX_NONSTANDARD ) fprintf(stderr,"IsStandard nonstandard tx\n"); return whichType != TX_NONSTANDARD; } From 7a82f2fc7383b2f83f1d70b0e97e6c12761d4e8f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 18:28:30 -0300 Subject: [PATCH 16/24] test --- src/main.cpp | 4 ++-- src/script/standard.cpp | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 840ab46f6..e2da7de1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -678,7 +678,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) { if (!::IsStandard(txout.scriptPubKey, whichType)) { - reason = "scriptpubkeyA"; + reason = "scriptpubkey"; fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut); return false; } @@ -686,7 +686,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason) if (whichType == TX_NULL_DATA) { nDataOut++; - fprintf(stderr,"is OP_RETURN\n"); + //fprintf(stderr,"is OP_RETURN\n"); } else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d0ec61632..71838853d 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -205,8 +205,6 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) if (m < 1 || m > n) return false; } - if ( whichType == TX_NONSTANDARD ) - fprintf(stderr,"IsStandard nonstandard tx\n"); return whichType != TX_NONSTANDARD; } From 06d1a655601687ca7aec91c51c6b4adea0511b70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 18:58:25 -0300 Subject: [PATCH 17/24] test --- src/komodo.h | 3 +++ src/komodo_gateway.h | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 350b1a486..92fad493d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -379,7 +379,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); if ( opretlen > len && scriptbuf[len] == 'A' ) + { + printf("Found extradata.[%d]\n",opretlen-len); komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,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 if ( i == 0 && j == 1 && opretlen == 149 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b340954cc..38aeb1847 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -427,6 +427,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { + printf("extra 'A' opret[%d]\n",opretlen); if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; iapproved = kmdheights[i]; + printf("i.%d approved.%d\n",i,kmdheights[i]); + } } } + printf("extra.[%d]\n",n); } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { From 400ee585823a2fbffe187496003e23e3892237e5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:07:29 -0300 Subject: [PATCH 18/24] test --- src/komodo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 92fad493d..0731510fa 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -152,7 +152,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char { if ( fread(opret,1,olen,fp) != olen ) errs++; - if ( matched != 0 ) + //if ( matched != 0 ) { int32_t i; for (i=0; i sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); From bc63863b182771d2a14ff8fae79f56237741b9d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:14:10 -0300 Subject: [PATCH 19/24] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 0731510fa..7f1dc72ba 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 errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - if ( 0 && sp != 0 ) + //if ( 0 && sp != 0 ) printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str()); //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); From 41f5997a57b0850a3b683d84f5bfed0e50bf4927 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:25:48 -0300 Subject: [PATCH 20/24] test --- src/komodo.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7f1dc72ba..f1b06ae28 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -371,7 +371,6 @@ 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],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); -notarized = 1; if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); @@ -493,7 +492,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { - //printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; } for (j=0; j Date: Mon, 21 Nov 2016 19:32:48 -0300 Subject: [PATCH 21/24] test --- src/komodo.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index f1b06ae28..33a716f4b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -461,14 +461,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); - /*if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - while ( KOMODO_PASSPORT_INITDONE == 0 ) - { - fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE); - sleep(3); - } - }*/ if ( pindex != 0 ) { height = pindex->nHeight; @@ -490,6 +482,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); + printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 3df533905c82fbf826f84bb84655f5afe54b84d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:49:06 -0300 Subject: [PATCH 22/24] test --- src/komodo.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 33a716f4b..67dff6499 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -449,7 +449,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_init(pindex->nHeight); KOMODO_INITDONE = (uint32_t)time(NULL); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + { + fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); return; + } numnotaries = komodo_notaries(pubkeys,pindex->nHeight); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -461,6 +464,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0); } komodo_currentheight_set(chainActive.Tip()->nHeight); + printf("HWM.%d connect.%d\n",chainActive.Tip()->nHeight,pindex->nHeight); if ( pindex != 0 ) { height = pindex->nHeight; @@ -545,7 +549,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } if ( pindex->nHeight == hwmheight ) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); - } else printf("komodo_connectblock: unexpected null pindex\n"); + } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); } From 0dfe3f3680d77cd1208209b66812601a6603810e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 19:57:12 -0300 Subject: [PATCH 23/24] 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 38aeb1847..51eb5f02e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -480,7 +480,7 @@ void komodo_passport_iteration() else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) - { + {break; sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; From 40d3a54fc5d8de5a4b094d1d41ca68e682fee0dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 20:09:33 -0300 Subject: [PATCH 24/24] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 2 +- src/pow.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 27d88d9b5..80d23b4b7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -535,7 +535,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) komodo_chosennotary(¬aryid,height,pubkey33); if ( height >= 34000 && notaryid >= 0 ) { - for (i=1; i<64; i++) + for (i=1; i<60; i++) { if ( komodo_minerid(height-i) == notaryid ) { diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51eb5f02e..38aeb1847 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -480,7 +480,7 @@ void komodo_passport_iteration() else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=0; baseid<=32; baseid++) - {break; + { sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; diff --git a/src/pow.cpp b/src/pow.cpp index 8d97786e0..3b64ce72c 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -135,8 +135,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in special2 = komodo_is_special(height,pubkey33); if ( special2 == -2 ) printf("height.%d special2.%d special.%d\n",height,special2,special); - if ( special2 == -2 || (height < 70000 && (special != 0 || special2 > 0)) || - (height >= 70000 && special2 > 0) ) + if ( special2 == -2 || (height < 80000 && (special != 0 || special2 > 0)) || + (height >= 80000 && special2 > 0) ) { bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); flag = 1;