From 992b75e31993b88c342ed0c6dc95f5a781f6c7fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 27 Jun 2016 14:33:01 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 43 +++++++++++++++++++++++++++++++++++-- basilisk/basilisk_CMD.c | 35 ------------------------------ basilisk/basilisk_bitcoin.c | 8 ++++--- gecko/gecko_blocks.c | 3 ++- iguana/tests/rawtxB | 2 +- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 338789be9..7c9ad6bc1 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -385,19 +385,58 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_add #include "basilisk_lisk.c" #include "basilisk_CMD.c" +#include "../includes/iguana_apidefs.h" +#include "../includes/iguana_apideclares.h" + +HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) +{ + return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); + //return(basilisk_standardcmd(myinfo,"BAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_balances,coin->basilisk_balancesmetric)); +} + +HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) +{ + return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1)); + //return(basilisk_standardcmd(myinfo,"VAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_value,coin->basilisk_valuemetric)); +} + +HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) +{ + char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; + if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) + { + if ( (coin= iguana_coinfind(symbol)) != 0 ) + { + basilisktag = juint(vals,"basilisktag"); + if ( juint(vals,"burn") == 0 ) + jaddnum(vals,"burn",0.0001); + if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) + timeoutmillis = BASILISK_TIMEOUT; + if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) + { + retstr = ptr->retstr; + } + if ( ptr != &Lptr ) + free(ptr); + } + } + return(retstr); +} +#include "../includes/iguana_apiundefs.h" + void basilisk_functions(struct iguana_info *coin,int32_t protocol) { coin->protocol = protocol; switch ( protocol ) { - case IGUANA_PROTOCOL_BITCOIN: + /*case IGUANA_PROTOCOL_BITCOIN: coin->basilisk_balances = basilisk_bitcoinbalances; coin->basilisk_rawtx = basilisk_bitcoinrawtx; //coin->basilisk_rawtxmetric = basilisk_bitcoin_rawtxmetric; coin->basilisk_value = basilisk_bitcoinvalue; coin->basilisk_valuemetric = basilisk_bitcoin_valuemetric; break; - /*case IGUANA_PROTOCOL_IOTA: + case IGUANA_PROTOCOL_IOTA: coin->basilisk_balances = basilisk_iotabalances; coin->basilisk_rawtx = basilisk_iotarawtx; break; diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index 306676f6e..fa67a5e94 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -210,41 +210,6 @@ char *basilisk_respond_balances(struct supernet_info *myinfo,char *CMD,void *add #include "../includes/iguana_apidefs.h" #include "../includes/iguana_apideclares.h" -HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) -{ - return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1)); - //return(basilisk_standardcmd(myinfo,"BAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_balances,coin->basilisk_balancesmetric)); -} - -HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) -{ - return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1)); - //return(basilisk_standardcmd(myinfo,"VAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_value,coin->basilisk_valuemetric)); -} - -HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) -{ - char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; - if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 ) - { - if ( (coin= iguana_coinfind(symbol)) != 0 ) - { - basilisktag = juint(vals,"basilisktag"); - if ( juint(vals,"burn") == 0 ) - jaddnum(vals,"burn",0.0001); - if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) - timeoutmillis = BASILISK_TIMEOUT; - if ( (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) - { - retstr = ptr->retstr; - } - if ( ptr != &Lptr ) - free(ptr); - } - } - return(retstr); -} - HASH_ARRAY_STRING(basilisk,addrelay,hash,vals,hexstr) { return(basilisk_standardservice("ADD",myinfo,0,hash,vals,hexstr,1)); diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 11f73981c..09c2a4ea5 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -576,15 +576,17 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi uint8_t buf[IGUANA_MAXSCRIPTSIZE]; int32_t oplen,offset,numsent,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; vins = 0; changeaddr = jstr(valsobj,"changeaddr"); - spendscriptstr = jstr(valsobj,"spendscript"); - amount = j64bits(valsobj,"satoshis"); + if ( (amount= j64bits(valsobj,"satoshis")) == 0 ) + amount = jdouble(valsobj,"value") * SATOSHIDEN; if ( (txfee= j64bits(valsobj,"txfee")) == 0 ) txfee = coin->chain->txfee; if ( txfee == 0 ) txfee = 10000; + spendscriptstr = jstr(valsobj,"spendscript"); minconf = juint(valsobj,"minconf"); locktime = juint(valsobj,"locktime"); - addresses = jobj(valsobj,"addresses"); + if ( (addresses= jobj(valsobj,"addresses")) == 0 ) + addresses = iguana_getaddressesbyaccount(myinfo,coin,"*"); if ( changeaddr == 0 || changeaddr[0] == 0 || spendscriptstr == 0 || spendscriptstr[0] == 0 || amount == 0 || addresses == 0 ) { printf("vals.(%s)\n",jprint(valsobj,0)); diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index 8e2310877..0309bb83a 100755 --- a/gecko/gecko_blocks.c +++ b/gecko/gecko_blocks.c @@ -265,7 +265,8 @@ char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,c prev->mainchain = 1; if ( prev->height != (adjacent + 1 - j) ) prev->height = (adjacent + 1 - j); - gecko_bundleset(virt,prev); + gecko_ensurebundle(virt,prev,prev->height,0); + //gecko_bundleset(virt,prev); if ( prev->height == 0 ) break; } diff --git a/iguana/tests/rawtxB b/iguana/tests/rawtxB index c0ed9efff..a7ede91c9 100755 --- a/iguana/tests/rawtxB +++ b/iguana/tests/rawtxB @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"timeout\":25000,\"agent\":\"basilisk\",\"method\":\"rawtx\",\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"addresses\":[\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\"],\"vals\":{\"coin\":\"BTCD\",\"amount\":\"20000\"},\"spendscriptstr\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}" +curl --url "http://127.0.0.1:7778" --data "{\"timeout\":25000,\"agent\":\"basilisk\",\"method\":\"rawtx\",\"vals\":{\"changeaddr\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"coin\":\"BTCD\",\"satoshis\":\"20000\",\"spendscript\":\"76a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac\"}}"