From d03fbd981fce86504b78d2a9582e4da988d59823 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Dec 2016 10:01:43 -0300 Subject: [PATCH 01/86] disable 100000 --- src/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fe832ac0f..8e8223c1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -550,7 +550,6 @@ CBlockTreeDB *pblocktree = NULL; // Komodo globals -#define KOMODO_TESTNET_EXPIRATION 100000 #define KOMODO_PAX #define KOMODO_ZCASH #include "komodo.h" @@ -2155,8 +2154,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } bool fScriptChecks = (!fCheckpointsEnabled || pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints())); - if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" - return(false); + //if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" + // return(false); // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. BOOST_FOREACH(const CTransaction& tx, block.vtx) { From b039abf96ca8e18ca4b6afce6bfc6b91ab1350e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 3 Jan 2017 14:57:13 +0200 Subject: [PATCH 02/86] Revert "disable 100000" This reverts commit d03fbd981fce86504b78d2a9582e4da988d59823. --- src/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8e8223c1f..fe832ac0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -550,6 +550,7 @@ CBlockTreeDB *pblocktree = NULL; // Komodo globals +#define KOMODO_TESTNET_EXPIRATION 100000 #define KOMODO_PAX #define KOMODO_ZCASH #include "komodo.h" @@ -2154,8 +2155,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } bool fScriptChecks = (!fCheckpointsEnabled || pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints())); - //if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" - // return(false); + if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" + return(false); // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. BOOST_FOREACH(const CTransaction& tx, block.vtx) { From 5d72480089b6ce65ffee625080b34d65c6a4ad45 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Mar 2017 00:05:36 +0200 Subject: [PATCH 03/86] Typo --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index a13a2f57a..597b5e400 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -636,7 +636,7 @@ void static BitcoinMiner(CWallet *pwallet) // uint8_t pubkeys[66][33]; int mids[66],gpucount,nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime(); savebits = pblock->nBits; - ari`th_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); + arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits); if ( ASSETCHAINS_SYMBOL[0] == 0 && notaryid >= 0 )//komodo_is_special(pindexPrev->nHeight+1,NOTARY_PUBKEY33) > 0 ) { j = 65; From d1775ced1ef74c398fcdb806adcc3632f61d5e5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Mar 2017 22:02:23 +0200 Subject: [PATCH 04/86] Syntax --- src/komodo_gateway.h | 2 +- src/main.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6f216b24d..57aeebdfe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -495,7 +495,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; { #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE - if ( height > 236000 ) + if ( pax->height > 236000 ) { if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) pax->validated = pax->komodoshis; diff --git a/src/main.cpp b/src/main.cpp index 31ee26c8e..8f3fdfddd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -875,7 +875,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, { static uint32_t counter; if ( counter++ < 100 ) +<<<<<<< Updated upstream printf("MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j); +======= + fprintf(stderr,"MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j); +>>>>>>> Stashed changes return(false); } } From dbc9ad1fd9358ece10d4b844cd9a472d33aa8222 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 14 Mar 2017 22:04:03 +0200 Subject: [PATCH 05/86] Resolve --- src/main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8f3fdfddd..31ee26c8e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -875,11 +875,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, { static uint32_t counter; if ( counter++ < 100 ) -<<<<<<< Updated upstream printf("MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j); -======= - fprintf(stderr,"MEMPOOL: banned tx.%d being used at ht.%d vini.%d\n",k,(int32_t)chainActive.Tip()->nHeight,j); ->>>>>>> Stashed changes return(false); } } From 3899eedf50e66b98ed1f0d4cc57ea37595857e06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:02:51 +0200 Subject: [PATCH 06/86] 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 7779eba6e..c8111e99e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -115,7 +115,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / 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 87ce5503063900841a5205c62f6d40539c350eb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:17:06 +0200 Subject: [PATCH 07/86] Test --- src/komodo_interest.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index c8111e99e..c1943eda0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -102,7 +102,10 @@ 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 < 236000 ) + interest = (numerator / denominator); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + } else { @@ -113,9 +116,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - interest = (numerator / denominator) / COIN; + if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + 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 c73a1174b52fe9f468375351c0eb031952c55170 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:38:35 +0200 Subject: [PATCH 08/86] Test --- src/komodo_interest.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index c1943eda0..fd07a44e0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -73,6 +73,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { if ( (minutes= (tiptime - nLockTime) / 60) >= 60 ) { + if ( minutes > 365 * 24 * 60 ) + minutes = 365 * 24 * 60; denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! @@ -102,10 +104,13 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 236000 ) + if ( txheight < 30000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - + else + { + interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + printf("(%llu * %llu) = %llu; ",(long long)numerator,(long long)minutes,(long long)(numerator * minutes)); + } } else { @@ -120,7 +125,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 7f2e458b29ce9f5b8cae624d060d34c3206c11ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:58:01 +0200 Subject: [PATCH 09/86] Test --- src/komodo_interest.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index fd07a44e0..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,13 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 30000 ) + if ( txheight < 300000 ) interest = (numerator / denominator); - else - { - interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - printf("(%llu * %llu) = %llu; ",(long long)numerator,(long long)minutes,(long long)(numerator * minutes)); - } + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -125,7 +121,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 dd2850969594a03d50a69ff7e8997a8b8125a1fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:19:27 +0200 Subject: [PATCH 10/86] Revert "Test" This reverts commit 7f2e458b29ce9f5b8cae624d060d34c3206c11ae. --- src/komodo_interest.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..fd07a44e0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,9 +104,13 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 300000 ) + if ( txheight < 30000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + else + { + interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + printf("(%llu * %llu) = %llu; ",(long long)numerator,(long long)minutes,(long long)(numerator * minutes)); + } } else { @@ -121,7 +125,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 2fa533e1cd316e291c827919d9bfcddb87d3bc0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:21:28 +0200 Subject: [PATCH 11/86] Test --- src/komodo_interest.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..3b9540a1c 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,9 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 300000 ) + //if ( txheight < 300000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + //else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -117,9 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + //if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; - else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / 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); } From 9b82df63592bcb6a1c7271fa1b44cd8519e58117 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:26:06 +0200 Subject: [PATCH 12/86] Test --- src/komodo_interest.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 3b9540a1c..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,9 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - //if ( txheight < 300000 ) + if ( txheight < 300000 ) interest = (numerator / denominator); - //else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -117,9 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - //if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; - //else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / 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); } From 8f68a6a7608363d50f4c3f9dae54bb591dbc1a4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:58:50 +0200 Subject: [PATCH 13/86] 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 cf7d01201..6ed8d8138 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -821,9 +821,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { - printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); From cfa255d35b08a075b13b4fa8b32ce93ff05959b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:04:07 +0200 Subject: [PATCH 14/86] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6ed8d8138..ddd54de2c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -839,7 +839,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -856,7 +856,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -874,7 +874,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); } } From b61ed4395c2e81a124b055e978cfa41dbf77c515 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:15:51 +0200 Subject: [PATCH 15/86] 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 ddd54de2c..d67e0fba9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -921,7 +921,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; pax->height = pax2->height; pax->otherheight = height; - if ( 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); } } From 9b445a1d0e64edc9becab9612c56ae588b829d4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:24:33 +0200 Subject: [PATCH 16/86] 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 d67e0fba9..67f2cc749 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -787,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64],str[65]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -875,7 +875,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,pax2->txid)); } } } From 4c9da8cf5d00dbaca1e084126938a19b76ad8aba Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:26:53 +0200 Subject: [PATCH 17/86] Test --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 67f2cc749..2d40c3262 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -787,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64],str[65]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -875,7 +875,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,pax2->txid)); + { + char str[65]; bits256 tmp; + memcpy(&tmp,&pax2->txid,sizeof(tmp)); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); + } } } } From 05d80480128496afe4dde41c3f514a56f9bf7f25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:31:02 +0200 Subject: [PATCH 18/86] 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 2d40c3262..6751cc07b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -878,7 +878,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d (%s)\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); } } } From 134c49d281ef5847780c69acb69b8edf1b6c97c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:36:20 +0200 Subject: [PATCH 19/86] Test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6751cc07b..57ee014cd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -343,7 +343,7 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; - if ( 0 && pax->type == 'A' ) + if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; @@ -821,7 +821,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); for (i=0; i<32; i++) @@ -839,7 +839,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -856,7 +856,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -874,7 +874,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); From 9f22a3940bc711dba29637137d9769e5ada47d2c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:41:05 +0200 Subject: [PATCH 20/86] 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 57ee014cd..127de8272 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -344,7 +344,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("(%s) pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From f06a20267695f53ec9e6185722eeed11f51655a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:41:22 +0200 Subject: [PATCH 21/86] 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 127de8272..00a0fed30 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -344,7 +344,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s) pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From 6ada6d9a008cd2fb0858ac39e16352238fa73566 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:42:09 +0200 Subject: [PATCH 22/86] Test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 00a0fed30..c59a67b02 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -343,8 +343,10 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; + char str[65]; bits256 tmp; + memcpy(&tmp,pax->txid,sizeof(tmp)); if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From 7658f5bdb117434e7ab2a9629a65670f22317cef Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:42:54 +0200 Subject: [PATCH 23/86] 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 c59a67b02..b60656781 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -344,7 +344,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; char str[65]; bits256 tmp; - memcpy(&tmp,pax->txid,sizeof(tmp)); + memcpy(&tmp,&pax->txid,sizeof(tmp)); if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); if ( pax->marked != 0 ) From d9229150424f7039f0be8fcdc854d254ba6ebbb7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:47:55 +0200 Subject: [PATCH 24/86] Test --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b60656781..5628a8a93 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -343,10 +343,11 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; - char str[65]; bits256 tmp; + char str[65],coinaddr[64]; bits256 tmp; + bitcoin_address(coinaddr,60,pax->rmd160,20); memcpy(&tmp,&pax->txid,sizeof(tmp)); - if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); + if ( 0 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) + printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From 5618b77a65c8b025dba7e7d5e9034b07a7f84e6c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:49:17 +0200 Subject: [PATCH 25/86] 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 5628a8a93..af63957f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -373,8 +373,8 @@ uint64_t komodo_paxtotal() { seed = 0; checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - //printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); + printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); + printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 && checktoshis != 0 ) { if ( checktoshis == pax->komodoshis ) From 9ae3d21c0cc4a4552477348ebf889a63e511b6e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:12:57 +0200 Subject: [PATCH 26/86] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index af63957f9..8259824a8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -373,8 +373,8 @@ uint64_t komodo_paxtotal() { seed = 0; checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); + //printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); + //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 && checktoshis != 0 ) { if ( checktoshis == pax->komodoshis ) @@ -519,7 +519,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); - continue; + //continue; } /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); if ( pax->marked != 0 || (pax->type != 'D' && pax->type != 'A') || pax->ready == 0 ) @@ -574,7 +574,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 64 ) + //if ( numvouts++ >= 64 ) break; } if ( numvouts > 1 ) From d4ab9b565af55cb89a4b88f93a95e9555122171c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:13:21 +0200 Subject: [PATCH 27/86] 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 8259824a8..2c0e8a322 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,7 +574,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - //if ( numvouts++ >= 64 ) + if ( numvouts++ >= 1 ) break; } if ( numvouts > 1 ) From 4502c41e746aa251e4c586e1a946191aa1bc98ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:29:53 +0200 Subject: [PATCH 28/86] Test --- src/komodo_gateway.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2c0e8a322..93ca7b889 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -28,7 +28,8 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + //netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + netliability = (sp->issued - MAX(sp->approved,sp->withdrawn)) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); @@ -519,7 +520,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); - //continue; + pax->marked = pax->fiatoshis; + continue; } /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); if ( pax->marked != 0 || (pax->type != 'D' && pax->type != 'A') || pax->ready == 0 ) From 4445eeae6a66227e36ee0071336850d09356a3d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:36:07 +0200 Subject: [PATCH 29/86] Test --- src/komodo_gateway.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 93ca7b889..b3eec1c66 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -17,7 +17,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { @@ -29,7 +29,10 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *approved = sp->approved; *redeemed = sp->redeemed; //netliability = (sp->deposited - sp->withdrawn) - sp->shorted; - netliability = (sp->issued - MAX(sp->approved,sp->withdrawn)) - sp->shorted; + maxval = sp->approved; + if ( sp->withdrawn > maxval ) + maxval = sp->withdrawn; + netliability = (sp->issued - maxval) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); From 8dfdb3d0871aee51f2f01f5cb1bf0f9433eb45c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 01:40:08 +0200 Subject: [PATCH 30/86] Test --- src/komodo_gateway.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b3eec1c66..0a5661b95 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -60,12 +60,22 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) return(pax); } -struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) +struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t vout) { struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; - for (i=0; ikomodoshis : pax->fiatoshis; srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis; @@ -716,7 +726,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(1,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) @@ -724,7 +734,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } - if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) ) + if ( (opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue) ) { if ( pax->marked != 0 && height >= 80820 ) { From e7b74d684713dff3f5a0608efb84576dae955721 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:01:21 +0200 Subject: [PATCH 31/86] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..8802362af 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 29 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From 8b64937a1efd04787c359dde688d4a11a6e0463c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:01:42 +0200 Subject: [PATCH 32/86] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8802362af..e9ab80741 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 -#define ROUNDROBIN_DELAY 29 +#define ROUNDROBIN_DELAY 59 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From f3b1dadf87f46d45c536432d3c28327401d5f097 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:17:20 +0200 Subject: [PATCH 33/86] 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 0a5661b95..c727ecbf2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -726,7 +726,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(1,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) From d92731b20108f4b1b33f1f8379b79ddf5da144d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:29:52 +0200 Subject: [PATCH 34/86] Test --- src/komodo_gateway.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c727ecbf2..0b93777d0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -648,7 +648,7 @@ void komodo_bannedset(uint256 *array,int32_t max) int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[15]; - int32_t i,j,k,n,ht,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,retval,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t maxval,total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); memset(baseids,0xff,sizeof(baseids)); @@ -729,7 +729,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; - if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) + { + matched++; // this node isnt running this assetchain, leaves validation to others + continue; + } + maxval = approved; + if ( redeemed > maxval ) + maxval = redeemed; + if ( (opcode == 'I' && available < pax->fiatoshis) || (opcode == 'X' && pax->komodoshis > issued-maxval) ) { printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; From caa197e878565afd7d76fed0d469e0b7b77b0e70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:39:01 +0200 Subject: [PATCH 35/86] Tighten paxdeposit limits --- src/wallet/rpcwallet.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e68ccc9be..2bcb3f703 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -627,12 +627,23 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; + baseid = komodo_baseid((char *)base.c_str()); if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + errflag = 1; + minval = approved; + if ( withdrawn < minval ) + minval = withdrawn; + netliability = (deposited - minval); + maxallowed = komodo_maxallowed(baseid); + if ( fiatoshis > (maxallowed - netliability) ) + errflag = 1; + if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); + komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From bf1f6b3355998ca2554c1438ce47dff46fcc439e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:42:05 +0200 Subject: [PATCH 36/86] Syntax fix --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2bcb3f703..4e8f2fc93 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,6 +496,8 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); +uint64_t komodo_maxallowed(int32_t baseid); +int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { From 82ecec24a7aa525e7f602ab9703136d7dd94170a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:43:05 +0200 Subject: [PATCH 37/86] Syntax --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4e8f2fc93..07c8fd377 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -629,7 +629,7 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; From c6bd7b17969ffe40bbe1ed80da536bccd66ac580 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 03:44:55 +0200 Subject: [PATCH 38/86] test --- src/komodo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 94fb1347c..037aa1601 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -427,8 +427,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( i == 0 && j == 1 && opretlen == 149 ) { - if ( notaryid >= 0 && notaryid < 64 ) + if ( signedmask != 0 ) //notaryid >= 0 && notaryid < 64 ) + { + printf("pricefeed.%llx\n",(long long)signedmask); komodo_paxpricefeed(height,&scriptbuf[len],opretlen); + } } else { @@ -446,7 +449,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 ) + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I') ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } From 634aefee09e498274e70c671fec3fcf8ae7db3fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 03:46:19 +0200 Subject: [PATCH 39/86] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 037aa1601..f12dc723f 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -449,7 +449,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I') ) + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } From 37d2dcfaaafb2a42a601cc3836f4dfe76421abed Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:05:40 +0200 Subject: [PATCH 40/86] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index f12dc723f..aeb055f87 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -431,7 +431,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { printf("pricefeed.%llx\n",(long long)signedmask); komodo_paxpricefeed(height,&scriptbuf[len],opretlen); - } + } else printf("ht.%d null signedmask for pricefeed?\n",height); } else { From 76b9b8b8081ff4a2dddc112d99a70d11912128ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:12:24 +0200 Subject: [PATCH 41/86] Test --- src/komodo.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index aeb055f87..bdb692d09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -427,11 +427,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( i == 0 && j == 1 && opretlen == 149 ) { - if ( signedmask != 0 ) //notaryid >= 0 && notaryid < 64 ) - { - printf("pricefeed.%llx\n",(long long)signedmask); + if ( notaryid >= 0 && notaryid < 64 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); - } else printf("ht.%d null signedmask for pricefeed?\n",height); } else { From 2cb18e4c818292ee6dde9c34dc49b589ac4a8024 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:35:01 +0200 Subject: [PATCH 42/86] Test --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0b93777d0..d03f4fb87 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -67,8 +67,8 @@ struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t { if ( (pax= komodo_paxfind(txid,vout,'I')) != 0 ) return(pax); - if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 ) - return(pax); + //if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 ) + // return(pax); } else { @@ -726,7 +726,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(opcode == 'I',txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) @@ -847,7 +847,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( 0 && strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp("EUR",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); for (i=0; i<32; i++) @@ -865,7 +865,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -882,7 +882,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -900,7 +900,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); From e827f4d820e300a1e75b3bd99113199920a0a8e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:44:23 +0200 Subject: [PATCH 43/86] 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 d03f4fb87..c6c03d3b6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -514,7 +514,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE if ( pax->height > 236000 ) { - if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) + if ( pax->type == 'D' || (kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height) ) pax->validated = pax->komodoshis; else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 ) pax->validated = pax->ready = 0; From 94933685a114e589a76ffc9e6a11ff986b7c2a01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:55:30 +0200 Subject: [PATCH 44/86] Test --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c6c03d3b6..546c49b7f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -132,7 +132,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t memcpy(pax->buf,buf,sizeof(pax->buf)); HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; - if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 1 && ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); @@ -599,9 +599,12 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; - for (i=0; itxid)[i]); + printf(" <- data[%d]\n",len); + } opretlen = komodo_opreturnscript(opret,opcode,data,len); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = 0; From 3c89218a54e6543e5717110d947743c3285e3760 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 05:30:52 +0200 Subject: [PATCH 45/86] 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 546c49b7f..d6d70d507 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -65,7 +65,7 @@ struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; if ( strictflag != 0 ) { - if ( (pax= komodo_paxfind(txid,vout,'I')) != 0 ) + if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) return(pax); //if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 ) // return(pax); From 56b38b8cf8d83d1584e45281ae16ac71fc141744 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 05:42:09 +0200 Subject: [PATCH 46/86] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d6d70d507..465705a39 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -253,7 +253,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t for (j=0; j<32; j++) { ((uint8_t *)&txids[n])[j] = opretbuf[len++]; - //printf("%02x",((uint8_t *)&txids[n])[j]); + printf("%02x",((uint8_t *)&txids[n])[j]); } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; @@ -267,7 +267,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t memcpy(&rmd160s[n * 20],pax->rmd160,20); } } - //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } } return(n); @@ -729,7 +729,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(opcode == 'I',txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) From 5e8e89d8c9fd1ba0d256071705108e7e03144356 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 06:10:12 +0200 Subject: [PATCH 47/86] 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 465705a39..38cba956d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -601,8 +601,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to data[len++] = 0; if ( pax != 0 ) { - for (i=0; itxid)[i]); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[32-1-i]); printf(" <- data[%d]\n",len); } opretlen = komodo_opreturnscript(opret,opcode,data,len); From ea6bdd9bf2c8c5989bddd7d38ca13f4d99eecf12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 06:40:33 +0200 Subject: [PATCH 48/86] Test --- src/bitcoind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 63adecece..3abaef959 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -42,7 +42,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); - MilliSleep(10000); + MilliSleep(10000/100); komodo_passport_iteration(); fShutdown = ShutdownRequested(); } From 572f12e98878d60f86cf0aa757aa251db89b5044 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 06:55:35 +0200 Subject: [PATCH 49/86] Test --- src/bitcoind.cpp | 2 +- src/main.cpp | 2 +- src/miner.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 3abaef959..63adecece 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -42,7 +42,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); - MilliSleep(10000/100); + MilliSleep(10000); komodo_passport_iteration(); fShutdown = ShutdownRequested(); } diff --git a/src/main.cpp b/src/main.cpp index 455e6f78e..c674a3766 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3293,7 +3293,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn CScript expect = CScript() << nHeight; if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { - return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); + return state.DoS(100, error("%s: block height mismatch in coinbase ht.%d", __func__,nHeight), REJECT_INVALID, "bad-cb-height"); } } diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..e18e0d962 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -383,6 +383,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; + fprintf(stderr,"set coinbase height to %d\n",nHeight); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; From a13467f55fab9133d4f5d195e84637c2aaa5f250 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:01:14 +0200 Subject: [PATCH 50/86] Test --- src/komodo_gateway.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38cba956d..22a1de15e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -253,7 +253,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t for (j=0; j<32; j++) { ((uint8_t *)&txids[n])[j] = opretbuf[len++]; - printf("%02x",((uint8_t *)&txids[n])[j]); + //printf("%02x",((uint8_t *)&txids[n])[j]); } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; @@ -267,7 +267,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t memcpy(&rmd160s[n * 20],pax->rmd160,20); } } - printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } } return(n); @@ -599,7 +599,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; - if ( pax != 0 ) + if ( 0 && pax != 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[32-1-i]); @@ -868,7 +868,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -885,7 +885,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -903,7 +903,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); From a17692de3c029489ddebaf92f49597b80f5fcd6e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:13:51 +0200 Subject: [PATCH 51/86] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e18e0d962..b1cab7ba5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -383,7 +383,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; - fprintf(stderr,"set coinbase height to %d\n",nHeight); + //fprintf(stderr,"set coinbase height to %d\n",nHeight); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; @@ -577,7 +577,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && + if (0 && chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 2c70b583c50306fd067789bfd6a7c2fcefb98de2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:19:58 +0200 Subject: [PATCH 52/86] Test --- src/komodo_gateway.h | 2 +- src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 22a1de15e..1e5f21f96 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1092,7 +1092,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("n.%d from opreturns\n",n); //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'X' ) + else if ( opretbuf[0] == 'x' ) { tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index b1cab7ba5..5d4d85493 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -577,7 +577,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && + if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From dd67ab017e72afafc461a83db4defacecd381d21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:23:10 +0200 Subject: [PATCH 53/86] Test --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 07c8fd377..cc5aa132e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -672,6 +672,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return(0); if (!EnsureWalletIsAvailable(fHelp)) return 0; + throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) From f3159f7712b33ae48260e4f855d0bb1be685525b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:24:40 +0200 Subject: [PATCH 54/86] 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 1e5f21f96..d19eca9f2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -132,7 +132,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t memcpy(pax->buf,buf,sizeof(pax->buf)); HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; - if ( 1 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); From 47609f61aa560a66fb1637e8b9e1b97997454dd4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:43:44 +0200 Subject: [PATCH 55/86] 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 d19eca9f2..a10dbb822 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -442,7 +442,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic if ( pax2->approved != 0 ) pax->approved = pax2->approved; } - else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'X')) != 0 ) + else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'x')) != 0 ) pax->approved = pax->height; //printf("pending_withdraw: pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated); if ( pax->marked == 0 && pax->approved == 0 && pax->validated != 0 ) //strcmp((char *)"KMD",pax->symbol) == 0 && @@ -477,7 +477,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic 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[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask; - if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 || ASSETCHAINS_SYMBOL[0] == 0 ) return(0); struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); sp = komodo_stateptr(symbol,dest); From 8c782a55cba002d67fbd2da7be4ab0bef1081c12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:51:04 +0200 Subject: [PATCH 56/86] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5d4d85493..da7e737c6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -142,7 +142,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; } - sleep(10); + sleep(1); } KOMODO_ON_DEMAND = 0; if ( 0 && deposits != 0 ) From 6fd0ae11b7b7ef1f5b6dcfd6fdad4d6630c20d4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:56:32 +0200 Subject: [PATCH 57/86] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index da7e737c6..5d4d85493 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -142,7 +142,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; } - sleep(1); + sleep(10); } KOMODO_ON_DEMAND = 0; if ( 0 && deposits != 0 ) From 05ca2ffc177742137b1abbf2307fc7ddf59430dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 08:15:03 +0200 Subject: [PATCH 58/86] disable redeems --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a10dbb822..914a5a182 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -702,6 +702,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,(char *)"KMD"); + return(-1); // no redeems for now } else { From ad4559b1405440079e8d3e034d7a7546a8d2c0c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 08:24:48 +0200 Subject: [PATCH 59/86] Test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 914a5a182..d7bf08219 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -702,7 +702,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,(char *)"KMD"); - return(-1); // no redeems for now + if ( height >= 235300 ) + return(-1); // no redeems for now } else { From 72460f0d6b42094d039376bb0847fcf66f48313e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 13:37:30 +0200 Subject: [PATCH 60/86] Test --- src/miner.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5d4d85493..5073923aa 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -630,6 +630,12 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; + if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + { + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + sleep(10); + continue; + } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // @@ -686,12 +692,6 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt - { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); - sleep(10); - break; - } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; From 7f44a3a97a4032193f749ce028435887780af9ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 13:58:04 +0200 Subject: [PATCH 61/86] Test --- src/miner.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5073923aa..9318ff1a6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -630,11 +630,14 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; - if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + if ( ASSETCHAINS_SYMBOL[0] != 0 ) { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); - sleep(10); - continue; + if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + { + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + sleep(10); + continue; + } else printf("vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); From 93722bf74151cea5eba32aa48febd998fae8da97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:02:32 +0200 Subject: [PATCH 62/86] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9318ff1a6..15a878b21 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else printf("vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); From 6a235586d9627f3c7f97026d9e9ac1acbb0191d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:11:36 +0200 Subject: [PATCH 63/86] 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 d7bf08219..04c049159 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1216,7 +1216,7 @@ void komodo_passport_iteration() isrealtime = 1; RTmask |= (1LL << baseid); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); - } else if ( (time(NULL)-buf[2]) > 1800 ) + } else if ( 0 && (time(NULL)-buf[2]) > 1800 ) fprintf(stderr,"[%s]: %s not RT %u %u %d\n",ASSETCHAINS_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2])); } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); From d82233d9409098c21bafe9e479d72b7376a440a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:13:25 +0200 Subject: [PATCH 64/86] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 15a878b21..7265935d7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -145,7 +145,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) sleep(10); } KOMODO_ON_DEMAND = 0; - if ( 0 && deposits != 0 ) + if ( 1 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); } // -regtest only: allow overriding block.nVersion with From 8aed57832b5c3837ec354632b0e5345e3da3a953 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:23:43 +0200 Subject: [PATCH 65/86] 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 04c049159..77e9c696e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -503,7 +503,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { opcode = 'X'; - if ( komodo_paxtotal() == 0 ) + if ( 1 || komodo_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -514,7 +514,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE if ( pax->height > 236000 ) { - if ( pax->type == 'D' || (kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height) ) + if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) pax->validated = pax->komodoshis; else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 ) pax->validated = pax->ready = 0; From d19a9837c2c8300c59b8156e46a7fe6124475c71 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:27:01 +0200 Subject: [PATCH 66/86] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7265935d7..5140d3595 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 59 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) + if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } From c2070e57ff9d9e9c3b224baa714df1087d88d8f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 15:09:19 +0200 Subject: [PATCH 67/86] Revert "Merge branch 'master' into dev" This reverts commit c0addba809c63493eb87ab06bed9da7d7ae89452, reversing changes made to d19a9837c2c8300c59b8156e46a7fe6124475c71. --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index cfdaea121..9246d6838 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -170,7 +170,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in for (i=0; i<66; i++) printf("%d ",mids[i]); printf(" minerids from ht.%d\n",height); - if ( notaryid >= 0 || height > 225000 ) + if ( notaryid >= 0 || height > 225065 ) return error("CheckProofOfWork(): hash doesn't match nBits"); } } From 16cd9f2db34da324f388114a22f9705ca7f79cdd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 15:42:27 +0200 Subject: [PATCH 68/86] Revert to main --- src/komodo.h | 2 +- src/komodo_gateway.h | 87 ++++++++++++---------------------------- src/komodo_interest.h | 10 +---- src/main.cpp | 2 +- src/miner.cpp | 22 +++++----- src/pow.cpp | 2 +- src/wallet/rpcwallet.cpp | 16 +------- 7 files changed, 41 insertions(+), 100 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index bdb692d09..94fb1347c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -446,7 +446,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) + if ( *isratificationp == 0 ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 77e9c696e..cf7d01201 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -17,7 +17,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { @@ -28,11 +28,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - //netliability = (sp->deposited - sp->withdrawn) - sp->shorted; - maxval = sp->approved; - if ( sp->withdrawn > maxval ) - maxval = sp->withdrawn; - netliability = (sp->issued - maxval) - sp->shorted; + netliability = (sp->deposited - sp->withdrawn) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); @@ -60,22 +56,12 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) return(pax); } -struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t vout) +struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; - if ( strictflag != 0 ) - { - if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) + for (i=0; ikomodoshis : pax->fiatoshis; srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis; @@ -357,11 +343,8 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; - char str[65],coinaddr[64]; bits256 tmp; - bitcoin_address(coinaddr,60,pax->rmd160,20); - memcpy(&tmp,&pax->txid,sizeof(tmp)); - if ( 0 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); + if ( 0 && pax->type == 'A' ) + printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) @@ -442,7 +425,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic if ( pax2->approved != 0 ) pax->approved = pax2->approved; } - else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'x')) != 0 ) + else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'X')) != 0 ) pax->approved = pax->height; //printf("pending_withdraw: pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated); if ( pax->marked == 0 && pax->approved == 0 && pax->validated != 0 ) //strcmp((char *)"KMD",pax->symbol) == 0 && @@ -477,7 +460,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic 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[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask; - if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 || ASSETCHAINS_SYMBOL[0] == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 ) return(0); struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); sp = komodo_stateptr(symbol,dest); @@ -503,7 +486,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { opcode = 'X'; - if ( 1 || komodo_paxtotal() == 0 ) + if ( komodo_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -533,7 +516,6 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); - pax->marked = pax->fiatoshis; continue; } /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); @@ -589,7 +571,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 1 ) + if ( numvouts++ >= 64 ) break; } if ( numvouts > 1 ) @@ -599,12 +581,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; - if ( 0 && pax != 0 ) - { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[32-1-i]); - printf(" <- data[%d]\n",len); - } + for (i=0; ivout.resize(numvouts+1); txNew->vout[numvouts].nValue = 0; @@ -651,7 +630,7 @@ void komodo_bannedset(uint256 *array,int32_t max) int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[15]; - int32_t i,j,k,n,ht,retval,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t maxval,total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); memset(baseids,0xff,sizeof(baseids)); @@ -702,8 +681,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,(char *)"KMD"); - if ( height >= 235300 ) - return(-1); // no redeems for now } else { @@ -731,23 +708,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) - { - matched++; // this node isnt running this assetchain, leaves validation to others - continue; - } - maxval = approved; - if ( redeemed > maxval ) - maxval = redeemed; - if ( (opcode == 'I' && available < pax->fiatoshis) || (opcode == 'X' && pax->komodoshis > issued-maxval) ) + if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) { printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } - if ( (opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue) ) + if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) ) { if ( pax->marked != 0 && height >= 80820 ) { @@ -818,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -852,9 +821,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( 1 && strcmp("EUR",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { - printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); @@ -906,11 +875,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - { - char str[65]; bits256 tmp; - memcpy(&tmp,&pax2->txid,sizeof(tmp)); - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d (%s)\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); - } + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); } } } @@ -956,7 +921,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; pax->height = pax2->height; pax->otherheight = height; - if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); } } @@ -1094,7 +1059,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("n.%d from opreturns\n",n); //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'x' ) + else if ( opretbuf[0] == 'X' ) { tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) @@ -1216,7 +1181,7 @@ void komodo_passport_iteration() isrealtime = 1; RTmask |= (1LL << baseid); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); - } else if ( 0 && (time(NULL)-buf[2]) > 1800 ) + } else if ( (time(NULL)-buf[2]) > 1800 ) fprintf(stderr,"[%s]: %s not RT %u %u %d\n",ASSETCHAINS_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2])); } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..7779eba6e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -73,8 +73,6 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { if ( (minutes= (tiptime - nLockTime) / 60) >= 60 ) { - if ( minutes > 365 * 24 * 60 ) - minutes = 365 * 24 * 60; denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! @@ -104,9 +102,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 < 300000 ) - interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + interest = (numerator / denominator); } else { @@ -117,9 +113,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) - interest = (numerator / denominator) / COIN; - else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + interest = (numerator / denominator) / 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); } diff --git a/src/main.cpp b/src/main.cpp index c674a3766..455e6f78e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3293,7 +3293,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn CScript expect = CScript() << nHeight; if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { - return state.DoS(100, error("%s: block height mismatch in coinbase ht.%d", __func__,nHeight), REJECT_INVALID, "bad-cb-height"); + return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); } } diff --git a/src/miner.cpp b/src/miner.cpp index 5140d3595..e9ab80741 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 59 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) + if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } @@ -145,7 +145,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) sleep(10); } KOMODO_ON_DEMAND = 0; - if ( 1 && deposits != 0 ) + if ( 0 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); } // -regtest only: allow overriding block.nVersion with @@ -383,7 +383,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; - //fprintf(stderr,"set coinbase height to %d\n",nHeight); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; @@ -630,15 +629,6 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt - { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); - sleep(10); - continue; - } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); - } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // @@ -695,6 +685,12 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + { + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + sleep(10); + break; + } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; diff --git a/src/pow.cpp b/src/pow.cpp index 9246d6838..cfdaea121 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -170,7 +170,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in for (i=0; i<66; i++) printf("%d ",mids[i]); printf(" minerids from ht.%d\n",height); - if ( notaryid >= 0 || height > 225065 ) + if ( notaryid >= 0 || height > 225000 ) return error("CheckProofOfWork(): hash doesn't match nBits"); } } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cc5aa132e..e68ccc9be 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,8 +496,6 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); -uint64_t komodo_maxallowed(int32_t baseid); -int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { @@ -629,23 +627,12 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; - baseid = komodo_baseid((char *)base.c_str()); if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) - errflag = 1; - minval = approved; - if ( withdrawn < minval ) - minval = withdrawn; - netliability = (deposited - minval); - maxallowed = komodo_maxallowed(baseid); - if ( fiatoshis > (maxallowed - netliability) ) - errflag = 1; - if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); - komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); @@ -672,7 +659,6 @@ Value paxwithdraw(const Array& params, bool fHelp) return(0); if (!EnsureWalletIsAvailable(fHelp)) return 0; - throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) From 16c7bf6bd741463d43caf1f6affc5a49468458a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:02:28 +0200 Subject: [PATCH 69/86] Merge back most changes --- src/komodo.h | 2 +- src/komodo_gateway.h | 10 +++++++--- src/komodo_interest.h | 10 ++++++++-- src/miner.cpp | 17 +++++++++++++---- src/wallet/rpcwallet.cpp | 18 +++++++++++++++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 94fb1347c..bdb692d09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -446,7 +446,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 ) + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cf7d01201..0441ce22c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -17,7 +17,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { @@ -28,7 +28,10 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + maxval = sp->approved; + if ( sp->withdrawn > maxval ) + maxval = sp->withdrawn; + netliability = (sp->issued - maxval) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); @@ -528,6 +531,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { if ( strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) printf("pax->symbol.%s != %s or null pax->validated %.8f ready.%d ht.(%d %d)\n",pax->symbol,symbol,dstr(pax->validated),pax->ready,kmdsp->CURRENT_HEIGHT,pax->height); + pax->marked = pax->fiatoshis; continue; } if ( pax->ready == 0 ) @@ -571,7 +575,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 64 ) + if ( numvouts++ >= 1 ) break; } if ( numvouts > 1 ) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 7779eba6e..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -73,6 +73,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { if ( (minutes= (tiptime - nLockTime) / 60) >= 60 ) { + if ( minutes > 365 * 24 * 60 ) + minutes = 365 * 24 * 60; denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! @@ -102,7 +104,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 < 300000 ) + interest = (numerator / denominator); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -113,7 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - interest = (numerator / denominator) / COIN; + if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + 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); } diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..40226176d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 59 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) + if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } @@ -629,6 +629,15 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) + { + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + sleep(10); + continue; + } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // @@ -685,12 +694,12 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + /*if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt { fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); break; - } + }*/ // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e68ccc9be..53a2bfd03 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,6 +496,8 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); +uint64_t komodo_maxallowed(int32_t baseid); +int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { @@ -627,11 +629,24 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; + baseid = komodo_baseid((char *)base.c_str()); if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + errflag = 1; + else + { + minval = approved; + if ( withdrawn < minval ) + minval = withdrawn; + netliability = (deposited - minval); + maxallowed = komodo_maxallowed(baseid); + if ( fiatoshis > (maxallowed - netliability) ) + errflag = 1; + } + if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); @@ -659,6 +674,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return(0); if (!EnsureWalletIsAvailable(fHelp)) return 0; + throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) From 74d67d42d170884a0bf3b7d08f96347929b1a863 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:25:20 +0200 Subject: [PATCH 70/86] Prevent 'A' and 'X' events --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0441ce22c..f8c20435c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -489,7 +489,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { opcode = 'X'; - if ( komodo_paxtotal() == 0 ) + if ( 1 || komodo_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -684,6 +684,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above // printf("%02x",script[i]); //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; + if ( height >= 235300 ) + return(-1); strcpy(symbol,(char *)"KMD"); } else @@ -984,7 +986,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } // else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); // need to allocate pax } - else if ( tokomodo != 0 && opretbuf[0] == 'A' ) + else if ( height < 236000 && tokomodo != 0 && opretbuf[0] == 'A' ) { tokomodo = 1; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -1063,7 +1065,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("n.%d from opreturns\n",n); //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'X' ) + else if ( height < 236000 && opretbuf[0] == 'X' ) { tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) From b24e2baaaa682e3bb4bad05c8e51ea4a069f8a22 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:31:21 +0200 Subject: [PATCH 71/86] Touch --- src/assetchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 9b0ddaaa6..23e00f362 100755 --- a/src/assetchains +++ b/src/assetchains @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash set -x source pubkey.txt echo $pubkey From fbe307fd32cdd14b16f5b7394f1a545be7a07def Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:38:03 +0200 Subject: [PATCH 72/86] Test --- src/wallet/rpcwallet.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53a2bfd03..5b69e20a7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -629,7 +629,7 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t netliability,maxval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; @@ -638,13 +638,18 @@ Value paxdeposit(const Array& params, bool fHelp) errflag = 1; else { - minval = approved; - if ( withdrawn < minval ) - minval = withdrawn; - netliability = (deposited - minval); + maxval = approved; + if ( withdrawn > maxval ) + maxval = withdrawn; + if ( redeemed > maxval ) + maxval = redeemed; + netliability = (deposited - maxval); maxallowed = komodo_maxallowed(baseid); - if ( fiatoshis > (maxallowed - netliability) ) + if ( fiatoshis > netliability ) + { + fprintf(stderr,"fiatoshis %llu > (max %llu - net %llu)\n",(long long)fiatoshis,(long long)maxallowed,(long long)netliability); errflag = 1; + } } if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); From 83c54f308f427ce23318ac40c153e2fae95be757 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:40:37 +0200 Subject: [PATCH 73/86] Test --- src/komodo_gateway.h | 2 +- src/miner.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f8c20435c..6b2c7548f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -941,7 +941,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("opreturn none issued?\n"); } } - else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 ) + else if ( height < 236000 && opretbuf[0] == 'W' )//&& opretlen >= 38 ) { if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 40226176d..181b24a87 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -633,7 +633,9 @@ void static BitcoinMiner(CWallet *pwallet) { if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + static uint32_t counter; + if ( counter++ < 10 ) + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); From d6cc943d622f2279fac56e1521db599f4a1579b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:42:47 +0200 Subject: [PATCH 74/86] Test --- src/komodo_gateway.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6b2c7548f..c59a4ba67 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -887,8 +887,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,ASSETCHAINS_SYMBOL) == 0) ) //seed != 0 && - printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed); + else + { + if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) + pax->marked = checktoshis; + if ( kmdheight > 238000 && (kmdheight > 214700 || strcmp(base,ASSETCHAINS_SYMBOL) == 0) ) //seed != 0 && + printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed); + } } //else printf("paxdeposit height.%d vs kmdheight.%d\n",height,kmdheight); } } From 5e9f4470d1e7016f1cee91153121022ff4cdd8d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:43:16 +0200 Subject: [PATCH 75/86] 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 c59a4ba67..0c00efba1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -268,7 +268,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che if ( seed == 0 && checkvalue != 0 ) { ratio = ((value << 6) / checkvalue); - if ( ratio >= 63 && ratio <= 65 ) + if ( ratio >= 62 && ratio <= 66 ) return(0); else { From 1ecb85418874b322a2fb7e8d87289525a57f044d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:49:18 +0200 Subject: [PATCH 76/86] Test --- src/miner.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 181b24a87..27e892fe1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -403,7 +403,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) else if ( komodo_is_issuer() != 0 ) { komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); - //if ( txNew.vout.size() > 1 ) + if ( txNew.vout.size() > 1 ) fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; @@ -612,7 +612,7 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5b69e20a7..2fd394f22 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -634,7 +634,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; baseid = komodo_baseid((char *)base.c_str()); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) errflag = 1; else { From 8577cb287043a13f55bfa22dfc38870a1518c426 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:53:06 +0200 Subject: [PATCH 77/86] Test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2fd394f22..46e0532c9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -634,7 +634,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; baseid = komodo_baseid((char *)base.c_str()); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) + /*if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) errflag = 1; else { @@ -652,7 +652,7 @@ Value paxdeposit(const Array& params, bool fHelp) } } if ( errflag != 0 ) - throw runtime_error("paxdeposit not enough available inventory"); + throw runtime_error("paxdeposit not enough available inventory");*/ komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From 7bf32ee2daefea890ac7a7144c6f51e398d10aeb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:05:15 +0200 Subject: [PATCH 78/86] Test --- src/komodo_gateway.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0c00efba1..858b7eeaf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -663,10 +663,24 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); if ( n <= 2 || script[0] != 0x6a ) { + int64_t val,prevtotal = 0; int32_t overflow = 0; total = 0; for (i=1; i COIN/10 ) + { + if ( (val= block.vtx[0].vout[i].nValue) < 0 || val >= MAX_MONEY ) + { + overflow = 1; + break; + } + total += val; + if ( total < prevtotal || (val != 0 && total == prevtotal) ) + { + overflow = 1; + break; + } + prevtotal = total; + } + if ( overflow != 0 || total > COIN/10 ) { //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) From 82fd1939be4e8a6002dd9f5a6b39e7b1770082e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:09:33 +0200 Subject: [PATCH 79/86] Test --- src/wallet/rpcwallet.cpp | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 46e0532c9..e931e96a4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,8 +496,6 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); -uint64_t komodo_maxallowed(int32_t baseid); -int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { @@ -629,30 +627,12 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t netliability,maxval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; - baseid = komodo_baseid((char *)base.c_str()); - /*if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) - errflag = 1; - else - { - maxval = approved; - if ( withdrawn > maxval ) - maxval = withdrawn; - if ( redeemed > maxval ) - maxval = redeemed; - netliability = (deposited - maxval); - maxallowed = komodo_maxallowed(baseid); - if ( fiatoshis > netliability ) - { - fprintf(stderr,"fiatoshis %llu > (max %llu - net %llu)\n",(long long)fiatoshis,(long long)maxallowed,(long long)netliability); - errflag = 1; - } - } - if ( errflag != 0 ) - throw runtime_error("paxdeposit not enough available inventory");*/ + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + throw runtime_error("paxdeposit not enough available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From ea73ef003b0569dff2e37cb092ec3c22f6aeb9d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:16:45 +0200 Subject: [PATCH 80/86] Test --- src/komodo_gateway.h | 2 +- src/wallet/rpcwallet.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 858b7eeaf..8f0b0dd0d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -35,7 +35,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); - //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } // else printf("pax_fiatstatus illegal base.%s\n",base); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e931e96a4..b829d3474 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -632,7 +632,10 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + { + fprintf("available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); throw runtime_error("paxdeposit not enough available inventory"); + } komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From f79f75befe0e9df6092255430773bb0502b77156 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:18:45 +0200 Subject: [PATCH 81/86] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b829d3474..819b5a8ec 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -633,7 +633,7 @@ Value paxdeposit(const Array& params, bool fHelp) height = chainActive.Tip()->nHeight; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) { - fprintf("available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); + fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); throw runtime_error("paxdeposit not enough available inventory"); } komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); From 68025c1c832b02815b686edccc50553571dd5e4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:03:33 +0200 Subject: [PATCH 82/86] Remove print --- 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 8f0b0dd0d..bd7538d9b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -35,7 +35,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); - printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + //printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } // else printf("pax_fiatstatus illegal base.%s\n",base); From 8f3aa743bd8fbe0989bb69f54b2903b61ea6c3f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:14:40 +0200 Subject: [PATCH 83/86] Touch --- src/komodo.h | 1 + src/komodo_gateway.h | 1 + src/komodo_interest.h | 1 + src/main.cpp | 1 - src/miner.cpp | 1 + 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index bdb692d09..33e4ea544 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -446,6 +446,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bd7538d9b..af3633a95 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -688,6 +688,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } return(0); } + //fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE); if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 || return(0); diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..fa19319ef 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -99,6 +99,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } + //if ( nValue == 4000000000000LL ) // printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( exception == 0 ) diff --git a/src/main.cpp b/src/main.cpp index 455e6f78e..1a92bcd91 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3258,7 +3258,6 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); } - // Reject block.nVersion < 4 blocks if (block.nVersion < 4) return state.Invalid(error("%s : rejected nVersion<4 block", __func__), diff --git a/src/miner.cpp b/src/miner.cpp index 27e892fe1..33fe68327 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -406,6 +406,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( txNew.vout.size() > 1 ) fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } + pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; // Randomise nonce From 72475d0bf602a18174a3b35aff8014048379d129 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:15:37 +0200 Subject: [PATCH 84/86] 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 fa19319ef..89e689b07 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -99,7 +99,6 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } - //if ( nValue == 4000000000000LL ) // printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( exception == 0 ) @@ -122,6 +121,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); } } From d1ceb5c250049de928576e6d957271a002cb0173 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:27:02 +0200 Subject: [PATCH 85/86] 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 551a31ec4..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,7 +104,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 < 30000 ) + if ( txheight < 300000 ) interest = (numerator / denominator); else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } From 4dabad2cf6dc6693291be463dee311937a5df827 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:50:49 +0200 Subject: [PATCH 86/86] 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 af3633a95..8cf3c880c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -880,7 +880,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } - } + } // if ( didstats != 0 ) pax->didstats = 1; if ( (pax2= komodo_paxfind(txid,vout,'I')) != 0 )