From 8ddb3dca5a0c6a64cd910e950deaa4d3a79bf2d1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Sep 2016 06:10:26 -0300 Subject: [PATCH] test --- iguana/iguana_payments.c | 11 +++++++++-- iguana/iguana_realtime.c | 27 ++++++++++----------------- iguana/iguana_spendvectors.c | 9 ++++++++- iguana/iguana_unspents.c | 10 +++++++--- iguana/tests/decoderawtransaction | 2 +- iguana/tests/signrawtransaction | 2 +- includes/iguana_funcs.h | 2 +- includes/iguana_structs.h | 2 +- 8 files changed, 38 insertions(+), 27 deletions(-) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index d5ee69441..5fdbf9143 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -218,7 +218,7 @@ cJSON *iguana_inputjson(bits256 txid,int32_t vout,uint8_t *spendscript,int32_t s cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,uint64_t amount,struct iguana_outpoint *unspents,int32_t num) { - cJSON *vins; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE]; struct iguana_txid *T; struct iguana_unspent *U,*u; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; char coinaddr[64]; int32_t vout,height,abovei,belowi,i,spendlen,ind; uint32_t txidind; struct iguana_ramchaindata *rdata; bits256 txid; int64_t above,below,total = 0,remains = amount; struct iguana_outpoint outpt,outpt2; //uint64_t RTspent; + struct iguana_outpoint outpt; cJSON *vins; int32_t abovei,belowi,i,ind; int64_t above,below,total = 0,remains = amount; *totalp = 0; vins = cJSON_CreateArray(); for (i=0; i remains %.8f\n",coinaddr,dstr(value),dstr(remains)); + if ( remains <= 0 ) + break; + /*continue; if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 ) { if ( (spendlen= basilisk_unspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 ) @@ -302,7 +309,7 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin printf("%s illegal unspentind.u%d [%d]\n",coin->symbol,outpt.unspentind,outpt.hdrsi); free_json(vins); return(0); - } + }*/ } *totalp = total; return(vins); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 0e468a380..9e1d7368b 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -838,25 +838,18 @@ int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info } } -int32_t iguana_outptset(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,bits256 txid,int32_t vout) +int32_t iguana_outptset(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,bits256 txid,int32_t vout,int64_t value,char *spendscriptstr) { - int32_t scriptlen,height; uint64_t RTspend; char coinaddr[64]; uint64_t value = 0; struct iguana_RTtxid *RTptr; + int32_t spendlen; memset(outpt,0,sizeof(*outpt)); - HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr); - if ( RTptr != 0 ) - { - outpt->isptr = 1; - outpt->ptr = RTptr; - } - else - { - if ( (outpt->unspentind= iguana_unspentindfind(myinfo,coin,&RTspend,coinaddr,0,&scriptlen,&value,&height,txid,vout,coin->bundlescount-1,0)) != 0 ) - { - outpt->hdrsi = (height / coin->chain->bundlesize); - if ( outpt->value == 0 ) - outpt->value = (value == 0) ? RTspend : value; - } else return(-1); - } + spendlen = (int32_t)strlen(spendscriptstr) >> 1; + if ( spendlen > sizeof(outpt->spendscript) ) + return(-1); + outpt->spendlen = spendlen; + decode_hex(outpt->spendscript,spendlen,spendscriptstr); + outpt->txid = txid; + outpt->vout = vout; + outpt->value = value; return(0); } diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 6f3f0cb10..84304ee8a 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -843,7 +843,14 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi Aptr = 0; Uptr = 0; numunspents = numpkinds = 0; - if ( (bp= coin->bundles[hdrsi]) != 0 && bp->ramchain.H.data != 0 && (numpkinds= bp->ramchain.H.data->numpkinds) > 0 && (numunspents= bp->ramchain.H.data->numunspents) > 0 && (Aptr= bp->ramchain.A2) != 0 && (Uptr= bp->ramchain.Uextras) != 0 ) + if ( (bp= coin->bundles[hdrsi]) == 0 ) + continue; + if ( iter == 0 ) + { + iguana_volatilespurge(coin,&bp->ramchain); + iguana_volatilesalloc(coin,&bp->ramchain,1); + } + if ( bp != 0 && bp->ramchain.H.data != 0 && (numpkinds= bp->ramchain.H.data->numpkinds) > 0 && (numunspents= bp->ramchain.H.data->numunspents) > 0 && (Aptr= bp->ramchain.A2) != 0 && (Uptr= bp->ramchain.Uextras) != 0 ) { sprintf(fname,"%s/%s/debits.%d_N%d",GLOBAL_TMPDIR,coin->symbol,bp->hdrsi,numhdrsi); sprintf(fname2,"%s/%s/lastspends.%d_N%d",GLOBAL_TMPDIR,coin->symbol,bp->hdrsi,numhdrsi); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 202e37061..d37962f77 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -951,7 +951,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; struct iguana_outpoint outpt; cJSON *array,*item; //struct iguana_waddress *waddr; struct iguana_waccount *wacct; + uint64_t sum = 0; int32_t i,n,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 ) @@ -980,8 +980,12 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info * for (i=0; i