Browse Source

Netid/seednode to passphrase hooks, and fix dancing chicken duplicate Gui field

dev
jl777 7 years ago
parent
commit
9e5d0963cf
  1. 8
      iguana/exchanges/LP_commands.c
  2. 5
      iguana/exchanges/LP_nativeDEX.c
  3. 4
      iguana/exchanges/LP_privkey.c
  4. 3
      iguana/exchanges/LP_remember.c
  5. 3
      iguana/exchanges/LP_signatures.c
  6. 6
      iguana/exchanges/LP_stats.c

8
iguana/exchanges/LP_commands.c

@ -123,7 +123,7 @@ sendrawtransaction(coin, signedtx)\n\
swapstatus(pending=0)\n\
swapstatus(coin, limit=10)\n\
swapstatus(base, rel, limit=10)\n\
swapstatus(requestid, quoteid)\n\
swapstatus(requestid, quoteid, pending=0)\n\
recentswaps(limit=3)\n\
notarizations(coin)\n\
public API:\n \
@ -131,7 +131,7 @@ getcoins()\n\
getcoin(coin)\n\
portfolio()\n\
getpeers()\n\
passphrase(passphrase, gui)\n\
passphrase(passphrase, gui, netid=0, seednode="")\n\
listunspent(coin, address)\n\
setconfirms(coin, numconfirms, maxconfirms=6)\n\
trust(pubkey, trust) # positive to trust, 0 for normal, negative to blacklist\n\
@ -202,7 +202,7 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\
{
char coinaddr[64],pub33str[67];
G.USERPASS_COUNTER = 1;
if ( LP_passphrase_init(jstr(argjson,"passphrase"),jstr(argjson,"gui")) < 0 )
if ( LP_passphrase_init(jstr(argjson,"passphrase"),jstr(argjson,"gui"),juint(argjson,"netid"),jstr(argjson,"seednode")) < 0 )
return(clonestr("{\"error\":\"couldnt change passphrase\"}"));
{
retjson = cJSON_CreateObject();
@ -571,7 +571,7 @@ jpg(srcfile, destfile, power2=7, passphrase, data="", required)\n\
{
ptr->privkeydepth = 0;
LP_address_utxo_reset(ptr);
LP_passphrase_init(jstr(argjson,"passphrase"),G.gui);
LP_passphrase_init(jstr(argjson,"passphrase"),G.gui,G.netid,G.seednode);
}
if ( bits256_nonz(G.LP_privkey) != 0 )
LP_privkey_init(-1,ptr,G.LP_privkey,G.LP_mypub25519);

5
iguana/exchanges/LP_nativeDEX.c

@ -113,10 +113,11 @@ struct LP_globals
//struct LP_utxoinfo *LP_utxoinfos[2],*LP_utxoinfos2[2];
bits256 LP_mypub25519,LP_privkey,LP_mypriv25519,LP_passhash;
uint64_t LP_skipstatus[10000];
uint16_t netid;
uint8_t LP_myrmd160[20],LP_pubsecp[33];
uint32_t LP_sessionid,counter;
int32_t LP_IAMLP,LP_pendingswaps,USERPASS_COUNTER,LP_numprivkeys,initializing,waiting,LP_numskips;
char USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16],LP_NXTaddr[64];
char seednode[64],USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16],LP_NXTaddr[64];
struct LP_privkey LP_privkeys[100];
} G;
@ -1286,7 +1287,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
}
LP_initcoins(ctx,pubsock,coinsjson);
G.waiting = 1;
LP_passphrase_init(passphrase,jstr(argjson,"gui"));
LP_passphrase_init(passphrase,jstr(argjson,"gui"),juint(argjson,"netid"),jstr(argjson,"seednode"));
#ifndef FROM_JS
if ( IAMLP != 0 && OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_psockloop,(void *)myipaddr) != 0 )
{

4
iguana/exchanges/LP_privkey.c

@ -345,7 +345,7 @@ void LP_privkey_updates(void *ctx,int32_t pubsock,char *passphrase)
}
}
int32_t LP_passphrase_init(char *passphrase,char *gui)
int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seednode)
{
static void *ctx; int32_t counter; //iambob,; struct LP_utxoinfo *utxo,*tmp;
if ( ctx == 0 )
@ -362,6 +362,8 @@ int32_t LP_passphrase_init(char *passphrase,char *gui)
sleep(5);
}
memset(&G,0,sizeof(G));
G.netid = netid;
safecopy(G.seednode,seednode,sizeof(G.seednode));
vcalc_sha256(0,G.LP_passhash.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
LP_privkey_updates(ctx,LP_mypubsock,passphrase);
init_hexbytes_noT(G.LP_myrmd160str,G.LP_myrmd160,20);

3
iguana/exchanges/LP_remember.c

@ -1202,7 +1202,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
{
jaddstr(item,"method","tradestatus");
jaddnum(item,"finishtime",rswap.finishtime);
jaddstr(item,"gui",G.gui);
if ( jobj(item,"gui") == 0 )
jaddstr(item,"gui",G.gui);
//jaddbits256(item,"srchash",rswap.Q.srchash);
//jaddbits256(item,"desthash",rswap.desthash);
itemstr = jprint(item,0);

3
iguana/exchanges/LP_signatures.c

@ -42,7 +42,8 @@ struct basilisk_request *LP_requestinit(struct basilisk_request *rp,bits256 srch
cJSON *LP_quotejson(struct LP_quoteinfo *qp)
{
double price; cJSON *retjson = cJSON_CreateObject();
jaddstr(retjson,"gui",qp->gui[0] != 0 ? qp->gui : LP_gui);
if ( jobj(retjson,"gui") == 0 )
jaddstr(retjson,"gui",qp->gui[0] != 0 ? qp->gui : LP_gui);
jadd64bits(retjson,"aliceid",qp->aliceid);
jaddnum(retjson,"tradeid",qp->tradeid);
jaddstr(retjson,"base",qp->srccoin);

6
iguana/exchanges/LP_stats.c

@ -201,9 +201,11 @@ int32_t LP_statslog_parse()
struct LP_swapstats *LP_swapstats_find(uint64_t aliceid)
{
struct LP_swapstats *sp;
portable_mutex_lock(&LP_statslogmutex);
HASH_FIND(hh,LP_RTstats,&aliceid,sizeof(aliceid),sp);
if ( sp == 0 )
HASH_FIND(hh,LP_swapstats,&aliceid,sizeof(aliceid),sp);
portable_mutex_unlock(&LP_statslogmutex);
return(sp);
}
@ -214,9 +216,11 @@ struct LP_swapstats *LP_swapstats_add(uint64_t aliceid,int32_t RTflag)
{
sp = calloc(1,sizeof(*sp));
sp->aliceid = aliceid;
portable_mutex_lock(&LP_statslogmutex);
if ( RTflag != 0 )
HASH_ADD(hh,LP_RTstats,aliceid,sizeof(aliceid),sp);
else HASH_ADD(hh,LP_swapstats,aliceid,sizeof(aliceid),sp);
portable_mutex_unlock(&LP_statslogmutex);
}
return(LP_swapstats_find(aliceid));
}
@ -742,8 +746,10 @@ cJSON *LP_statslog_disp(uint32_t starttime,uint32_t endtime,char *refgui,bits256
{
if ( LP_stats_dispiter(array,sp,starttime,endtime,refbase,refrel,refgui,refpubkey) > 0 )
{
portable_mutex_lock(&LP_statslogmutex);
HASH_DELETE(hh,LP_RTstats,sp);
HASH_ADD(hh,LP_swapstats,aliceid,sizeof(sp->aliceid),sp);
portable_mutex_unlock(&LP_statslogmutex);
}
else
{

Loading…
Cancel
Save