Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
faed022e4e
  1. 4
      basilisk/basilisk_MSG.c
  2. 1
      iguana/iguana_msg.c
  3. 105
      iguana/iguana_payments.c
  4. 2
      iguana/iguana_ramchain.c
  5. 10
      iguana/iguana_realtime.c
  6. 2
      includes/iguana_funcs.h
  7. 4
      includes/iguana_structs.h

4
basilisk/basilisk_MSG.c

@ -174,7 +174,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
free(retstr);
}
if ( vals != 0 && juint(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS));
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+2);
return(basilisk_standardservice("OUT",myinfo,0,hash,vals,hexstr,0));
}
#include "../includes/iguana_apiundefs.h"
@ -188,7 +188,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
jaddnum(valsobj,"channel",channel);
if ( msgid == 0 )
msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"fanout",(int32_t)sqrt(NUMRELAYS)+1);
jaddnum(valsobj,"fanout",(int32_t)sqrt(NUMRELAYS)+2);
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"sender",myinfo->myaddr.persistent);

1
iguana/iguana_msg.c

@ -582,6 +582,7 @@ int32_t iguana_rwtx(uint8_t zcash,int32_t rwflag,struct OS_memspace *mem,uint8_t
int32_t i,n,len = 0; uint8_t *txstart = serialized; char txidstr[65];
if ( maxsize < sizeof(msg->version) )
return(-1);
msg->serialized = serialized;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->version),&msg->version);
if ( hastimestamp != 0 )
{

105
iguana/iguana_payments.c

@ -833,64 +833,73 @@ THREE_STRINGS(bitcoinrpc,verifymessage,address,sig,message)
HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose)
{
struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_block *block; bits256 hash2;
struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len=0,height,extralen=65536; cJSON *retjson,*txobj; uint8_t *extraspace; struct iguana_block *block; bits256 hash2; struct iguana_RTtxid *RTptr;
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 )
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 )
{
retjson = cJSON_CreateObject();
if ( (len= iguana_ramtxbytes(coin,coin->blockspace,coin->blockspacesize,&checktxid,tx,height,0,0,0)) > 0 )
checktxid = RTptr->txid;
height = RTptr->height;
len = RTptr->txlen;
memcpy(coin->blockspace,RTptr->rawtxbytes,len);
}
else if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 )
{
len = iguana_ramtxbytes(coin,coin->blockspace,coin->blockspacesize,&checktxid,tx,height,0,0,0);
}
retjson = cJSON_CreateObject();
if ( len > 0 )
{
txbytes = calloc(1,len*2+1);
init_hexbytes_noT(txbytes,coin->blockspace,len);
if ( verbose != 0 )
{
txbytes = calloc(1,len*2+1);
init_hexbytes_noT(txbytes,coin->blockspace,len);
if ( verbose != 0 )
extraspace = calloc(1,extralen);
txobj = bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&checktxid,0,txbytes,extraspace,extralen,0,0,0);
free(extraspace);
free(txbytes);
if ( txobj != 0 )
{
extraspace = calloc(1,extralen);
txobj = bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&checktxid,0,txbytes,extraspace,extralen,0,0,0);
free(extraspace);
free(txbytes);
if ( txobj != 0 )
{
hash2 = iguana_blockhash(coin,height);
jaddbits256(txobj,"blockhash",hash2);
if ( (block= iguana_blockfind("rawtx",coin,hash2)) != 0 )
jaddnum(txobj,"blocktime",block->RO.timestamp);
jaddnum(txobj,"height",height);
jaddnum(txobj,"confirmations",coin->blocks.hwmchain.height - height);
return(jprint(txobj,1));
}
hash2 = iguana_blockhash(coin,height);
jaddbits256(txobj,"blockhash",hash2);
if ( (block= iguana_blockfind("rawtx",coin,hash2)) != 0 )
jaddnum(txobj,"blocktime",block->RO.timestamp);
jaddnum(txobj,"height",height);
jaddnum(txobj,"confirmations",coin->blocks.hwmchain.height - height);
return(jprint(txobj,1));
}
jaddstr(retjson,"result",txbytes);
char str[65]; printf("txbytes.(%s) len.%d (%s) %s\n",txbytes,len,jprint(retjson,0),bits256_str(str,checktxid));
free(txbytes);
return(jprint(retjson,1));
}
else if ( height >= 0 )
jaddstr(retjson,"result",txbytes);
char str[65]; printf("txbytes.(%s) len.%d (%s) %s\n",txbytes,len,jprint(retjson,0),bits256_str(str,checktxid));
free(txbytes);
return(jprint(retjson,1));
}
else if ( height >= 0 )
{
if ( coin->APIblockstr != 0 )
jaddstr(retjson,"error","already have pending request");
else
{
if ( coin->APIblockstr != 0 )
jaddstr(retjson,"error","already have pending request");
else
int32_t datalen; uint8_t *data; char *blockstr; bits256 blockhash;
blockhash = iguana_blockhash(coin,height);
if ( (blockstr= iguana_APIrequest(coin,blockhash,txid,2)) != 0 )
{
int32_t datalen; uint8_t *data; char *blockstr; bits256 blockhash;
blockhash = iguana_blockhash(coin,height);
if ( (blockstr= iguana_APIrequest(coin,blockhash,txid,2)) != 0 )
datalen = (int32_t)(strlen(blockstr) >> 1);
data = malloc(datalen);
decode_hex(data,datalen,blockstr);
if ( (txbytes= iguana_txscan(coin,verbose != 0 ? retjson : 0,data,datalen,txid)) != 0 )
{
datalen = (int32_t)(strlen(blockstr) >> 1);
data = malloc(datalen);
decode_hex(data,datalen,blockstr);
if ( (txbytes= iguana_txscan(coin,verbose != 0 ? retjson : 0,data,datalen,txid)) != 0 )
{
jaddstr(retjson,"result",txbytes);
jaddbits256(retjson,"blockhash",blockhash);
jaddnum(retjson,"height",height);
free(txbytes);
} else jaddstr(retjson,"error","cant find txid in block");
free(blockstr);
free(data);
} else jaddstr(retjson,"error","cant find blockhash");
return(jprint(retjson,1));
}
} else printf("height.%d\n",height);
jaddstr(retjson,"result",txbytes);
jaddbits256(retjson,"blockhash",blockhash);
jaddnum(retjson,"height",height);
free(txbytes);
} else jaddstr(retjson,"error","cant find txid in block");
free(blockstr);
free(data);
} else jaddstr(retjson,"error","cant find blockhash");
return(jprint(retjson,1));
}
}
return(clonestr("{\"error\":\"cant find txid\"}"));
}

