Browse Source

test

etomic
jl777 8 years ago
parent
commit
ccd5ac07ee
  1. 2
      iguana/dPoW.h
  2. 32
      iguana/dpow/dpow_network.c
  3. 18
      iguana/dpow/dpow_rpc.c
  4. 5
      iguana/iguana_notary.c
  5. 2
      iguana/tests/dexlistunspent
  6. 1
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -157,6 +157,7 @@ cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits2
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);
cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
@ -168,5 +169,6 @@ char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32
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);
char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *coinaddr,int32_t count,int32_t skip);
#endif

32
iguana/dpow/dpow_network.c

@ -186,14 +186,14 @@ char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32
return(retstr);
}
struct dex_request { bits256 hash; int32_t height; uint16_t vout; char name[15]; uint8_t func; };
struct dex_request { bits256 hash; int32_t intarg; uint16_t shortarg; char name[15]; uint8_t func; };
int32_t dex_rwrequest(int32_t rwflag,uint8_t *serialized,struct dex_request *dexreq)
{
int32_t len = 0;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(dexreq->hash),dexreq->hash.bytes);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(dexreq->height),&dexreq->height);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(dexreq->vout),&dexreq->vout);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(dexreq->intarg),&dexreq->intarg);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(dexreq->shortarg),&dexreq->shortarg);
if ( rwflag != 0 )
{
memcpy(&serialized[len],dexreq->name,sizeof(dexreq->name)), len += sizeof(dexreq->name);
@ -224,12 +224,12 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
}
else if ( dexreq.func == 'O' )
{
if ( (retjson= dpow_gettxout(myinfo,coin,dexreq.hash,dexreq.vout)) != 0 )
if ( (retjson= dpow_gettxout(myinfo,coin,dexreq.hash,dexreq.shortarg)) != 0 )
retstr = jprint(retjson,1);
}
else if ( dexreq.func == 'H' )
{
hash2 = dpow_getblockhash(myinfo,coin,dexreq.height);
hash2 = dpow_getblockhash(myinfo,coin,dexreq.intarg);
bits256_str(buf,hash2);
retstr = clonestr(buf);
}
@ -256,14 +256,17 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
}
else if ( dexreq.func == 'S' )
{
printf("SEND.(%s) datalen.%d strlen.%ld\n",(char *)&dexp->packet[datalen],datalen,strlen((char *)&dexp->packet[datalen]));
retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen]);
}
else if ( dexreq.func == 'L' )
{
if ( (retjson= dpow_listtransactions(myinfo,coin,(char *)&dexp->packet[datalen],dexreq.shortarg,dexreq.intarg)) != 0 )
retstr = jprint(retjson,1);
}
else if ( dexreq.func == 'A' )
{
retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
*broadcastflagp = 1;
printf("address.(%s) datalen.%d strlen.%ld ->(%s)\n",(char *)&dexp->packet[datalen],datalen,strlen((char *)&dexp->packet[datalen]),retstr);
if ( retstr == 0 )
retstr = dpow_validateaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
}
@ -315,7 +318,7 @@ char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.hash = txid;
dexreq.vout = vout;
dexreq.shortarg = vout;
dexreq.func = 'O';
return(_dex_sendrequest(myinfo,&dexreq));
}
@ -344,7 +347,7 @@ char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.height = height;
dexreq.intarg = height;
dexreq.func = 'H';
return(_dex_sendrequest(myinfo,&dexreq));
}
@ -394,6 +397,17 @@ char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address)
return(_dex_sendrequeststr(myinfo,&dexreq,address));
}
char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *address,int32_t count,int32_t skip)
{
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.intarg = skip;
dexreq.shortarg = count;
dexreq.func = 'L';
return(_dex_sendrequeststr(myinfo,&dexreq,address));
}
int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32)
{
int32_t i,firstz = -1;

18
iguana/dpow/dpow_rpc.c

@ -322,6 +322,24 @@ cJSON *dpow_listunspent(struct supernet_info *myinfo,struct iguana_info *coin,ch
return(json);
}
cJSON *dpow_listtransactions(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip)
{
char buf[128],*retstr; cJSON *json = 0;
if ( coin->FULLNODE < 0 )
{
if ( count == 0 )
count = 100;
sprintf(buf,"[\"%s\", %d, %d, true]",coinaddr,count,skip);
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"listtransactions",buf)) != 0 )
{
json = cJSON_Parse(retstr);
free(retstr);
return(json);
} else printf("%s null retstr from (%s)n",coin->symbol,buf);
}
return(0);
}
char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx,cJSON *vins)
{
cJSON *array,*privkeys,*item; char *wifstr,*str,*paramstr,*retstr; uint8_t script[256]; int32_t i,n,len,hashtype; struct vin_info V; struct iguana_waddress *waddr; struct iguana_waccount *wacct;

5
iguana/iguana_notary.c

@ -568,6 +568,11 @@ TWO_STRINGS(dex,listunspent,symbol,address)
{
return(_dex_listunspent(myinfo,symbol,address));
}
TWO_STRINGS_AND_TWO_DOUBLES(dest,listtransactions,symbol,address,count,skip)
{
return(_dex_listtransactions(myinfo,symbol,address,count,skip));
}
#include "../includes/iguana_apiundefs.h"

2
iguana/tests/dexlistunspent

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

1
includes/iguana_apideclares.h

@ -31,6 +31,7 @@ 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_AND_TWO_DOUBLES(dest,listtransactions,symbol,address,count,skip);
TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex);

Loading…
Cancel
Save