Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
6dc95cf6bd
  1. 4
      iguana/exchanges/bitcoin.c
  2. 1
      iguana/iguana777.h
  3. 4
      iguana/iguana_accept.c
  4. 2
      iguana/iguana_msg.c
  5. 8
      iguana/iguana_ramchain.c
  6. 29
      iguana/iguana_unspents.c
  7. 4
      iguana/swaps/iguana_BTCswap.c

4
iguana/exchanges/bitcoin.c

@ -1141,7 +1141,7 @@ ffffffff\
cJSON *bitcoin_txtest(struct iguana_info *coin,char *rawtxstr,bits256 txid) cJSON *bitcoin_txtest(struct iguana_info *coin,char *rawtxstr,bits256 txid)
{ {
struct iguana_msgtx msgtx; char str[65],str2[65]; bits256 checktxid,blockhash,signedtxid; struct iguana_msgtx msgtx; char str[65],str2[65]; bits256 checktxid,blockhash,signedtxid;
cJSON *retjson,*txjson; uint8_t *serialized,*serialized2; struct iguana_txid T,*tp; cJSON *retjson,*txjson; uint8_t *serialized,*serialized2; uint32_t firstvout;
struct vin_info *V; char vpnstr[64],*txbytes,*signedtx; int32_t n,txstart,height,n2,maxsize,len; struct vin_info *V; char vpnstr[64],*txbytes,*signedtx; int32_t n,txstart,height,n2,maxsize,len;
rawtxstr = refstr; rawtxstr = refstr;
len = (int32_t)strlen(rawtxstr); len = (int32_t)strlen(rawtxstr);
@ -1174,7 +1174,7 @@ rawtxstr = refstr;
if ( bitcoin_verifytx(coin,&signedtxid,&signedtx,rawtxstr,V) != 0 ) if ( bitcoin_verifytx(coin,&signedtxid,&signedtx,rawtxstr,V) != 0 )
printf("bitcoin_verifytx error\n"); printf("bitcoin_verifytx error\n");
jadd(retjson,"result",txjson); jadd(retjson,"result",txjson);
if ( (tp= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 ) if ( (firstvout= iguana_unspentindfind(coin,&height,txid,0,coin->bundlescount-1)) != 0 )
{ {
if ( height >= 0 ) if ( height >= 0 )
{ {

1
iguana/iguana777.h

@ -901,6 +901,7 @@ void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramc
int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr); int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr);
int32_t iguana_process_msgrequestQ(struct iguana_info *coin); int32_t iguana_process_msgrequestQ(struct iguana_info *coin);
uint32_t iguana_fastfindinit(struct iguana_info *coin); uint32_t iguana_fastfindinit(struct iguana_info *coin);
int32_t iguana_unspentindfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi);
extern int32_t HDRnet,netBLOCKS; extern int32_t HDRnet,netBLOCKS;

4
iguana/iguana_accept.c

@ -249,8 +249,8 @@ int32_t iguana_peerdatarequest(struct iguana_info *coin,struct iguana_peer *addr
int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2) int32_t iguana_peerhdrrequest(struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_peer *addr,bits256 hash2)
{ {
struct iguana_txid *tx,T; int32_t len=0,i,height,retval=-1; struct iguana_block *block; struct iguana_msgblock msgB; bits256 checkhash2; int32_t len=0,i,height,firstvout,retval=-1; struct iguana_block *block; struct iguana_msgblock msgB; bits256 checkhash2;
if ( (tx= iguana_txidfind(coin,&height,&T,hash2,coin->bundlescount-1)) != 0 ) if ( (firstvout= iguana_unspentindfind(coin,&height,hash2,0,coin->bundlescount-1)) != 0 )
{ {
for (i=0; i<coin->chain->bundlesize; i++) for (i=0; i<coin->chain->bundlesize; i++)
{ {

2
iguana/iguana_msg.c

@ -264,7 +264,7 @@ int32_t iguana_send_ping(struct iguana_info *coin,struct iguana_peer *addr)
addr->pingnonce = ((nonce & 0xffffffff) << 32) | ((uint32_t)addr->ipbits & 0xffffffff); addr->pingnonce = ((nonce & 0xffffffff) << 32) | ((uint32_t)addr->ipbits & 0xffffffff);
addr->pingtime = (uint32_t)time(NULL); addr->pingtime = (uint32_t)time(NULL);
} }
printf("pingnonce.%llx from (%s)\n",(long long)nonce,addr->ipaddr); //printf("pingnonce.%llx from (%s)\n",(long long)nonce,addr->ipaddr);
iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0); iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0);
len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce); len = iguana_rwnum(1,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint64_t),&nonce);
if ( addr->supernet != 0 ) if ( addr->supernet != 0 )

8
iguana/iguana_ramchain.c

@ -2318,14 +2318,6 @@ struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana
//printf("mapped bundle.%d\n",bp->bundleheight); //printf("mapped bundle.%d\n",bp->bundleheight);
bp->emitfinish = (uint32_t)time(NULL) + 1; bp->emitfinish = (uint32_t)time(NULL) + 1;
iguana_bundlecalcs(coin,bp,60); iguana_bundlecalcs(coin,bp,60);
/*for (i=1; i<mapchain->H.data->numtxids; i++)
{break;
if ( iguana_txidfind(coin,&height,&tx,T[i].txid) == 0 )
printf("error couldnt find T[%d] %s\n",i,bits256_str(str,T[i].txid));
else if ( memcmp(&tx,&T[i],sizeof(T[i])) != 0 )
printf("compare error T[%d] %s\n",i,bits256_str(str,T[i].txid));
}*/
} }
else else
{ {

29
iguana/iguana_unspents.c

@ -762,6 +762,11 @@ int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 tx
memcpy(&firstvout,&item[sizeof(uint64_t)],sizeof(firstvout)); memcpy(&firstvout,&item[sizeof(uint64_t)],sizeof(firstvout));
memcpy(heightp,&item[sizeof(uint64_t) + sizeof(firstvout)],sizeof(*heightp)); memcpy(heightp,&item[sizeof(uint64_t) + sizeof(firstvout)],sizeof(*heightp));
//printf("i.%d val.%d height.%d firstvout.%d j.%d\n",i,val,*heightp,firstvout,j); //printf("i.%d val.%d height.%d firstvout.%d j.%d\n",i,val,*heightp,firstvout,j);
if ( *heightp >= (lasthdrsi+1)*coin->chain->bundlesize )
{
printf("txidfastfind: unexpected height.%d with lasthdrsi.%d\n",*heightp,lasthdrsi);
return(-1);
}
return(firstvout); return(firstvout);
} }
else if ( 0 ) else if ( 0 )
@ -785,6 +790,21 @@ int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 tx
return(-1); return(-1);
} }
int32_t iguana_unspentindfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi)
{
struct iguana_txid *tp,TX; int32_t firstvout;
if ( coin->fastfind != 0 && (firstvout= iguana_txidfastfind(coin,heightp,txid,lasthdrsi)) >= 0 )
{
return(firstvout + vout);
}
else
{
if ( (tp= iguana_txidfind(coin,heightp,&TX,txid,lasthdrsi)) != 0 )
return(tp->firstvout + vout);
}
return(-1);
}
int32_t iguana_fastfindadd(struct iguana_info *coin,bits256 txid,int32_t height,uint32_t firstvout) int32_t iguana_fastfindadd(struct iguana_info *coin,bits256 txid,int32_t height,uint32_t firstvout)
{ {
FILE *fp; FILE *fp;
@ -901,7 +921,7 @@ int64_t iguana_fastfindcreate(struct iguana_info *coin)
{ {
fclose(coin->fastfps[i]); fclose(coin->fastfps[i]);
sprintf(fname,"DB/%s/fastfind/%02x",coin->symbol,i), OS_compatible_path(fname); sprintf(fname,"DB/%s/fastfind/%02x",coin->symbol,i), OS_compatible_path(fname);
printf("%s\n",fname); //printf("%s\n",fname);
if ( (sortbuf= OS_filestr(&allocsize,fname)) != 0 ) if ( (sortbuf= OS_filestr(&allocsize,fname)) != 0 )
{ {
num = (int32_t)allocsize/sizeof(bits256); num = (int32_t)allocsize/sizeof(bits256);
@ -1045,7 +1065,7 @@ cJSON *iguana_unspentjson(struct iguana_info *coin,int32_t hdrsi,uint32_t unspen
"spendable" : true "spendable" : true
},*/ },*/
//struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind; uint16_t hdrsi:12,type:4,vout; } __attribute__((packed)); //struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind; uint16_t hdrsi:12,type:4,vout; } __attribute__((packed));
struct iguana_waccount *wacct; struct iguana_txid TX; int32_t height,ind; char scriptstr[8192],asmstr[sizeof(scriptstr)+1024]; cJSON *item; struct iguana_waccount *wacct; int32_t height,ind; char scriptstr[8192],asmstr[sizeof(scriptstr)+1024]; cJSON *item; uint32_t checkind;
item = cJSON_CreateObject(); item = cJSON_CreateObject();
jaddbits256(item,"txid",T[up->txidind].txid); jaddbits256(item,"txid",T[up->txidind].txid);
jaddnum(item,"vout",up->vout); jaddnum(item,"vout",up->vout);
@ -1053,8 +1073,11 @@ cJSON *iguana_unspentjson(struct iguana_info *coin,int32_t hdrsi,uint32_t unspen
if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),hdrsi,unspentind,T[up->txidind].txid,up->vout,rmd160,up->type,pubkey33) != 0 ) if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),hdrsi,unspentind,T[up->txidind].txid,up->vout,rmd160,up->type,pubkey33) != 0 )
jaddstr(item,"scriptPubKey",scriptstr); jaddstr(item,"scriptPubKey",scriptstr);
jaddnum(item,"amount",dstr(up->value)); jaddnum(item,"amount",dstr(up->value));
if ( iguana_txidfind(coin,&height,&TX,T[up->txidind].txid,coin->bundlescount-1) != 0 ) if ( (checkind= iguana_unspentindfind(coin,&height,T[up->txidind].txid,up->vout,coin->bundlescount-1)) != 0 )
{
jaddnum(item,"confirmations",coin->longestchain - height); jaddnum(item,"confirmations",coin->longestchain - height);
jaddnum(item,"checkind",checkind);
}
if ( (wacct= iguana_waddressfind(coin,&ind,coinaddr)) != 0 ) if ( (wacct= iguana_waddressfind(coin,&ind,coinaddr)) != 0 )
{ {
jaddstr(item,"account",wacct->account); jaddstr(item,"account",wacct->account);

4
iguana/swaps/iguana_BTCswap.c

@ -593,11 +593,11 @@ double iguana_numconfs(struct iguana_info *coin,bits256 txid,int32_t height)
char *BTC_txconfirmed(struct supernet_info *myinfo,struct iguana_info *coin,struct bitcoin_swapinfo *swap,cJSON *newjson,bits256 txid,double *numconfirmsp,char *virtualevent,double requiredconfs) char *BTC_txconfirmed(struct supernet_info *myinfo,struct iguana_info *coin,struct bitcoin_swapinfo *swap,cJSON *newjson,bits256 txid,double *numconfirmsp,char *virtualevent,double requiredconfs)
{ {
struct iguana_txid *tx,T; int32_t height; char *retstr; double confs; int32_t height,firstvout; char *retstr; double confs;
*numconfirmsp = -1.; *numconfirmsp = -1.;
if ( coin != 0 && *numconfirmsp < 0 ) if ( coin != 0 && *numconfirmsp < 0 )
{ {
if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 && (confs= iguana_numconfs(coin,txid,height)) >= requiredconfs ) if ( (firstvout= iguana_unspentindfind(coin,&height,txid,0,coin->bundlescount-1)) != 0 && (confs= iguana_numconfs(coin,txid,height)) >= requiredconfs )
{ {
*numconfirmsp = confs; *numconfirmsp = confs;
if ( (retstr= instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,virtualevent,myinfo->myaddr.persistent,0,0,0)) != 0 ) if ( (retstr= instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,virtualevent,myinfo->myaddr.persistent,0,0,0)) != 0 )

Loading…
Cancel
Save