Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
bf3ced623c
  1. 15
      iguana/SuperNET.c
  2. 2
      iguana/exchanges777.h
  3. 4
      iguana/iguana_instantdex.c
  4. 14
      iguana/swaps/iguana_BTCswap.c
  5. 1
      includes/iguana_apideclares.h

15
iguana/SuperNET.c

@ -966,6 +966,21 @@ STRING_ARG(SuperNET,addr2rmd160,address)
return(jprint(retjson,1));
}
STRING_ARG(SuperNET,rmd160conv,rmd160)
{
uint8_t rmdbuf[20]; char coinaddr[64],p2shaddr[64]; cJSON *retjson = cJSON_CreateObject();
if ( rmd160 != 0 && strlen(rmd160) == 40 )
{
decode_hex(rmdbuf,20,rmd160);
bitcoin_address(coinaddr,coin->chain->pubtype,rmdbuf,20);
bitcoin_address(p2shaddr,coin->chain->p2shtype,rmdbuf,20);
jaddstr(retjson,"result","success");
jaddstr(retjson,"address",coinaddr);
jaddstr(retjson,"p2sh",p2shaddr);
}
return(jprint(retjson,1));
}
HASH_AND_INT(SuperNET,priv2pub,privkey,addrtype)
{
cJSON *retjson; bits256 pub; uint8_t pubkey[33]; char coinaddr[64],pubkeystr[67];

2
iguana/exchanges777.h

@ -164,7 +164,7 @@ struct bitcoin_swapinfo
struct bitcoin_swapinfo *next,*prev;
queue_t eventsQ; struct bitcoin_eventitem *pollevent;
bits256 privkeys[INSTANTDEX_DECKSIZE+2],mypubs[2],otherpubs[2],privAm,pubAm,privBn,pubBn;
bits256 myorderhash,otherorderhash,mypubkey,othertrader;
bits256 myorderhash,otherorderhash,mypubkey,othertrader,bothorderhash;
uint64_t otherdeck[INSTANTDEX_DECKSIZE][2],deck[INSTANTDEX_DECKSIZE][2];
uint64_t altsatoshis,BTCsatoshis,insurance,altinsurance;
int32_t choosei,otherchoosei,cutverified,otherverifiedcut,numpubs,havestate,otherhavestate;

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;
struct bitcoin_swapinfo *swap = 0; struct iguana_info *coinbtc,*altcoin; int32_t i;
swap = calloc(1,sizeof(struct bitcoin_swapinfo));
swap->state = instantdex_statefind(BTC_states,BTC_numstates,statename);
swap->mine = *myap, swap->other = *otherap;
@ -1149,6 +1149,8 @@ struct bitcoin_swapinfo *bitcoin_swapinit(struct supernet_info *myinfo,struct ex
strcpy(swap->status,"pending");
vcalc_sha256(0,swap->myorderhash.bytes,(void *)&swap->mine.offer,sizeof(swap->mine.offer));
vcalc_sha256(0,swap->otherorderhash.bytes,(void *)&swap->other.offer,sizeof(swap->other.offer));
for (i=0; i<4; i++)
swap->bothorderhash.ulongs[i] = (swap->myorderhash.ulongs[i] ^ swap->otherorderhash.ulongs[i]);
swap->mypubkey = myinfo->myaddr.persistent;
swap->othertrader = jbits256(argjson,"traderpub");
swap->altsatoshis = myap->offer.basevolume64;

14
iguana/swaps/iguana_BTCswap.c

@ -443,13 +443,12 @@ int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapin
//printf("i.%d n.%d numpubs.%d %02x vs %02x\n",i,n,numpubs,pubkey[0],firstbyte);
if ( pubkey[0] != firstbyte )
continue;
if ( n < 2 && numpubs > 2 )
if ( n < 2 )
{
sprintf(buf+1,"%d",n);
if ( jobj(newjson,buf) == 0 )
jaddbits256(newjson,buf,pubi);
if ( bits256_nonz(swap->mypubs[n]) == 0 )
memcpy(swap->mypubs[n].bytes,pubkey+1,sizeof(bits256));
}
else if ( swap->numpubs < INSTANTDEX_DECKSIZE )
if ( swap->numpubs < INSTANTDEX_DECKSIZE )
{
calc_rmd160_sha256(secret160,swap->privkeys[n].bytes,sizeof(swap->privkeys[n]));
memcpy(&txid,secret160,sizeof(txid));
@ -1079,7 +1078,7 @@ void instantdex_eventfree(struct bitcoin_eventitem *ptr)
char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numstates,struct supernet_info *myinfo,struct exchange_info *exchange,struct bitcoin_swapinfo *swap,char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen)
{
uint32_t i,j; struct iguana_info *altcoin=0,*coinbtc=0; struct instantdex_stateinfo *state=0;
uint32_t i; struct iguana_info *altcoin=0,*coinbtc=0; struct instantdex_stateinfo *state=0;
if ( swap == 0 || (state= swap->state) == 0 || (coinbtc= iguana_coinfind("BTC")) == 0 || (altcoin= iguana_coinfind(swap->mine.offer.base)) == 0 )
{
printf("state.%s btc.%p altcoin.%p (%s)\n",state->name,coinbtc,altcoin,swap->mine.offer.base);
@ -1164,9 +1163,6 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta
jaddbits256(newjson,"pubBn",swap->pubBn);
if ( bits256_nonz(swap->privBn) != 0 )
jaddbits256(newjson,"privn",swap->privBn);
for (j=0; j<2; j++)
if ( bits256_nonz(swap->mypubs[j]) == 0 )
swap->mypubs[j] = rand256(0);
if ( instantdex_isbob(swap) == 0 )
{
if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEALTPAYMENT) == 0 && swap->altpayment != 0 && jobj(newjson,"altpayment") == 0 )

1
includes/iguana_apideclares.h

@ -190,6 +190,7 @@ HASH_AND_INT(SuperNET,priv2pub,privkey,addrtype);
STRING_ARG(SuperNET,wif2priv,wif);
STRING_ARG(SuperNET,priv2wif,priv);
STRING_ARG(SuperNET,addr2rmd160,address);
STRING_ARG(SuperNET,rmd160conv,rmd160);
TWOHASHES_AND_STRING(SuperNET,cipher,privkey,destpubkey,message);
TWOHASHES_AND_STRING(SuperNET,decipher,privkey,srcpubkey,cipherstr);

Loading…
Cancel
Save