Browse Source

test

etomic
jl777 8 years ago
parent
commit
0a7c8d7c5f
  1. 1
      basilisk/basilisk.h
  2. 10
      basilisk/basilisk_DEX.c
  3. 3
      basilisk/basilisk_MSG.c
  4. 38
      iguana/iguana_payments.c

1
basilisk/basilisk.h

@ -142,5 +142,6 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp);
int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swap *swap,int32_t depositflag,int32_t genflag);
void basilisk_txlog(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,int32_t delay);
int32_t basilisk_messagekey(uint8_t *key,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash);
cJSON *basilisk_unspents(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
#endif

10
basilisk/basilisk_DEX.c

@ -558,10 +558,9 @@ ZERO_ARGS(InstantDEX,allcoins)
return(jprint(retjson,1));
}
cJSON *basilisk_unspents(struct supernet_info *myinfo,struct iguana_info *coin)
cJSON *basilisk_unspents(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr)
{
cJSON *unspents=0,*array=0; char *retstr,coinaddr[64];
bitcoin_address(coinaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
cJSON *unspents=0,*array=0; char *retstr;
if ( coin->FULLNODE > 0 )
{
array = cJSON_CreateArray();
@ -583,12 +582,13 @@ cJSON *basilisk_unspents(struct supernet_info *myinfo,struct iguana_info *coin)
STRING_ARG(InstantDEX,available,source)
{
uint64_t total = 0; int32_t i,n=0; cJSON *item,*unspents,*retjson = 0;
uint64_t total = 0; int32_t i,n=0; char coinaddr[64]; cJSON *item,*unspents,*retjson = 0;
if ( source != 0 && source[0] != 0 && (coin= iguana_coinfind(source)) != 0 )
{
if ( myinfo->expiration != 0 )
{
if ( (unspents= basilisk_unspents(myinfo,coin)) != 0 )
bitcoin_address(coinaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
if ( (unspents= basilisk_unspents(myinfo,coin,coinaddr)) != 0 )
{
//printf("available.(%s)\n",jprint(unspents,0));
if ( (n= cJSON_GetArraySize(unspents)) > 0 )

3
basilisk/basilisk_MSG.c

@ -335,10 +335,9 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 srchash,bits25
jaddnum(valsobj,"timeout",1000);
jaddbits256(valsobj,"srchash",srchash);
jaddbits256(valsobj,"desthash",desthash);
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS);
//char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS);
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,desthash,valsobj,hexstr)) != 0 )
free(retstr);
printf("message sent\n");
free_json(valsobj);
if ( ptr != 0 )
free(ptr);

38
iguana/iguana_payments.c

@ -403,16 +403,46 @@ uint64_t iguana_interests(struct supernet_info *myinfo,struct iguana_info *coin,
char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,cJSON *txobj,int64_t satoshis,char *changeaddr,int64_t txfee,cJSON *addresses,int32_t minconf,uint8_t *opreturn,int32_t oplen,int64_t burnamount,char *remoteaddr,struct vin_info *V,int32_t maxmode)
{
uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t allocflag=0,max,num,spendlen; char *rawtx=0; bits256 txid; cJSON *vins=0; uint64_t avail,total,change; struct iguana_outpoint *unspents = 0;
uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; char *coinaddr; int32_t allocflag=0,max,i,j,m,n,num,spendlen; char *spendscriptstr,*rawtx=0; bits256 txid; cJSON *vins=0,*array,*item; uint64_t value,avail=0,total,change; struct iguana_outpoint *unspents = 0;
*vinsp = 0;
max = 10000;
max = 0;//10000;
satoshis += burnamount;
unspents = calloc(max,sizeof(*unspents));
if ( (n= cJSON_GetArraySize(addresses)) == 0 )
return(0);
for (i=0; i<n; i++)
{
coinaddr = jstri(addresses,i);
if ( (array= basilisk_unspents(myinfo,coin,coinaddr)) != 0 )
{
printf("unspents.(%s)\n",jprint(array,0));
if ( (m= cJSON_GetArraySize(array)) > 0 )
{
for (j=0; j<m; j++)
{
item = jitem(array,j);
if ( coin->FULLNODE != 0 && is_cJSON_False(jobj(item,"spendable")) != 0 )
continue;
if ( (spendscriptstr= jstr(item,"scriptPubKey")) == 0 )
{
printf("no spendscriptstr.(%s)\n",jprint(item,0));
continue;
}
unspents = realloc(unspents,(1 + max) * sizeof(*unspents));
value = jdouble(item,"amount") * SATOSHIDEN;
iguana_outptset(myinfo,coin,&unspents[max++],jbits256(item,"txid"),jint(item,"vout"),value,spendscriptstr);
avail += value;
}
}
free_json(array);
}
}
num = max;
/*unspents = calloc(max,sizeof(*unspents));
if ( (num= iguana_RTunspentslists(myinfo,coin,&avail,unspents,max,satoshis+txfee,minconf,addresses,remoteaddr)) <= 0 )
{
free(unspents);
return(0);
}
}*/
printf("avail %.8f satoshis %.8f, txfee %.8f burnamount %.8f vin0.scriptlen %d\n",dstr(avail),dstr(satoshis),dstr(txfee),dstr(burnamount),unspents[0].spendlen);
if ( txobj != 0 && avail >= satoshis+txfee )
{

Loading…
Cancel
Save