Browse Source

Test

etomic
jl777 7 years ago
parent
commit
f435e264f3
  1. 14
      iguana/exchanges/LP_scan.c
  2. 5
      iguana/exchanges/LP_socket.c
  3. 10
      iguana/exchanges/LP_swap.c

14
iguana/exchanges/LP_scan.c

@ -120,7 +120,9 @@ int32_t LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter)
if ( (txobj= LP_gettx(coin->symbol,txid)) != 0 )
{
//printf("TX.(%s)\n",jprint(txobj,0));
height = LP_txheight(coin,txid);
if ( coin->electrum == 0 )
height = LP_txheight(coin,txid);
else height = -1;
vins = jarray(&numvins,txobj,"vin");
vouts = jarray(&numvouts,txobj,"vout");
if ( iter == 0 && vouts != 0 && (tx= LP_transactionadd(coin,txid,height,numvouts,numvins)) != 0 )
@ -655,7 +657,7 @@ int32_t LP_mempoolscan(char *symbol,bits256 searchtxid)
int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t duration)
{
struct iguana_info *coin; cJSON *array; uint32_t expiration,i,n;
struct iguana_info *coin; struct LP_transaction *tx; cJSON *array,*item; uint32_t expiration,i,n;
if ( (coin= LP_coinfind(symbol)) == 0 || coin->inactive != 0 )
return(-1);
expiration = (uint32_t)time(NULL) + duration;
@ -668,13 +670,19 @@ int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t duration
}
else
{
if ( (tx= LP_transactionfind(coin,txid)) != 0 && tx->height >= 0 )
{
char str[65]; printf("LP_waitmempool found %s %s\n",symbol,bits256_str(str,txid));
return(tx->height);
}
if ( (array= electrum_address_getmempool(symbol,coin->electrum,&array,coinaddr)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
if ( bits256_cmp(txid,jbits256i(array,i)) == 0 )
item = jitem(array,i);
if ( bits256_cmp(txid,jbits256(item,"tx_hash")) == 0 )
{
free(array);
char str[65]; printf("found %s %s in mempool\n",symbol,bits256_str(str,txid));

5
iguana/exchanges/LP_socket.c

@ -313,12 +313,13 @@ void electrum_process_array(struct iguana_info *coin,cJSON *array)
{
item = jitem(array,i);
txid = jbits256(item,"tx_hash");
if ( LP_transactionfind(coin,txid) == 0 )
if ( (tx= LP_transactionfind(coin,txid)) == 0 )
{
LP_transactioninit(coin,txid,0);
LP_transactioninit(coin,txid,1);
tx = LP_transactionfind(coin,txid);
}
if ( (tx= LP_transactionfind(coin,txid)) != 0 && tx->height <= 0 )
if ( tx != 0 && tx->height <= 0 )
{
tx->height = jint(item,"height");
char str[65]; printf(">>>>>>>>>> set %s <- height %d\n",bits256_str(str,txid),tx->height);

10
iguana/exchanges/LP_swap.c

@ -716,11 +716,11 @@ void LP_bobloop(void *_swap)
basilisk_bobdeposit_refund(swap,swap->I.putduration);
//printf("depositlen.%d\n",swap->bobdeposit.I.datalen);
LP_swapsfp_update(&swap->I.req);
if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*3,LP_verify_otherfee) < 0 )
if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_otherfee) < 0 )
printf("error waiting for alicefee\n");
else if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 )
printf("error sending bobdeposit\n");
else if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*3,LP_verify_alicepayment) < 0 )
else if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_alicepayment) < 0 )
printf("error waiting for alicepayment\n");
else
{
@ -775,7 +775,7 @@ void LP_aliceloop(void *_swap)
LP_swapsfp_update(&swap->I.req);
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 )
printf("error sending alicefee\n");
else if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*3,LP_verify_bobdeposit) < 0 )
else if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_bobdeposit) < 0 )
printf("error waiting for bobdeposit\n");
else if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 )
printf("error sending alicepayment\n");
@ -787,10 +787,10 @@ void LP_aliceloop(void *_swap)
while ( (n= LP_numconfirms(swap->alicecoin.symbol,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,1)) < m )
{
char str[65];printf("%d waiting for alicepayment to be confirmed.%d %s %s\n",n,1,swap->alicecoin.symbol,bits256_str(str,swap->alicepayment.I.signedtxid));
sleep(LP_SWAPSTEP_TIMEOUT);
sleep(10);
}
swap->sentflag = 1;
if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*3,LP_verify_bobpayment) < 0 )
if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_bobpayment) < 0 )
printf("error waiting for bobpayment\n");
else
{

Loading…
Cancel
Save