Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
7e2a86eec8
  1. 59
      basilisk/basilisk_bitcoin.c
  2. 2
      iguana/iguana_unspents.c
  3. 1
      includes/iguana_funcs.h
  4. 2
      includes/iguana_structs.h

59
basilisk/basilisk_bitcoin.c

@ -1009,6 +1009,31 @@ int32_t basilisk_unspentfind(struct supernet_info *myinfo,struct iguana_info *co
return(-1);
}
struct basilisk_spend *basilisk_addspend(struct supernet_info *myinfo,char *symbol,bits256 txid,uint16_t vout)
{
int32_t i; struct basilisk_spend *s;
// mutex
for (i=0; i<myinfo->numspends; i++)
{
if ( myinfo->spends[i].vout == vout && bits256_cmp(txid,myinfo->spends[i].txid) == 0 )
break;
}
if ( i == myinfo->numspends )
{
myinfo->spends = realloc(myinfo->spends,sizeof(*myinfo->spends) * (myinfo->numspends+1));
s = &myinfo->spends[myinfo->numspends++];
memset(s,0,sizeof(*s));
s->txid = txid;
s->vout = vout;
strcpy(s->symbol,symbol);
char str[65]; printf("ADDSPEND.%s %s/v%d\n",symbol,bits256_str(str,txid),vout);
// mutex
return(s);
}
// mutex
return(0);
}
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"}}
@ -1070,17 +1095,20 @@ void basilisk_unspent_update(struct supernet_info *myinfo,struct iguana_info *co
}
waddr->numunspents++;
printf("new unspent.%s %d script.%p [%d]\n",waddr->coinaddr,waddr->numunspents,bu.script,bu.spendlen);
if ( spentheight != 0 && (dest= jobj(item,"dest")) != 0 )
}
waddr->unspents[i] = bu;
if ( i == n && bu.spentheight != 0 && (dest= jobj(item,"dest")) != 0 )
{
struct basilisk_spend s;
struct basilisk_spend *s;
//{"txid":"cd4fb72f871d481c534f15d7f639883958936d49e965f58276f0925798e762df","vin":1,"height":<spentheight>,"unspentheight":<bu.height>,"relays":2}},
s.vini = jint(dest,"vin");
strcpy(s.symbol,coin->symbol);
s.txid = jbits256(dest,"spentfrom");
s.height = spentheight;
s.timestamp = juint(dest,"timestamp");
s.unspentheight = bu.height;
s.relaymask = bu.relaymask;
if ( (s= basilisk_addspend(myinfo,coin->symbol,bu.txid,bu.vout)) != 0 )
{
s->spentfrom = jbits256(dest,"spentfrom");
s->vini = jint(dest,"vin");
s->height = bu.spentheight;
s->timestamp = juint(dest,"timestamp");
s->unspentheight = bu.height;
s->relaymask = bu.relaymask;
ratio = jdouble(dest,"ratio");
if ( (vouts= jobj(dest,"vouts")) != 0 && (m= cJSON_GetArraySize(vouts)) > 0 )
{
@ -1089,19 +1117,16 @@ void basilisk_unspent_update(struct supernet_info *myinfo,struct iguana_info *co
vitem = jitem(vouts,j);
if ( (destaddr= jfieldname(vitem)) != 0 )
{
safecopy(s.destaddr,destaddr,sizeof(s.destaddr));
s.ismine = (iguana_waddresssearch(myinfo,&wacct,destaddr) != 0);
s.value = jdouble(vitem,jfieldname(vitem)) * SATOSHIDEN;
printf("(%s %.8f) ",s.destaddr,dstr(s.value));
myinfo->spends = realloc(myinfo->spends,sizeof(*myinfo->spends) * (myinfo->numspends+1));
myinfo->spends[myinfo->numspends++] = s;
safecopy(s->destaddr,destaddr,sizeof(s->destaddr));
s->ismine = (iguana_waddresssearch(myinfo,&wacct,destaddr) != 0);
s->value = jdouble(vitem,jfieldname(vitem)) * SATOSHIDEN;
printf("(%s %.8f) ",s->destaddr,dstr(s->value));
}
}
char str[65]; printf("dest.(%s) ratio %.8f (%s/v%d)\n",jprint(dest,0),ratio,bits256_str(str,s.txid),s.vini);
char str[65]; printf("SPEND dest.(%s) ratio %.8f (%s/v%d)\n",jprint(dest,0),ratio,bits256_str(str,s->txid),s->vini);
}
}
}
waddr->unspents[i] = bu;
}
}

2
iguana/iguana_unspents.c

@ -551,7 +551,7 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
unspents[0] = ((uint64_t)bu->hdrsi << 32) | bu->unspentind;
unspents[1] = bu->value;
sum += bu->value;
bu->status = 1;
basilisk_addspend(myinfo,coin->symbol,bu->txid,bu->vout);
unspents++;
numunspents++;
} else printf("skip pending txid.%s/v%d\n",bits256_str(str,bu->txid),bu->vout);

1
includes/iguana_funcs.h

@ -414,6 +414,7 @@ cJSON *iguana_unspentjson(struct supernet_info *myinfo,struct iguana_info *coin,
int32_t bitcoin_standardspend(uint8_t *script,int32_t n,uint8_t rmd160[20]);
struct iguana_waddress *iguana_waddresssearch(struct supernet_info *myinfo,struct iguana_waccount **wacctp,char *coinaddr);
void calc_shares(struct supernet_info *myinfo,uint8_t *shares,uint8_t *secret,int32_t size,int32_t width,int32_t M,int32_t N,uint8_t *sharenrs,uint8_t *space,int32_t spacesize);
struct basilisk_spend *basilisk_addspend(struct supernet_info *myinfo,char *symbol,bits256 txid,uint16_t vout);
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);
int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,cJSON *txids,cJSON *vouts,cJSON *unspents,cJSON *spends,char *coinaddr,int32_t minconf,int32_t firstheight);
cJSON *iguana_walletjson(struct supernet_info *myinfo);

2
includes/iguana_structs.h

@ -364,7 +364,7 @@ struct iguana_bundlereq
struct iguana_bitmap { int32_t width,height,amplitude; char name[52]; uint8_t data[IGUANA_WIDTH*IGUANA_HEIGHT*3]; };
struct basilisk_spend { bits256 txid; uint64_t relaymask,value; uint32_t timestamp; int32_t vini,height,unspentheight,ismine; char destaddr[64],symbol[16]; };
struct basilisk_spend { bits256 txid,spentfrom; uint64_t relaymask,value; uint32_t timestamp; int32_t vini,vout,height,unspentheight,ismine; char destaddr[64],symbol[16]; };
struct basilisk_unspent { bits256 txid; uint64_t value,relaymask; uint32_t unspentind,timestamp; int32_t RTheight,height,spentheight; int16_t status,hdrsi,vout,spendlen; char symbol[16]; uint8_t script[256]; };

Loading…
Cancel
Save