From 45224934739f645d8fc6852e3100c2c77e22b35a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 14 Mar 2016 03:17:41 -0300 Subject: [PATCH] test --- iguana/exchanges/bitcoin.c | 2 +- iguana/iguana777.h | 2 +- iguana/iguana_ramchain.c | 8 +++++--- iguana/iguana_unspents.c | 4 ++-- iguana/ramchain_api.c | 2 +- iguana/swaps/iguana_BTCswap.c | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/iguana/exchanges/bitcoin.c b/iguana/exchanges/bitcoin.c index 9a080a560..b2c854f41 100755 --- a/iguana/exchanges/bitcoin.c +++ b/iguana/exchanges/bitcoin.c @@ -1165,7 +1165,7 @@ rawtxstr = refstr; if ( bitcoin_verifytx(coin,&signedtxid,&signedtx,rawtxstr,V) != 0 ) printf("bitcoin_verifytx error\n"); jadd(retjson,"result",txjson); - if ( (tp= iguana_txidfind(coin,&height,&T,txid)) != 0 ) + if ( (tp= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 ) { if ( height >= 0 ) { diff --git a/iguana/iguana777.h b/iguana/iguana777.h index dd5a2900d..689e982c0 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -697,7 +697,7 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl int32_t iguana_txidreq(struct iguana_info *coin,char **retstrp,bits256 txid); void iguana_bundleiclear(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei); int32_t hcalc_bitsize(uint64_t x); -struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,struct iguana_txid *tx,bits256 txid); +struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,struct iguana_txid *tx,bits256 txid,int32_t lasthdrsi); int32_t iguana_scriptgen(struct iguana_info *coin,int32_t *Mp,int32_t *nump,char *coinaddr,uint8_t *script,char *asmstr,uint8_t rmd160[20],uint8_t type,const struct vin_info *vp,int32_t txi); int32_t iguana_ramchain_spendtxid(struct iguana_info *coin,uint32_t *unspentindp,bits256 *txidp,struct iguana_txid *T,int32_t numtxids,bits256 *X,int32_t numexternaltxids,struct iguana_spend *s); struct iguana_info *iguana_coinselect(); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index b8d34f12e..4aeaa39c7 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -197,12 +197,14 @@ void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block block->RO.firstexternalind = ramchain->externalind; } -struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,struct iguana_txid *tx,bits256 txid) +struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,struct iguana_txid *tx,bits256 txid,int32_t lasthdrsi) { uint8_t *TXbits; struct iguana_txid *T; uint32_t txidind; int32_t i,j; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_block *block; *heightp = -1; - for (i=coin->bundlescount-1; i>=0; i--) + if ( lasthdrsi < 0 ) + return(0); + for (i=lasthdrsi; i>=0; i--) { if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish > coin->startutc ) { @@ -211,7 +213,7 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st { TXbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->TXoffset); T = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Toffset); - printf("search bp.%p TXbits.%p T.%p %d %d\n",bp,TXbits,T,(int32_t)ramchain->H.data->TXoffset,(int32_t)ramchain->H.data->Toffset); + //printf("search bp.%p TXbits.%p T.%p %d %d\n",bp,TXbits,T,(int32_t)ramchain->H.data->TXoffset,(int32_t)ramchain->H.data->Toffset); if ( (txidind= iguana_sparseaddtx(TXbits,ramchain->H.data->txsparsebits,ramchain->H.data->numtxsparse,txid,T,0)) > 0 ) { printf("found txidind.%d\n",txidind); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 648925a06..86453960f 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -93,7 +93,7 @@ struct iguana_bundle *iguana_spent(struct iguana_info *coin,bits256 *prevhashp,u *unspentindp = unspentind; if ( unspentind == 0 ) { - if ( (tp= iguana_txidfind(coin,&height,&TX,prev_hash)) != 0 ) + if ( (tp= iguana_txidfind(coin,&height,&TX,prev_hash,spend_hdrsi-1)) != 0 ) { unspentind = TX.firstvout + ((prev_vout > 0) ? prev_vout : 0); hdrsi = height / coin->chain->bundlesize; @@ -216,7 +216,7 @@ 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 ) jaddstr(item,"scriptPubKey",scriptstr); jaddnum(item,"amount",dstr(up->value)); - if ( iguana_txidfind(coin,&height,&TX,T[up->txidind].txid) != 0 ) + if ( iguana_txidfind(coin,&height,&TX,T[up->txidind].txid,coin->bundlescount-1) != 0 ) jaddnum(item,"confirmations",coin->longestchain - height); return(item); } diff --git a/iguana/ramchain_api.c b/iguana/ramchain_api.c index bd0399095..3dca7e86d 100755 --- a/iguana/ramchain_api.c +++ b/iguana/ramchain_api.c @@ -145,7 +145,7 @@ int32_t iguana_ramtxbytes(struct iguana_info *coin,uint8_t *serialized,int32_t m HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose) { struct iguana_txid *tx,T; char *txbytes; bits256 checktxid; int32_t len,height; cJSON *retjson; - if ( (tx= iguana_txidfind(coin,&height,&T,txid)) != 0 ) + if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 ) { retjson = cJSON_CreateObject(); if ( (len= iguana_ramtxbytes(coin,coin->blockspace,sizeof(coin->blockspace),&checktxid,tx,height,0,0)) > 0 ) diff --git a/iguana/swaps/iguana_BTCswap.c b/iguana/swaps/iguana_BTCswap.c index 40531f9af..1852d4169 100755 --- a/iguana/swaps/iguana_BTCswap.c +++ b/iguana/swaps/iguana_BTCswap.c @@ -597,7 +597,7 @@ char *BTC_txconfirmed(struct supernet_info *myinfo,struct iguana_info *coin,stru *numconfirmsp = -1.; if ( coin != 0 && *numconfirmsp < 0 ) { - if ( (tx= iguana_txidfind(coin,&height,&T,txid)) != 0 && (confs= iguana_numconfs(coin,txid,height)) >= requiredconfs ) + if ( (tx= iguana_txidfind(coin,&height,&T,txid,coin->bundlescount-1)) != 0 && (confs= iguana_numconfs(coin,txid,height)) >= requiredconfs ) { *numconfirmsp = confs; if ( (retstr= instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,virtualevent,myinfo->myaddr.persistent,0,0,0)) != 0 )