jl777 8 years ago
parent
commit
9d08a01aa6
  1. 2
      basilisk/basilisk.h
  2. 4
      iguana/iguana_payments.c
  3. 2
      iguana/iguana_realtime.c
  4. 23
      iguana/iguana_unspents.c
  5. 4
      iguana/iguana_volatiles.c
  6. 1
      includes/iguana_funcs.h

2
basilisk/basilisk.h

@ -16,7 +16,7 @@
#ifndef H_BASILISK_H
#define H_BASILISK_H
//#define BASILISK_DISABLESENDTX
#define BASILISK_DISABLESENDTX
#define BASILISK_DISABLEWAITTX
#include "../iguana/iguana777.h"

4
iguana/iguana_payments.c

@ -686,7 +686,7 @@ INT_ARRAY_STRING(bitcoinrpc,addmultisigaddress,M,pubkeys,account) //
HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
{
uint8_t script[IGUANA_MAXSCRIPTSIZE],rmd160[20],pubkey33[33]; char coinaddr[128],asmstr[IGUANA_MAXSCRIPTSIZE*2+1]; struct iguana_bundle *bp; int32_t minconf,scriptlen,unspentind,height,spentheight; struct iguana_RTtxid *ptr; int64_t RTspend; int64_t value; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P; struct iguana_txid *T; struct iguana_unspent *U; struct iguana_outpoint outpt; struct iguana_ramchain *ramchain; cJSON *scriptobj,*retjson = cJSON_CreateObject();
uint8_t script[IGUANA_MAXSCRIPTSIZE],rmd160[20],pubkey33[33]; char coinaddr[128],asmstr[IGUANA_MAXSCRIPTSIZE*2+1]; struct iguana_bundle *bp; int32_t firstslot,minconf,scriptlen,unspentind,height,spentheight=-1; struct iguana_RTtxid *ptr; int64_t RTspend; int64_t value; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P; struct iguana_txid *T; struct iguana_unspent *U; struct iguana_outpoint outpt; struct iguana_ramchain *ramchain; cJSON *scriptobj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 )
@ -722,7 +722,7 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool)
memset(&outpt,0,sizeof(outpt));
outpt.hdrsi = bp->hdrsi;
outpt.unspentind = unspentind;
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,height,minconf,coin->longestchain,U[unspentind].value) == 0 )
if ( iguana_markedunspents_find(coin,&firstslot,txid,vout) < 0 && iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,height,minconf,coin->longestchain,U[unspentind].value) == 0 )
{
jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2);
jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height);

2
iguana/iguana_realtime.c

