Browse Source

set script in all paths

release/v0.1
jl777 9 years ago
parent
commit
28dbdbc60d
  1. 2
      iguana/iguana_payments.c
  2. 6
      iguana/iguana_peers.c
  3. 42
      iguana/iguana_unspents.c
  4. 1
      iguana/tests/rawtx5
  5. 6
      includes/iguana_defines.h
  6. 6
      includes/iguana_structs.h

2
iguana/iguana_payments.c

@ -381,7 +381,7 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
free(unspents);
return(0);
}
printf("avail %.8f satoshis %.8f, txfee %.8f burnamount %.8f\n",dstr(avail),dstr(satoshis),dstr(txfee),dstr(burnamount));
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 )
{
if ( (vins= iguana_RTinputsjson(myinfo,coin,&total,satoshis + txfee,unspents,num)) != 0 )

6
iguana/iguana_peers.c

@ -1188,7 +1188,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
ipbits = (uint32_t)addr->ipbits;
vcalc_sha256(0,addr->iphash.bytes,(uint8_t *)&ipbits,sizeof(ipbits));
//char str[65]; printf("start dedicatedloop.%s addrind.%d %s\n",addr->ipaddr,addr->addrind,bits256_str(str,addr->iphash));
addr->maxfilehash2 = IGUANA_MAXFILEITEMS;
//addr->maxfilehash2 = IGUANA_MAXFILEITEMS;
bufsize = IGUANA_MAXPACKETSIZE;
if ( addr->blockspace == 0 )
addr->blockspace = mycalloc('r',1,bufsize + 8192);
@ -1311,8 +1311,8 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
}
iguana_iAkill(coin,addr,addr->dead != 0);
myfree(buf,bufsize);
if ( addr->filehash2 != 0 )
myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0;
//if ( addr->filehash2 != 0 )
// myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0;
if ( 0 )
{
iguana_mempurge(&addr->RAWMEM);

42
iguana/iguana_unspents.c

@ -380,6 +380,33 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua
else return(bundleheight);
}
int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout)
{
char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t rmd160[20],pubkey33[33];
memset(outpt,0,sizeof(*outpt));
outpt->txid = txid;
outpt->vout = vout;
outpt->hdrsi = hdrsi;
outpt->isptr = 0;
outpt->unspentind = unspentind;
outpt->value = u->value;
memset(rmd160,0,sizeof(rmd160));
memset(pubkey33,0,sizeof(pubkey33));
if ( iguana_scriptget(coin,scriptstr,0,sizeof(scriptstr),outpt->hdrsi,outpt->unspentind,outpt->txid,outpt->vout,rmd160,u->type,pubkey33) != 0 )
{
outpt->spendlen = (int32_t)strlen(scriptstr) >> 1;
if ( outpt->spendlen < sizeof(outpt->spendscript) )
decode_hex(outpt->spendscript,outpt->spendlen,scriptstr);
else
{
outpt->spendlen = 0;
printf("error scriptstr.(%s) is too big for %d\n",scriptstr,(int32_t)sizeof(outpt->spendscript));
return(-1);
}
}
return(0);
}
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20])
{
int64_t deposits,crypto777_payment; struct iguana_outpoint lastpt; uint32_t unspentind; int32_t i,j,num,uheight; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P,p; struct iguana_unspent *U,*u; struct iguana_txid *T,*tx;
@ -438,6 +465,13 @@ int32_t iguana_RTscanunspents(struct supernet_info *myinfo,struct iguana_info *c
outpt.vout = unspent->vout;
outpt.value = unspent->value;
outpt.hdrsi = unspent->height / coin->chain->bundlesize;
if ( (outpt.spendlen= unspent->scriptlen) > 0 && outpt.spendlen < sizeof(outpt.spendscript) )
memcpy(outpt.spendscript,unspent->script,outpt.spendlen);
else
{
printf("spendscript.%d doesnt fit into %d\n",outpt.spendlen,(int32_t)sizeof(outpt.spendscript));
outpt.spendlen = 0;
}
if ( array != 0 )
jaddi(array,iguana_RTunspentjson(myinfo,coin,outpt,txid,unspent->vout,unspent->value,0,rmd160,coinaddr,pubkey33,spentheight,remoteaddr));
*depositsp += unspent->value;
@ -495,13 +529,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
{
//printf("u%u ",unspentind);
deposits += U[unspentind].value;
memset(&outpt,0,sizeof(outpt));
outpt.txid = T[U[unspentind].txidind].txid;
outpt.vout = unspentind - T[U[unspentind].txidind].firstvout;
outpt.hdrsi = lastpt.hdrsi;
outpt.isptr = 0;
outpt.unspentind = unspentind;
outpt.value = U[unspentind].value;
iguana_outpt_set(coin,&outpt,&U[unspentind],unspentind,lastpt.hdrsi,T[U[unspentind].txidind].txid,unspentind - T[U[unspentind].txidind].firstvout);
RTspend = 0;
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,lastheight,minconf,maxconf,U[unspentind].value) == 0 )
{

1
iguana/tests/rawtx5

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"agent\":\"basilisk\",\"method\":\"rawtx\",\"vals\":{\"changeaddr\":\"RD1rFucYCMhCGeEqdztivP3DFdJwVAzXn7\",\"addresses\":[\"RD1rFucYCMhCGeEqdztivP3DFdJwVAzXn7\"],\"timeout\":15000,\"satoshis\":\"130000\",\"spendscript\":\"76a9145da2ae69885741a6946e01ad8aa8b5312eed856088ac\"}}"

6
includes/iguana_defines.h

@ -58,15 +58,11 @@
#define IGUANA_MINPEERS 64
#define IGUANA_LOG2MAXPEERS 11 // cant exceed 13 bits as ramchain unspents has bitfield
#define IGUANA_LOG2PEERFILESIZE 23
#define IGUANA_MAXPEERS (1 << IGUANA_LOG2MAXPEERS)
#define IGUANA_LOG2PACKETSIZE 21
#define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE)
#define IGUANA_PEERFILESIZE (1 << IGUANA_LOG2PEERFILESIZE)
struct iguana_txdatabits { uint64_t addrind:IGUANA_LOG2MAXPEERS,filecount:10,fpos:IGUANA_LOG2PEERFILESIZE,datalen:IGUANA_LOG2PACKETSIZE,isdir:1; };
#define IGUANA_MAXFILEITEMS 8192
//#define IGUANA_MAXFILEITEMS 8192
#define IGUANA_RECENTPEER (3600 * 24 * 7)
#define IGUANA_PERMTHREAD 0

6
includes/iguana_structs.h

@ -183,7 +183,7 @@ struct iguana_packet { struct queueitem DL; struct iguana_peer *addr; struct tai
struct msgcounts { uint32_t version,verack,getaddr,addr,inv,getdata,notfound,getblocks,getheaders,headers,tx,block,mempool,ping,pong,reject,filterload,filteradd,filterclear,merkleblock,alert; };
struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; };
//struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; };
struct iguana_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; }PACKEDSTRUCT;
@ -349,7 +349,7 @@ struct iguana_peer
struct msgcounts msgcounts;
struct OS_memspace RAWMEM,TXDATA,HASHMEM;
struct iguana_ramchain ramchain;
struct iguana_fileitem *filehash2; int32_t numfilehash2,maxfilehash2;
//struct iguana_fileitem *filehash2; int32_t numfilehash2,maxfilehash2;
FILE *voutsfp,*vinsfp;
uint8_t *blockspace;//[IGUANA_MAXPACKETSIZE + 8192];
#ifdef IGUANA_PEERALLOC
@ -391,7 +391,7 @@ struct iguana_bundlereq
{
struct queueitem DL; struct iguana_info *coin; int32_t type;
struct iguana_peer *addr; struct iguana_zblock *blocks; bits256 *hashes,txid;
struct iguana_txdatabits txdatabits;
//struct iguana_txdatabits txdatabits;
struct iguana_msghdr H;
int32_t allocsize,datalen,n,recvlen,numtx; uint32_t ipbits;
struct iguana_zblock zblock;

Loading…
Cancel
Save