Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
497b608515
  1. 8
      iguana/iguana_instantdex.c
  2. 19
      iguana/swaps/iguana_BTCswap.c

8
iguana/iguana_instantdex.c

@ -1350,13 +1350,9 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms
if ( signerbits == swap->othertrader.txid )
{
swap->expiration += INSTANTDEX_OFFERDURATION;
printf("OTHER SIDE sent packet\n");
}
if ( swap->cutverified == 0 && swap->choosei >= 0 && serdatalen == sizeof(swap->privkeys) )
{
printf("cutverfied.%d choosei.%d privkeyextract\n",swap->cutverified,swap->choosei);
instantdex_privkeyextract(myinfo,swap,serdata,serdatalen);
printf("OTHER SIDEf sent packet\n");
}
instantdex_privkeyextract(myinfo,swap,serdata,serdatalen);
printf("found existing state machine %llx choosei.%d other.%d\n",(long long)A.orderid,swap->choosei,swap->otherchoosei);
newjson = instantdex_parseargjson(myinfo,exchange,swap,argjson,0);
if ( serdatalen == sizeof(swap->otherdeck) && swap->choosei < 0 && (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 )

19
iguana/swaps/iguana_BTCswap.c

@ -524,14 +524,14 @@ void instantdex_privkeyextract(struct supernet_info *myinfo,struct bitcoin_swapi
{
if ( otherpubkey[0] == 3 )
{
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privkeys[i]);
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privBn);
} else printf("wrong first byte.%02x\n",otherpubkey[0]);
}
else
{
if ( otherpubkey[0] == 2 )
{
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privkeys[i]);
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privAm);
} else printf("wrong first byte.%02x\n",otherpubkey[0]);
}
continue;
@ -554,7 +554,7 @@ void instantdex_privkeyextract(struct supernet_info *myinfo,struct bitcoin_swapi
}
}
if ( errs == 0 && wrongfirstbyte == 0 )
swap->cutverified = 1;
swap->cutverified = 1, printf("CUT VERIFIED\n");
else printf("failed verification: wrong firstbyte.%d errs.%d\n",wrongfirstbyte,errs);
}
}
@ -646,12 +646,20 @@ void instantdex_newjson(struct supernet_info *myinfo,struct bitcoin_swapinfo *sw
swap->pubA0 = swap->mypubs[0];
//swap->pubA1 = swap->mypubs[1];
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]);
swap->privAm = swap->privkeys[swap->otherchoosei];
memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei]));
}
}
else
{
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]);
swap->privBn = swap->privkeys[swap->otherchoosei];
memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei]));
}
jaddbits256(newjson,"B0",swap->mypubs[0]);
jaddbits256(newjson,"B1",swap->mypubs[1]);
swap->pubB0 = swap->mypubs[0];
@ -1086,6 +1094,11 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta
instantdex_newjson(myinfo,swap,newjson);
//printf("i.%d (%s) %s %s.%d -> %s.%d send.(%s) %p\n",i,jprint(newjson,0),cmdstr,swap->state->name,state->ind,states[state->events[i].nextstateind].name,state->events[i].nextstateind,state->events[i].sendcmd,&states[state->events[i].nextstateind]);
swap->state = &states[state->events[i].nextstateind];
if ( swap->otherchoosei >= 0 && bits256_nonz(swap->privkeys[swap->otherchoosei]) == 0 && swap->cutverified == 0 )
{
serdata = swap->privkeys[0].bytes;
serdatalen = (int32_t)sizeof(swap->privkeys);
}
return(instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,state->events[i].sendcmd,swap->othertrader,INSTANTDEX_HOPS,serdata,serdatalen,0,swap));
} else return(clonestr("{\"error\":\"instantdex_statemachine: illegal state\"}"));
} else return(clonestr("{\"result\":\"instantdex_statemachine: processed\"}"));

Loading…
Cancel
Save