Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
ac144b4aef
  1. 9
      iguana/iguana_interpreter.c
  2. 6
      iguana/iguana_sign.c
  3. 22
      iguana/swaps/iguana_BTCswap.c

9
iguana/iguana_interpreter.c

@ -855,9 +855,12 @@ int32_t iguana_expandscript(struct iguana_info *coin,char *asmstr,int32_t maxlen
{
n = script[i++];
n = (n << 8) | script[i++];
for (j=0; j<n; j++)
sprintf(&asmstr[len],"%02x",script[i++]), len += 2;
extraflag = 1;
if ( n+len < maxlen )
{
for (j=0; j<n; j++)
sprintf(&asmstr[len],"%02x",script[i++]), len += 2;
extraflag = 1;
} else return(-1);
}
else if ( opcode == IGUANA_OP_PUSHDATA4 )
{

6
iguana/iguana_sign.c

@ -836,11 +836,9 @@ cJSON *iguana_scriptpubkeys(struct iguana_info *coin,uint8_t *script,int32_t scr
void iguana_addscript(struct iguana_info *coin,cJSON *dest,uint8_t *script,int32_t scriptlen,char *fieldname)
{
char *scriptstr,scriptbuf[8192+256]; int32_t maxlen; cJSON *scriptobj;
if ( scriptlen < 0 )
if ( scriptlen < 0 || scriptlen > IGUANA_MAXSCRIPTSIZE || scriptlen > sizeof(scriptbuf) )
return;
if ( scriptlen > sizeof(scriptbuf) )
maxlen = (scriptlen << 1) + 2048, scriptstr = malloc(maxlen);
else scriptstr = scriptbuf, maxlen = sizeof(scriptbuf);
scriptstr = scriptbuf, maxlen = sizeof(scriptbuf);
init_hexbytes_noT(scriptstr,script,scriptlen);
if ( strcmp(fieldname,"coinbase") == 0 )
jaddstr(dest,"coinbase",scriptstr);

22
iguana/swaps/iguana_BTCswap.c

@ -238,6 +238,11 @@ struct bitcoin_statetx *instantdex_bobtx(struct supernet_info *myinfo,struct bit
int32_t n,secretstart; struct bitcoin_statetx *ptr = 0; uint8_t script[1024],secret[20]; uint32_t locktime; int64_t satoshis; char scriptstr[512];
if ( coin == 0 )
return(0);
if ( bits256_nonz(pub1) == 0 || bits256_nonz(pub2) == 0 )
{
printf("instantdex_bobtx null pub1.%llx or pub2.%llx\n",(long long)pub1.txid,(long long)pub2.txid);
return(0);
}
locktime = (uint32_t)(reftime + INSTANTDEX_LOCKTIME * (1 + depositflag));
calc_rmd160_sha256(secret,priv.bytes,sizeof(priv));
n = instantdex_bobscript(script,0,&secretstart,locktime,pub1,secret,pub2);
@ -331,6 +336,11 @@ struct bitcoin_statetx *instantdex_alicetx(struct supernet_info *myinfo,struct i
int32_t n; uint8_t script[1024]; char scriptstr[2048]; struct bitcoin_statetx *ptr = 0;
if ( altcoin != 0 )
{
if ( bits256_nonz(pubAm) == 0 || bits256_nonz(pubBn) == 0 )
{
printf("instantdex_bobtx null pubAm.%llx or pubBn.%llx\n",(long long)pubAm.txid,(long long)pubBn.txid);
return(0);
}
n = instantdex_alicescript(script,0,msigaddr,altcoin->chain->p2shtype,pubAm,pubBn);
init_hexbytes_noT(scriptstr,script,n);
if ( (ptr= instantdex_signtx(myinfo,altcoin,0,scriptstr,amount,altcoin->txfee,swap->mine.minconfirms,swap->mine.offer.myside)) != 0 )
@ -589,16 +599,16 @@ cJSON *instantdex_parseargjson(struct supernet_info *myinfo,struct exchange_info
{
if ( instantdex_isbob(swap) != 0 )
{
instantdex_swapbits256update(&swap->otherpubs[0],argjson,"pubA0");
instantdex_swapbits256update(&swap->otherpubs[1],argjson,"pubA1");
instantdex_swapbits256update(&swap->otherpubs[0],argjson,"A0");
instantdex_swapbits256update(&swap->otherpubs[1],argjson,"A1");
instantdex_swapbits256update(&swap->pubAm,argjson,"pubAm");
instantdex_swapbits256update(&swap->privAm,argjson,"privAm");
swap->havestate |= instantdex_swaptxupdate(&swap->altpayment,argjson,"altpayment","altpaymenttxid");
}
else
{
instantdex_swapbits256update(&swap->otherpubs[0],argjson,"pubB0");
instantdex_swapbits256update(&swap->otherpubs[1],argjson,"pubB1");
instantdex_swapbits256update(&swap->otherpubs[0],argjson,"B0");
instantdex_swapbits256update(&swap->otherpubs[1],argjson,"B1");
instantdex_swapbits256update(&swap->pubBn,argjson,"pubBn");
instantdex_swapbits256update(&swap->privBn,argjson,"privBn");
swap->havestate |= instantdex_swaptxupdate(&swap->deposit,argjson,"deposit","deposittxid");
@ -1121,9 +1131,13 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta
jaddstr(newjson,"altpayment",swap->altpayment->txbytes);
printf("add altpayment.(%s) have.%x\n",swap->altpayment->txbytes,swap->havestate);
}
jaddbits256(newjson,"A0",swap->mypubs[0]);
jaddbits256(newjson,"A1",swap->mypubs[1]);
}
else
{
jaddbits256(newjson,"B0",swap->mypubs[0]);
jaddbits256(newjson,"B1",swap->mypubs[1]);
if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEDEPOSIT) == 0 && swap->deposit != 0 )
{
jaddbits256(newjson,"deposittxid",swap->deposit->txid);

Loading…
Cancel
Save