Browse Source

Test

etomic
jl777 8 years ago
parent
commit
2b44cc203e
  1. 39
      basilisk/basilisk_swap.c
  2. 4
      iguana/iguana_json.c

39
basilisk/basilisk_swap.c

@ -1412,6 +1412,7 @@ int32_t basilisk_swap_loadtx(struct basilisk_rawtx *rawtx,FILE *fp,char *bobcoin
rawtx->coin = iguana_coinfind(rawtx->I.coinstr);
if ( rawtx->vinstr[0] != 0 )
rawtx->vins = cJSON_Parse(rawtx->vinstr);
printf("loaded.%s\n",rawtx->name);
return(0);
}
}
@ -1427,20 +1428,27 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,bits256 priv
if ( (fp= fopen(fname,"rb")) != 0 )
{
fread(&swap->I,1,sizeof(swap->I),fp);
basilisk_swap_loadtx(&swap->bobdeposit,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobpayment,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->alicepayment,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->myfee,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->otherfee,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->aliceclaim,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->alicespend,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobreclaim,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobspend,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobrefund,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->alicereclaim,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
fread(swap->privkeys,1,sizeof(swap->privkeys),fp);
fread(swap->otherdeck,1,sizeof(swap->otherdeck),fp);
fread(swap->deck,1,sizeof(swap->deck),fp);
if ( swap->bobcoin == 0 )
swap->bobcoin = iguana_coinfind(swap->I.req.dest);
if ( swap->alicecoin == 0 )
swap->alicecoin = iguana_coinfind(swap->I.req.src);
if ( swap->alicecoin != 0 && swap->bobcoin == 0 )
{
basilisk_swap_loadtx(&swap->bobdeposit,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobpayment,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->alicepayment,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->myfee,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->otherfee,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->aliceclaim,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->alicespend,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobreclaim,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobspend,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->bobrefund,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
basilisk_swap_loadtx(&swap->alicereclaim,fp,swap->bobcoin->symbol,swap->alicecoin->symbol);
fread(swap->privkeys,1,sizeof(swap->privkeys),fp);
fread(swap->otherdeck,1,sizeof(swap->otherdeck),fp);
fread(swap->deck,1,sizeof(swap->deck),fp);
} else printf("missing coins (%p %p)\n",swap->bobcoin,swap->alicecoin);
fclose(fp);
}
}
@ -1723,7 +1731,7 @@ uint32_t basilisk_swapdata_rawtxsend(struct supernet_info *myinfo,struct basilis
}
}
return(nextbits);
} else printf("error from basilisk_swapdata_rawtx %p len.%d\n",rawtx->txbytes,rawtx->I.datalen);
} else printf("error from basilisk_swapdata_rawtx.%s %p len.%d\n",rawtx->name,rawtx->txbytes,rawtx->I.datalen);
return(0);
}
@ -2183,6 +2191,7 @@ void basilisk_swaploop(void *_swap)
printf("couldnt establish connection\n");
retval = -1;
}
basilisk_swap_saveupdate(myinfo,swap);
while ( retval == 0 && (swap->I.statebits & 0x20) == 0 && time(NULL) < expiration )
{
if ( swap->connected == 0 )

4
iguana/iguana_json.c

@ -86,6 +86,7 @@ cJSON *SuperNET_helpjson()
cJSON *array=0,*json,*agents;
json = cJSON_CreateObject();
agents = cJSON_CreateArray();
#ifndef WIN32
#define IGUANA_ARGS json,array,agents
#define IGUANA_HELP0(agent,name) array = helpjson(IGUANA_ARGS,#agent,#name,0)
#define IGUANA_HELP_S(agent,name,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray(cJSON_CreateArray(),helpitem(#str,"string")))
@ -194,7 +195,8 @@ cJSON *SuperNET_helpjson()
#undef IGUANA_ARGS
#undef _IGUANA_APIDEC_H_
#include "../includes/iguana_apiundefs.h"
#endif
if ( array != 0 )
jadd(json,"API",array);
jadd(json,"agents",agents);

Loading…
Cancel
Save