char *placequote_func(int32_t dir,char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { int32_t polarity; uint64_t obookid,nxt64bits,assetA,assetB,txid; double price,volume; struct orderbook_tx tx; char buf[1024],txidstr[512],*retstr = 0; nxt64bits = calc_nxt64bits(sender); obookid = get_API_nxt64bits(objs[1]); polarity = get_API_int(objs[2],1); if ( polarity == 0 ) polarity = 1; volume = get_API_float(objs[3]); price = get_API_float(objs[4]); assetA = get_API_nxt64bits(objs[5]); assetB = get_API_nxt64bits(objs[6]); printf("PLACE QUOTE polarity.%d dir.%d\n",polarity,dir); if ( sender[0] != 0 && find_raw_orders(obookid) != 0 && valid != 0 ) { if ( price != 0. && volume != 0. && dir != 0 ) { if ( dir*polarity > 0 ) bid_orderbook_tx(&tx,0,nxt64bits,obookid,price,volume); else ask_orderbook_tx(&tx,0,nxt64bits,obookid,price,volume); txid = pNXT_submit_tx(Global_pNXT->core,Global_pNXT->wallet,(unsigned char *)&tx,sizeof(tx)); if ( txid != 0 ) { expand_nxt64bits(txidstr,txid); sprintf(buf,"{\"txid\":\"%s\"}",txidstr); retstr = clonestr(buf); } } if ( retstr == 0 ) { sprintf(buf,"{\"error submitting\":\"place%s error obookid.%llx polarity.%d volume %f price %f\"}",dir>0?"bid":"ask",(long long)obookid,polarity,volume,price); retstr = clonestr(buf); } } else if ( assetA != 0 && assetB != 0 && assetA != assetB ) { if ( (obookid= create_raw_orders(assetA,assetB)) != 0 ) { sprintf(buf,"{\"obookid\":\"%llu\"}",(long long)obookid); retstr = clonestr(buf); } else { sprintf(buf,"{\"error\":\"couldnt create orderbook for assets %llu and %llu\"}",(long long)assetA,(long long)assetB); retstr = clonestr(buf); } } else { sprintf(buf,"{\"error\":\"place%s error obookid.%llx polarity.%d volume %f price %f\"}",polarity>0?"bid":"ask",(long long)obookid,polarity,volume,price); retstr = clonestr(buf); } return(retstr); }
double jdouble(cJSON *json,char *field) { if ( json != 0 ) { if ( field == 0 ) return(get_API_float(json)); else return(get_API_float(cJSON_GetObjectItem(json,field))); } else return(0.); }
char *telepod_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { uint64_t satoshis; struct coin_info *cp; uint32_t crc,ind,height,vout,totalcrc,sharei,M,N; char NXTACCTSECRET[1024],coinstr[512],coinaddr[512],otherpubaddr[512],txid[512],pubkey[512],privkey[2048],privkeyhex[2048],*retstr = 0; copy_cJSON(NXTACCTSECRET,objs[1]); if ( NXTACCTSECRET[0] == 0 && (cp= get_coin_info("BTCD")) != 0 ) safecopy(NXTACCTSECRET,cp->NXTACCTSECRET,sizeof(NXTACCTSECRET)); crc = get_API_uint(objs[2],0); ind = get_API_uint(objs[3],0); height = get_API_uint(objs[4],0); copy_cJSON(coinstr,objs[5]); satoshis = SATOSHIDEN * get_API_float(objs[6]); copy_cJSON(coinaddr,objs[7]); copy_cJSON(txid,objs[8]); vout = get_API_uint(objs[9],0); copy_cJSON(pubkey,objs[10]); copy_cJSON(privkeyhex,objs[11]); decode_hex((unsigned char *)privkey,(int32_t)strlen(privkeyhex)/2,privkeyhex); privkey[strlen(privkeyhex)/2] = 0; totalcrc = get_API_uint(objs[12],0); sharei = get_API_uint(objs[13],0); M = get_API_uint(objs[14],1); N = get_API_uint(objs[15],1); copy_cJSON(otherpubaddr,objs[16]); if ( coinstr[0] != 0 && sender[0] != 0 && valid != 0 ) retstr = telepod_received(sender,NXTACCTSECRET,coinstr,crc,ind,height,satoshis,coinaddr,txid,vout,pubkey,privkey,totalcrc,sharei,M,N,otherpubaddr); else retstr = clonestr("{\"error\":\"invalid telepod received\"}"); return(retstr); }
char *teleport_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { //static char *teleport[] = { (char *)teleport_func, "teleport", "V", "NXT", "secret", "amount", "dest", "coin", "minage", 0 }; double amount; int32_t M,N; struct coin_info *cp; char NXTACCTSECRET[512],destaddr[512],minage[512],coinstr[512],*retstr = 0; if ( Historical_done == 0 ) return(clonestr("historical processing is not done yet")); copy_cJSON(NXTACCTSECRET,objs[1]); amount = get_API_float(objs[2]); copy_cJSON(destaddr,objs[3]); copy_cJSON(coinstr,objs[4]); copy_cJSON(minage,objs[5]); M = get_API_int(objs[6],1); N = get_API_int(objs[7],1); if ( M > N || N >= 0xff || M <= 0 ) M = N = 1; printf("amount.(%.8f) minage.(%s) %d | M.%d N.%d\n",amount,minage,atoi(minage),M,N); cp = get_coin_info(coinstr); if ( cp != 0 && sender[0] != 0 && amount > 0 && valid != 0 && destaddr[0] != 0 ) retstr = teleport(sender,NXTACCTSECRET,(uint64_t)(SATOSHIDEN * amount),destaddr,cp,atoi(minage),M,N); else retstr = clonestr("{\"error\":\"invalid teleport request\"}"); return(retstr); }
char *makeoffer_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { uint64_t assetA,assetB; double qtyA,qtyB; int32_t type; char NXTACCTSECRET[512],otherNXTaddr[256],*retstr = 0; copy_cJSON(NXTACCTSECRET,objs[1]); copy_cJSON(otherNXTaddr,objs[2]); assetA = get_API_nxt64bits(objs[3]); qtyA = get_API_float(objs[4]); assetB = get_API_nxt64bits(objs[5]); qtyB = get_API_float(objs[6]); type = get_API_int(objs[7],0); if ( sender[0] != 0 && valid != 0 && otherNXTaddr[0] != 0 )//&& assetA != 0 && qtyA != 0. && assetB != 0. && qtyB != 0. ) retstr = makeoffer(sender,NXTACCTSECRET,otherNXTaddr,assetA,qtyA,assetB,qtyB,type); else retstr = clonestr("{\"result\":\"invalid makeoffer_func request\"}"); return(retstr); }
char *buypNXT_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { double amount; char NXTACCTSECRET[512],*retstr = 0; amount = get_API_float(objs[1]); copy_cJSON(NXTACCTSECRET,objs[2]); if ( sender[0] != 0 && amount > 0 && valid != 0 ) retstr = buypNXT(sender,NXTACCTSECRET,amount); else retstr = clonestr("{\"error\":\"invalid buypNXT request\"}"); return(retstr); }
char *sendpNXT_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { double amount; int32_t level; char NXTACCTSECRET[512],paymentid[256],dest[256],*retstr = 0; amount = get_API_float(objs[1]); copy_cJSON(NXTACCTSECRET,objs[2]); copy_cJSON(dest,objs[3]); level = get_API_int(objs[4],0); copy_cJSON(paymentid,objs[5]); if ( sender[0] != 0 && amount > 0 && valid != 0 && dest[0] != 0 ) retstr = send_pNXT(sender,NXTACCTSECRET,amount,level,dest,paymentid); else retstr = clonestr("{\"error\":\"invalid send request\"}"); return(retstr); }
char *transporterstatus_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { uint64_t value; cJSON *array; struct coin_info *cp; int32_t minage; uint8_t sharenrs[255]; uint32_t totalcrc,status,i,sharei,M,N,height,ind,num,n=0,*crcs = 0; char NXTACCTSECRET[1024],sharenrsbuf[1024],otherpubaddr[512],coinstr[512],*retstr = 0; copy_cJSON(NXTACCTSECRET,objs[1]); if ( NXTACCTSECRET[0] == 0 && (cp= get_coin_info("BTCD")) != 0 ) safecopy(NXTACCTSECRET,cp->NXTACCTSECRET,sizeof(NXTACCTSECRET)); status = get_API_int(objs[2],0); copy_cJSON(coinstr,objs[3]); totalcrc = get_API_uint(objs[4],0); value = (SATOSHIDEN * get_API_float(objs[5])); num = get_API_int(objs[6],0); minage = get_API_int(objs[7],0); height = get_API_int(objs[8],0); array = objs[9]; if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 ) { crcs = calloc(n,sizeof(*crcs)); for (i=0; i<n; i++) crcs[i] = get_API_uint(cJSON_GetArrayItem(array,i),0); } sharei = get_API_int(objs[9],0); M = get_API_int(objs[11],0); N = get_API_int(objs[12],0); copy_cJSON(sharenrsbuf,objs[13]); memset(sharenrs,0,sizeof(sharenrs)); if ( M <= N && N < 0xff && M > 0 ) decode_hex(sharenrs,N,sharenrsbuf); else M = N = 1; ind = get_API_int(objs[14],0); copy_cJSON(otherpubaddr,objs[15]); //printf("transporterstatus_func sharei.%d M.%d N.%d other.(%s)\n",sharei,M,N,otherpubaddr); if ( coinstr[0] != 0 && sender[0] != 0 && valid != 0 && num > 0 ) retstr = got_transporter_status(NXTACCTSECRET,sender,coinstr,status,totalcrc,value,num,crcs,ind,minage,height,sharei,M,N,sharenrs,otherpubaddr); else retstr = clonestr("{\"error\":\"invalid incoming transporter status\"}"); if ( crcs != 0 ) free(crcs); return(retstr); }
char *transporter_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { uint64_t value; struct coin_info *cp; uint8_t sharenrs[255]; uint32_t totalcrc,M,N,minage,height,i,n=0,*crcs = 0; char NXTACCTSECRET[1024],sharenrsbuf[1024],coinstr[512],otherpubaddr[512],*retstr = 0; copy_cJSON(NXTACCTSECRET,objs[1]); if ( NXTACCTSECRET[0] == 0 && (cp= get_coin_info("BTCD")) != 0 ) safecopy(NXTACCTSECRET,cp->NXTACCTSECRET,sizeof(NXTACCTSECRET)); copy_cJSON(coinstr,objs[2]); height = get_API_uint(objs[3],0); minage = get_API_uint(objs[4],0); value = (SATOSHIDEN * get_API_float(objs[5])); totalcrc = get_API_uint(objs[6],0); if ( is_cJSON_Array(objs[7]) != 0 && (n= cJSON_GetArraySize(objs[7])) > 0 ) { crcs = calloc(n,sizeof(*crcs)); for (i=0; i<n; i++) crcs[i] = get_API_uint(cJSON_GetArrayItem(objs[7],i),0); } M = get_API_int(objs[8],0); N = get_API_int(objs[9],0); copy_cJSON(sharenrsbuf,objs[10]); memset(sharenrs,0,sizeof(sharenrs)); if ( M <= N && N < 0xff && M > 0 ) decode_hex(sharenrs,N,sharenrsbuf); else M = N = 1; copy_cJSON(otherpubaddr,objs[11]); printf("transporterstatus_func M.%d N.%d [%s] otherpubaddr.(%s)\n",M,N,sharenrsbuf,otherpubaddr); if ( coinstr[0] != 0 && sender[0] != 0 && valid != 0 && n > 0 ) retstr = transporter_received(sender,NXTACCTSECRET,coinstr,totalcrc,height,value,minage,crcs,n,M,N,sharenrs,otherpubaddr); else retstr = clonestr("{\"error\":\"invalid incoming transporter bundle\"}"); if ( crcs != 0 ) free(crcs); return(retstr); }
struct coin777 *coin777_create(char *coinstr,cJSON *argjson) { char *serverport,*path=0,*conf=0; struct destbuf tmp; struct coin777 *coin = calloc(1,sizeof(*coin)); safecopy(coin->name,coinstr,sizeof(coin->name)); if ( argjson == 0 ) { coin->minconfirms = (strcmp("BTC",coinstr) == 0) ? 3 : 10; coin->estblocktime = (strcmp("BTC",coinstr) == 0) ? 600 : 120; } else { coin->minoutput = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"minoutput")); coin->minconfirms = get_API_int(cJSON_GetObjectItem(argjson,"minconfirms"),(strcmp("BTC",coinstr) == 0) ? 3 : 10); coin->estblocktime = get_API_int(cJSON_GetObjectItem(argjson,"estblocktime"),(strcmp("BTC",coinstr) == 0) ? 600 : 120); coin->jsonstr = cJSON_Print(argjson); coin->argjson = cJSON_Duplicate(argjson,1); if ( (serverport= cJSON_str(cJSON_GetObjectItem(argjson,"rpc"))) != 0 ) safecopy(coin->serverport,serverport,sizeof(coin->serverport)); path = cJSON_str(cJSON_GetObjectItem(argjson,"path")); conf = cJSON_str(cJSON_GetObjectItem(argjson,"conf")); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"assetid")), safecopy(coin->mgw.assetidstr,tmp.buf,sizeof(coin->mgw.assetidstr)); coin->mgw.assetidbits = calc_nxt64bits(coin->mgw.assetidstr); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"issuer")), safecopy(coin->mgw.issuer,tmp.buf,sizeof(coin->mgw.issuer));; coin->mgw.issuerbits = conv_acctstr(coin->mgw.issuer); printf(">>>>>>>>>>>> a issuer.%s %llu assetid.%llu minoutput.%llu\n",coin->mgw.issuer,(long long)coin->mgw.issuerbits,(long long)coin->mgw.assetidbits,(long long)coin->minoutput); //uint32_t set_assetname(uint64_t *multp,char *name,uint64_t assetbits); _set_assetname(&coin->mgw.ap_mult,coin->mgw.assetname,0,coin->mgw.assetidbits); printf("assetname.(%s) mult.%llu\n",coin->mgw.assetname,coin->mgw.ap_mult); strcpy(coin->mgw.coinstr,coinstr); if ( (coin->mgw.special= cJSON_GetObjectItem(argjson,"special")) == 0 ) coin->mgw.special = cJSON_GetObjectItem(COINS.argjson,"special"); if ( coin->mgw.special != 0 ) coin->mgw.special = NXT_convjson(coin->mgw.special); printf("CONVERTED.(%s)\n",cJSON_Print(coin->mgw.special)); coin->mgw.limbo = cJSON_GetObjectItem(argjson,"limbo"); coin->mgw.dust = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"dust")); coin->mgw.txfee = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"txfee_satoshis")); if ( coin->mgw.txfee == 0 ) coin->mgw.txfee = (uint64_t)(SATOSHIDEN * get_API_float(cJSON_GetObjectItem(argjson,"txfee"))); if ( coin->mgw.txfee == 0 ) coin->mgw.txfee = 10000; coin->mgw.NXTfee_equiv = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"NXTfee_equiv_satoshis")); if ( coin->mgw.NXTfee_equiv == 0 ) coin->mgw.NXTfee_equiv = (uint64_t)(SATOSHIDEN * get_API_float(cJSON_GetObjectItem(argjson,"NXTfee_equiv"))); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"opreturnmarker")), safecopy(coin->mgw.opreturnmarker,tmp.buf,sizeof(coin->mgw.opreturnmarker)); printf("OPRETURN.(%s)\n",coin->mgw.opreturnmarker); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"marker2")), safecopy(coin->mgw.marker2,tmp.buf,sizeof(coin->mgw.marker2)); coin->mgw.redeemheight = get_API_int(cJSON_GetObjectItem(argjson,"redeemheight"),430000); coin->mgw.use_addmultisig = get_API_int(cJSON_GetObjectItem(argjson,"useaddmultisig"),(strcmp("BTC",coinstr) != 0)); coin->mgw.do_opreturn = get_API_int(cJSON_GetObjectItem(argjson,"do_opreturn"),(strcmp("BTC",coinstr) == 0)); coin->mgw.oldtx_format = get_API_int(cJSON_GetObjectItem(argjson,"oldtx_format"),(strcmp("BTC",coinstr) == 0)); coin->mgw.firstunspentind = get_API_int(cJSON_GetObjectItem(argjson,"firstunspent"),(strcmp("BTCD",coinstr) == 0) ? 2500000 : 0); if ( (coin->mgw.NXTconvrate = get_API_float(cJSON_GetObjectItem(argjson,"NXTconvrate"))) == 0 ) { if ( coin->mgw.NXTfee_equiv != 0 && coin->mgw.txfee != 0 ) coin->mgw.NXTconvrate = ((double)coin->mgw.NXTfee_equiv / coin->mgw.txfee); } copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"marker")), safecopy(coin->mgw.marker,tmp.buf,sizeof(coin->mgw.marker)); printf("OPRETURN.(%s)\n",coin->mgw.opreturnmarker); } printf("coin777_create %s: (%s) %llu mult.%llu NXTconvrate %.8f minconfirms.%d issuer.(%s) %llu opreturn.%d oldformat.%d\n",coin->mgw.coinstr,coin->mgw.assetidstr,(long long)coin->mgw.assetidbits,(long long)coin->mgw.ap_mult,coin->mgw.NXTconvrate,coin->minconfirms,coin->mgw.issuer,(long long)coin->mgw.issuerbits,coin->mgw.do_opreturn,coin->mgw.oldtx_format); extract_userpass(coin->serverport,coin->userpass,coinstr,SUPERNET.userhome,path,conf); printf("COIN.%s serverport.(%s) userpass.(%s)\n",coin->name,coin->serverport,coin->userpass); COINS.LIST = realloc(COINS.LIST,(COINS.num+1) * sizeof(*coin)); COINS.LIST[COINS.num] = coin, COINS.num++; //ensure_packedptrs(coin); return(coin); }
double jdoublei(cJSON *json,int32_t i) { if ( json != 0 ) return(get_API_float(cJSON_GetArrayItem(json,i))); else return(0.); }
struct coin777 *coin777_create(char *coinstr,cJSON *argjson) { char *serverport,*path=0,*conf=0; struct destbuf tmp; struct coin777 *coin = calloc(1,sizeof(*coin)); if ( coinstr == 0 || coinstr[0] == 0 ) { printf("null coinstr?\n"); //getchar(); return(0); } safecopy(coin->name,coinstr,sizeof(coin->name)); coin->jvin = -1; if ( argjson == 0 || strcmp(coinstr,"NXT") == 0 ) { coin->usep2sh = 1; coin->minconfirms = (strcmp("BTC",coinstr) == 0) ? 3 : 10; coin->estblocktime = (strcmp("BTC",coinstr) == 0) ? 600 : 120; coin->mgw.use_addmultisig = (strcmp("BTC",coinstr) != 0); } else { coin->minoutput = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"minoutput")); coin->minconfirms = get_API_int(cJSON_GetObjectItem(argjson,"minconfirms"),(strcmp("BTC",coinstr) == 0) ? 3 : 10); coin->estblocktime = get_API_int(cJSON_GetObjectItem(argjson,"estblocktime"),(strcmp("BTC",coinstr) == 0) ? 600 : 120); coin->jsonstr = cJSON_Print(argjson); coin->argjson = cJSON_Duplicate(argjson,1); if ( (serverport= cJSON_str(cJSON_GetObjectItem(argjson,"rpc"))) != 0 ) safecopy(coin->serverport,serverport,sizeof(coin->serverport)); path = cJSON_str(cJSON_GetObjectItem(argjson,"path")); conf = cJSON_str(cJSON_GetObjectItem(argjson,"conf")); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"assetid")), safecopy(coin->mgw.assetidstr,tmp.buf,sizeof(coin->mgw.assetidstr)); if ( (coin->mgw.assetidbits= calc_nxt64bits(coin->mgw.assetidstr)) == 0 ) coin->mgw.assetidbits = is_MGWcoin(coinstr); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"issuer")), safecopy(coin->mgw.issuer,tmp.buf,sizeof(coin->mgw.issuer));; coin->mgw.issuerbits = conv_acctstr(coin->mgw.issuer); printf(">>>>>>>>>>>> a issuer.%s %llu assetid.%llu minoutput.%llu\n",coin->mgw.issuer,(long long)coin->mgw.issuerbits,(long long)coin->mgw.assetidbits,(long long)coin->minoutput); //uint32_t set_assetname(uint64_t *multp,char *name,uint64_t assetbits); if ( coin->mgw.assetidbits != 0 ) _set_assetname(&coin->mgw.ap_mult,coin->mgw.assetname,0,coin->mgw.assetidbits); printf("assetname.(%s) mult.%llu\n",coin->mgw.assetname,coin->mgw.ap_mult); strcpy(coin->mgw.coinstr,coinstr); if ( (coin->mgw.special= cJSON_GetObjectItem(argjson,"special")) == 0 ) coin->mgw.special = cJSON_GetObjectItem(COINS.argjson,"special"); if ( coin->mgw.special != 0 ) { coin->mgw.special = NXT_convjson(coin->mgw.special); printf("CONVERTED.(%s)\n",cJSON_Print(coin->mgw.special)); } coin->mgw.limbo = cJSON_GetObjectItem(argjson,"limbo"); coin->mgw.dust = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"dust")); coin->mgw.txfee = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"txfee_satoshis")); if ( coin->mgw.txfee == 0 ) coin->mgw.txfee = (uint64_t)(SATOSHIDEN * get_API_float(cJSON_GetObjectItem(argjson,"txfee"))); coin->mgw.NXTfee_equiv = get_API_nxt64bits(cJSON_GetObjectItem(argjson,"NXTfee_equiv_satoshis")); if ( coin->mgw.NXTfee_equiv == 0 ) coin->mgw.NXTfee_equiv = (uint64_t)(SATOSHIDEN * get_API_float(cJSON_GetObjectItem(argjson,"NXTfee_equiv"))); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"opreturnmarker")), safecopy(coin->mgw.opreturnmarker,tmp.buf,sizeof(coin->mgw.opreturnmarker)); printf("OPRETURN.(%s)\n",coin->mgw.opreturnmarker); copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"marker2")), safecopy(coin->mgw.marker2,tmp.buf,sizeof(coin->mgw.marker2)); coin->mgw.redeemheight = get_API_int(cJSON_GetObjectItem(argjson,"redeemheight"),430000); coin->mgw.use_addmultisig = get_API_int(cJSON_GetObjectItem(argjson,"useaddmultisig"),(strcmp("BTC",coinstr) != 0)); coin->mgw.do_opreturn = get_API_int(cJSON_GetObjectItem(argjson,"do_opreturn"),(strcmp("BTC",coinstr) == 0)); coin->mgw.oldtx_format = get_API_int(cJSON_GetObjectItem(argjson,"oldtx_format"),(strcmp("BTC",coinstr) == 0)); coin->mgw.firstunspentind = get_API_int(cJSON_GetObjectItem(argjson,"firstunspent"),(strcmp("BTCD",coinstr) == 0) ? 2500000 : 0); if ( (coin->mgw.NXTconvrate = get_API_float(cJSON_GetObjectItem(argjson,"NXTconvrate"))) == 0 ) { if ( coin->mgw.NXTfee_equiv != 0 && coin->mgw.txfee != 0 ) coin->mgw.NXTconvrate = ((double)coin->mgw.NXTfee_equiv / coin->mgw.txfee); } copy_cJSON(&tmp,cJSON_GetObjectItem(argjson,"marker")), safecopy(coin->mgw.marker,tmp.buf,sizeof(coin->mgw.marker)); printf("OPRETURN.(%s)\n",coin->mgw.opreturnmarker); coin->addrtype = get_API_int(jobj(argjson,"addrtype"),0); coin->p2shtype = get_API_int(jobj(argjson,"p2shtype"),0); coin->usep2sh = get_API_int(jobj(argjson,"usep2sh"),1); } if ( coin->mgw.txfee == 0 ) coin->mgw.txfee = 10000; if ( strcmp(coin->name,"BTC") == 0 ) { coin->addrtype = 0, coin->p2shtype = 5; if ( coin->donationaddress[0] == 0 ) { strcpy(coin->donationaddress,"177MRHRjAxCZc7Sr5NViqHRivDu1sNwkHZ"); sprintf(coin->donationscript,"76a91443044b8d5dc8f3758dbc83374c596e96d25ead4f88ac"); } } else if ( strcmp(coin->name,"LTC") == 0 ) coin->addrtype = 48, coin->p2shtype = 5, coin->minconfirms = 1, coin->mgw.txfee = 100000, coin->usep2sh = 0; else if ( strcmp(coin->name,"BTCD") == 0 ) coin->addrtype = 60, coin->p2shtype = 85, coin->mgw.txfee = 1000000;//, strcpy(coin->donationaddress,"RDRWMSrDdoUcfZRBWUz7KZQSxPS9bZRerM"); else if ( strcmp(coin->name,"DOGE") == 0 ) coin->addrtype = 30, coin->p2shtype = 35; else if ( strcmp(coin->name,"VRC") == 0 ) coin->addrtype = 70, coin->p2shtype = 85; else if ( strcmp(coin->name,"OPAL") == 0 ) coin->addrtype = 115, coin->p2shtype = 28; else if ( strcmp(coin->name,"BITS") == 0 ) coin->addrtype = 25, coin->p2shtype = 8; printf("coin777_create %s: (%s) %llu mult.%llu NXTconvrate %.8f minconfirms.%d issuer.(%s) %llu opreturn.%d oldformat.%d\n",coin->mgw.coinstr,coin->mgw.assetidstr,(long long)coin->mgw.assetidbits,(long long)coin->mgw.ap_mult,coin->mgw.NXTconvrate,coin->minconfirms,coin->mgw.issuer,(long long)coin->mgw.issuerbits,coin->mgw.do_opreturn,coin->mgw.oldtx_format); if ( strcmp(coin->name,"NXT") != 0 ) { extract_userpass(coin->serverport,coin->userpass,coinstr,SUPERNET.userhome,path,conf); set_atomickeys(coin); printf("COIN.%s serverport.(%s) userpass.(%s) %s/%s %s/%s\n",coin->name,coin->serverport,coin->userpass,coin->atomicrecv,coin->atomicrecvpubkey,coin->atomicsend,coin->atomicsendpubkey); } COINS.LIST = realloc(COINS.LIST,(COINS.num+1) * sizeof(*coin)); COINS.LIST[COINS.num] = coin, COINS.num++; //ensure_packedptrs(coin); return(coin); }