From 07c47bcd6c31dec1145d2ed65954a2256fcbd41f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 22 May 2016 16:50:17 -0500 Subject: [PATCH] test --- iguana/swaps/iguana_BTCswap.c | 57 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/iguana/swaps/iguana_BTCswap.c b/iguana/swaps/iguana_BTCswap.c index c5b1e4c04..484d5a896 100755 --- a/iguana/swaps/iguana_BTCswap.c +++ b/iguana/swaps/iguana_BTCswap.c @@ -441,34 +441,7 @@ int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapin } n++; } - if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEOTHERFEE) == 0 && swap->myfee != 0 ) - { - jaddbits256(newjson,"feetxid",swap->myfee->txid); - jaddstr(newjson,"feetx",swap->myfee->txbytes); - } - if ( instantdex_isbob(swap) != 0 ) - { - if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEALTPAYMENT) == 0 && swap->altpayment != 0 ) - { - jaddbits256(newjson,"altpaymenttxid",swap->altpayment->txid); - jaddstr(newjson,"altpayment",swap->altpayment->txbytes); - } - } - else - { - if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEDEPOSIT) == 0 && swap->deposit != 0 ) - { - jaddbits256(newjson,"deposittxid",swap->deposit->txid); - jaddstr(newjson,"deposit",swap->deposit->txbytes); - } - else if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEPAYMENT) == 0 && swap->payment != 0 ) - { - jaddbits256(newjson,"paymenttxid",swap->payment->txid); - jaddstr(newjson,"payment",swap->payment->txbytes); - } - } - jaddnum(newjson,"have",swap->havestate); - printf("got have.%x, myhave.%x\n",swap->otherhavestate,swap->havestate); + printf("got otherhave.%x, myhave.%x\n",swap->otherhavestate,swap->havestate); if ( n > 2 || m > 2 ) { printf("n.%d m.%d len.%d numpubs.%d\n",n,m,len,swap->numpubs); @@ -1175,6 +1148,34 @@ void instantdex_statemachine_iter(struct supernet_info *myinfo,struct exchange_i { //printf("send poll event\n"); newjson = jduplicate(swap->pollevent->newjson); + if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEOTHERFEE) == 0 && swap->myfee != 0 ) + { + jaddbits256(newjson,"feetxid",swap->myfee->txid); + jaddstr(newjson,"feetx",swap->myfee->txbytes); + printf("add feetx to newjson\n"); + } + if ( instantdex_isbob(swap) != 0 ) + { + if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEALTPAYMENT) == 0 && swap->altpayment != 0 ) + { + jaddbits256(newjson,"altpaymenttxid",swap->altpayment->txid); + jaddstr(newjson,"altpayment",swap->altpayment->txbytes); + } + } + else + { + if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEDEPOSIT) == 0 && swap->deposit != 0 ) + { + jaddbits256(newjson,"deposittxid",swap->deposit->txid); + jaddstr(newjson,"deposit",swap->deposit->txbytes); + } + else if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEPAYMENT) == 0 && swap->payment != 0 ) + { + jaddbits256(newjson,"paymenttxid",swap->payment->txid); + jaddstr(newjson,"payment",swap->payment->txbytes); + } + } + jaddnum(newjson,"have",swap->havestate); if ( (str= instantdex_statemachine(BTC_states,BTC_numstates,myinfo,exchange,swap,"poll",swap->pollevent->argjson,newjson,swap->pollevent->serdata,swap->pollevent->serdatalen)) != 0 ) free(str); free_json(newjson);