Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
cc877bf88c
  1. 2
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk.h
  3. 4
      basilisk/basilisk_CMD.c
  4. 44
      basilisk/basilisk_bitcoin.c
  5. 26
      basilisk/basilisk_swap.c
  6. 7
      iguana/iguana_payments.c
  7. 7
      iguana/iguana_unspents.c
  8. 2
      includes/iguana_apideclares.h
  9. 1
      includes/iguana_funcs.h

2
basilisk/basilisk.c

@ -588,7 +588,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{ (void *)"END", &basilisk_respond_VPNlogout }, // logout { (void *)"END", &basilisk_respond_VPNlogout }, // logout
// coin services // coin services
{ (void *)"RAW", &basilisk_respond_rawtx }, //{ (void *)"RAW", &basilisk_respond_rawtx },
{ (void *)"VAL", &basilisk_respond_value }, { (void *)"VAL", &basilisk_respond_value },
{ (void *)"BAL", &basilisk_respond_balances }, { (void *)"BAL", &basilisk_respond_balances },
}; };

2
basilisk/basilisk.h

@ -130,5 +130,7 @@ void basilisk_request_goodbye(struct supernet_info *myinfo);
int32_t basilisk_update(char *symbol,uint32_t reftimestamp); int32_t basilisk_update(char *symbol,uint32_t reftimestamp);
void basilisk_seqresult(struct supernet_info *myinfo,char *retstr); void basilisk_seqresult(struct supernet_info *myinfo,char *retstr);
struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbol,char *chainname,cJSON *valsobj); struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbol,char *chainname,cJSON *valsobj);
void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn);
void basilisk_rawtx_setparms(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,struct iguana_info *coin,int32_t numconfirms,int32_t vintype,uint64_t satoshis,int32_t vouttype,uint8_t *pubkey33);
#endif #endif

4
basilisk/basilisk_CMD.c

