Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
2021976583
  1. 19
      iguana/iguana_blocks.c
  2. 2
      iguana/iguana_msg.c
  3. 25
      iguana/iguana_payments.c
  4. 4
      iguana/main.c
  5. 2
      iguana/tests/rawtx

19
iguana/iguana_blocks.c

@ -542,13 +542,18 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
{
if ( bits256_nonz(bp->hashes[block->height % coin->chain->bundlesize]) != 0 )
{
char str[65],str2[65];
printf("ERROR: need to fix up bundle for height.%d (%p %p) (%s %s)\n",block->height,block,bp->blocks[block->height % coin->chain->bundlesize],bits256_str(str,block->RO.hash2),bits256_str(str2,bp->hashes[block->height % coin->chain->bundlesize]));
if ( bp == coin->current && coin->RTheight > 0 )
coin->RTdatabad = 1;
//iguana_bundleremove(coin,bp->hdrsi,0);
//exit(-1);
//getchar();
if ( bp->blocks[block->height % coin->chain->bundlesize] == 0 && block != 0 )
bp->blocks[block->height % coin->chain->bundlesize] = block;
else
{
char str[65],str2[65];
printf("ERROR: need to fix up bundle for height.%d (%p %p) (%s %s)\n",block->height,block,bp->blocks[block->height % coin->chain->bundlesize],bits256_str(str,block->RO.hash2),bits256_str(str2,bp->hashes[block->height % coin->chain->bundlesize]));
if ( bp == coin->current && coin->RTheight > 0 )
coin->RTdatabad = 1;
//iguana_bundleremove(coin,bp->hdrsi,0);
//exit(-1);
//getchar();
}
}
iguana_blockunmark(coin,block,bp,block->height % coin->chain->bundlesize,0);
iguana_bundlehash2add(coin,0,bp,block->height % coin->chain->bundlesize,block->RO.hash2);

2
iguana/iguana_msg.c

@ -589,7 +589,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
iguana_send_supernet(coin,addr,retstr,delay);
free(retstr);
}
//printf("GOT.(%s) [%s] len.%d from %s -> (%s)\n",H->command,data,recvlen,addr->ipaddr,retstr==0?"null":retstr);
printf("GOT.(%s) [%s] len.%d from %s -> (%s)\n",H->command,data,recvlen,addr->ipaddr,retstr==0?"null":retstr);
return(0);
}
else if ( strcmp(H->command,"InstantDEX") == 0 )

25
iguana/iguana_payments.c

@ -434,6 +434,7 @@ char *iguana_rawtxissue(struct supernet_info *myinfo,struct iguana_info *coin,cJ
jaddstr(reqjson,"changeaddr",changeaddr);
jaddstr(reqjson,"spendscriptstr",spendscriptstr);
jadd(reqjson,"addresses",addresses);
jaddnum(reqjson,"plaintext",1);
OS_randombytes((uint8_t *)&rawtxtag,sizeof(rawtxtag));
jaddnum(reqjson,"rawtxtag",rawtxtag);
valsobj = cJSON_CreateObject();
@ -457,6 +458,7 @@ char *iguana_rawtxissue(struct supernet_info *myinfo,struct iguana_info *coin,cJ
if ( rawtxtag == ptr->rawtxtag )
{
rawtx = clonestr(ptr->rawtx);
printf("got RAWTX.(%s)\n",rawtx);
*vinsp = ptr->vins;
break;
}
@ -524,17 +526,24 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *
char *iguana_createrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJSON **vinsp,uint32_t locktime,uint64_t satoshis,char *spendscriptstr,char *changeaddr,int64_t txfee,int32_t minconf,cJSON *addresses)
{
cJSON *txobj; char *rawtx=0; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE]; int32_t spendlen;
cJSON *retjson; char *signedtx,*rawtx=0; bits256 signedtxid; int32_t completed;
*vinsp = 0;
if ( (txobj= bitcoin_txcreate(coin,locktime)) != 0 )
if ( (rawtx= iguana_rawtxissue(myinfo,coin,vinsp,locktime,satoshis,changeaddr,txfee,addresses,minconf,spendscriptstr)) != 0 )
{
spendlen = (int32_t)strlen(spendscriptstr) >> 1;
decode_hex(spendscript,spendlen,spendscriptstr);
bitcoin_txoutput(coin,txobj,spendscript,spendlen,satoshis);
rawtx = iguana_calcrawtx(myinfo,coin,vinsp,txobj,satoshis,changeaddr,txfee,addresses,minconf);
free_json(txobj);
if ( (signedtx= iguana_signrawtx(myinfo,coin,&signedtxid,&completed,*vinsp,rawtx)) != 0 )
{
iguana_unspentslock(myinfo,coin,*vinsp);
retjson = cJSON_CreateObject();
jaddbits256(retjson,"result",signedtxid);
jaddstr(retjson,"signedtx",signedtx);
jadd(retjson,"complete",completed != 0 ? jtrue() : jfalse());
free(rawtx);
free(signedtx);
return(jprint(retjson,1));
}
return(rawtx);
}
return(rawtx);
return(0);
}
#include "../includes/iguana_apidefs.h"

4
iguana/main.c

@ -1156,10 +1156,10 @@ void iguana_appletests(struct supernet_info *myinfo)
//int32_t iguana_schnorr_test(void *ctx);
//iguana_schnorr_test(myinfo->ctx); getchar();
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 )

2
iguana/tests/rawtx

@ -1 +1 @@
curl --url "http://127.0.0.1:14632" --data "{\"agent\":\"iguana\",\"method\":\"rawtx\",\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"],\"vals\":{\"coin\":\"BTCD\",\"amount\":\"10000000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}"
curl --url "http://127.0.0.1:14632" --data "{\"timeout\":15,\"agent\":\"iguana\",\"method\":\"rawtx\",\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"],\"vals\":{\"coin\":\"BTCD\",\"amount\":\"10000000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}"

Loading…
Cancel
Save