@ -295,6 +295,8 @@ void iguana_RTspend_create(struct supernet_info *myinfo,struct iguana_info *coin
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
unspent = iguana_RTunspent_create(rmd160,value,spendscript,spendlen>0?spendlen:0,0,prev_vout);
memset(&spentpt,0,sizeof(spentpt));
spentpt.txid = prev_hash;
spentpt.vout = prev_vout;
spentpt.unspentind = unspentind;
spentpt.hdrsi = height / coin->chain->bundlesize;
spentpt.value = value;

23
iguana/iguana_unspents.c

@ -66,7 +66,7 @@ int32_t iguana_RTunspentind2txid(struct supernet_info *myinfo,struct iguana_info
int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *spentamountp,char *coinaddr,uint8_t *spendscript,int32_t *spendlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool)
{
struct iguana_txid *tp,TX; struct gecko_memtx *memtx; struct iguana_pkhash *P; struct iguana_unspent *U; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int64_t RTspend; int64_t value; struct iguana_outpoint spentpt; int32_t pkind,hdrsi,firstvout,spentheight,flag=0,unspentind = 0;
struct iguana_txid *tp,TX; struct gecko_memtx *memtx; struct iguana_pkhash *P; struct iguana_unspent *U; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int64_t RTspend; int64_t value; struct iguana_outpoint spentpt; int32_t firstslot,pkind,hdrsi,firstvout,spentheight,flag=0,unspentind = 0;
//portable_mutex_lock(&coin->RTmutex);
if ( valuep != 0 )
*valuep = 0;
@ -96,7 +96,7 @@ int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *c
spentpt.hdrsi = bp->hdrsi;
spentpt.unspentind = unspentind;
bitcoin_address(coinaddr,iguana_addrtype(coin,U[unspentind].type),P[pkind].rmd160,sizeof(P[pkind].rmd160));
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,&bp->ramchain,spentpt,0,1,coin->longestchain,U[unspentind].value) == 0 ) //bp == coin->current ? &coin->RTramchain :
if ( iguana_markedunspents_find(coin,&firstslot,txid,vout) < 0 && iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,&bp->ramchain,spentpt,0,1,coin->longestchain,U[unspentind].value) == 0 ) //bp == coin->current ? &coin->RTramchain :
{
if ( valuep != 0 )
*valuep = U[unspentind].value;
@ -489,7 +489,7 @@ int32_t iguana_RTscanunspents(struct supernet_info *myinfo,struct iguana_info *c
int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,int64_t *spentp,struct iguana_outpoint *unspents,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,struct iguana_outpoint lastpt,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespent)
{
struct iguana_unspent *U; struct iguana_utxo *U2; int32_t spentflag,max,uheight,spentheight; uint32_t pkind=0,unspentind; int64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; int64_t RTspend = 0; //struct iguana_spend *S;
struct iguana_unspent *U; struct iguana_utxo *U2; int32_t firstslot,vout,spentflag,max,uheight,spentheight; uint32_t pkind=0,unspentind; int64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; int64_t RTspend = 0; bits256 txid;
max = *nump;
*spentp = *nump = 0;
if ( 0 && coin->RTramchain_busy != 0 )
@ -514,9 +514,10 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
{
if ( ramchain->height < (coin->bundlescount-1)*coin->chain->bundlesize )
{
//printf("iguana_pkhashbalance.[%d] %d: unexpected null spents.%p or rdata.%p\n",ramchain->height,(coin->bundlescount-1)*coin->chain->bundlesize,ramchain->Uextras,rdata);
} else iguana_volatilesalloc(coin,ramchain,0);
return(0);
printf("iguana_pkhashbalance.[%d] %d: unexpected null spents.%p or rdata.%p\n",ramchain->height,(coin->bundlescount-1)*coin->chain->bundlesize,ramchain->Uextras,rdata);
}
iguana_volatilesmap(myinfo,coin,ramchain);
//return(0);
}
unspentind = lastpt.unspentind;
U = RAMCHAIN_PTR(rdata,Uoffset);
@ -531,9 +532,11 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *
{
//printf("u%u ",unspentind);
deposits += U[unspentind].value;
iguana_outpt_set(coin,&outpt,&U[unspentind],unspentind,lastpt.hdrsi,T[U[unspentind].txidind].txid,unspentind - T[U[unspentind].txidind].firstvout,p->rmd160,pubkey33);
txid = T[U[unspentind].txidind].txid;
vout = unspentind - T[U[unspentind].txidind].firstvout;
iguana_outpt_set(coin,&outpt,&U[unspentind],unspentind,lastpt.hdrsi,txid,vout,p->rmd160,pubkey33);
RTspend = 0;
if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,lastheight,minconf,maxconf,U[unspentind].value) == 0 )
if ( iguana_markedunspents_find(coin,&firstslot,txid,vout) < 0 && iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,lastheight,minconf,maxconf,U[unspentind].value) == 0 )
{
if ( *nump < max && unspents != 0 )
unspents[*nump] = outpt;
@ -1082,7 +1085,7 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi
int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr)
{
uint64_t sum = 0; int32_t i,n,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item;
uint64_t sum = 0; int32_t i,n,firstslot,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item;
*totalp = 0;
numunspents = 0;
if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 )
@ -1111,6 +1114,8 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( iguana_markedunspents_find(coin,&firstslot,jbits256(item,"txid"),jint(item,"vout")) >= 0 )
continue;
if ( (spendscriptstr= jstr(item,"scriptPubKey")) == 0 )
{
printf("no spendscriptstr.(%s)\n",jprint(item,0));

4
iguana/iguana_volatiles.c

@ -216,7 +216,7 @@ int32_t iguana_RTutxofunc(struct iguana_info *coin,int32_t *fromheightp,int32_t
int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,int64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,struct iguana_outpoint spentpt,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount)
{
uint32_t numunspents; int32_t RTspentflag,spentflag,lockedflag,fromheight=0; uint64_t confs;//,RTspend = 0;
uint32_t numunspents; int32_t firstslot,RTspentflag,spentflag,lockedflag,fromheight=0; uint64_t confs;
struct iguana_ramchaindata *rdata; struct iguana_RTunspent *unspent;
*spentheightp = -1;
if ( coin->disableUTXO != 0 )
@ -228,6 +228,8 @@ int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin
{
if ( (unspent= spentpt.ptr) != 0 )
{
if ( unspent->parent != 0 && iguana_markedunspents_find(coin,&firstslot,unspent->parent->txid,unspent->vout) >= 0 )
return(1);
*spentheightp = unspent->fromheight;
if ( unspent->spend != 0 )
{

1
includes/iguana_funcs.h

@ -500,6 +500,7 @@ cJSON *bitcoin_data2json(struct iguana_info *coin,int32_t height,bits256 *txidp,
int32_t iguana_unspentind2txid(struct supernet_info *myinfo,struct iguana_info *coin,int32_t *spentheightp,bits256 *txidp,int32_t *voutp,struct iguana_outpoint outpt);
int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt);
char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj,struct vin_info *V);
int32_t iguana_markedunspents_find(struct iguana_info *coin,int32_t *firstslotp,bits256 txid,int32_t vout);
char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height,bits256 *signedtxidp,int32_t *completedp,cJSON *vins,char *rawtx,cJSON *privkey,struct vin_info *V);
bits256 scrypt_blockhash(const void *input);

Loading…
Cancel
Save