Browse Source

Test

etomic
jl777 8 years ago
parent
commit
56aa3712bb
  1. 3
      iguana/exchanges/LP_commands.c
  2. 16
      iguana/exchanges/LP_nativeDEX.c
  3. 2
      iguana/exchanges/LP_rpc.c
  4. 16
      iguana/exchanges/LP_utxos.c

3
iguana/exchanges/LP_commands.c

@ -309,8 +309,7 @@ forward(pubkey,hexstr)\n\
{
privkey = LP_privkeycalc(pubkey33,&pubkey,ptr,"",USERPASS_WIFSTR);
LP_utxopurge(0);
LP_privkey_init(-1,ptr,privkey,pubkey,pubkey33,0);
LP_privkey_init(-1,ptr,privkey,pubkey,pubkey33,1);
LP_privkey_init(-1,ptr,privkey,pubkey,pubkey33);
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jadd(retjson,"alice",LP_inventory(coin,0));

16
iguana/exchanges/LP_nativeDEX.c

@ -167,16 +167,8 @@ void LP_utxo_spentcheck(int32_t pubsock,struct LP_utxoinfo *utxo,double profitma
void LP_utxo_updates(int32_t pubsock,char *passphrase,double profitmargin)
{
int32_t iambob; struct LP_utxoinfo *utxo,*tmp;
LP_utxopurge(0);
for (iambob=0; iambob<=1; iambob++)
{
LP_privkey_updates(pubsock,passphrase,iambob);
HASH_ITER(hh,LP_utxoinfos[iambob],utxo,tmp)
{
LP_utxo_spentcheck(pubsock,utxo,profitmargin);
}
}
LP_privkey_updates(pubsock,passphrase);
}
void LP_mainloop(char *myipaddr,struct LP_peerinfo *mypeer,uint16_t mypubport,int32_t pubsock,char *pushaddr,int32_t pullsock,uint16_t myport,char *passphrase,double profitmargin,cJSON *coins)
@ -219,10 +211,8 @@ void LP_mainloop(char *myipaddr,struct LP_peerinfo *mypeer,uint16_t mypubport,in
LP_priceinfoadd(jstr(item,"coin"));
}
}
printf("update alice\n");
LP_privkey_updates(pubsock,passphrase,0);
printf("update bob\n");
LP_privkey_updates(pubsock,passphrase,1);
printf("update utxos\n");
LP_privkey_updates(pubsock,passphrase);
printf("update swaps\n");
if ( (retstr= basilisk_swaplist()) != 0 )
free(retstr);

2
iguana/exchanges/LP_rpc.c

@ -83,7 +83,7 @@ cJSON *bitcoin_json(struct iguana_info *coin,char *method,char *params)
retstr = bitcoind_passthru(coin->symbol,coin->serverport,coin->userpass,method,params);
if ( retstr != 0 && retstr[0] != 0 )
{
printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr);
//printf("%s: %s.%s -> (%s)\n",coin->symbol,method,params,retstr);
retjson = cJSON_Parse(retstr);
free(retstr);
}

16
iguana/exchanges/LP_utxos.c

@ -527,20 +527,24 @@ int32_t LP_nearestvalue(uint64_t *values,int32_t n,uint64_t targetval)
return(mini);
}
uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 myprivkey,bits256 mypub,uint8_t *pubkey33,int32_t iambob)
uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 myprivkey,bits256 mypub,uint8_t *pubkey33)
{
char *script; struct LP_utxoinfo *utxo; cJSON *array,*item; bits256 txid,deposittxid; int32_t used,i,n,vout,depositvout; uint64_t *values,satoshis,depositval,targetval,value,total = 0;
char *script; struct LP_utxoinfo *utxo; cJSON *array,*item; bits256 txid,deposittxid; int32_t used,i,n,iambob,vout,depositvout; uint64_t *values=0,satoshis,depositval,targetval,value,total = 0;
if ( coin == 0 )
{
printf("coin not active\n");
return(0);
}
//printf("privkey init.(%s) %s\n",symbol,coin->symbol);
printf("privkey init.(%s)\n",coin->symbol);
if ( coin->inactive == 0 && (array= LP_listunspent(coin->symbol,coin->smartaddr)) != 0 )
{
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
for (iambob=0; iambob<=1; iambob++)
{
if ( iambob == 0 )
values = calloc(n,sizeof(*values));
else memset(values,0,n * sizeof(*values));
for (i=0; i<n; i++)
{
item = jitem(array,i);
@ -593,8 +597,10 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
}
} else break;
}
if ( iambob == 1 )
free(values);
}
}
free_json(array);
}
//printf("privkey.%s %.8f\n",symbol,dstr(total));
@ -630,7 +636,7 @@ bits256 LP_privkeycalc(uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *co
return(privkey);
}
void LP_privkey_updates(int32_t pubsock,char *passphrase,int32_t iambob)
void LP_privkey_updates(int32_t pubsock,char *passphrase)
{
int32_t i; struct iguana_info *coin; bits256 pubkey,privkey; uint8_t pubkey33[33];
memset(privkey.bytes,0,sizeof(privkey));
@ -643,7 +649,7 @@ void LP_privkey_updates(int32_t pubsock,char *passphrase,int32_t iambob)
if ( bits256_nonz(privkey) == 0 || coin->smartaddr[0] == 0 )
privkey = LP_privkeycalc(pubkey33,&pubkey,coin,passphrase,"");
if ( coin->inactive == 0 )
LP_privkey_init(pubsock,coin,privkey,pubkey,pubkey33,iambob);
LP_privkey_init(pubsock,coin,privkey,pubkey,pubkey33);
}
}
}

Loading…
Cancel
Save