2
iguana/iguana_ramchain.c

@ -2813,7 +2813,7 @@ int32_t iguana_RTramchaindata(struct supernet_info *myinfo,struct iguana_info *c
for (i=0; i<txn_count; i++,ramchain->H.txidind++)
{
tx = &txarray[i];
RTptr = iguana_RTtxid_create(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp);
RTptr = iguana_RTtxid_create(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp,tx->serialized,tx->allocsize);
if ( polarity > 0 )
{
if ( iter == 0 )

10
iguana/iguana_realtime.c

@ -485,6 +485,8 @@ void iguana_RTtxid_free(struct iguana_RTtxid *RTptr)
for (i=0; i<RTptr->numvins; i++)
if ( RTptr->spends[i] != 0 )
free(RTptr->spends[i]);
if ( RTptr->rawtxbytes != 0 )
free(RTptr->rawtxbytes);
free(RTptr);
}
@ -715,7 +717,7 @@ void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct
//fprintf(stderr,",");
}
struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp)
struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp,uint8_t *serialized,int32_t txlen)
{
struct iguana_RTtxid *RTptr; char str[65];
if ( block == 0 || block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) )
@ -740,6 +742,12 @@ struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguan
RTptr->version = version;
RTptr->timestamp = timestamp;
RTptr->unspents = (void *)&RTptr->spends[numvins];
if ( txlen > 0 )
{
RTptr->rawtxbytes = malloc(txlen);
RTptr->txlen = txlen;
memcpy(RTptr->rawtxbytes,serialized,txlen);
}
HASH_ADD_KEYPTR(hh,coin->RTdataset,RTptr->txid.bytes,sizeof(RTptr->txid),RTptr);
if ( 0 && strcmp("BTC",coin->symbol) != 0 )
printf("%s txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",coin->symbol,bits256_str(str,txid),numvouts,numvins,version,locktime,timestamp,(long long)polarity);

2
includes/iguana_funcs.h

@ -551,7 +551,7 @@ int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fil
struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *btcd,uint32_t ipbits);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
int32_t iguana_RTramchaindata(struct supernet_info *myinfo,struct iguana_info *coin,struct OS_memspace *TXDATA,struct OS_memspace *HASHMEM,int64_t polarity,struct iguana_block *block,struct iguana_msgtx *txarray,int32_t txn_count);
struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp);
struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp,uint8_t *serialized,int32_t txlen);
void iguana_RTspend(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout);
void iguana_RTunspent(struct iguana_info *coin,struct iguana_RTtxid *RTptr,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value);

4
includes/iguana_structs.h

@ -137,6 +137,7 @@ struct iguana_msgtx
bits256 txid;
int32_t allocsize,timestamp,numinputs,numoutputs;
int64_t inputsum,outputsum,txfee;
uint8_t *serialized;
} __attribute__((packed));
struct iguana_msgjoinsplit
@ -414,8 +415,9 @@ struct iguana_RTtxid
{
UT_hash_handle hh; struct iguana_info *coin; struct iguana_block *block;
bits256 txid;
int32_t height,txi,txn_count,numvouts,numvins;
int32_t height,txi,txn_count,numvouts,numvins,txlen;
uint32_t locktime,version,timestamp;
uint8_t *rawtxbytes;
struct iguana_RTunspent **unspents;
struct iguana_RTspend *spends[];
};

Loading…
Cancel
Save