diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index aa4360df4..4a2a714dc 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -954,7 +954,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) timeoutmillis = BASILISK_TIMEOUT; if ( coin != 0 ) { - if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) + if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 ) { if ( (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) { diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index 9ba011a28..badaee894 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -502,21 +502,25 @@ THREE_STRINGS_AND_DOUBLE(tradebot,aveprice,comment,base,rel,basevolume) ZERO_ARGS(InstantDEX,allcoins) { - struct iguana_info *tmp; cJSON *basilisk,*virtual,*full,*retjson = cJSON_CreateObject(); + struct iguana_info *tmp; cJSON *notarychains,*basilisk,*virtual,*full,*retjson = cJSON_CreateObject(); full = cJSON_CreateArray(); basilisk = cJSON_CreateArray(); virtual = cJSON_CreateArray(); + notarychains = cJSON_CreateArray(); HASH_ITER(hh,myinfo->allcoins,coin,tmp) { if ( coin->virtualchain != 0 ) jaddistr(virtual,coin->symbol); if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) jaddistr(full,coin->symbol); + else if ( coin->notarychain >= 0 ) + jaddistr(notarychains,coin->symbol); else jaddistr(basilisk,coin->symbol); } jadd(retjson,"basilisk",basilisk); jadd(retjson,"full",full); jadd(retjson,"virtual",virtual); + jadd(retjson,"notarychains",notarychains); return(jprint(retjson,1)); } diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index dcc261f89..014fc121e 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -447,7 +447,7 @@ void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,s return(clonestr("{\"error\":\"null valsobj\"}")); if ( (myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0) && strcmp(coin->symbol,"RELAY") != 0 ) return(0); - if ( coin->VALIDATENODE > 0 || coin->FULLNODE > 0 ) + if ( coin->VALIDATENODE > 0 || coin->FULLNODE > 0 || coin->notarychain >= 0 ) { infojson = iguana_getinfo(myinfo,coin); Lptr->retstr = jprint(infojson,1); diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index ea80d7140..951aa5c74 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -410,7 +410,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk } } else noquoteflag++; } - printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount)); + //printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount)); double retvals[4],refprice,profitmargin,aveprice; cJSON *retjson; char *retstr; if ( myinfo->IAMLP != 0 && myrequest == 0 && pendingid == 0 && noquoteflag != 0 && (profitmargin= tradebot_liquidity_active(myinfo,&refprice,list[0].src,list[0].dest)) > 0. ) { diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 1fa12cb3c..976c12e23 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -154,7 +154,7 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin, bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin); char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout); -char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); +char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address,int32_t forceflag); char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address); cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index dfa572631..defa0f43d 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -270,7 +270,7 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d } else if ( dexreq.func == 'A' ) { - retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen]); + retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen],0); *broadcastflagp = 1; if ( retstr == 0 ) retstr = dpow_validateaddress(myinfo,coin,(char *)&dexp->packet[datalen]); diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index fe62ef314..3b942a953 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1462,7 +1462,7 @@ void PAX_update(struct PAX_data *dp,double *btcusdp,double *kmdbtcp) } else { - for (iter=0; iter<2; iter++) + for (iter=1; iter<2; iter++) { kmdhist = url_json(iter == 0 ? url : url2); //{"date":1406160000,"high":0.01,"low":0.00125,"open":0.01,"close":0.001375,"volume":1.50179994,"quoteVolume":903.58818412,"weightedAverage":0.00166204}, diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 6094cebda..1530fbb97 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -434,7 +434,7 @@ char *dpow_alladdresses(struct supernet_info *myinfo,struct iguana_info *coin) return(retstr); } -char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address) +char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address,int32_t forceflag) { char buf[1024],*retstr,*alladdresses,*outstr,fname[1024]; cJSON *alljson; int32_t i,n; FILE *fp; if ( coin->FULLNODE < 0 ) @@ -447,21 +447,27 @@ char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,c { if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 ) { - for (i=0; isymbol), OS_compatible_path(fname); - if ( (fp= fopen(fname,"wb")) != 0 ) + if ( forceflag == 0 ) { - fwrite(outstr,1,strlen(outstr)+1,fp); - fclose(fp); - printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol); + outstr = jprint(alljson,0); + sprintf(fname,"%s/alladdresses.%s",GLOBAL_CONFSDIR,coin->symbol), OS_compatible_path(fname); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + fwrite(outstr,1,strlen(outstr)+1,fp); + fclose(fp); + printf("importaddress.(%s) -> alladdresses.%s\n",address,coin->symbol); + } + free(outstr); } - free(outstr); } } free_json(alljson); diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 56259af43..3b471900f 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -839,7 +839,10 @@ void iguana_helper(void *arg) void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin) { - struct iguana_bundle *bp; struct iguana_peer *addr; int32_t bundlei; bits256 zero; char dirname[512],*symbol; + char NOTARYCHAINS[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies + "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", + "KMD", "BTC", "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW" }; + struct iguana_bundle *bp; struct iguana_peer *addr; int32_t i,bundlei; bits256 zero; char dirname[512],*symbol; iguana_rwiAddrind(coin,0,0,0); //for (i=0; ichain); i++) // printf("%02x",((uint8_t *)coin->chain)[i]); @@ -869,10 +872,23 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin) memset(zero.bytes,0,sizeof(zero)); if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 ) bp->bundleheight = 0; + if ( coin->FULLNODE == 0 ) + { + coin->notarychain = -1; + for (i=0; isymbol,NOTARYCHAINS[i]) == 0 ) + { + coin->notarychain = i; + break; + } + } addr = &coin->peers->active[IGUANA_MAXPEERS-2]; iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(coin->seedipaddr)); - printf("SEED_IPADDR initpeer.(%s)\n",addr->ipaddr); - iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); + printf("SEED_IPADDR initpeer.(%s) notarychain.%d\n",addr->ipaddr,coin->notarychain); + if ( coin->notarychain < 0 ) + { + iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); + } } void iguana_coinloop(void *arg) @@ -890,7 +906,7 @@ void iguana_coinloop(void *arg) if ( is_cJSON_Array(alljson) != 0 && (n= cJSON_GetArraySize(alljson)) > 0 ) { for (i=0; iFULLNODE < 0 ) + if ( coin->FULLNODE < 0 || coin->notarychain >= 0 ) continue; /*if ( strcmp(coin->symbol,"RELAY") == 0 ) { diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 5d07685ba..8d9ccacfd 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -564,6 +564,8 @@ struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_ } } } + if ( coin->notarychain >= 0 ) + return(coin); //coin->firstblock = coin->blocks.parsedblocks + 1; iguana_genesis(myinfo,coin,coin->chain); int32_t bundlei = -2; diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index bb27f597a..db778a1f6 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -293,9 +293,12 @@ bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_inf serialized = calloc(1,sizeof(struct iguana_msghdr) + len); decode_hex(&serialized[sizeof(struct iguana_msghdr)],len,signedtx); txid = bits256_doublesha256(0,&serialized[sizeof(struct iguana_msghdr)],len); - if ( coin->FULLNODE < 0 ) + if ( coin->FULLNODE < 0 || coin->notarychain >= 0 ) { - if ( (str= dpow_sendrawtransaction(myinfo,coin,signedtx)) != 0 ) + if ( coin->FULLNODE < 0 || coin->notarychain >= 0 ) + str = dpow_sendrawtransaction(myinfo,coin,signedtx); + else str = _dex_sendrawtransaction(myinfo,coin->symbol,signedtx); + if ( str != 0 ) { if ( is_hexstr(str,0) == sizeof(checktxid)*2 ) { diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 759993e73..ded00c7a8 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -585,6 +585,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info * return(deposits - spent); } +// jl777: todo support notarychain iterate listunspent int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int32_t minconf,int32_t maxconf,uint64_t *totalp,struct iguana_pkhash *P,int32_t max,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,struct iguana_outpoint *unspents,int32_t *numunspentsp,int32_t maxunspents,char *remoteaddr,int32_t includespent) { int32_t i,n,m,numunspents; uint64_t spent,deposits,netbalance,total; struct iguana_outpoint lastpt; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; @@ -1071,7 +1072,7 @@ int32_t iguana_unspentfindjson(cJSON *destarray,cJSON *item) cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespends) { uint64_t total = 0; int32_t i,j,m,n,numrmds,numunspents=0; char *coinaddr,*retstr; uint8_t *rmdarray; cJSON *vals,*unspents,*item,*array,*retjson,*retarray; bits256 hash; - if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) + if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 ) { retjson = cJSON_CreateArray(); rmdarray = iguana_rmdarray(myinfo,coin,&numrmds,argarray,0); @@ -1168,7 +1169,7 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info * } memset(pubkey,0,sizeof(pubkey)); //remains = required * 1.1 + coin->txfee; - if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) + if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 ) { for (i=numunspents=0; inotarychain >= 0 ) + { + if ( (retstr= _dex_getinfo(myinfo,coin->symbol)) != 0 ) + { + retjson = cJSON_Parse(retstr); + free(retstr); + return(retjson); + } else return(cJSON_Parse("{\"error\":\"null return\"}")); + } jaddstr(retjson,"result","success"); jaddnum(retjson,"protocolversion",PROTOCOL_VERSION); jaddnum(retjson,"kbfee",dstr(coin->txfee_perkb)); @@ -1146,7 +1155,7 @@ ZERO_ARGS(bitcoinrpc,getinfo) struct basilisk_item Lptr,*ptr; int32_t incr,i,j,m,n,longest; cJSON *valsobj,*getinfoobj=0,*array,*item,*fullnodes; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); - if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) + if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 || coin->notarychain >= 0 ) return(jprint(iguana_getinfo(myinfo,coin),1)); else { diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index c2a9f86cd..2d53fd9cc 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -517,6 +517,7 @@ struct iguana_info char lastdispstr[2048]; double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num; struct iguana_monitorinfo monitoring[256]; + int32_t notarychain; struct datachain_info dPoW; struct iguana_zblock newblock; char *newblockstr; int32_t relay_RTheights[BASILISK_MAXRELAYS];