Browse Source

test

etomic
jl777 8 years ago
parent
commit
99e4ed53a7
  1. 2
      iguana/dPoW.h
  2. 60
      iguana/dpow/dpow_network.c
  3. 7
      iguana/dpow/dpow_rpc.c
  4. 5
      iguana/iguana_notary.c
  5. 2
      iguana/tests/dexvalidate
  6. 1
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -156,6 +156,7 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address);
cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
@ -166,5 +167,6 @@ char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *si
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address);
char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address);
#endif

60
iguana/dpow/dpow_network.c

@ -243,6 +243,11 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
if ( (retjson= dpow_getinfo(myinfo,coin)) != 0 )
retstr = jprint(retjson,1);
}
else if ( dexreq.func == 'U' )
{
if ( (retjson= dpow_listunspent(myinfo,coin,(char *)&dexp->packet[datalen])) != 0 )
retstr = jprint(retjson,1);
}
else if ( dexreq.func == 'P' )
{
hash2 = dpow_getbestblockhash(myinfo,coin);
@ -280,6 +285,19 @@ char *_dex_sendrequest(struct supernet_info *myinfo,struct dex_request *dexreq)
return(dex_reqsend(myinfo,"request",packet,datalen));
}
char *_dex_sendrequeststr(struct supernet_info *myinfo,struct dex_request *dexreq,char *str)
{
uint8_t *packet; int32_t datalen,slen; char *retstr;
slen = (int32_t)strlen(str)+1;
packet = calloc(1,sizeof(*dexreq)+slen);
datalen = dex_rwrequest(1,packet,dexreq);
strcpy((char *)&packet[datalen],str);
datalen += slen;
retstr = dex_reqsend(myinfo,"request",packet,datalen);
free(packet);
return(retstr);
}
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid)
{
struct dex_request dexreq;
@ -342,50 +360,38 @@ char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol)
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx)
{
struct dex_request dexreq; uint8_t *packet; int32_t datalen; char *retstr;
packet = calloc(1,sizeof(dexreq)+strlen(signedtx)+1);
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'S';
datalen = dex_rwrequest(1,packet,&dexreq);
strcpy((char *)&packet[datalen],signedtx);
printf("PACKET.(%s) datalen.%d strlen.%ld\n",(char *)&packet[datalen],datalen,strlen(signedtx));
datalen += strlen(signedtx) + 1;
retstr = dex_reqsend(myinfo,"request",packet,datalen);
free(packet);
return(retstr);
return(_dex_sendrequeststr(myinfo,&dexreq,signedtx));
}
char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address)
{
struct dex_request dexreq; uint8_t *packet; int32_t datalen; char *retstr;
packet = calloc(1,sizeof(dexreq)+strlen(address)+1);
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'A';
datalen = dex_rwrequest(1,packet,&dexreq);
strcpy((char *)&packet[datalen],address);
printf("address.(%s) datalen.%d strlen.%ld\n",(char *)&packet[datalen],datalen,strlen(address));
datalen += strlen(address) + 1;
retstr = dex_reqsend(myinfo,"request",packet,datalen);
free(packet);
return(retstr);
return(_dex_sendrequeststr(myinfo,&dexreq,address));
}
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address)
{
struct dex_request dexreq; uint8_t *packet; int32_t datalen; char *retstr;
packet = calloc(1,sizeof(dexreq)+strlen(address)+1);
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'V';
datalen = dex_rwrequest(1,packet,&dexreq);
strcpy((char *)&packet[datalen],address);
printf("address.(%s) datalen.%d strlen.%ld\n",(char *)&packet[datalen],datalen,strlen(address));
datalen += strlen(address) + 1;
retstr = dex_reqsend(myinfo,"request",packet,datalen);
free(packet);
return(retstr);
return(_dex_sendrequeststr(myinfo,&dexreq,address));
}
char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address)
{
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'U';
return(_dex_sendrequeststr(myinfo,&dexreq,address));
}
int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32)

7
iguana/dpow/dpow_rpc.c

@ -297,7 +297,7 @@ cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin
cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr)
{
char buf[128],*retstr; cJSON *json = 0;
char buf[128],*retstr; cJSON *array,*json = 0;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"0, 99999999, [\"%s\"]",coinaddr);
@ -310,7 +310,10 @@ cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,ch
}
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
{
json = iguana_listunspents(myinfo,coin,0,1,coin->longestchain,"");
array = cJSON_CreateArray();
jaddistr(array,coinaddr);
json = iguana_listunspents(myinfo,coin,array,1,coin->longestchain,"");
free_json(array);
}
else
{

5
iguana/iguana_notary.c

@ -563,6 +563,11 @@ TWO_STRINGS(dex,validateaddress,symbol,address)
{
return(_dex_validateaddress(myinfo,symbol,address));
}
TWO_STRINGS(dex,listunspent,symbol,address)
{
return(_dex_listunspent(myinfo,symbol,address));
}
#include "../includes/iguana_apiundefs.h"

2
iguana/tests/dexvalidate

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"validateaddress\",\"address\":\"1GxuYbLmMVoP4tCzm4s98Q6YU7H963W9kp\",\"symbol\":\"BTC\"}"

1
includes/iguana_apideclares.h

@ -30,6 +30,7 @@ TWO_STRINGS(dex,sendrawtransaction,symbol,signedtx);
HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout);
TWO_STRINGS(dex,importaddress,symbol,address);
TWO_STRINGS(dex,validateaddress,symbol,address);
TWO_STRINGS(dex,listunspent,symbol,address);
TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex);

Loading…
Cancel
Save