@ -181,7 +181,7 @@ char *basilisk_respond_VPNmessage(struct supernet_info *myinfo,char *CMD,void *a
return(retstr); return(retstr);
} }
char *basilisk_respond_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) /*char *basilisk_respond_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{ {
char *symbol,*retstr=0; struct basilisk_item Lptr,*ptr; int32_t timeoutmillis; struct iguana_info *coin = 0; char *symbol,*retstr=0; struct basilisk_item Lptr,*ptr; int32_t timeoutmillis; struct iguana_info *coin = 0;
timeoutmillis = jint(valsobj,"timeout"); timeoutmillis = jint(valsobj,"timeout");
@ -193,7 +193,7 @@ char *basilisk_respond_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,c
ptr->finished = (uint32_t)time(NULL); ptr->finished = (uint32_t)time(NULL);
} else retstr = clonestr("{\"error\":\"no coin specified or error bitcoinrawtx\"}"); } else retstr = clonestr("{\"error\":\"no coin specified or error bitcoinrawtx\"}");
return(retstr); return(retstr);
} }*/
char *basilisk_respond_value(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) char *basilisk_respond_value(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{ {

44
basilisk/basilisk_bitcoin.c

@ -477,9 +477,9 @@ int32_t basilisk_vins_validate(struct supernet_info *myinfo,struct iguana_info *
return(retval); return(retval);
} }
void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{ {
uint8_t buf[4096]; int32_t oplen,offset,numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount;
vins = 0; vins = 0;
changeaddr = jstr(valsobj,"changeaddr"); changeaddr = jstr(valsobj,"changeaddr");
if ( (amount= j64bits(valsobj,"satoshis")) == 0 ) if ( (amount= j64bits(valsobj,"satoshis")) == 0 )
@ -498,14 +498,9 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi
} }
//printf("use addresses.(%s)\n",jprint(addresses,0)); //printf("use addresses.(%s)\n",jprint(addresses,0));
//printf("vals.(%s) change.(%s) spend.%s\n",jprint(valsobj,0),changeaddr,spendscriptstr); //printf("vals.(%s) change.(%s) spend.%s\n",jprint(valsobj,0),changeaddr,spendscriptstr);
if ( changeaddr == 0 || changeaddr[0] == 0 || spendscriptstr == 0 || spendscriptstr[0] == 0 )//|| amount == 0 || addresses == 0 ) if ( changeaddr == 0 || changeaddr[0] == 0 || spendscriptstr == 0 || spendscriptstr[0] == 0 )
{ return(clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}"));
Lptr->retstr = clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}");
return(Lptr);
}
if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 ) if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 )
{
//if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 )
{ {
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion)) != 0 ) if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion)) != 0 )
{ {
@ -529,12 +524,6 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi
rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount,remoteaddr); rawtx = iguana_calcrawtx(myinfo,coin,&vins,txobj,amount,changeaddr,txfee,addresses,minconf,oplen!=0?buf:0,oplen+offset,burnamount,remoteaddr);
printf("generated.(%s) vins.(%s)\n",rawtx!=0?rawtx:"",vins!=0?jprint(vins,0):""); printf("generated.(%s) vins.(%s)\n",rawtx!=0?rawtx:"",vins!=0?jprint(vins,0):"");
} }
else
{
Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx locally\"}");
return(Lptr);
}
} //else rawtx = bitcoin_calcrawtx(myinfo,coin,vinsp,satoshis,spendscriptstr,changeaddr,txfee,addresses,minconf,locktime);
if ( rawtx != 0 ) if ( rawtx != 0 )
{ {
if ( vins != 0 ) if ( vins != 0 )
@ -545,18 +534,17 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi
jaddstr(valsobj,"rawtx",rawtx); jaddstr(valsobj,"rawtx",rawtx);
jaddstr(valsobj,"coin",coin->symbol); jaddstr(valsobj,"coin",coin->symbol);
free(rawtx); free(rawtx);
Lptr->retstr = jprint(valsobj,1); return(jprint(valsobj,1));
return(Lptr);
} else free(rawtx); } else free(rawtx);
} }
if ( txobj != 0 ) if ( txobj != 0 )
free_json(txobj); free_json(txobj);
if ( vins != 0 ) if ( vins != 0 )
free_json(vins); free_json(vins);
Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx\"}"); return(clonestr("{\"error\":\"couldnt create rawtx\"}"));
return(Lptr);
} }
return(basilisk_issueremote(myinfo,0,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF)); return(clonestr("{\"error\":\"dont have coin to create rawtx\"}"));
//return(basilisk_issueremote(myinfo,0,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,0,0,0,0,BASILISK_DEFAULTDIFF));
} }
/* /*
@ -810,7 +798,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1)); return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1));
} }
HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) /*HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
{ {
char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis,i,retval = -1; uint64_t amount,txfee; cJSON *retarray; char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis,i,retval = -1; uint64_t amount,txfee; cJSON *retarray;
//if ( coin == 0 ) //if ( coin == 0 )
@ -867,7 +855,7 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
} }
} }
return(retstr); return(retstr);
} }*/
HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
{ {
@ -1172,16 +1160,26 @@ void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *c
portable_mutex_lock(&myinfo->bu_mutex); portable_mutex_lock(&myinfo->bu_mutex);
if ( (retarray= cJSON_Parse(retstr)) != 0 ) if ( (retarray= cJSON_Parse(retstr)) != 0 )
{ {
printf("%s UNSPENTS_UPDATE.(%s)\n",coin->symbol,retstr);
if ( jobj(retarray,"error") == 0 ) if ( jobj(retarray,"error") == 0 )
{ {
if ( (jstr(retarray,"ipaddr") == 0 || strcmp(jstr(retarray,"ipaddr"),myinfo->ipaddr) != 0) && (n= cJSON_GetArraySize(retarray)) > 0 ) if ( (jstr(retarray,"ipaddr") == 0 || strcmp(jstr(retarray,"ipaddr"),myinfo->ipaddr) != 0) && (n= cJSON_GetArraySize(retarray)) > 0 )
{ {
printf("n.%d GOT.(%s)\n",n,jprint(retarray,0));
for (i=0; i<n; i++) for (i=0; i<n; i++)
basilisk_relay_unspentsprocess(myinfo,coin,jitem(retarray,i)); basilisk_relay_unspentsprocess(myinfo,coin,jitem(retarray,i));
} else basilisk_relay_unspentsprocess(myinfo,coin,retarray); } else basilisk_relay_unspentsprocess(myinfo,coin,retarray);
if ( 0 )
{
bits256 pubAm,pubBn; struct basilisk_rawtx test; struct basilisk_swap swap;
memset(&swap,0,sizeof(swap));
printf("create alicepayment\n");
swap.alicecoin = iguana_coinfind("BTCD");
swap.alicesatoshis = 100000;
basilisk_rawtx_setparms("alicepayment",myinfo,&swap,&test,swap.alicecoin,swap.aliceconfirms,0,swap.alicesatoshis,2,0);
basilisk_alicepayment(myinfo,swap.alicecoin,&test,pubAm,pubBn);
} }
} }
} else printf("couldnt parse.(%s)\n",retstr);
if ( retarray != 0 ) if ( retarray != 0 )
free_json(retarray); free_json(retarray);
free(retstr); free(retstr);

26
basilisk/basilisk_swap.c

@ -526,7 +526,7 @@ int32_t basilisk_rawtx_return(struct supernet_info *myinfo,struct basilisk_rawtx
return(retval); return(retval);
} }
int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf) int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf)
{ {
struct iguana_waddress *waddr; struct iguana_waccount *wacct; char coinaddr[64],wifstr[64],*retstr,scriptstr[1024]; uint32_t basilisktag; int32_t flag,i,n,retval = -1; cJSON *valsobj,*retarray=0,*privkeyarray,*addresses; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char coinaddr[64],wifstr[64],*retstr,scriptstr[1024]; uint32_t basilisktag; int32_t flag,i,n,retval = -1; cJSON *valsobj,*retarray=0,*privkeyarray,*addresses;
if ( (waddr= iguana_getaccountaddress(myinfo,rawtx->coin,0,0,rawtx->coin->changeaddr,"change")) == 0 ) if ( (waddr= iguana_getaccountaddress(myinfo,rawtx->coin,0,0,rawtx->coin->changeaddr,"change")) == 0 )
@ -560,7 +560,7 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilis
jaddnum(valsobj,"timeout",30000); jaddnum(valsobj,"timeout",30000);
rawtx->locktime = locktime; rawtx->locktime = locktime;
printf("%s locktime.%u\n",rawtx->name,locktime); printf("%s locktime.%u\n",rawtx->name,locktime);
if ( (retstr= basilisk_rawtx(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 ) if ( (retstr= basilisk_bitcoinrawtx(myinfo,rawtx->coin,"",basilisktag,jint(valsobj,"timeout"),valsobj)) != 0 )
{ {
printf("%s got.(%s)\n",str,retstr); printf("%s got.(%s)\n",str,retstr);
flag = 0; flag = 0;
@ -578,7 +578,7 @@ int32_t basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,struct basilis
free(retarray); free(retarray);
} else printf("error parsing.(%s)\n",retstr); } else printf("error parsing.(%s)\n",retstr);
free(retstr); free(retstr);
} else printf("error creating %s feetx\n",swap->iambob != 0 ? "BOB" : "ALICE"); } else printf("error creating %s feetx\n",iambob != 0 ? "BOB" : "ALICE");
free_json(privkeyarray); free_json(privkeyarray);
free_json(valsobj); free_json(valsobj);
printf("rawtx retval.%d\n",retval); printf("rawtx retval.%d\n",retval);
@ -915,7 +915,6 @@ void basilisk_swap01(struct supernet_info *myinfo,struct basilisk_swap *swap,uin
void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
{ {
if ( (rand() % 100) == 0 )
basilisk_swap01(myinfo,swap,data,maxlen); basilisk_swap01(myinfo,swap,data,maxlen);
printf("check for other deck\n"); printf("check for other deck\n");
if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 ) if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 )
@ -925,7 +924,7 @@ void basilisk_swap02(struct supernet_info *myinfo,struct basilisk_swap *swap,uin
void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
{ {
int32_t i,datalen; char str[65]; int32_t i,datalen; char str[65];
if ( (rand() % 10) == 0 ) //if ( (rand() % 10) == 0 )
basilisk_swap02(myinfo,swap,data,maxlen); basilisk_swap02(myinfo,swap,data,maxlen);
datalen = iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei); datalen = iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei);
if ( swap->iambob != 0 ) if ( swap->iambob != 0 )
@ -950,7 +949,7 @@ void basilisk_swap04(struct supernet_info *myinfo,struct basilisk_swap *swap,uin
void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen) void basilisk_swap08(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
{ {
uint8_t pubkey33[33]; char str[65]; uint8_t pubkey33[33]; char str[65];
if ( (rand() % 10) == 0 ) //if ( (rand() % 10) == 0 )
basilisk_swap04(myinfo,swap,data,maxlen); basilisk_swap04(myinfo,swap,data,maxlen);
printf("check otherchoosei\n"); printf("check otherchoosei\n");
if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 ) if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 )
@ -1010,6 +1009,12 @@ void basilisk_swap10(struct supernet_info *myinfo,struct basilisk_swap *swap,uin
swap->statebits |= basilisk_swapsend(myinfo,swap,0x20,data,datalen,0x10); swap->statebits |= basilisk_swapsend(myinfo,swap,0x20,data,datalen,0x10);
} }
void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin,struct basilisk_rawtx *alicepayment,bits256 pubAm,bits256 pubBn)
{
alicepayment->spendlen = basilisk_alicescript(alicepayment->spendscript,0,alicepayment->destaddr,coin->chain->p2shtype,pubAm,pubBn);
basilisk_rawtx_gen("alicepayment",myinfo,0,1,alicepayment,alicepayment->locktime,alicepayment->spendscript,alicepayment->spendlen,coin->chain->txfee,1);
}
void basilisk_swaploop(void *_swap) void basilisk_swaploop(void *_swap)
{ {
uint8_t *data; int32_t i,j,maxlen,datalen; struct supernet_info *myinfo; struct basilisk_swap *swap = _swap; uint8_t *data; int32_t i,j,maxlen,datalen; struct supernet_info *myinfo; struct basilisk_swap *swap = _swap;
@ -1067,8 +1072,8 @@ void basilisk_swaploop(void *_swap)
{ {
swap->bobpayment.spendlen = basilisk_bobscript(swap->bobpayment.spendscript,0,&swap->bobpayment.locktime,&swap->bobpayment.secretstart,swap,0); swap->bobpayment.spendlen = basilisk_bobscript(swap->bobpayment.spendscript,0,&swap->bobpayment.locktime,&swap->bobpayment.secretstart,swap,0);
swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1); swap->bobdeposit.spendlen = basilisk_bobscript(swap->bobdeposit.spendscript,0,&swap->bobdeposit.locktime,&swap->bobdeposit.secretstart,swap,1);
basilisk_rawtx_gen("deposit",myinfo,swap,1,&swap->bobdeposit,swap->bobdeposit.locktime,swap->bobdeposit.spendscript,swap->bobdeposit.spendlen,swap->bobdeposit.coin->chain->txfee,1); basilisk_rawtx_gen("deposit",myinfo,1,1,&swap->bobdeposit,swap->bobdeposit.locktime,swap->bobdeposit.spendscript,swap->bobdeposit.spendlen,swap->bobdeposit.coin->chain->txfee,1);
basilisk_rawtx_gen("payment",myinfo,swap,1,&swap->bobpayment,swap->bobpayment.locktime,swap->bobpayment.spendscript,swap->bobpayment.spendlen,swap->bobpayment.coin->chain->txfee,1); basilisk_rawtx_gen("payment",myinfo,1,1,&swap->bobpayment,swap->bobpayment.locktime,swap->bobpayment.spendscript,swap->bobpayment.spendlen,swap->bobpayment.coin->chain->txfee,1);
if ( swap->bobdeposit.txbytes == 0 || swap->bobdeposit.spendlen == 0 || swap->bobpayment.txbytes == 0 || swap->bobpayment.spendlen == 0 ) if ( swap->bobdeposit.txbytes == 0 || swap->bobdeposit.spendlen == 0 || swap->bobpayment.txbytes == 0 || swap->bobpayment.spendlen == 0 )
{ {
printf("error bob generating deposit.%d or payment.%d\n",swap->bobdeposit.spendlen,swap->bobpayment.spendlen); printf("error bob generating deposit.%d or payment.%d\n",swap->bobdeposit.spendlen,swap->bobpayment.spendlen);
@ -1077,15 +1082,14 @@ void basilisk_swaploop(void *_swap)
} }
else else
{ {
swap->alicepayment.spendlen = basilisk_alicescript(swap->alicepayment.spendscript,0,swap->alicepayment.destaddr,swap->alicepayment.coin->chain->p2shtype,swap->pubAm,swap->pubBn); basilisk_alicepayment(myinfo,swap->alicepayment.coin,&swap->alicepayment,swap->pubAm,swap->pubBn);
basilisk_rawtx_gen("alicepayment",myinfo,swap,1,&swap->alicepayment,swap->alicepayment.locktime,swap->alicepayment.spendscript,swap->alicepayment.spendlen,swap->alicepayment.coin->chain->txfee,1);
if ( swap->alicepayment.txbytes == 0 || swap->alicepayment.spendlen == 0 ) if ( swap->alicepayment.txbytes == 0 || swap->alicepayment.spendlen == 0 )
{ {
printf("error alice generating payment.%d\n",swap->alicepayment.spendlen); printf("error alice generating payment.%d\n",swap->alicepayment.spendlen);
break; break;
} }
} }
if ( basilisk_rawtx_gen("myfee",myinfo,swap,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.spendlen,swap->myfee.coin->chain->txfee,1) == 0 ) if ( basilisk_rawtx_gen("myfee",myinfo,swap->iambob,1,&swap->myfee,0,swap->myfee.spendscript,swap->myfee.spendlen,swap->myfee.coin->chain->txfee,1) == 0 )
swap->statebits |= basilisk_swapdata_rawtxsend(myinfo,swap,0x80,data,maxlen,&swap->myfee,0x40); swap->statebits |= basilisk_swapdata_rawtxsend(myinfo,swap,0x80,data,maxlen,&swap->myfee,0x40);
else else
{ {

7
iguana/iguana_payments.c

@ -190,8 +190,7 @@ int32_t iguana_bestunspent(struct supernet_info *myinfo,struct iguana_info *coin
above = gap; above = gap;
abovei = i; abovei = i;
} }
} } else gap = (value - atx_value);
gap = (value - atx_value);
if ( below == 0 || gap < below ) if ( below == 0 || gap < below )
{ {
below = gap; below = gap;
@ -361,7 +360,7 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
max = 10000; max = 10000;
satoshis += burnamount; satoshis += burnamount;
unspents = calloc(max,sizeof(*unspents)); unspents = calloc(max,sizeof(*unspents));
if ( (num= iguana_unspentslists(myinfo,coin,&avail,unspents,max,satoshis,minconf,addresses,remoteaddr)) <= 0 ) if ( (num= iguana_unspentslists(myinfo,coin,&avail,unspents,max,satoshis+txfee,minconf,addresses,remoteaddr)) <= 0 )
{ {
free(unspents); free(unspents);
return(0); return(0);
@ -468,7 +467,7 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
jaddnum(valsobj,"timeout",30000); jaddnum(valsobj,"timeout",30000);
if ( comment != 0 && is_hexstr(comment,0) > 0 ) if ( comment != 0 && is_hexstr(comment,0) > 0 )
jaddstr(valsobj,"opreturn",comment); jaddstr(valsobj,"opreturn",comment);
if ( (retstr= basilisk_rawtx(myinfo,coin,0,0,myinfo->myaddr.persistent,valsobj,"")) != 0 ) if ( (retstr= basilisk_bitcoinrawtx(myinfo,coin,remoteaddr,basilisktag,jint(valsobj,"timeout"),valsobj)) != 0 )
{ {
if ( (retjson= cJSON_Parse(retstr)) != 0 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
{ {

7
iguana/iguana_unspents.c

@ -23,14 +23,14 @@
int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind) int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind)
{ {
struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T,*t; struct iguana_ramchaindata *rdata=0; struct iguana_bundle *bp=0; struct iguana_unspent *U,*u; struct iguana_txid *T,*t;
*voutp = *spentheightp = -1; *voutp = *spentheightp = -1;
memset(txidp,0,sizeof(*txidp)); memset(txidp,0,sizeof(*txidp));
if ( hdrsi < coin->bundlescount-1 ) if ( hdrsi < coin->bundlescount-1 )
rdata = coin->RTramchain.H.data; rdata = coin->RTramchain.H.data;
else if ( (bp= coin->bundles[hdrsi]) != 0 ) else if ( (bp= coin->bundles[hdrsi]) != 0 )
rdata = bp->ramchain.H.data; rdata = bp->ramchain.H.data;
if ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents ) while ( rdata != 0 && unspentind > 0 && unspentind < rdata->numunspents )
{ {
U = RAMCHAIN_PTR(rdata,Uoffset); U = RAMCHAIN_PTR(rdata,Uoffset);
u = &U[unspentind]; u = &U[unspentind];
@ -46,6 +46,9 @@ int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *
return(0); return(0);
} }
} }
else if ( bp == 0 && (bp= coin->bundles[hdrsi]) != 0 )
rdata = bp->ramchain.H.data;
else break;
} }
return(-1); return(-1);
} }

2
includes/iguana_apideclares.h

@ -28,7 +28,7 @@ HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr); //HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr);

1
includes/iguana_funcs.h

@ -474,6 +474,7 @@ void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct
cJSON *bitcoin_data2json(struct iguana_info *coin,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len); cJSON *bitcoin_data2json(struct iguana_info *coin,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len);
int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind); int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,int16_t hdrsi,uint32_t unspentind);
int32_t iguana_unspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind); int32_t iguana_unspent_check(struct supernet_info *myinfo,struct iguana_info *coin,uint16_t hdrsi,uint32_t unspentind);
char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj);
char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V); char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V);
bits256 scrypt_blockhash(const void *input); bits256 scrypt_blockhash(const void *input);

Loading…
Cancel
Save