|
|
@ -409,10 +409,10 @@ int32_t LP_waitfor(int32_t pairsock,struct basilisk_swap *swap,int32_t timeout,i |
|
|
|
void *data; int32_t datalen,retval = -1; uint32_t expiration = (uint32_t)time(NULL) + timeout; |
|
|
|
while ( time(NULL) < expiration ) |
|
|
|
{ |
|
|
|
printf("start wait\n"); |
|
|
|
//printf("start wait\n");
|
|
|
|
if ( (datalen= nn_recv(pairsock,&data,NN_MSG,0)) >= 0 ) |
|
|
|
{ |
|
|
|
printf("wait for got.%d\n",datalen); |
|
|
|
//printf("wait for got.%d\n",datalen);
|
|
|
|
retval = (*verify)(swap,data,datalen); |
|
|
|
nn_freemsg(data); |
|
|
|
return(retval); |
|
|
@ -425,18 +425,17 @@ int32_t LP_waitfor(int32_t pairsock,struct basilisk_swap *swap,int32_t timeout,i |
|
|
|
int32_t LP_waitsend(char *statename,int32_t timeout,int32_t pairsock,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen,int32_t (*verify)(struct basilisk_swap *swap,uint8_t *data,int32_t datalen),int32_t (*datagen)(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)) |
|
|
|
{ |
|
|
|
int32_t datalen,sendlen,retval = -1; |
|
|
|
printf("waitsend.%s\n",statename); |
|
|
|
//printf("waitsend.%s\n",statename);
|
|
|
|
if ( LP_waitfor(pairsock,swap,timeout,verify) == 0 ) |
|
|
|
{ |
|
|
|
printf("waited for %s\n",statename); |
|
|
|
//printf("waited for %s\n",statename);
|
|
|
|
if ( (datalen= (*datagen)(swap,data,maxlen)) > 0 ) |
|
|
|
{ |
|
|
|
if ( (sendlen= nn_send(pairsock,data,datalen,0)) == datalen ) |
|
|
|
{ |
|
|
|
printf("sent.%d after waitfor.%s\n",sendlen,statename); |
|
|
|
//printf("sent.%d after waitfor.%s\n",sendlen,statename);
|
|
|
|
retval = 0; |
|
|
|
} |
|
|
|
else printf("send %s error\n",statename); |
|
|
|
} else printf("send %s error\n",statename); |
|
|
|
} else printf("%s datagen no data\n",statename); |
|
|
|
} else printf("didnt get valid data\n"); |
|
|
|
return(retval); |
|
|
@ -445,16 +444,16 @@ int32_t LP_waitsend(char *statename,int32_t timeout,int32_t pairsock,struct basi |
|
|
|
int32_t LP_sendwait(char *statename,int32_t timeout,int32_t pairsock,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen,int32_t (*verify)(struct basilisk_swap *swap,uint8_t *data,int32_t datalen),int32_t (*datagen)(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)) |
|
|
|
{ |
|
|
|
int32_t datalen,sendlen,retval = -1; |
|
|
|
printf("sendwait.%s\n",statename); |
|
|
|
//printf("sendwait.%s\n",statename);
|
|
|
|
if ( (datalen= (*datagen)(swap,data,maxlen)) > 0 ) |
|
|
|
{ |
|
|
|
printf("generated %d for %s\n",datalen,statename); |
|
|
|
//printf("generated %d for %s\n",datalen,statename);
|
|
|
|
if ( (sendlen= nn_send(pairsock,data,datalen,0)) == datalen ) |
|
|
|
{ |
|
|
|
printf("sendwait.%s sent %d\n",statename,sendlen); |
|
|
|
//printf("sendwait.%s sent %d\n",statename,sendlen);
|
|
|
|
if ( LP_waitfor(pairsock,swap,timeout,verify) == 0 ) |
|
|
|
{ |
|
|
|
printf("waited! sendwait.%s sent %d\n",statename,sendlen); |
|
|
|
//printf("waited! sendwait.%s sent %d\n",statename,sendlen);
|
|
|
|
retval = 0; |
|
|
|
} else printf("didnt get %s\n",statename); |
|
|
|
} else printf("send pubkeys error\n"); |
|
|
@ -512,7 +511,7 @@ uint32_t LP_swapdata_rawtxsend(int32_t pairsock,struct basilisk_swap *swap,uint3 |
|
|
|
sendbuf[sendlen++] = rawtx->I.datalen & 0xff; |
|
|
|
sendbuf[sendlen++] = (rawtx->I.datalen >> 8) & 0xff; |
|
|
|
sendbuf[sendlen++] = rawtx->I.redeemlen; |
|
|
|
int32_t z; for (z=0; z<rawtx->I.datalen; z++) printf("%02x",rawtx->txbytes[z]); printf(" >>>>>>> send.%d %s\n",rawtx->I.datalen,rawtx->name); |
|
|
|
//int32_t z; for (z=0; z<rawtx->I.datalen; z++) printf("%02x",rawtx->txbytes[z]); printf(" >>>>>>> send.%d %s\n",rawtx->I.datalen,rawtx->name);
|
|
|
|
//printf("datalen.%d redeemlen.%d\n",rawtx->I.datalen,rawtx->I.redeemlen);
|
|
|
|
memcpy(&sendbuf[sendlen],rawtx->txbytes,rawtx->I.datalen), sendlen += rawtx->I.datalen; |
|
|
|
if ( rawtx->I.redeemlen > 0 && rawtx->I.redeemlen < 0x100 ) |
|
|
@ -558,7 +557,7 @@ void LP_bobloop(void *_utxo) |
|
|
|
printf("error bobscripts deposit\n"); |
|
|
|
else |
|
|
|
{ |
|
|
|
printf("depositlen.%d\n",swap->bobdeposit.I.datalen); |
|
|
|
//printf("depositlen.%d\n",swap->bobdeposit.I.datalen);
|
|
|
|
LP_swapsfp_update(&swap->I.req); |
|
|
|
if ( LP_waitfor(utxo->pair,swap,10,LP_verify_otherfee) < 0 ) |
|
|
|
printf("error waiting for alicefee\n"); |
|
|
|