diff --git a/OSlibs/win/mingw.h b/OSlibs/win/mingw.h index 2c35aa78c..5690d6f91 100755 --- a/OSlibs/win/mingw.h +++ b/OSlibs/win/mingw.h @@ -5,8 +5,8 @@ #include #define _USE_W32_SOCKETS 1 -#define WIN32_LEAN_AND_MEAN -#include +//#define WIN32_LEAN_AND_MEAN +//#include #include #define PTW32_STATIC_LIB #include "pthread.h" diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 4d15df781..be78a05e2 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -584,7 +584,12 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi *completedp = 0; if ( signedtxidp != 0 ) memset(signedtxidp,0,sizeof(*signedtxidp)); - bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); + + if (strcmp(coin->chain->symbol, "HUSH") == 0) + bitcoin_address_ex(coin->chain->symbol, changeaddr, 0x1c, coin->chain->pubtype, myinfo->persistent_pubkey33, 33); + else + bitcoin_address(changeaddr, coin->chain->pubtype, myinfo->persistent_pubkey33, 33); + txfee = (coin->txfee + duplicates*coin->txfee/10); if ( strcmp(coin->symbol,"GAME") == 0 ) printf("GAME txfee %.8f\n",dstr(txfee)); diff --git a/crypto777/OS_nonportable.c b/crypto777/OS_nonportable.c index ca3f90695..d46fb2b1b 100755 --- a/crypto777/OS_nonportable.c +++ b/crypto777/OS_nonportable.c @@ -26,10 +26,10 @@ * not from the mingw header, so we need to include the windows header * if we are compiling in windows 64bit */ -//#if defined(_M_X64) -//#define WIN32_LEAN_AND_MEAN -//#include -//#endif +#if defined(_M_X64) +#define WIN32_LEAN_AND_MEAN +#include +#endif #include "OS_portable.h" diff --git a/iguana/coins/hush_7776 b/iguana/coins/hush_7776 new file mode 100755 index 000000000..2181d3cdf --- /dev/null +++ b/iguana/coins/hush_7776 @@ -0,0 +1,3 @@ +#!/bin/bash + +curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"hush.conf\",\"path\":\"${HOME#"/"}/.hush\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":8,\"endpend\":8,\"services\":129,\"maxpeers\":32,\"newcoin\":\"HUSH\",\"name\":\"Hush\",\"hasheaders\":0,\"useaddmultisig\":0,\"netmagic\":\"24e92764\",\"p2p\":8888,\"rpc\":8822,\"pubval\":184,\"p2shval\":189,\"wifval\":128,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"0003a67bc26fe564b75daf11186d360652eb435a35ba3d9d3e7e5d5f8e62dc17\",\"protover\":170002,\"genesisblock\":\"04000000000000000000000000000000000000000000000000000000000000000000000077e16b66afd4fe560cf16abf7bba8e661ba574b6389675a2366f19ecf939058300000000000000000000000000000000000000000000000000000000000000008be02d58ffff071f0000000000000000000000000000000000000000000000000000000000000512fd40050045f33727869d999e1d90de13eec508bb9eedf7c623ae0926922a749df12927967ce41f0363365e536a149ced0a25ce7258bcf4d36c9d69ea830ecafaac0a20576ee2405fa6e1ed91e5e5f3e72add8dae92175e05bb114100c654b90a0ea0e35e3ecee480d073b90c0d252963519492dce839f14bd3e54b017972fe05c30f61d73437d2ccb8a8dac1f33ba27c9d8a81bc02911a0f04f0af099ba8cc9114bd0de60fcd699673bc7a05d06baf544c5daa773991ff85c269c17f3a58618818f91d6ee9e4c393cd8d03428a2cc9be4243384caf197c77029b8c6c9387ab7a4966faac8efb13f7f9e259040fbbc1295551ad10084dba5ef0b732da7c90bd06026152acc74aad871aa3c2e46666d262129f07e128a0ea322b532851d649d2e0443954dafaaddfa6af28a70c786b94d904cb8ad3fda5364d9d5cccd1ce802f801dad25644a7dcab1c44191f24cdd8997f19c3602bc6e936aca34413a3270f837d94b211c5ad7533a070fe7b5651db5bf5d2aa13d503af5eef912fdcb5704a1bfc4c095d9b3da8f62261ed0dea089bf5b12db067ce1b4bee14f6515a180dedfeac9d794649da2b203e2a975db5c961daf788239ec722a7afbc63b8cb30c11e0ce1943f71981c3437530a4c0fcec0f9e7c6c1f5e85373ff132ddccb202916665c5559ddbcff20c743f15e2b7748a11d5de283f8cf190cb0c47feec730f6bde470ae172b9fdfc07e96362dd9238833876ff14b8028e811af7610b08842aac55f79f066e5df160104bd571f44fb16d7476e2626458c2992f6291781915d5ee927594c8a5966ba379ace56cf30a9c5f79e70fa6347e664796eea268d74862522ac275bf94ef2e406034ff121345351b92245ba834c752249d3506a111407bbd10e31b1167f9c3702fc54176e18ad8ca6211c892d4ba4598b3d834c2aa06392e21b4ff3d6d510132989a9828086bbbd1e03debe3fd44e34550c54103df97e25709e086efefc27013b9fc08bc777f96630876dfcba638d5f1f2fe10935d5fb950388ca485044535350e83267d0b5c75e5f570cd849d8567daecb90b011f72bccde31e8c6b13a630b82dc1fe68f7ef261013e2a91ed033c11fa201f4a32f7a05a58cbbce0a13f175c5e08a3ced164686a26277be7bbac9fed583276d12d67a12649b4f46e466bdc57bed60c3f8bd6e05f73d54686d36e97a6461cbda430abf9ec8df6699160822abbc947463338741c961fcaab0dbbd2a2b92084d0b372242e6103aa54479fc7b350f35c23eb1f3161352ec3e1ba178fd82147ff42ba02164405fe74606b6c525883dddc5fd8431bb49c889571c155974af19291e49f55fbfe7c823f526f77edc9bba773f9e370baf614175515eef3f7be1750ee2a3c915a0f8e3ea31bdd397668ebef7f0cf75ddecec887df2baf771e1013d2d4795c39ba8449c18d559eab9c2718f39531c0b632437506c9061ee9995e11173da85948b5b82e02e54977eb64db682af9a1993bbd16fcab3d55be7493a38ab9012d6c3f5834f3740fcc725aa70e0570b46073ad43c7b0a582af576f8e2afd4c6c75d933b0d8955a49c2b522d84a9fc9c75bbf2b5363667e5b42b420eddfa537ac5d15d7a4ea9c5dfd063cb03e81da219163fe7135d61db9d19f891e5784613a59df7ffefa2017f8d6edfde9ce19babd5963aae94ad7bfd52e736323c73f9765c9026f1b0a560dbdcc71563586f4ced072c0903bdf6362fe4f4c0cea265ad48a6639bccaa08b5593a9f0eeac5cfcc14ca6d2e7449ec029598b4061793745ba3e53dc289c16ee84c7c2575824e7a5e372d8c8e1bf0a2dfa90283a67bd305c684b39af1d109004522301344a9c346a0e227c45749aa24b11623211155bad78e1a137376738662a78619dceaf0c79f0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff071f0104455a6461736865353430656366313030303031383839383336633764343931613266343465366263363037366435396535653331373235353934366237316265336663353136ffffffff010000000000000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000\",\"debug\":0}" diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index c531c27a7..f4aeed7c6 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -265,6 +265,7 @@ void dpow_statemachinestart(void *ptr) void **ptrs = ptr; struct supernet_info *myinfo; struct dpow_info *dp; struct dpow_checkpoint checkpoint; int32_t i,j,ht,extralen,destprevvout0,srcprevvout0,src_or_dest,numratified=0,kmdheight,myind = -1; uint8_t extras[10000],pubkeys[64][33]; cJSON *ratified=0,*item; struct iguana_info *src,*dest; char *jsonstr,*handle,*hexstr,str[65],str2[65],srcaddr[64],destaddr[64]; bits256 zero,MoM,merkleroot,srchash,destprevtxid0,srcprevtxid0; struct dpow_block *bp; struct dpow_entry *ep = 0; uint32_t MoMdepth,duration,minsigs,starttime,srctime; + char *destlockunspent,*srclockunspent,*destunlockunspent,*srcunlockunspent; memset(&zero,0,sizeof(zero)); MoM = zero; srcprevtxid0 = destprevtxid0 = zero; @@ -384,8 +385,13 @@ void dpow_statemachinestart(void *ptr) return; } dp->ratifying += bp->isratify; - bitcoin_address(srcaddr,src->chain->pubtype,dp->minerkey33,33); - bitcoin_address(destaddr,dest->chain->pubtype,dp->minerkey33,33); + + if (strcmp(src->chain->symbol, "HUSH") == 0) + bitcoin_address_ex(src->chain->symbol, srcaddr, 0x1c, src->chain->pubtype, dp->minerkey33, 33); + else + bitcoin_address(srcaddr, src->chain->pubtype, dp->minerkey33, 33); + + bitcoin_address(destaddr,dest->chain->pubtype,dp->minerkey33,33); if ( kmdheight >= 0 ) { ht = kmdheight;///strcmp("KMD",src->symbol) == 0 ? kmdheight : bp->height; @@ -501,6 +507,29 @@ void dpow_statemachinestart(void *ptr) bp->desttxid = bp->notaries[myind].src.prev_hash; dpow_signedtxgen(myinfo,dp,src,bp,bp->myind,1LL<myind,bp->myind,DPOW_SIGCHANNEL,0,0); }*/ + + if (strcmp("KMD",dest->symbol) == 0 ) + { + // lock the dest utxo if destination coin is KMD. + destlockunspent = dpow_lockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + if (strncmp(destlockunspent,"true", 4) == 0 ) + printf(">>>> LOCKED %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + else + printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + free(destlockunspent); + } + + if ( strcmp("BTC",dest->symbol) == 0 ) + { + // lock the src coin selected utxo if the source coin is KMD. + srclockunspent = dpow_lockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); + if (strncmp(srclockunspent,"true", 4) == 0 ) + printf(">>>> LOCKED %s UTXO.(%s) vout.(%d\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); + else + printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); + free(srclockunspent); + } + bp->recvmask |= (1LL << myind); bp->notaries[myind].othermask |= (1LL << myind); dp->checkpoint = checkpoint; @@ -594,8 +623,26 @@ void dpow_statemachinestart(void *ptr) printf("[%d] END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",Numallocated,bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest); dp->lastrecvmask = bp->recvmask; dp->ratifying -= bp->isratify; + + // unlock the dest utxo on KMD. + if (strcmp("KMD",dest->symbol) == 0 ) + { + destunlockunspent = dpow_unlockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + if (strncmp(destunlockunspent,"true", 4) == 0 ) + printf(">>>>UNLOCKED %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + free(destunlockunspent); + } + + // unlock the src selected utxo on KMD, as those are the only ones we LOCK, and CHIPS does not like the lockunspent call. + if ( strcmp("BTC",dest->symbol) == 0 ) + { + srcunlockunspent = dpow_unlockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); + if (strncmp(srcunlockunspent,"true", 4) == 0 ) + printf(">>>>UNLOCKED %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); + free(srcunlockunspent); + } + // dp->blocks[bp->height] = 0; bp->state = 0xffffffff; free(ptr); } - diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index edcd687d3..447de82bc 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -236,7 +236,7 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c } else { - + } if ( bits256_nonz(blockhash) != 0 ) { @@ -370,6 +370,36 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin, return(blockhash); } +char *dpow_lockunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,char *txid,int32_t vout) +{ + char buf[128],*retstr; + if ( coin->FULLNODE < 0 ) + { + sprintf(buf,"false, [{\"txid\":\"%s\",\"vout\":%d}]", txid, vout); + if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"lockunspent",buf)) != 0 ) + { + //printf("RESULT.(%s)\n",retstr); + return(retstr); + } else printf("%s null retstr from (%s)n",coin->symbol,buf); + } + return(0); +} + +char *dpow_unlockunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,char *txid,int32_t vout) +{ + char buf[128],*retstr; + if ( coin->FULLNODE < 0 ) + { + sprintf(buf,"true, [{\"txid\":\"%s\",\"vout\":%d}]", txid, vout); + if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"lockunspent",buf)) != 0 ) + { + //printf("RESULT.(%s)\n",retstr); + return(retstr); + } else printf("%s null retstr from (%s)n",coin->symbol,buf); + } + return(0); +} + cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash) { char buf[128],str[65],*retstr=0; cJSON *json = 0; @@ -399,7 +429,7 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2 int32_t dpow_is015(char *symbol) { - if ( strcmp("CHIPS",symbol) == 0 || strcmp("GAME",symbol) == 0 ) //strcmp("BTC",symbol) == 0 || + if ( strcmp("CHIPS",symbol) == 0 || strcmp("GAME",symbol) == 0 ) //strcmp("BTC",symbol) == 0 || return(1); else return(0); } @@ -1254,7 +1284,7 @@ void dpow_issuer_voutupdate(struct dpow_info *dp,char *symbol,int32_t isspecial, printf(" opret[%c] fiatoshis %.8f vs check %.8f\n",script[0],dstr(fiatoshis),dstr(checktoshis)); if ( seed == 0 || fiatoshis < checktoshis ) { - + }*/ } } @@ -1424,4 +1454,3 @@ int32_t dpow_issuer_iteration(struct dpow_info *dp,struct iguana_info *coin,int3 //printf("[%s -> %s] %s ht.%d current.%d\n",dp->symbol,dp->dest,coin->symbol,height,currentheight); return(height); } - diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index dbb46e4f1..0b0ff0da7 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -321,7 +321,7 @@ struct iguana_info bits256 cachedmerkle,notarizedhash; int32_t cachedmerkleheight; }; -struct _LP_utxoinfo { bits256 txid; uint64_t value; int32_t vout,height; }; +struct _LP_utxoinfo { bits256 txid; uint64_t value; int32_t height; uint32_t vout:30,suppress:1,pad:1; }; struct LP_utxostats { uint32_t sessionid,lasttime,errors,swappending,spentflag,lastspentcheck,bestflag; }; diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index a58b4ae4a..76539117b 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -999,11 +999,13 @@ int32_t LP_vin_select(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t //return(abovei >= 0 && above < (below>>1) ? abovei : belowi); } -cJSON *LP_inputjson(bits256 txid,int32_t vout,char *spendscriptstr) +cJSON *LP_inputjson(bits256 txid,int32_t vout,char *spendscriptstr,int32_t suppress) { cJSON *sobj,*item = cJSON_CreateObject(); jaddbits256(item,"txid",txid); jaddnum(item,"vout",vout); + if ( suppress != 0 ) + jaddnum(item,"suppress",1); sobj = cJSON_CreateObject(); jaddstr(sobj,"hex",spendscriptstr); jadd(item,"scriptPubKey",sobj); @@ -1059,7 +1061,7 @@ int64_t LP_komodo_interest(bits256 txid,int64_t value) int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_t amount,struct vin_info *V,struct LP_address_utxo **utxos,int32_t numunspents,int32_t suppress_pubkeys,int32_t ignore_cltverr,bits256 privkey,cJSON *privkeys,cJSON *vins,uint8_t *script,int32_t scriptlen,bits256 utxotxid,int32_t utxovout,int32_t dustcombine) { - char wifstr[128],spendscriptstr[128],str[65]; int32_t i,j,maxiters,n,numpre,ind,abovei,belowi,maxmode=0; struct vin_info *vp; cJSON *txobj; struct LP_address_utxo *up,*min0,*min1,*preselected[3]; int64_t value,interest,interestsum,above,below,remains = amount,total = 0; + char wifstr[128],spendscriptstr[128],str[65]; int32_t i,j,maxiters,n,numpre,ind,abovei,belowi,maxmode=0; struct vin_info *vp; cJSON *txobj,*sobj; struct LP_address_utxo *up,*min0,*min1,*preselected[3]; int64_t value,interest,interestsum,above,below,remains = amount,total = 0; *totalp = 0; interestsum = 0; init_hexbytes_noT(spendscriptstr,script,scriptlen); @@ -1083,6 +1085,8 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_ { up->spendheight = 1; utxos[j] = 0; + if ( (sobj= jobj(txobj,"scriptPubKey")) != 0 && jstr(sobj,"hex") != 0 && strlen(jstr(sobj,"hex")) == 35*2 ) + up->U.suppress = 1; } else { @@ -1211,9 +1215,9 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_ vp->signers[0].privkey = privkey; jaddistr(privkeys,wifstr); bitcoin_pubkey33(ctx,vp->signers[0].pubkey,privkey); - vp->suppress_pubkeys = suppress_pubkeys; + vp->suppress_pubkeys = up->U.suppress; vp->ignore_cltverr = ignore_cltverr; - jaddi(vins,LP_inputjson(up->U.txid,up->U.vout,spendscriptstr)); + jaddi(vins,LP_inputjson(up->U.txid,up->U.vout,spendscriptstr,up->U.suppress)); LP_unavailableset(up->U.txid,up->U.vout,(uint32_t)time(NULL)+LP_RESERVETIME*2,G.LP_mypub25519); if ( remains <= 0 && i >= numpre-1 ) break; @@ -1447,6 +1451,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf return(0); } } + //printf("suppress.%d\n",V->suppress_pubkeys); if ( (rawtxbytes= bitcoin_json2hex(coin->symbol,coin->isPoS,&txid,txobj,V)) != 0 ) { } else printf("error making rawtx suppress.%d\n",suppress_pubkeys); @@ -1596,7 +1601,7 @@ char *LP_createblasttransaction(uint64_t *changep,int32_t *changeoutp,cJSON **tx scriptlen = bitcoin_standardspend(script,0,rmd160); init_hexbytes_noT(spendscriptstr,script,scriptlen); vins = cJSON_CreateArray(); - jaddi(vins,LP_inputjson(utxotxid,utxovout,spendscriptstr)); + jaddi(vins,LP_inputjson(utxotxid,utxovout,spendscriptstr,suppress_pubkeys)); jdelete(txobj,"vin"); jadd(txobj,"vin",jduplicate(vins)); *vinsp = vins; diff --git a/iguana/exchanges/LP_utxo.c b/iguana/exchanges/LP_utxo.c index 92f91e686..4b807865a 100644 --- a/iguana/exchanges/LP_utxo.c +++ b/iguana/exchanges/LP_utxo.c @@ -357,7 +357,7 @@ int32_t LP_address_minmax(int32_t iambob,uint64_t *medianp,uint64_t *minp,uint64 int32_t LP_address_utxo_ptrs(struct iguana_info *coin,int32_t iambob,struct LP_address_utxo **utxos,int32_t max,struct LP_address *ap,char *coinaddr) { - struct LP_address_utxo *up,*tmp; struct LP_transaction *tx; cJSON *txout; int32_t i,n = 0; + struct LP_address_utxo *up,*tmp; struct LP_transaction *tx; cJSON *txout,*sobj; int32_t i,n = 0; if ( strcmp(ap->coinaddr,coinaddr) != 0 ) printf("UNEXPECTED coinaddr mismatch (%s) != (%s)\n",ap->coinaddr,coinaddr); //portable_mutex_lock(&LP_utxomutex); @@ -370,6 +370,12 @@ int32_t LP_address_utxo_ptrs(struct iguana_info *coin,int32_t iambob,struct LP_a { if ( (txout= LP_gettxout(coin->symbol,coinaddr,up->U.txid,up->U.vout)) != 0 ) { + //printf("check sobj.hex %s\n",jprint(txout,0)); + if ( (sobj= jobj(txout,"scriptPubKey")) != 0 && jstr(sobj,"hex") != 0 && strlen(jstr(sobj,"hex")) == 35*2 ) + { + up->U.suppress = 1; + //printf("suppress %s\n",jprint(sobj,0)); + } if ( LP_value_extract(txout,0,up->U.txid) == 0 ) { //char str[65]; printf("LP_address_utxo_ptrs skip zero value %s/v%d\n",bits256_str(str,up->U.txid),up->U.vout); @@ -464,7 +470,7 @@ int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,str if ( spendheight > 0 ) // dont autocreate entries for spends we dont care about ap = LP_addressfind(coin,coinaddr); else ap = LP_address(coin,coinaddr); - //printf("%s add addr.%s ht.%d ap.%p\n",coin->symbol,coinaddr,height,ap); + //printf("skipflag.%d %s add addr.%s ht.%d ap.%p\n",skipsearchcoin->symbol,coinaddr,height,ap); if ( ap != 0 ) { flag = 0; @@ -500,7 +506,7 @@ int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,str { if ( (hexstr= jstr(sobj,"hex")) != 0 ) { - if ( strlen(hexstr) != 25*2 ) + if ( strlen(hexstr) != 25*2 && strlen(hexstr) != 35*2 ) { //printf("skip non-standard utxo.(%s)\n",hexstr); free_json(txobj); diff --git a/iguana/exchanges/autoprice b/iguana/exchanges/autoprice index 52fc68df0..68e45e893 100755 --- a/iguana/exchanges/autoprice +++ b/iguana/exchanges/autoprice @@ -39,7 +39,7 @@ sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"komodo\",\"b curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}" -curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":600}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}" +curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":486}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}" curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"HODL\",\"rel\":\"KMD\",\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}" diff --git a/iguana/exchanges/bitcoin.c b/iguana/exchanges/bitcoin.c index 62c0ed592..f7a5661fa 100755 --- a/iguana/exchanges/bitcoin.c +++ b/iguana/exchanges/bitcoin.c @@ -22,6 +22,51 @@ char *bitcoind_passthru(char *coinstr,char *serverport,char *userpass,char *meth return(bitcoind_RPC(0,coinstr,serverport,userpass,method,params,0)); } + +int32_t bitcoin_addr2rmd160_ex(char *symbol, uint8_t taddr, uint8_t *addrtypep, uint8_t rmd160[20], char *coinaddr) +{ + bits256 hash; uint8_t *buf, _buf[26], data5[128], rmd21[21]; char prefixaddr[64], hrp[64]; int32_t len, len5, offset; + *addrtypep = 0; + memset(rmd160, 0, 20); + if (coinaddr == 0 || coinaddr[0] == 0) + return(0); + if (coinaddr[0] == '0' && coinaddr[1] == 'x' && is_hexstr(coinaddr + 2, 0) == 40) // for ETH + { + decode_hex(rmd160, 20, coinaddr + 2); // not rmd160 hash but hopefully close enough; + return(20); + } + + offset = 1 + (taddr != 0); + memset(rmd160, 0, 20); + *addrtypep = 0; + buf = _buf; + if ((len = bitcoin_base58decode(buf, coinaddr)) >= 4) + { + // validate with trailing hash, then remove hash + hash = bits256_doublesha256(0, buf, 20 + offset); + + *addrtypep = (taddr == 0) ? *buf : buf[1]; + memcpy(rmd160, buf + offset, 20); + if ((buf[20 + offset] & 0xff) == hash.bytes[31] && (buf[21 + offset] & 0xff) == hash.bytes[30] && (buf[22 + offset] & 0xff) == hash.bytes[29] && (buf[23 + offset] & 0xff) == hash.bytes[28]) + { + //printf("coinaddr.(%s) valid checksum addrtype.%02x\n",coinaddr,*addrtypep); + return(20); + } + else if ((strcmp(symbol, "GRS") == 0 || strcmp(symbol, "SMART") == 0) && (buf[20 + offset] & 0xff) == hash.bytes[0] && (buf[21 + offset] & 0xff) == hash.bytes[1] && (buf[22 + offset] & 0xff) == hash.bytes[2] && (buf[23 + offset] & 0xff) == hash.bytes[3]) + return(20); + else if (strcmp(symbol, "BTC") != 0 || *addrtypep == 0 || *addrtypep == 5) + { + int32_t i; + //if ( len > 20 ) + // hash = bits256_calcaddrhash(symbol,buf,len); + for (i = 0; iminerkey33,33,tmp); - bitcoin_address(srcaddr,src->chain->pubtype,dp->minerkey33,33); + + if (strcmp(src->chain->symbol, "HUSH") == 0) + bitcoin_address_ex(src->chain->symbol, srcaddr, 0x1c, src->chain->pubtype, dp->minerkey33, 33); + else + bitcoin_address(srcaddr, src->chain->pubtype, dp->minerkey33, 33); + if ( (retstr= dpow_validateaddress(myinfo,src,srcaddr)) != 0 ) { json = cJSON_Parse(retstr); diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 14df8eaac..3051c728e 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -522,7 +522,12 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS printf("illegal destination address.(%s)\n",changeaddr); return(0); } - bitcoin_addr2rmd160(&addrtype,rmd160,changeaddr); + + if (strcmp(coin->symbol, "HUSH") == 0) + bitcoin_addr2rmd160_ex(coin->symbol, 0x1c, &addrtype, rmd160, changeaddr); + else + bitcoin_addr2rmd160(&addrtype,rmd160,changeaddr); + spendlen = bitcoin_standardspend(spendscript,0,rmd160); bitcoin_txoutput(txobj,spendscript,spendlen,change); if ( opreturn != 0 ) diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index d633ff569..3c46ff1fb 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -321,7 +321,10 @@ cJSON *iguana_getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_i { HASH_ITER(hh,subset->waddr,waddr,tmp2) { - bitcoin_address(coinaddr,coin->chain->pubtype,waddr->rmd160,20); + if (strcmp(coin->chain->symbol, "HUSH") == 0) + bitcoin_address_ex(coin->chain->symbol, coinaddr, 0x1c, coin->chain->pubtype, waddr->rmd160, 20); + else + bitcoin_address(coinaddr, coin->chain->pubtype, waddr->rmd160, 20); printf("%s ",coinaddr); jaddistr(array,coinaddr); } @@ -329,12 +332,20 @@ cJSON *iguana_getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_i } else { - bitcoin_address(refaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); - HASH_ITER(hh,myinfo->wallet,subset,tmp) + if (strcmp(coin->chain->symbol, "HUSH") == 0) + bitcoin_address_ex(coin->chain->symbol, refaddr, 0x1c, coin->chain->pubtype, myinfo->persistent_pubkey33, 33); + else + bitcoin_address(refaddr, coin->chain->pubtype, myinfo->persistent_pubkey33, 33); + + HASH_ITER(hh,myinfo->wallet,subset,tmp) { HASH_ITER(hh,subset->waddr,waddr,tmp2) { - bitcoin_address(coinaddr,coin->chain->pubtype,waddr->rmd160,20); + if (strcmp(coin->chain->symbol, "HUSH") == 0) + bitcoin_address_ex(coin->chain->symbol, coinaddr, 0x1c, coin->chain->pubtype, waddr->rmd160, 20); + else + bitcoin_address(coinaddr, coin->chain->pubtype, waddr->rmd160, 20); + jaddistr(array,coinaddr); if ( strcmp(coinaddr,refaddr) == 0 ) refaddr[0] = 0; @@ -359,17 +370,36 @@ int32_t iguana_addressvalidate(struct iguana_info *coin,uint8_t *addrtypep,char char checkaddr[64]; uint8_t rmd160[20]; *addrtypep = 0; memset(rmd160,0,sizeof(rmd160)); - bitcoin_addr2rmd160(addrtypep,rmd160,address); + + if (strcmp(coin->symbol, "HUSH") == 0) + bitcoin_addr2rmd160_ex(coin->symbol, 0x1c, addrtypep, rmd160, address); + else + bitcoin_addr2rmd160(addrtypep,rmd160,address); + //int32_t i; for (i=0; i<20; i++) // printf("%02x",rmd160[i]); // 764692cd5473f62ffa8a93e55d876f567623de07 //printf(" rmd160 addrtype.%02x\n",*addrtypep); - if ( bitcoin_address(checkaddr,*addrtypep,rmd160,20) == checkaddr && strcmp(address,checkaddr) == 0 && (*addrtypep == coin->chain->pubtype || *addrtypep == coin->chain->p2shtype) ) - return(0); - else - { - //printf(" checkaddr.(%s) address.(%s) type.%02x vs (%02x %02x)\n",checkaddr,address,*addrtypep,coin->chain->pubtype,coin->chain->p2shtype); - return(-1); - } + + if (strcmp(coin->symbol, "HUSH") == 0) + { + if (bitcoin_address_ex(coin->symbol, checkaddr, 0x1c, *addrtypep, rmd160, 20) == checkaddr && strcmp(address, checkaddr) == 0 && (*addrtypep == coin->chain->pubtype || *addrtypep == coin->chain->p2shtype)) + return(0); + else + { + //printf(" checkaddr.(%s) address.(%s) type.%02x vs (%02x %02x)\n",checkaddr,address,*addrtypep,coin->chain->pubtype,coin->chain->p2shtype); + return(-1); + } + } + else + { + if (bitcoin_address(checkaddr, *addrtypep, rmd160, 20) == checkaddr && strcmp(address, checkaddr) == 0 && (*addrtypep == coin->chain->pubtype || *addrtypep == coin->chain->p2shtype)) + return(0); + else + { + //printf(" checkaddr.(%s) address.(%s) type.%02x vs (%02x %02x)\n",checkaddr,address,*addrtypep,coin->chain->pubtype,coin->chain->p2shtype); + return(-1); + } + } } cJSON *iguana_waddressjson(struct iguana_info *coin,cJSON *item,struct iguana_waddress *waddr) diff --git a/iguana/m_notary_run b/iguana/m_notary_run index fde6f4db9..87c1cb604 100755 --- a/iguana/m_notary_run +++ b/iguana/m_notary_run @@ -1,4 +1,6 @@ #!/bin/bash +# Unlock all lockunspents to make sure we can access all our utxo! +komodo-cli lockunspent true `komodo-cli listlockunspent | jq -c .` cd secp256k1; ./m_unix; cd .. cd ../crypto777; ./m_LP; cd ../iguana @@ -41,6 +43,9 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"ad curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"217.182.203.106\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"149.56.19.212\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"95.213.205.222\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"144.217.11.235\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"209.58.190.117\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"209.58.144.205\"}" #tests/addnotarys_7776 @@ -85,6 +90,7 @@ coins/vrsc_7776 coins/rfox_7776 coins/sec_7776 coins/ccl_7776 +coins/hush_7776 #curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"passthru\",\"method\":\"paxfiats\",\"timeout\":900000}" diff --git a/iguana/main.c b/iguana/main.c index 571f45549..96ccaec3c 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -891,7 +891,7 @@ uint8_t *SuperNET_ciphercalc(void **ptrp,int32_t *cipherlenp,bits256 *privkeyp,b cJSON *SuperNET_rosettajson(struct supernet_info *myinfo,bits256 privkey,int32_t showprivs) { uint8_t rmd160[20],pub[33]; uint64_t nxt64bits; bits256 pubkey; - char str2[41],wifbuf[64],pbuf[65],addr[64],str[128],coinwif[16]; cJSON *retjson; struct iguana_info *coin,*tmp; + char str2[41],wifbuf[64],pbuf[65],addr[64],str[128],coinwif[16],*paddr = 0; cJSON *retjson; struct iguana_info *coin,*tmp; pubkey = acct777_pubkey(privkey); nxt64bits = acct777_nxt64bits(pubkey); retjson = cJSON_CreateObject(); @@ -910,7 +910,12 @@ cJSON *SuperNET_rosettajson(struct supernet_info *myinfo,bits256 privkey,int32_t { if ( coin != 0 && coin->symbol[0] != 0 ) { - if ( bitcoin_address(addr,coin->chain->pubtype,pub,33) != 0 ) + if (strcmp(coin->chain->symbol, "HUSH") == 0) + paddr = bitcoin_address_ex(coin->chain->symbol, addr, 0x1c, coin->chain->pubtype, pub, 33); + else + paddr = bitcoin_address(addr, coin->chain->pubtype, pub, 33); + + if ( paddr != 0 ) { jaddstr(retjson,coin->symbol,addr); sprintf(coinwif,"%swif",coin->symbol); diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index b0fa20b84..934cc081a 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -327,6 +327,7 @@ char *_setVsigner(struct iguana_info *coin,struct vin_info *V,int32_t ind,char * char *bitcoin_json2hex(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,cJSON *txjson,struct vin_info *V); int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr); +int32_t bitcoin_addr2rmd160_ex(char *symbol, uint8_t taddr, uint8_t *addrtypep, uint8_t rmd160[20], char *coinaddr); char *issue_startForging(struct supernet_info *myinfo,char *secret); struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct iguana_info *coin,char **retstrp,double *balancep,int32_t *numunspentsp,double minconfirms,char *address); void iguana_chainparms(struct supernet_info *myinfo,struct iguana_chain *chain,cJSON *argjson); @@ -560,6 +561,7 @@ bits256 calc_categoryhashes(bits256 *subhashp,char *category,char *subcategory); struct gecko_chain *category_find(bits256 categoryhash,bits256 subhash); void *category_subscribe(struct supernet_info *myinfo,bits256 category,bits256 keyhash); char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); +char *bitcoin_address_ex(char *symbol, char *coinaddr, uint8_t taddr, uint8_t addrtype, uint8_t *pubkey_or_rmd160, int32_t len); char *SuperNET_JSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,uint16_t port); int64_t iguana_txdetails(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *item,bits256 txid,int32_t vout,int32_t height); int32_t iguana_txidheight(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid);