From 7ffc40b025fb7388a74fd0c038ddfdbff0b31831 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 7 Mar 2016 12:03:22 -0300 Subject: [PATCH] test --- iguana/iguana777.h | 4 ++-- iguana/iguana_ramchain.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 8cdd51435..c050db917 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -320,8 +320,8 @@ struct iguana_ledger } __attribute__((packed)); // ramchain append only structs -> canonical 32bit inds and ledgerhashes -struct iguana_unspent20 { uint64_t value; uint32_t scriptfpos,txidind:28,type:4; uint16_t scriptlen; uint8_t rmd160[20],script[128]; } __attribute__((packed)); -struct iguana_spend256 { bits256 prevhash2; uint8_t vinscript[256]; uint32_t sequenceid,scriptfpos; int16_t prevout; uint16_t vinscriptlen,spendind; } __attribute__((packed)); +struct iguana_unspent20 { uint64_t value; uint32_t scriptfpos,txidind:28,type:4; uint16_t scriptlen; uint8_t rmd160[20],*script; } __attribute__((packed)); +struct iguana_spend256 { bits256 prevhash2; uint8_t *vinscript; uint32_t sequenceid,scriptfpos; int16_t prevout; uint16_t vinscriptlen,spendind; } __attribute__((packed)); struct iguana_txid { bits256 txid; uint32_t txidind,firstvout,firstvin,locktime,version,timestamp,extraoffset; uint16_t numvouts,numvins; } __attribute__((packed)); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 884fe6cda..e4604d485 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -407,7 +407,7 @@ uint32_t iguana_ramchain_addunspent20(struct iguana_info *coin,RAMCHAIN_FUNC,uin //fprintf(stderr,"type.%d scriptlen.%d bp.%p\n",type,scriptlen,bp); if ( (u->scriptlen= scriptlen) != 0 ) { - if ( scriptlen <= sizeof(u->script) ) + /*if ( scriptlen <= sizeof(u->script) ) memcpy(u->script,script,scriptlen); else { @@ -416,7 +416,9 @@ uint32_t iguana_ramchain_addunspent20(struct iguana_info *coin,RAMCHAIN_FUNC,uin { u->scriptfpos = (uint32_t)iguana_scriptadd(coin,bp,unspentind,type,script,scriptlen,rmd160,vout); } - } + }*/ + u->script = malloc(scriptlen); + memcpy(u->script,script,scriptlen); } u->txidind = ramchain->H.txidind; memcpy(u->rmd160,rmd160,sizeof(u->rmd160)); @@ -936,13 +938,13 @@ uint32_t iguana_ramchain_addspend256(struct iguana_info *coin,RAMCHAIN_FUNC,bits struct iguana_spend256 *s; uint32_t spendind,scriptfpos = 0; spendind = ramchain->H.spendind++; s = &S[spendind]; - if ( vinscriptlen > sizeof(s->vinscript) ) + /*if ( vinscriptlen > sizeof(s->vinscript) ) { fprintf(stderr,"vin scriptsave %d\n",vinscriptlen); scriptfpos = iguana_scriptsave(coin,bp,spendind,1,vinscript,vinscriptlen); fprintf(stderr,"done vin scriptsave %d\n",vinscriptlen); //printf("S%d added sig.%d len.%d %08x\n",spendind,scriptfpos,vinscriptlen,calc_crc32(0,vinscript,vinscriptlen)); - } + }*/ if ( ramchain->H.ROflag != 0 ) { if ( vinscriptlen != s->vinscriptlen || (s->sequenceid == 1 && sequence != 0xffffffff) || (s->sequenceid == 2 && sequence != 0xfffffffe) || memcmp(s->prevhash2.bytes,prev_hash.bytes,sizeof(bits256)) != 0 || s->prevout != prev_vout ) //|| s->hdrsi != hdrsi @@ -960,8 +962,11 @@ uint32_t iguana_ramchain_addspend256(struct iguana_info *coin,RAMCHAIN_FUNC,bits s->prevhash2 = prev_hash, s->prevout = prev_vout; s->spendind = spendind; s->scriptfpos = scriptfpos; - if ( (s->vinscriptlen= vinscriptlen) > 0 && vinscriptlen <= sizeof(s->vinscript) && scriptfpos == 0 ) + if ( (s->vinscriptlen= vinscriptlen) > 0 )//&& vinscriptlen <= sizeof(s->vinscript) && scriptfpos == 0 ) + { + s->vinscript = malloc(vinscriptlen); memcpy(s->vinscript,vinscript,vinscriptlen); + } //else printf("spend256 scriptfpos.%d\n",s->scriptfpos); //char str[65]; printf("W.%p s.%d vout.%d/%d [%d] %s fpos.%u slen.%d\n",s,spendind,s->prevout,prev_vout,bp->hdrsi,bits256_str(str,prev_hash),s->scriptfpos,s->vinscriptlen); }