Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
b9a651eacc
  1. 4
      iguana/exchanges777.h
  2. 7
      iguana/iguana_instantdex.c
  3. 19
      iguana/swaps/iguana_BTCswap.c

4
iguana/exchanges777.h

@ -24,7 +24,7 @@
#define INSTANTDEX_DECKSIZE 777
#define INSTANTDEX_HOPS 2
#define INSTANTDEX_DURATION 60
#define INSTANTDEX_DURATION 30
#define INSTANTDEX_ORDERSTATE_IDLE 0
#define INSTANTDEX_ORDERSTATE_HAVEOTHERFEE 1
@ -41,7 +41,7 @@
#define INSTANTDEX_BTCD "RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf"
#define INSTANTDEX_MINPERC 50
#define INSTANTDEX_OFFERDURATION 120
#define INSTANTDEX_OFFERDURATION 60
#define INSTANTDEX_LOCKTIME 3600
#define EXCHANGES777_MINPOLLGAP 1

7
iguana/iguana_instantdex.c

@ -437,12 +437,11 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o
//printf("extralen.%d datalen.%d slen.%d olen.%d\n",extralen,datalen,slen,olen);
if ( extralen > 0 )
{
char str[65];
memcpy(&msg->serialized[slen + olen],extraser,extralen);
len = 0;
if ( serflag == 1 )
{
printf("send deck (%llx %llx)\n",(long long)swap->deck[0][0],(long long)swap->deck[0][1]);
//printf("send deck (%llx %llx)\n",(long long)swap->deck[0][0],(long long)swap->deck[0][1]);
while ( len < extralen )
{
memcpy(&x,&((uint8_t *)extraser)[len],sizeof(x));
@ -458,8 +457,8 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o
for (j=0; j<32; j++)
((uint8_t *)extraser)[len++] = tmphash.bytes[j];
//iguana_rwbignum(1,&((uint8_t *)extraser)[len],sizeof(bits256),tmphash.bytes);
if ( len == 0 )
printf("ser privkeys0 %s\n",bits256_str(str,*(bits256 *)extraser));
//if ( len == 0 )
// printf("ser privkeys0 %s\n",bits256_str(str,*(bits256 *)extraser));
len += sizeof(bits256);
}
}

19
iguana/swaps/iguana_BTCswap.c

@ -527,6 +527,7 @@ void instantdex_privkeyextract(struct supernet_info *myinfo,struct bitcoin_swapi
if ( otherpubkey[0] == 0x02 )
{
swap->privBn = swap->privkeys[i];
calc_rmd160_sha256(swap->secretBn,swap->privBn.bytes,sizeof(swap->privBn));
swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privBn);
} else printf("wrong first byte.%02x\n",otherpubkey[0]);
}
@ -535,6 +536,7 @@ void instantdex_privkeyextract(struct supernet_info *myinfo,struct bitcoin_swapi
if ( otherpubkey[0] == 0x03 )
{
swap->privAm = swap->privkeys[i];
calc_rmd160_sha256(swap->secretAm,swap->privAm.bytes,sizeof(swap->privAm));
swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey,swap->privAm);
} else printf("wrong first byte.%02x\n",otherpubkey[0]);
}
@ -608,7 +610,7 @@ 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],*secret160; int32_t deckflag; char secretstr[41],*field; bits256 priv;
uint8_t pubkey[33],*secret160; int32_t deckflag; char secretstr[41],*field;
deckflag = (newjson != 0 && swap->otherchoosei < 0) ? 1 : 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);
@ -622,26 +624,21 @@ void instantdex_newjson(struct supernet_info *myinfo,struct bitcoin_swapinfo *sw
{
secret160 = swap->secretBn;
field = "secretBn";
priv = swap->privBn;
}
else
{
secret160 = swap->secretAm;
field = "secretAm";
priv = swap->privAm;
}
if ( bits256_nonz(priv) != 0 )
{
calc_rmd160_sha256(secret160,priv.bytes,sizeof(priv));
init_hexbytes_noT(secretstr,secret160,20);
jaddstr(newjson,field,secretstr);
}
init_hexbytes_noT(secretstr,secret160,20);
jaddstr(newjson,field,secretstr);
printf("send secretstr.(%s)\n",secretstr);
}
if ( swap->myfee != 0 && jobj(newjson,"feetx") == 0 && (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEOTHERFEE) == 0 )
if ( jobj(newjson,"feetx") == 0 && swap->myfee != 0 ) // && (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEOTHERFEE) == 0 )
{
jaddbits256(newjson,"feetxid",swap->myfee->txid);
jaddstr(newjson,"feetx",swap->myfee->txbytes);
printf("add feetx to newjson have.%x\n",swap->havestate);
//printf("add feetx to newjson have.%x\n",swap->havestate);
}
if ( instantdex_isbob(swap) == 0 )
{

Loading…
Cancel
Save