Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
a2575cc201
  1. 4
      iguana/iguana_instantdex.c
  2. 13
      iguana/swaps/iguana_BTCswap.c

4
iguana/iguana_instantdex.c

@ -1140,7 +1140,7 @@ int32_t instantdex_acceptextract(struct instantdex_accept *ap,cJSON *argjson)
struct bitcoin_swapinfo *bitcoin_swapinit(struct supernet_info *myinfo,struct exchange_info *exchange,struct instantdex_accept *myap,struct instantdex_accept *otherap,int32_t aminitiator,cJSON *argjson,char *statename)
{
struct bitcoin_swapinfo *swap = 0; struct iguana_info *coinbtc,*altcoin; int32_t i;
struct bitcoin_swapinfo *swap = 0; struct iguana_info *coinbtc,*altcoin; int32_t i,deckflag = 1;
swap = calloc(1,sizeof(struct bitcoin_swapinfo));
portable_mutex_init(&swap->mutex);
swap->state = instantdex_statefind(BTC_states,BTC_numstates,statename);
@ -1168,6 +1168,8 @@ struct bitcoin_swapinfo *bitcoin_swapinit(struct supernet_info *myinfo,struct ex
printf("isbob error.(%d %d) %d\n",myap->offer.myside,otherap->offer.myside,instantdex_isbob(swap));
return(0);
}
if ( instantdex_pubkeyargs(myinfo,swap,2 + deckflag*INSTANTDEX_DECKSIZE,myinfo->persistent_priv,swap->myorderhash,0x02+instantdex_isbob(swap)) != 2 + deckflag*INSTANTDEX_DECKSIZE )
printf("couldnt generate privkeys\n");
instantdex_statemachineadd(exchange,swap);
return(swap);
}

13
iguana/swaps/iguana_BTCswap.c

@ -430,7 +430,7 @@ bits256 instantdex_derivekeypair(struct supernet_info *myinfo,bits256 *newprivp,
return(bitcoin_pubkey33(myinfo->ctx,pubkey,*newprivp));
}
int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapinfo *swap,cJSON *newjson,int32_t numpubs,bits256 privkey,bits256 hash,int32_t firstbyte)
int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapinfo *swap,int32_t numpubs,bits256 privkey,bits256 hash,int32_t firstbyte)
{
char buf[3]; int32_t i,n,m,len=0; bits256 pubi; uint64_t txid; uint8_t secret160[20],pubkey[33];
sprintf(buf,"%c0",'A' - 0x02 + firstbyte);
@ -589,11 +589,8 @@ void instantdex_swapbits256update(bits256 *txidp,cJSON *argjson,char *fieldname)
void instantdex_newjson(struct supernet_info *myinfo,struct bitcoin_swapinfo *swap,cJSON *newjson)
{
uint8_t pubkey[33]; int32_t deckflag;
if ( swap->otherchoosei < 0 )
deckflag = 1;
else deckflag = 0;
if ( instantdex_pubkeyargs(myinfo,swap,newjson,2 + deckflag*INSTANTDEX_DECKSIZE,myinfo->persistent_priv,swap->myorderhash,0x02+instantdex_isbob(swap)) != 2 + deckflag*INSTANTDEX_DECKSIZE )
uint8_t pubkey[33]; int32_t deckflag = 0;
if ( instantdex_pubkeyargs(myinfo,swap,2 + deckflag*INSTANTDEX_DECKSIZE,myinfo->persistent_priv,swap->myorderhash,0x02+instantdex_isbob(swap)) != 2 + deckflag*INSTANTDEX_DECKSIZE )
printf("ERROR: couldnt generate pubkeys deckflag.%d\n",deckflag);
jaddnum(newjson,"have",swap->havestate);
if ( swap->choosei >= 0 )
@ -616,14 +613,14 @@ void instantdex_newjson(struct supernet_info *myinfo,struct bitcoin_swapinfo *sw
}
jaddbits256(newjson,"A0",swap->mypubs[0]);
jaddbits256(newjson,"A1",swap->mypubs[1]);
if ( bits256_nonz(swap->pubAm) == 0 && swap->otherchoosei >= 0 )
if ( bits256_nonz(swap->pubAm) == 0 && swap->otherchoosei >= 0 && bits256_nonz(swap->privkeys[swap->otherchoosei]) != 0 )
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privkeys[swap->otherchoosei]);
if ( bits256_nonz(swap->pubAm) != 0 )
jaddbits256(newjson,"pubAm",swap->pubAm);
}
else
{
if ( bits256_nonz(swap->pubBn) == 0 && swap->otherchoosei >= 0 )
if ( bits256_nonz(swap->pubBn) == 0 && swap->otherchoosei >= 0 && bits256_nonz(swap->privkeys[swap->otherchoosei]) != 0 )
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privkeys[swap->otherchoosei]);
if ( bits256_nonz(swap->pubBn) != 0 )
jaddbits256(newjson,"pubBn",swap->pubBn);

Loading…
Cancel
Save