From 085f28a067c2108afbef2bca462debc9750adbe6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 3 Sep 2021 11:44:22 -0400 Subject: [PATCH 1/6] Hush does not have elections --- src/hush.h | 2 +- src/hush_defs.h | 2 +- src/hush_globals.h | 2 +- src/hush_notary.h | 28 ++++++++++++++-------------- src/miner.cpp | 2 +- src/pow.cpp | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/hush.h b/src/hush.h index 1570499c9..b25dcfcb4 100644 --- a/src/hush.h +++ b/src/hush.h @@ -944,7 +944,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) { memset(&txhash,0,sizeof(txhash)); hush_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); - printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); + printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+HUSH_DPOW_GAP/2)/HUSH_DPOW_GAP)+1)*HUSH_DPOW_GAP,height); } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } } diff --git a/src/hush_defs.h b/src/hush_defs.h index e51255dd8..190dae86c 100644 --- a/src/hush_defs.h +++ b/src/hush_defs.h @@ -23,7 +23,7 @@ #define HUSH_EARLYTXID_HEIGHT 100 #define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MAX_ERAS 7 -#define KOMODO_ELECTION_GAP 2000 +#define HUSH_DPOW_GAP 2000 #define ROUNDROBIN_DELAY 61 #define HUSH_SMART_CHAIN_MAXLEN 65 #define HUSH_LIMITED_NETWORKSIZE 4 diff --git a/src/hush_globals.h b/src/hush_globals.h index 2f3a5eba1..c298d8c15 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -34,7 +34,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts); pthread_mutex_t hush_mutex; -#define KOMODO_ELECTION_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100) +#define HUSH_DPOW_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100) #define HUSH_SMART_CHAIN_MAXLEN 65 struct pax_transaction *PAX; diff --git a/src/hush_notary.h b/src/hush_notary.h index a9280a923..610407df3 100644 --- a/src/hush_notary.h +++ b/src/hush_notary.h @@ -143,17 +143,17 @@ void hush_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) static int32_t hwmheight; int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N; if ( Pubkeys == 0 ) - Pubkeys = (struct knotaries_entry *)calloc(1 + (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys)); + Pubkeys = (struct knotaries_entry *)calloc(1 + (HUSH_MAXBLOCKS / HUSH_DPOW_GAP),sizeof(*Pubkeys)); memset(&N,0,sizeof(N)); if ( origheight > 0 ) { - height = (origheight + KOMODO_ELECTION_GAP/2); - height /= KOMODO_ELECTION_GAP; - height = ((height + 1) * KOMODO_ELECTION_GAP); - htind = (height / KOMODO_ELECTION_GAP); - if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; - //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,SMART_CHAIN_SYMBOL); + height = (origheight + HUSH_DPOW_GAP/2); + height /= HUSH_DPOW_GAP; + height = ((height + 1) * HUSH_DPOW_GAP); + htind = (height / HUSH_DPOW_GAP); + if ( htind >= HUSH_MAXBLOCKS / HUSH_DPOW_GAP ) + htind = (HUSH_MAXBLOCKS / HUSH_DPOW_GAP) - 1; + //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+HUSH_DPOW_GAP/2)/HUSH_DPOW_GAP)+1)*HUSH_DPOW_GAP,hwmheight,SMART_CHAIN_SYMBOL); } else htind = 0; pthread_mutex_lock(&hush_mutex); for (k=0; k hwmheight ) @@ -207,9 +207,9 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui return(-1); if ( Pubkeys == 0 ) hush_init(0); - htind = height / KOMODO_ELECTION_GAP; - if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP ) - htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; + htind = height / HUSH_DPOW_GAP; + if ( htind >= HUSH_MAXBLOCKS / HUSH_DPOW_GAP ) + htind = (HUSH_MAXBLOCKS / HUSH_DPOW_GAP) - 1; pthread_mutex_lock(&hush_mutex); HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); pthread_mutex_unlock(&hush_mutex); diff --git a/src/miner.cpp b/src/miner.cpp index 7e5e0361c..2f4b7495e 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1183,7 +1183,7 @@ void static BitcoinMiner() if ( SMART_CHAIN_SYMBOL[0] == 0 && notaryid >= 0 ) { j = 65; - if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 || Mining_height > 1000000 ) + if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % HUSH_DPOW_GAP) > 64 || (Mining_height % HUSH_DPOW_GAP) == 0 || Mining_height > 1000000 ) { int32_t dispflag = 0; if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) diff --git a/src/pow.cpp b/src/pow.cpp index e42af6720..143ee71c0 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -677,7 +677,7 @@ bool hush_checkopret(CBlock *pblock, CScript &merkleroot); CScript hush_makeopret(CBlock *pblock, bool fNew); extern int32_t HUSH_CHOSEN_ONE; extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN]; -#define KOMODO_ELECTION_GAP 2000 +#define HUSH_DPOW_GAP 2000 int32_t hush_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height); int32_t HUSH_LOADINGBLOCKS = 1; From 9e643ba7e96d6b256e10f9ba7349c49afa350275 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 3 Sep 2021 11:55:46 -0400 Subject: [PATCH 2/6] Remove unused code --- src/hush_pax.h | 173 +------------------------------------------------ 1 file changed, 1 insertion(+), 172 deletions(-) diff --git a/src/hush_pax.h b/src/hush_pax.h index eca3cc917..242e4d0fe 100644 --- a/src/hush_pax.h +++ b/src/hush_pax.h @@ -195,45 +195,6 @@ double PAX_BTCUSD(int32_t height,uint32_t btcusd) return(BTCUSD); } -int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double *KMDBTCp,double *BTCUSDp,double *CNYUSDp,uint32_t *pvals) -{ - uint32_t kmdbtc,btcusd,cnyusd; int32_t i,n,nonz,len = 0; - if ( data[0] == 'P' && data[5] == 35 ) - data++; - len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp); - len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n); - if ( n != 35 ) - { - printf("dpow_readprices illegal n.%d\n",n); - return(-1); - } - len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000 - len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000 - len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd); - *KMDBTCp = ((double)kmdbtc / (1000000000. * 1000.)); - *BTCUSDp = PAX_BTCUSD(height,btcusd); - *CNYUSDp = ((double)cnyusd / 1000000000.); - for (i=nonz=0; i= 35 ) - { - for (nonz=i=0; i<32; i++) - { - if ( pvals[i] != 0 ) - nonz++; - //printf("%u ",pvals[i]); - } - if ( nonz == 32 ) - { - kmdbtc = pvals[i++]; - btcusd = pvals[i++]; - cnyusd = pvals[i++]; - KMDBTC = ((double)kmdbtc / (1000000000. * 1000.)); - BTCUSD = PAX_BTCUSD(height,btcusd); - CNYUSD = ((double)cnyusd / 1000000000.); - portable_mutex_lock(&hush_mutex); - PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36); - PVALS[36 * NUM_PRICES] = height; - memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35); - NUM_PRICES++; - portable_mutex_unlock(&hush_mutex); - if ( 0 ) - printf("OP_RETURN.%d HUSH %.8f BTC %.6f CNY %.6f NUM_PRICES.%d (%llu %llu %llu)\n",height,KMDBTC,BTCUSD,CNYUSD,NUM_PRICES,(long long)kmdbtc,(long long)btcusd,(long long)cnyusd); - } - } } uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) @@ -360,80 +294,6 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) return(sum); } -uint64_t komodo_paxcalc(int32_t height,uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume,uint64_t refkmdbtc,uint64_t refbtcusd) -{ - uint32_t pvalb,pvalr; double BTCUSD; uint64_t price,kmdbtc,btcusd,usdvol,baseusd,usdkmd,baserel,ranked[32]; - if ( basevolume > HUSH_PAXMAX ) - { - printf("paxcalc overflow %.8f\n",dstr(basevolume)); - return(0); - } - if ( (pvalb= pvals[baseid]) != 0 ) - { - if ( relid == MAX_CURRENCIES ) - { - if ( height < 236000 ) - { - if ( kmdbtc == 0 ) - kmdbtc = pvals[MAX_CURRENCIES]; - if ( btcusd == 0 ) - btcusd = pvals[MAX_CURRENCIES + 1]; - } - else - { - if ( (kmdbtc= pvals[MAX_CURRENCIES]) == 0 ) - kmdbtc = refkmdbtc; - if ( (btcusd= pvals[MAX_CURRENCIES + 1]) == 0 ) - btcusd = refbtcusd; - } - if ( kmdbtc < 25000000 ) - kmdbtc = 25000000; - if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) - { - baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]); - usdvol = komodo_paxvol(basevolume,baseusd); - usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; - if ( height >= 236000-10 ) - { - BTCUSD = PAX_BTCUSD(height,btcusd); - if ( height < BTCFACTOR_HEIGHT || (height < 500000 && BTCUSD > 20000) ) - usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000; - else usdkmd = ((uint64_t)kmdbtc * btcusd) / 10000000; - ///if ( height >= BTCFACTOR_HEIGHT && BTCUSD >= 43 ) - // usdkmd = ((uint64_t)kmdbtc * btcusd) / 10000000; - //else usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000; - price = ((uint64_t)10000000000 * MINDENOMS[USD] / MINDENOMS[baseid]) / komodo_paxvol(usdvol,usdkmd); - //fprintf(stderr,"ht.%d %.3f kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",height,BTCUSD,(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); - //fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)),(long long)price); - //fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); - } else price = (MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); - return(price); - } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); - } - else if ( baseid == relid ) - { - if ( baseid != MAX_CURRENCIES ) - { - pax_rank(ranked,pvals); - //printf("%s M1 percentage %.8f\n",CURRENCIES[baseid],dstr(10 * ranked[baseid])); - return(10 * ranked[baseid]); // scaled percentage of M1 total - } else return(basevolume); - } - else if ( (pvalr= pvals[relid]) != 0 ) - { - baserel = ((uint64_t)pvalb * 1000000000) / pvalr; - //printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); - if ( MINDENOMS[baseid] > MINDENOMS[relid] ) - basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]); - else if ( MINDENOMS[baseid] < MINDENOMS[relid] ) - basevolume *= (MINDENOMS[relid] / MINDENOMS[baseid]); - return(komodo_paxvol(basevolume,baserel)); - } - else printf("null pval for %s\n",CURRENCIES[relid]); - } else printf("null pval for %s\n",CURRENCIES[baseid]); - return(0); -} - uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume) { return 0; @@ -451,40 +311,9 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen) { - double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero; - numpvals = dpow_readprices(height,pricefeed,×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals); - memset(&zero,0,sizeof(zero)); - hush_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0,zero,0); - if ( 0 ) - { - int32_t i; - for (i=0; i KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); - if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) - { - PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); - bitcoin_address(destaddr,HUSH_PUBTYPE,pubkey33,33); - } - return(komodoshis); + return 0; } From ae9b87740d53fcc14e590dc6e51b2382fe5e2f44 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 3 Sep 2021 12:05:20 -0400 Subject: [PATCH 3/6] Remove broken links --- src/cc/dapps/zmigrate.c | 4 ++-- src/test-hush/test_eval_notarization.cpp | 8 -------- src/wallet/test/wallet_tests.cpp | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 0e9d08112..fd9e381d5 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -1044,8 +1044,8 @@ int32_t itemvalid(char *refcoin,int64_t *refundedp,int64_t *waitingp,struct clai *refundedp = *waitingp = 0; if ( item->refundvalue < 0 ) return(-1); - // change "kmd" -> %s, tolowerstr(refcoin) - sprintf(url,"https://kmd.explorer.dexstats.info/insight-api-komodo/addr/%s",item->destaddr); + + sprintf(url,"https://explorer.hush.is/api/addr/%s",item->destaddr); if ( (retstr= send_curl(url,"/tmp/itemvalid")) != 0 ) { if ( (curljson= cJSON_Parse(retstr)) != 0 ) diff --git a/src/test-hush/test_eval_notarization.cpp b/src/test-hush/test_eval_notarization.cpp index c0c1c6751..d42327718 100644 --- a/src/test-hush/test_eval_notarization.cpp +++ b/src/test-hush/test_eval_notarization.cpp @@ -3,7 +3,6 @@ // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html #include #include - #include "cc/betprotocol.h" #include "cc/eval.h" #include "base58.h" @@ -14,16 +13,12 @@ #include "primitives/transaction.h" #include "script/interpreter.h" #include "script/serverchecker.h" - #include "testutils.h" - extern int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); - namespace TestEvalNotarization { - class EvalMock : public Eval { public: @@ -86,7 +81,6 @@ namespace TestEvalNotarization { } - // https://kmd.explorer.supernet.org/tx/5b8055d37cff745a404d1ae45e21ffdba62da7b28ed6533c67468d7379b20bae // inputs have been dropped static auto rawNotaryTx = "01000000000290460100000000002321020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9ac0000000000000000506a4c4dae8e0f3e6e5de498a072f5967f3c418c4faba5d56ac8ce17f472d029ef3000008f2e0100424f545300050ba773f0bc31da5839fc7cb9bd7b87f3b765ca608e5cf66785a466659b28880500000000000000"; CTransaction notaryTx; @@ -201,6 +195,4 @@ TEST(TestEvalNotarization, testInvalidNotarizationInputNotCheckSig) ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data)); } - - } /* namespace TestEvalNotarization */ diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 529449ba1..3831aaed4 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests) BOOST_CHECK( wallet.SelectCoinsMinConf(1 * CENT, 1, 1, vCoins, setCoinsRet, nValueRet,0)); BOOST_CHECK_EQUAL(nValueRet, 1 * CENT); // we should get the exact amount - // run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf) + // run the 'mtgox' test // they tried to consolidate 10 50k coins into one 500k coin, and ended up with 50k in change empty_wallet(); for (int i = 0; i < 20; i++) From 3d4123ee88551b1db02c579ccf5f0576f45078cc Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 3 Sep 2021 12:35:59 -0400 Subject: [PATCH 4/6] Cleanup --- src/cc/CC_made_easy.md | 4 +-- src/cc/dapps/dappinc.h | 4 +-- src/cc/dapps/zmigrate.c | 69 +++++++++++++--------------------------- src/hush_curve25519.h | 6 ++-- src/hush_defs.h | 2 +- src/hush_gateway.h | 2 +- src/hush_globals.h | 2 +- src/hush_kv.h | 34 ++++++++++---------- src/hush_structs.h | 2 +- src/rpc/blockchain.cpp | 2 +- src/wallet/rpcwallet.cpp | 28 ++++++++-------- 11 files changed, 65 insertions(+), 90 deletions(-) diff --git a/src/cc/CC_made_easy.md b/src/cc/CC_made_easy.md index daf7cbedd..48ccde25a 100644 --- a/src/cc/CC_made_easy.md +++ b/src/cc/CC_made_easy.md @@ -17,7 +17,7 @@ How to write utxo based CryptoConditions contracts for HUSH chains by jl777 -This is not the only smart contracts methodology that is possible to build on top of OP_CHECKCRYPTOCONDITION, just the first one. All the credit for getting OP_CHECKCRYPTOCONDITION working in the Komodo codebase goes to @libscott. I am just hooking into the code that he made and tried to make it just a little easier to make new contracts. +This is not the only smart contracts methodology that is possible to build on top of OP_CHECKCRYPTOCONDITION, just the first one. All the credit for getting OP_CHECKCRYPTOCONDITION working in the Hush codebase goes to @libscott. I am just hooking into the code that he made and tried to make it just a little easier to make new contracts. There is probably some fancy marketing name to use, but for now, I will just call it "CC contract" for short, knowing that it is not 100% technically accurate as the CryptoConditions aspect is not really the main attribute. However, the HUSH contracts were built to make the CryptoConditions codebase that was integrated into it to be more accessible. @@ -677,7 +677,7 @@ This codebase and tools in between the GUI and the rpc level will be a very good ########## Conclusion -I hope this document has helped you understand what a Komodo utxo based CC contract is and how it is different from the other smart contracts. If you are now able to dive into the cc directory and start making your own CC contract, then I am very happy! +I hope this document has helped you understand what a Hush utxo based CC contract is and how it is different from the other smart contracts. If you are now able to dive into the cc directory and start making your own CC contract, then I am very happy! gateways CC diff --git a/src/cc/dapps/dappinc.h b/src/cc/dapps/dappinc.h index c89658e72..f81db7dd2 100644 --- a/src/cc/dapps/dappinc.h +++ b/src/cc/dapps/dappinc.h @@ -384,7 +384,7 @@ cJSON *hushdex_cli(char *clistr,char **retstrp,char *method,char *arg0,char *arg return(retjson); } -bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson) +bits256 hushbroadcast(char *refcoin,char *acname,cJSON *hexjson) { char *hexstr,*retstr,str[65]; cJSON *retjson; bits256 txid; memset(txid.bytes,0,sizeof(txid)); @@ -439,7 +439,7 @@ bits256 tokentransfer(char *refcoin,char *acname,char *tokenid,char *destpub,int sprintf(numstr,"%llu",(long long)units); if ( (retjson= get_hushcli(refcoin,&retstr,acname,"tokentransfer",tokenid,destpub,numstr,"","","","")) != 0 ) { - txid = komodobroadcast(refcoin,acname,retjson); + txid = hushbroadcast(refcoin,acname,retjson); fprintf(stderr,"tokentransfer returned (%s)\n",jprint(retjson,0)); free_json(retjson); } diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index fd9e381d5..e8b547c6b 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -316,7 +316,7 @@ cJSON *get_urljson(char *url,char *fname) char *REFCOIN_CLI; -cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3) +cJSON *get_hushcli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3) { long fsize; cJSON *retjson = 0; char cmdstr[32768],*jsonstr,fname[256]; sprintf(fname,"/tmp/zmigrate.%s",method); @@ -346,37 +346,12 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char return(retjson); } -bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson) -{ - char *hexstr,*retstr,str[65]; cJSON *retjson; bits256 txid; - memset(txid.bytes,0,sizeof(txid)); - if ( (hexstr= jstr(hexjson,"hex")) != 0 ) - { - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","")) != 0 ) - { - //fprintf(stderr,"broadcast.(%s)\n",jprint(retjson,0)); - free_json(retjson); - } - else if ( retstr != 0 ) - { - if ( strlen(retstr) >= 64 ) - { - retstr[64] = 0; - decode_hex(txid.bytes,32,retstr); - } - fprintf(stderr,"broadcast %s txid.(%s)\n",strlen(acname)>0?acname:refcoin,bits256_str(str,txid)); - free(retstr); - } - } - return(txid); -} - bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis) { char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid; memset(txid.bytes,0,sizeof(txid)); sprintf(numstr,"%.8f",(double)satoshis/SATOSHIDEN); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"","")) != 0 ) { fprintf(stderr,"unexpected sendrawtransaction json.(%s)\n",jprint(retjson,0)); free_json(retjson); @@ -397,7 +372,7 @@ bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis int32_t get_coinheight(char *refcoin,char *acname) { cJSON *retjson; char *retstr; int32_t height=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 ) { height = jint(retjson,"blocks"); free_json(retjson); @@ -415,7 +390,7 @@ bits256 get_coinblockhash(char *refcoin,char *acname,int32_t height) cJSON *retjson; char *retstr,heightstr[32]; bits256 hash; memset(hash.bytes,0,sizeof(hash)); sprintf(heightstr,"%d",height); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 ) { fprintf(stderr,"unexpected blockhash json.(%s)\n",jprint(retjson,0)); free_json(retjson); @@ -436,7 +411,7 @@ bits256 get_coinmerkleroot(char *refcoin,char *acname,bits256 blockhash) { cJSON *retjson; char *retstr,str[65]; bits256 merkleroot; memset(merkleroot.bytes,0,sizeof(merkleroot)); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 ) { merkleroot = jbits256(retjson,"merkleroot"); //fprintf(stderr,"got merkleroot.(%s)\n",bits256_str(str,merkleroot)); @@ -474,7 +449,7 @@ int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *m cJSON *get_rawmempool(char *refcoin,char *acname) { cJSON *retjson; char *retstr; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 ) { //printf("mempool.(%s)\n",jprint(retjson,0)); return(retjson); @@ -493,7 +468,7 @@ cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) if ( refcoin[0] != 0 && strcmp(refcoin,"HUSH3") != 0 ) printf("warning: assumes %s has addressindex enabled\n",refcoin); sprintf(jsonbuf,"{\\\"addresses\\\":[\\\"%s\\\"]}",coinaddr); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 ) { //printf("addressutxos.(%s)\n",jprint(retjson,0)); return(retjson); @@ -509,7 +484,7 @@ cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid) { cJSON *retjson; char *retstr,str[65]; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 ) { return(retjson); } @@ -524,7 +499,7 @@ cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid) cJSON *get_listunspent(char *refcoin,char *acname) { cJSON *retjson; char *retstr,str[65]; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"listunspent","","","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"listunspent","","","","")) != 0 ) { return(retjson); } @@ -539,7 +514,7 @@ cJSON *get_listunspent(char *refcoin,char *acname) cJSON *z_listunspent(char *refcoin,char *acname) { cJSON *retjson; char *retstr,str[65]; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_listunspent","","","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_listunspent","","","","")) != 0 ) { return(retjson); } @@ -554,7 +529,7 @@ cJSON *z_listunspent(char *refcoin,char *acname) cJSON *z_listoperationids(char *refcoin,char *acname) { cJSON *retjson; char *retstr,str[65]; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_listoperationids","","","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_listoperationids","","","","")) != 0 ) { return(retjson); } @@ -570,7 +545,7 @@ cJSON *z_getoperationstatus(char *refcoin,char *acname,char *opid) { cJSON *retjson; char *retstr,str[65],params[512]; sprintf(params,"'[\"%s\"]'",opid); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getoperationstatus",params,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getoperationstatus",params,"","","")) != 0 ) { //printf("got status (%s)\n",jprint(retjson,0)); return(retjson); @@ -587,7 +562,7 @@ cJSON *z_getoperationresult(char *refcoin,char *acname,char *opid) { cJSON *retjson; char *retstr,str[65],params[512]; sprintf(params,"'[\"%s\"]'",opid); - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getoperationresult",params,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getoperationresult",params,"","","")) != 0 ) { return(retjson); } @@ -602,7 +577,7 @@ cJSON *z_getoperationresult(char *refcoin,char *acname,char *opid) int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* compare) { cJSON *retjson; char *retstr; int32_t res=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 ) { if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1; free_json(retjson); @@ -618,7 +593,7 @@ int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* comp int32_t z_validateaddress(char *refcoin,char *acname,char *depositaddr, char *compare) { cJSON *retjson; char *retstr; int32_t res=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_validateaddress",depositaddr,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_validateaddress",depositaddr,"","","")) != 0 ) { if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1; @@ -635,7 +610,7 @@ int32_t z_validateaddress(char *refcoin,char *acname,char *depositaddr, char *co int64_t z_getbalance(char *refcoin,char *acname,char *coinaddr) { cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getbalance",coinaddr,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getbalance",coinaddr,"","","")) != 0 ) { fprintf(stderr,"z_getbalance.(%s) %s returned json!\n",refcoin,acname); free_json(retjson); @@ -656,7 +631,7 @@ int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr) { cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; privkey[0] = 0; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","")) != 0 ) { fprintf(stderr,"z_exportkey.(%s) %s returned json!\n",refcoin,acname); free_json(retjson); @@ -675,7 +650,7 @@ int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr) int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) { cJSON *retjson; char *retstr; int64_t amount=0; int32_t retval = -1; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getnewaddress","","","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"getnewaddress","","","","")) != 0 ) { fprintf(stderr,"getnewaddress.(%s) %s returned json!\n",refcoin,acname); free_json(retjson); @@ -692,7 +667,7 @@ int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr) { cJSON *retjson; char *retstr; int64_t amount=0; int32_t retval = -1; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","")) != 0 ) { fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname); free_json(retjson); @@ -764,7 +739,7 @@ int64_t find_sprout_amount(char *coinstr,char *zcaddr) void importaddress(char *refcoin,char *acname,char *depositaddr) { cJSON *retjson; char *retstr; - if ( (retjson= get_komodocli(refcoin,&retstr,acname,"importaddress",depositaddr,"","true","")) != 0 ) + if ( (retjson= get_hushcli(refcoin,&retstr,acname,"importaddress",depositaddr,"","true","")) != 0 ) { printf("importaddress.(%s)\n",jprint(retjson,0)); free_json(retjson); @@ -782,7 +757,7 @@ int32_t z_sendmany(char *opidstr,char *coinstr,char *acname,char *srcaddr,char * sprintf(params,"'[{\"address\":\"%s\",\"amount\":%.8f}]'",destaddr,dstr(amount)); sprintf(addr,"\"%s\"",srcaddr); printf("z_sendmany from.(%s) -> %s\n",srcaddr,params); - if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 ) + if ( (retjson= get_hushcli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","")) != 0 ) { printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0)); free_json(retjson); @@ -801,7 +776,7 @@ int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr { cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; sprintf(addr,"[\\\"ANY_SPROUT\\\"]"); - if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) + if ( (retjson= get_hushcli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","")) != 0 ) { if ( (opstr= jstr(retjson,"opid")) != 0 ) strcpy(opidstr,opstr); diff --git a/src/hush_curve25519.h b/src/hush_curve25519.h index 5094719e7..688d9cc9b 100644 --- a/src/hush_curve25519.h +++ b/src/hush_curve25519.h @@ -955,14 +955,14 @@ uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_ return(addr); } -uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase) +uint256 hush_kvprivkey(uint256 *pubkeyp,char *passphrase) { uint256 privkey; conv_NXTpassword((uint8_t *)&privkey,(uint8_t *)pubkeyp,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); return(privkey); } -uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 _privkey) +uint256 hush_kvsig(uint8_t *buf,int32_t len,uint256 _privkey) { bits256 sig,hash,otherpub,checksig,pubkey,privkey; uint256 usig; memcpy(&privkey,&_privkey,sizeof(privkey)); @@ -984,7 +984,7 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 _privkey) return(usig); } -int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig) +int32_t hush_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig) { bits256 hash,checksig,pubkey; static uint256 zeroes; memcpy(&pubkey,&_pubkey,sizeof(pubkey)); diff --git a/src/hush_defs.h b/src/hush_defs.h index 190dae86c..8fa2024ee 100644 --- a/src/hush_defs.h +++ b/src/hush_defs.h @@ -539,7 +539,7 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); int32_t hush_minerids(uint8_t *minerids,int32_t height,int32_t width); -int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); +int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); uint32_t hush_blocktime(uint256 hash); int32_t hush_longestchain(); diff --git a/src/hush_gateway.h b/src/hush_gateway.h index c85755d63..ddaf366a2 100644 --- a/src/hush_gateway.h +++ b/src/hush_gateway.h @@ -846,7 +846,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 tokomodo = (hush_is_issuer() == 0); if ( opretbuf[0] == 'K' && opretlen != 40 ) { - komodo_kvupdate(opretbuf,opretlen,value); + hush_kvupdate(opretbuf,opretlen,value); return("kv"); } else if ( SMART_CHAIN_SYMBOL[0] == 0 && HUSH_PAX == 0 ) diff --git a/src/hush_globals.h b/src/hush_globals.h index c298d8c15..12f4f7f65 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -103,7 +103,7 @@ int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL; CScript HUSH_EARLYTXID_SCRIPTPUB; int32_t ASSETCHAINS_EARLYTXIDCONTRACT; std::map mapHeightEvalActivate; -struct komodo_kv *HUSH_KV; +struct hush_kv *HUSH_KV; pthread_mutex_t HUSH_KV_mutex,HUSH_CC_mutex; #define MAX_CURRENCIES 32 diff --git a/src/hush_kv.h b/src/hush_kv.h index b64522f36..9149c9ec4 100644 --- a/src/hush_kv.h +++ b/src/hush_kv.h @@ -21,7 +21,7 @@ #include "hush_defs.h" -int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize) +int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize) { if ( refvalue == 0 && value == 0 ) return(0); @@ -32,7 +32,7 @@ int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint else return(memcmp(refvalue,value,valuesize)); } -int32_t komodo_kvnumdays(uint32_t flags) +int32_t hush_kvnumdays(uint32_t flags) { int32_t numdays; if ( (numdays= ((flags>>2)&0x3ff)+1) > 365 ) @@ -40,25 +40,25 @@ int32_t komodo_kvnumdays(uint32_t flags) return(numdays); } -int32_t komodo_kvduration(uint32_t flags) +int32_t hush_kvduration(uint32_t flags) { - return(komodo_kvnumdays(flags) * HUSH_KVDURATION); + return(hush_kvnumdays(flags) * HUSH_KVDURATION); } -uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen) +uint64_t hush_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen) { int32_t numdays,k; uint64_t fee; if ( (k= keylen) > 32 ) k = 32; - numdays = komodo_kvnumdays(flags); + numdays = hush_kvnumdays(flags); if ( (fee= (numdays*(opretlen * opretlen / k))) < 100000 ) fee = 100000; return(fee); } -int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen) +int32_t hush_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen) { - struct komodo_kv *ptr; int32_t duration,retval = -1; + struct hush_kv *ptr; int32_t duration,retval = -1; *heightp = -1; *flagsp = 0; memset(pubkeyp,0,sizeof(*pubkeyp)); @@ -66,7 +66,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp HASH_FIND(hh,HUSH_KV,key,keylen,ptr); if ( ptr != 0 ) { - duration = komodo_kvduration(ptr->flags); + duration = hush_kvduration(ptr->flags); //fprintf(stderr,"duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize); if ( current_height > (ptr->height + duration) ) { @@ -100,10 +100,10 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp return(retval); } -void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) +void hush_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) { static uint256 zeroes; - uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; + uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct hush_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV return; dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); @@ -115,11 +115,11 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) { static uint32_t counter; if ( ++counter < 1 ) - fprintf(stderr,"komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen); + fprintf(stderr,"hush_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen); return; } valueptr = &key[keylen]; - fee = komodo_kvfee(flags,opretlen,keylen); + fee = hush_kvfee(flags,opretlen,keylen); //fprintf(stderr,"fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]); if ( value >= fee ) { @@ -139,13 +139,13 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) ((uint8_t *)&sig)[i] = opretbuf[coresize+sizeof(uint256)+i]; } memcpy(keyvalue,key,keylen); - if ( (refvaluesize= komodo_kvsearch((uint256 *)&refpubkey,height,&flags,&kvheight,&keyvalue[keylen],key,keylen)) >= 0 ) + if ( (refvaluesize= hush_kvsearch((uint256 *)&refpubkey,height,&flags,&kvheight,&keyvalue[keylen],key,keylen)) >= 0 ) { if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) { - if ( komodo_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 ) + if ( hush_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 ) { - //fprintf(stderr,"komodo_kvsigverify error [%d]\n",coresize-13); + //fprintf(stderr,"hush_kvsigverify error [%d]\n",coresize-13); return; } } @@ -169,7 +169,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) } else if ( ptr == 0 ) { - ptr = (struct komodo_kv *)calloc(1,sizeof(*ptr)); + ptr = (struct hush_kv *)calloc(1,sizeof(*ptr)); ptr->key = (uint8_t *)calloc(1,keylen); ptr->keylen = keylen; memcpy(ptr->key,key,keylen); diff --git a/src/hush_structs.h b/src/hush_structs.h index fde010d7b..3ba56fefc 100644 --- a/src/hush_structs.h +++ b/src/hush_structs.h @@ -56,7 +56,7 @@ union _bits320 { uint8_t bytes[40]; uint16_t ushorts[20]; uint32_t uints[10]; uint64_t ulongs[5]; uint64_t txid; }; typedef union _bits320 bits320; -struct komodo_kv { UT_hash_handle hh; bits256 pubkey; uint8_t *key,*value; int32_t height; uint32_t flags; uint16_t keylen,valuesize; }; +struct hush_kv { UT_hash_handle hh; bits256 pubkey; uint8_t *key,*value; int32_t height; uint32_t flags; uint16_t keylen,valuesize; }; struct hush_event_notarized { uint256 blockhash,desttxid,MoM; int32_t notarizedheight,MoMdepth; char dest[16]; }; struct hush_event_pubkeys { uint8_t num; uint8_t pubkeys[64][33]; }; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 82f73036c..bf38cc5e2 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -893,7 +893,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk) if ( keylen < sizeof(key) ) { memcpy(key,params[0].get_str().c_str(),keylen); - if ( (valuesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&flags,&height,value,key,keylen)) >= 0 ) + if ( (valuesize= hush_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&flags,&height,value,key,keylen)) >= 0 ) { std::string val; char *valuestr; val.resize(valuesize); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 38546dcea..f7cc48433 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -616,19 +616,19 @@ int32_t hush_is_issuer(); int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t hush_isrealtime(int32_t *kmdheightp); 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 komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); -int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize); -uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen); -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); +int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); +int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize); +uint64_t hush_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen); +uint256 hush_kvsig(uint8_t *buf,int32_t len,uint256 privkey); +int32_t hush_kvduration(uint32_t flags); +uint256 hush_kvprivkey(uint256 *pubkeyp,char *passphrase); +int32_t hush_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) { static uint256 zeroes; CWalletTx wtx; UniValue ret(UniValue::VOBJ); - uint8_t keyvalue[DRAGON_MAXSCRIPTSIZE*8],opretbuf[DRAGON_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig; + uint8_t keyvalue[DRAGON_MAXSCRIPTSIZE*8],opretbuf[DRAGON_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct hush_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig; if (fHelp || params.size() < 3 ) throw runtime_error( "kvupdate key \"value\" days passphrase\n" @@ -670,7 +670,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) //printf("flags.%d (%s) n.%d\n",flags,params[2].get_str().c_str(),n); } else flags = 0; if ( n >= 4 ) - privkey = komodo_kvprivkey(&pubkey,(char *)(n >= 4 ? params[3].get_str().c_str() : "password")); + privkey = hush_kvprivkey(&pubkey,(char *)(n >= 4 ? params[3].get_str().c_str() : "password")); haveprivkey = 1; flags |= 1; /*for (i=0; i<32; i++) @@ -690,7 +690,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) valuesize = (int32_t)strlen(params[1].get_str().c_str()); } memcpy(keyvalue,key,keylen); - if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 ) + if ( (refvaluesize= hush_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 ) { if ( (tmpflags & HUSH_KVPROTECTED) != 0 ) { @@ -702,8 +702,8 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) } if ( keylen+refvaluesize <= sizeof(keyvalue) ) { - sig = komodo_kvsig(keyvalue,keylen+refvaluesize,privkey); - if ( komodo_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 ) + sig = hush_kvsig(keyvalue,keylen+refvaluesize,privkey); + if ( hush_kvsigverify(keyvalue,keylen+refvaluesize,refpubkey,sig) < 0 ) { ret.push_back(Pair("error",(char *)"error verifying sig, passphrase is probably wrong")); printf("VERIFY ERROR\n"); @@ -719,7 +719,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) ret.push_back(Pair("owner",refpubkey.GetHex())); ret.push_back(Pair("height", (int64_t)height)); - duration = komodo_kvduration(flags); //((flags >> 2) + 1) * HUSH_KVDURATION; + duration = hush_kvduration(flags); //((flags >> 2) + 1) * HUSH_KVDURATION; ret.push_back(Pair("expiration", (int64_t)(height+duration))); ret.push_back(Pair("flags",(int64_t)flags)); ret.push_back(Pair("key",params[0].get_str())); @@ -755,7 +755,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) // printf("%02x",opretbuf[i]); //printf(" opretbuf keylen.%d valuesize.%d height.%d (%02x %02x %02x)\n",*(uint16_t *)&keyvalue[0],*(uint16_t *)&keyvalue[2],*(uint32_t *)&keyvalue[4],keyvalue[8],keyvalue[9],keyvalue[10]); EnsureWalletIsUnlocked(); - fee = komodo_kvfee(flags,opretlen,keylen); + fee = hush_kvfee(flags,opretlen,keylen); ret.push_back(Pair("fee",(double)fee/COIN)); CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); if (!destaddress.IsValid()) From f19c70bfa65b91d41d4ea1da1778d08bada73232 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 9 Sep 2021 12:36:59 -0400 Subject: [PATCH 5/6] Add missing newline to rescan log line --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index bab6fa5c1..4217e3825 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2738,7 +2738,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) // Build initial witness caches for blocks involving one of our addresses if (involvesMe) { - LogPrintf("%s: block has one of our transactions, building witness cache", __func__); + LogPrintf("%s: block has one of our transactions, building witness cache\n", __func__); BuildWitnessCache(pindex, true); } From 844d8163bddb785e1c072c65e0a36cda02a9c09f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 16 Sep 2021 10:15:02 -0400 Subject: [PATCH 6/6] Add more default nodes --- src/hush_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hush_utils.h b/src/hush_utils.h index 6c19523e4..71f46d0d4 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -1810,7 +1810,7 @@ void hush_args(char *argv0) vector HUSH_nodes= {"node1.hush.is","node2.hush.is","node3.hush.is", "node4.hush.is","node5.hush.is","node6.hush.is", - "node7.hush.is","node8.hush.is"}; + "node7.hush.is","node8.hush.is","node1.hush.land", "node2.hush.land"}; vector more_nodes = mapMultiArgs["-addnode"]; if (more_nodes.size() > 0) { fprintf(stderr,"%s: Adding %lu more nodes via custom -addnode arguments\n", __func__, more_nodes.size() );