Browse Source

Merge branch 'master' into release/v0.1

release/v0.1
jl777 8 years ago
parent
commit
251c24b666
  1. 2
      basilisk/basilisk_CMD.c
  2. 10
      basilisk/basilisk_bitcoin.c
  3. 7
      iguana/iguana_rpc.c
  4. 32
      iguana/main.c
  5. 1
      iguana/tests/rawtx6
  6. 1
      includes/iguana_funcs.h

2
basilisk/basilisk_CMD.c

@ -141,6 +141,8 @@ void basilisk_request_goodbye(struct supernet_info *myinfo)
char *basilisk_respond_addrelay(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
char *ipaddr,*retstr=0;
if ( valsobj == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( (ipaddr= jstr(valsobj,"ipaddr")) != 0 )
retstr = basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(ipaddr),jbits256(valsobj,"pubkey"));
else retstr = clonestr("{\"error\":\"need rmd160, address and ipaddr\"}");

10
basilisk/basilisk_bitcoin.c

@ -383,6 +383,8 @@ double basilisk_bitcoin_valuemetric(struct supernet_info *myinfo,struct basilisk
void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
int32_t i,height,vout,numsent; struct basilisk_item *ptr; char coinaddr[64],str[65]; struct basilisk_value *v; uint64_t value = 0; bits256 txid; struct iguana_outpoint outpt;
if ( valsobj == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 )
return(0);
txid = jbits256(valsobj,"txid");
@ -424,6 +426,8 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
struct basilisk_item *ptr; cJSON *infojson; int32_t numsent,fanout,numrequired;
if ( valsobj == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( (myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0) && strcmp(coin->symbol,"NOTARY") != 0 )
return(0);
if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
@ -516,6 +520,8 @@ int32_t basilisk_vins_validate(struct supernet_info *myinfo,struct iguana_info *
char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj)
{
uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount;
if ( valsobj == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}"));
vins = 0;
@ -815,6 +821,8 @@ cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exch
HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
{
char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis;
if ( vals == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}"));
//if ( coin == 0 )
@ -843,6 +851,8 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
{
char *retstr=0,*symbol; uint32_t basilisktag; int32_t timeoutmillis,i,retval = -1; uint64_t amount,txfee; cJSON *retarray;
if ( vals == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
//if ( coin == 0 )
{
if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 )

7
iguana/iguana_rpc.c

@ -708,7 +708,7 @@ struct iguana_info *iguana_coinchoose(struct supernet_info *myinfo,char *symbol,
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr,uint16_t port)
{
cJSON *params[16],*array; struct iguana_info *coin = 0; char symbol[16]; int32_t i,n; char *retstr = 0;
cJSON *params[16],*array; struct iguana_info *coin = 0; char symbol[16]; uint32_t immed; int32_t i,n; char *retstr = 0;
symbol[0] = 0;
memset(params,0,sizeof(params));
//printf("bitcoinRPC\n");
@ -722,6 +722,11 @@ char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,ch
//printf("method.(%s) (%s) remote.(%s) symbol.(%s)\n",method,jprint(json,0),remoteaddr,symbol);
if ( method != 0 && symbol[0] != 0 && (coin != 0 || (coin= iguana_coinfind(symbol)) != 0) )
{
if ( (immed= juint(json,"immediate")) != 0 )
{
if ( iguana_immediate(coin,immed) == 0 )
return(clonestr("{\"error\":\"coin is busy processing\"}"));
}
if ( (array= jarray(&n,json,"params")) == 0 )
{
i = 0, n = 0;

32
iguana/main.c

@ -251,9 +251,26 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,struct iguana_info *co
return(clonestr("{\"error\":\"iguana jsonstr expired\"}"));
}
int32_t iguana_immediate(struct iguana_info *coin,int32_t immedmillis)
{
double endmillis;
if ( immedmillis > 60000 )
immedmillis = 60000;
endmillis = OS_milliseconds() + immedmillis;
while ( 1 )
{
if ( coin->busy_processing == 0 )
break;
usleep(100);
if ( OS_milliseconds() > endmillis )
break;
}
return(coin->busy_processing == 0);
}
char *SuperNET_processJSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,uint16_t port)
{
cJSON *retjson; double endmillis; uint64_t tag; uint32_t timeout,immedmillis; char *jsonstr,*retjsonstr,*retstr = 0; //*hexmsg,*method,
cJSON *retjson; uint64_t tag; uint32_t timeout,immedmillis; char *jsonstr,*retjsonstr,*retstr = 0; //*hexmsg,*method,
//char str[65]; printf("processJSON %p %s\n",&myinfo->privkey,bits256_str(str,myinfo->privkey));
if ( json != 0 )
{
@ -276,18 +293,7 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,struct iguana_info *coin
{
if ( coin != 0 )
{
if ( immedmillis > 60000 )
immedmillis = 60000;
endmillis = OS_milliseconds() + immedmillis;
while ( 1 )
{
if ( coin->busy_processing == 0 )
break;
usleep(100);
if ( OS_milliseconds() > endmillis )
break;
}
if ( coin->busy_processing == 0 )
if ( iguana_immediate(coin,immedmillis) != 0 )
retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);
else retjsonstr = clonestr("{\"error\":\"coin is busy processing\"}");
} else retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);

1
iguana/tests/rawtx6

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"rawtx\",\"agent\":\"basilisk\",\"vals\":{\"addresses\":[\"19pE1sb6hPbV5644Fud6u7voNeKPfmfP3Y\", \"17SuJzHEuLzBtyHe83sYDjQFq2HeczRA1b\", \"1DyCyE5f4wCT9vBNUrCshg3ZkF7C9hT5wK\", \"15K5spF7woSF4rzGsQWSLVttmCF1nGGDXe\", \"1APJX58afkt2A25SmPQb9TrzGHbYYHLiVu\", \"12KFXEJ9C6VmvFabj4uqKeLYLm4XMsATU1\", \"12qDPNmMXez9r8CiHaww9dJooUk8AZSueF\", \"1DM9PDaBkYU27fB9ZQipZtGJtfBakpuYDv\", \"1HiTUabo7ruYY3NbxiDZi9dpnb5t4K6AqD\", \"1Q1thfWmTTwkR1yWEUHytrKcU6uGU8gUTu\", \"187ozeW6E1pbsQYvw5yqU6kzros5uXKcZk\", \"1FtJpcQ7q9msxYwR8QpF92bZDmGzVNHpxo\", \"1KDeCZiFXuNtpARcwEwohKJJb3Yeyjy8Ui\"],\"coin\":\"SYS\",\"changeaddr\":\"15K5spF7woSF4rzGsQWSLVttmCF1nGGDXe\",\"spendscript\":\"76a914df3f034f9805301d881b0d8c24a106f8d4c7fc8c88ac\",\"satoshis\":\"10000\",\"txfee\":\"10000\",\"minconf\":2},\"basilisktag\":995811301,\"locktime\":0,\"timeout\":30000}"

1
includes/iguana_funcs.h

@ -451,6 +451,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
void iguana_utxoaddrs_purge(struct iguana_info *coin);
int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight,uint8_t *rmd160);
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);
int32_t iguana_immediate(struct iguana_info *coin,int32_t immedmillis);
int32_t iguana_fastfindreset(struct iguana_info *coin);
int64_t iguana_unspentset(struct supernet_info *myinfo,struct iguana_info *coin);
int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t lasthdrsi);

Loading…
Cancel
Save