From cb3e4d2a89a997f32455ea65a3291899d9d0bd14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 9 Aug 2016 17:33:43 -0300 Subject: [PATCH] test --- basilisk/basilisk_swap.c | 12 ++++++++++++ iguana/iguana_payments.c | 8 +++++--- iguana/iguana_realtime.c | 2 +- iguana/iguana_sign.c | 30 ++++++++++++++++++------------ iguana/iguana_spendvectors.c | 2 +- iguana/tests/decoderawtransaction | 2 +- includes/iguana_defines.h | 2 +- 7 files changed, 39 insertions(+), 19 deletions(-) diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 1a7f93836..311123780 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -233,6 +233,18 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b jaddi(vins,item); jdelete(txobj,"vin"); jadd(txobj,"vin",vins); + //010000000141f18ce3a5c90069a04ade56f3277dbaa2d141f8ff708543455d9d620be512ee00000000 + //8b + //20fe936da3707c8c4cc7eb0352160ec3f50b9454d46425df6347b2fbc5b2ec87ea00 + //4c676304165daa57b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a9143805600256ed8498ca1ec426759212e5835e8dc2882103a7b696908f77d69ec89887f8c4a0423b9e80b5974dc43301bd7d8abad07e1211ac68ffffffff013d55 + //0000000000001976a9143ef4734c1141725c095342095f6e0e7748b6c16588ac00000000 + // + // + // 010000000141f18ce3a5c90069a04ade56f3277dbaa2d141f8ff708543455d9d620be512ee00000000 + //d147304402206b65cdd65f646bcc8ed3011e1d6bdb78d615c0f96f00b204d8561599ef77860c02202c5fca26317cc42ea037c1925530ac0e9ad22beda63717617da84107f833f30901 + //20fe936da3707c8c4cc7eb0352160ec3f50b9454d46425df6347b2fbc5b2ec87ea00 + //4c676304165daa57b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a9143805600256ed8498ca1ec426759212e5835e8dc2882103a7b696908f77d69ec89887f8c4a0423b9e80b5974dc43301bd7d8abad07e1211ac68ffffffff013d55 + //0000000000001976a9143ef4734c1141725c095342095f6e0e7748b6c16588ac00000000 printf("basilisk_rawtx_sign locktime.%u/%u for %s spendscript.%s -> %s, suppress.%d\n",rawtx->locktime,dest->locktime,rawtx->name,hexstr,dest->name,dest->suppress_pubkeys); txobj = bitcoin_txoutput(txobj,dest->spendscript,dest->spendlen,dest->amount); if ( (rawtxbytes= bitcoin_json2hex(myinfo,rawtx->coin,&dest->txid,txobj,&V)) != 0 ) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 7638d0eb6..3c31e8c56 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -972,16 +972,18 @@ STRING_AND_INT(bitcoinrpc,validaterawtransaction,rawtx,suppress) uint8_t *extraspace; int32_t extralen=65536; char *retstr; struct iguana_msgtx msgtx; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); + + cJSON *txobj; char *teststr= "{\"version\":1,\"locktime\":0,\"vin\":[{\"userdata\":\"20fe936da3707c8c4cc7eb0352160ec3f50b9454d46425df6347b2fbc5b2ec87ea00\",\"txid\":\"ee12e50b629d5d45438570fff841d1a2ba7d27f356de4aa06900c9a5e38cf141\",\"vout\":0,\"scriptPubKey\":{\"hex\":\"a9145cc47cc123e3f9b7dce0230009b9d3013a9e0c9687\"},\"suppress\":1,\"redeemScript\":\"6304165daa57b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a9143805600256ed8498ca1ec426759212e5835e8dc2882103a7b696908f77d69ec89887f8c4a0423b9e80b5974dc43301bd7d8abad07e1211ac68\"}],\"vout\":[{\"satoshis\":\"21821\",\"scriptPubkey\":{\"hex\":\"76a9143ef4734c1141725c095342095f6e0e7748b6c16588ac\"}}]}"; //cJSON *txobj; char *teststr= "{\"version\":1,\"locktime\":0,\"vin\":[{\"userdata\":\"20ae439d344513eab8e718d8214fe6ae8133b8b5b594afd64da21d0e40b9c37cdd00\",\"txid\":\"2c1320315f4fb519cbf2b4d7b67855013b9a09a85e515df43b41d407a0083b09\",\"vout\":0,\"scriptPubKey\":{\"hex\":\"a9142e7674400d04217f770f2222126dc7fee44b06b487\"},\"suppress\":1,\"redeemScript\":\"63041686a657b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a914ed74c61c27656abc6c20687c3a9212ffdc6f34cd88210398a4cb9f6ea7c52a4e27455028a95e2e4e397a110fb75f072c2c58a8bdcbf4baac68\"}],\"vout\":[{\"satoshis\":\"16733\",\"scriptPubkey\":{\"hex\":\"76a91454a752f0d71b89d7c014ed0be29ca231c9546f9f88ac\"}}]}"; extraspace = calloc(1,extralen); - /*if ( (txobj= cJSON_Parse(teststr)) != 0 ) + if ( (txobj= cJSON_Parse(teststr)) != 0 ) { bits256 txid; rawtx = bitcoin_json2hex(myinfo,coin,&txid,txobj,0); txobj = bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&txid,0,rawtx,extraspace,extralen,0,0,suppress); printf("RAWTX.(%s) -> (%s)\n",rawtx,jprint(txobj,0)); - }*/ - retstr = iguana_validaterawtx(myinfo,coin,coin->blocks.hwmchain.height,&msgtx,extraspace,extralen,rawtx,0,suppress); + } + //retstr = iguana_validaterawtx(myinfo,coin,coin->blocks.hwmchain.height,&msgtx,extraspace,extralen,rawtx,0,suppress); free(extraspace); return(rawtx); } diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index ccb0a8dd5..519cc4272 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -302,7 +302,7 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * { printf("cant find bundleblock [%d:%d]\n",bp->hdrsi,bundlei); iguana_blockQ("RTmissing",coin,bp,bundlei,hash2,1); - //break; + break; } if ( coin->RTdatabad == 0 && block != 0 && (block->height == 0 || bits256_nonz(block->RO.prev_block) != 0) ) { diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index f9125abe1..2bfe8767d 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -33,6 +33,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali printf("iguana_vinparse illegal scriptlen.%d\n",msg->scriptlen); return(-1); } + printf("len.%d scriptlen.%d user.%d p2sh.%d\n",len,msg->scriptlen,msg->userdatalen,msg->p2shlen); if ( rwflag == 0 ) { msg->vinscript = &serialized[len]; @@ -67,7 +68,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali } } len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->sequence),&msg->sequence); - if ( 0 ) + if ( 1 ) { int32_t i; char str[65]; for (i=0; i> 1; if ( suppress_pubkeys == 0 && (pubkeysjson= jarray(&n,vinobj,"pubkeys")) != 0 ) @@ -218,17 +219,19 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin else if ( n <= 0xff ) tmp += 2; else tmp += 3; - } + }*/ + tmp = IGUANA_MAXSCRIPTSIZE; len += iguana_rwvarint32(rwflag,&serialized[len],&tmp); + starti = len; if ( need_op0 != 0 ) serialized[len++] = 0; // hack for bug for bug backward compatibility if ( hexstr != 0 ) { n = (int32_t)strlen(hexstr) >> 1; - //printf("add.(%s) offset.%d\n",hexstr,len); + printf("add.(%s) offset.%d\n",hexstr,len); vin->vinscript = &serialized[len]; - decode_hex(&serialized[len],n,hexstr), len += n; - vin->scriptlen = n; + decode_hex(&serialized[len],n,hexstr); + vin->scriptlen = n + need_op0; if ( V != 0 ) { i = m = 0; @@ -243,6 +246,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin printf("ERROR: "); printf("len.%d n.%d i.%d\n",m,n,i); } + len += n; } //else printf("iguana_parsevinobj: hex script missing (%s)\n",jprint(vinobj,0)); if ( (pubkeysjson= jarray(&n,vinobj,"pubkeys")) != 0 ) { @@ -298,7 +302,9 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin n = iguana_parsehexstr(&vin->redeemscript,&vin->p2shlen,V!=0?V->p2shscript:0,V!=0?&V->p2shlen:0,&serialized[len],redeemstr); len += n; } - //printf("len.%d: ",len); + tmp = (len - starti); + serialized[starti-2] = (tmp & 0xff); + serialized[starti-1] = ((tmp >> 8) & 0xff); if ( spendstr != 0 ) { n = iguana_parsehexstr(&vin->spendscript,&vin->spendlen,V!=0?V->spendscript:0,V!=0?&V->spendlen:0,0,spendstr); @@ -448,7 +454,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ { if ( sizeof(struct iguana_msgvin)*msg->tx_in > extralen ) { - printf("len.%d + tx_in.%d > extralen.%d\n",len,msg->tx_in,extralen); + printf("(size.%d * tx_in.%d) > extralen.%d\n",(int32_t)sizeof(struct iguana_msgvin),msg->tx_in,extralen); return(-1); } msg->vins = (struct iguana_msgvin *)extraspace; @@ -458,10 +464,10 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ } for (i=0; itx_in; i++) { - //printf("vin.%d starts offset.%d\n",i,len); + printf("vin.%d starts offset.%d\n",i,len); if ( (n= iguana_vinparse(coin,rwflag,&serialized[len],&msg->vins[i])) < 0 ) return(-1); - //printf("vin.%d n.%d len.%d\n",i,n,len); + printf("vin.%d n.%d len.%d\n",i,n,len); len += n; if ( len > maxsize ) { @@ -496,7 +502,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ extraused += 0xf - (extraused & 0xf); if ( extraused + sizeof(struct iguana_msgvout)*msg->tx_out > extralen ) { - printf("len.%d + tx_in.%d > extralen.%d\n",len,msg->tx_in,extralen); + printf("extraused.%d + tx_out.%d > extralen.%d\n",extraused,msg->tx_out,extralen); return(-1); } msg->vouts = (struct iguana_msgvout *)&extraspace[extraused]; diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 1eeeaab5f..190a4f7ea 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -1108,7 +1108,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp, free(blockspace); bp->validated = (uint32_t)time(NULL); printf("VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d %llx\n",bp->hdrsi,bp->bundleheight,bp->validated - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated,(long long)validatehash.txid); - iguana_volatilesmap(coin,&bp->ramchain); + //iguana_volatilesmap(coin,&bp->ramchain); //if ( bp == coin->current ) // coin->RTdatabad = -1; } diff --git a/iguana/tests/decoderawtransaction b/iguana/tests/decoderawtransaction index 443c3e3f4..02e4f7248 100755 --- a/iguana/tests/decoderawtransaction +++ b/iguana/tests/decoderawtransaction @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000a6c1a95701999a0b4ed513b0bdf60107ea2694abe7c151394abfebffe754552d612b4ea360010000006b483045022100a35f12a433b80eab144ac775bbe84b72adfe8448f4199c4f9f71e31e3515abd202203729e302cb1a97ae55534594a833cb2e2b0f75e7b92c5bc4fd79eae6575f370e012103403fcaccb4a9fa16819b6d45752bb1c5c51b5436c73f7f4280bd89769506a4a6ffffffff03a0860100000000001976a9143eb8de53fa6c334f59acafcab24b85468f848a3588ac102700000000000025512102eaa4ee1ddfb771007a1bb1df6e0000000008d0a10601000000b02109d3d87f0051ae004ebc1d000000001976a914696e69358e39824ccbefec25513b994735437a1f88ac00000000\", 0]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"010000000141f18ce3a5c90069a04ade56f3277dbaa2d141f8ff708543455d9d620be512ee00000000d147304402206b65cdd65f646bcc8ed3011e1d6bdb78d615c0f96f00b204d8561599ef77860c02202c5fca26317cc42ea037c1925530ac0e9ad22beda63717617da84107f833f3090120fe936da3707c8c4cc7eb0352160ec3f50b9454d46425df6347b2fbc5b2ec87ea004c676304165daa57b1752102a9669e63ef1ab04913615c2f3887ea3584f81e5f08feee9535b19ab3739d8afdac67a9143805600256ed8498ca1ec426759212e5835e8dc2882103a7b696908f77d69ec89887f8c4a0423b9e80b5974dc43301bd7d8abad07e1211ac68ffffffff013d550000000000001976a9143ef4734c1141725c095342095f6e0e7748b6c16588ac00000000\", 1]}" diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index 3c2a860f0..e4c846c90 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -58,10 +58,10 @@ #define IGUANA_MINPEERS 64 #define IGUANA_LOG2MAXPEERS 10 -#define IGUANA_LOG2PACKETSIZE 21 #define IGUANA_LOG2PEERFILESIZE 23 #define IGUANA_MAXPEERS (1 << IGUANA_LOG2MAXPEERS) +#define IGUANA_LOG2PACKETSIZE 21 #define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE) #define IGUANA_PEERFILESIZE (1 << IGUANA_LOG2PEERFILESIZE) struct iguana_txdatabits { uint64_t addrind:IGUANA_LOG2MAXPEERS,filecount:10,fpos:IGUANA_LOG2PEERFILESIZE,datalen:IGUANA_LOG2PACKETSIZE,isdir:1; };