Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
c1d31fe8fa
  1. 21
      basilisk/basilisk_bitcoin.c
  2. 2
      basilisk/basilisk_swap.c
  3. 8
      iguana/iguana_unspents.c

21
basilisk/basilisk_bitcoin.c

@ -979,7 +979,7 @@ HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr)
int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,uint8_t *spendscript,int16_t hdrsi,uint32_t unspentind,int64_t value)
{
struct basilisk_unspent *bu; int32_t i,spendlen; struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2;
struct basilisk_unspent *bu; int32_t i,spendlen; struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2; char str[65];
memset(txidp,0,sizeof(*txidp));
*voutp = -1;
portable_mutex_lock(&myinfo->bu_mutex);
@ -990,14 +990,17 @@ int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *co
for (i=0; i<waddr->numunspents; i++)
{
bu = &waddr->unspents[i];
if ( bu->status == 0 && bu->hdrsi == hdrsi && bu->unspentind == unspentind && bu->value == value )
if ( bu->hdrsi == hdrsi && bu->unspentind == unspentind && bu->value == value )
{
*txidp = bu->txid;
*voutp = bu->vout;
memcpy(spendscript,bu->script,bu->spendlen);
spendlen = bu->spendlen;
portable_mutex_unlock(&myinfo->bu_mutex);
return(spendlen);
if ( bu->status == 0 )
{
*txidp = bu->txid;
*voutp = bu->vout;
memcpy(spendscript,bu->script,bu->spendlen);
spendlen = bu->spendlen;
portable_mutex_unlock(&myinfo->bu_mutex);
return(spendlen);
} else printf("unspentfind skip %s/v%d\n",bits256_str(str,bu->txid),bu->vout);
}
}
}
@ -1009,7 +1012,7 @@ int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *co
void basilisk_unspent_update(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *item,int32_t spentheight,int32_t relayid,int32_t RTheight)
{
//{"txid":"4814dc8a357f93f16271eb43806a69416ec41ab1956b128d170402b0a1b37c7f","vout":2,"address":"RSyKVKNxrSDc1Vwvh4guYb9ZDEpvMFz2rm","scriptPubKey":"76a914c210f6711e98fe9971757ede2b2dcb0507f3f25e88ac","amount":9.99920000,"timestamp":1466684518,"height":1160306,"confirmations":22528,"checkind":1157,"spent":{"hdrsi":2320,"pkind":168,"unspentind":1157,"prevunspentind":0,"satoshis":"999920000","txidind":619,"vout":2,"type":2,"fileid":0,"scriptpos":0,"scriptlen":25},"spentheight":1161800,"dest":{"error":"couldnt find spent info"}}
int32_t i,n,j,m,already_spent=0; struct basilisk_unspent bu,bu2; char *address,*script,*destaddr,str[65]; struct iguana_waccount *wacct; struct iguana_waddress *waddr; cJSON *dest,*vouts,*vitem; double ratio;
int32_t i,n,j,m,already_spent=0; struct basilisk_unspent bu,bu2; char *address,*script,*destaddr; struct iguana_waccount *wacct; struct iguana_waddress *waddr; cJSON *dest,*vouts,*vitem; double ratio;
if ( (address= jstr(item,"address")) != 0 && (script= jstr(item,"scriptPubKey")) != 0 && (waddr= iguana_waddresssearch(myinfo,&wacct,address)) != 0 )
{
if ( relayid >= 64 )

2
basilisk/basilisk_swap.c

@ -897,7 +897,7 @@ void basilisk_swaploop(void *_swap)
data = malloc(maxlen);
while ( time(NULL) < swap->expiration )
{
fprintf(stderr,"swapstate.%x\n",swap->statebits);
fprintf(stderr,"r%u/q%u swapstate.%x\n",swap->req.requestid,swap->req.quoteid,swap->statebits);
if ( (swap->statebits & 0x01) == 0 ) // send pubkeys
{
datalen = basilisk_swapdata_deck(myinfo,swap,data,maxlen);

8
iguana/iguana_unspents.c

@ -510,7 +510,7 @@ uint8_t *iguana_rmdarray(struct supernet_info *myinfo,struct iguana_info *coin,i
int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *totalp,int64_t *unspents,int32_t max,int64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr)
{
int64_t total,sum = 0; int32_t i,n,numunspents,numaddrs; uint8_t addrtype,pubkey[65],rmd160[20]; char *coinaddr; struct iguana_waddress *waddr; struct iguana_waccount *wacct; struct basilisk_unspent *bu;
int64_t total,sum = 0; int32_t i,n,j,r,numunspents,numaddrs; uint8_t addrtype,pubkey[65],rmd160[20]; char *coinaddr,str[65]; struct iguana_waddress *waddr; struct iguana_waccount *wacct; struct basilisk_unspent *bu;
*totalp = 0;
if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 )
{
@ -541,8 +541,10 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
{
if ( (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 )
{
for (i=0; i<waddr->numunspents; i++)
r = (rand() % waddr->numunspents);
for (j=0; j<waddr->numunspents; j++)
{
i = ((j + r) % waddr->numunspents);
bu = &waddr->unspents[i];
if ( bu->status == 0 )
{
@ -552,7 +554,7 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
bu->status = 1;
unspents++;
numunspents++;
}
} else printf("skip pending txid.%s/v%d\n",bits256_str(str,bu->txid),bu->vout);
}
}
}

Loading…
Cancel
Save