Browse Source

test

etomic
jl777 8 years ago
parent
commit
f4c1d7ceb4
  1. 2
      iguana/dPoW.h
  2. 21
      iguana/dpow/dpow_network.c
  3. 12
      iguana/dpow/dpow_rpc.c
  4. 4
      iguana/iguana_notary.c
  5. 2
      iguana/tests/deximportaddress
  6. 1
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -154,6 +154,7 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin); bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin);
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout); 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 *_dex_getinfo(struct supernet_info *myinfo,char *symbol); char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid); char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
@ -162,5 +163,6 @@ char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height
char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol); char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol);
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx); char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx);
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout); 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);
#endif #endif

21
iguana/dpow/dpow_network.c

@ -253,6 +253,11 @@ char *dex_response(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp)
printf("SEND.(%s) datalen.%d strlen.%ld\n",(char *)&dexp->packet[datalen],datalen,strlen((char *)&dexp->packet[datalen])); 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]); retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen]);
} }
else if ( dexreq.func == 'A' )
{
printf("address.(%s) datalen.%d strlen.%ld\n",(char *)&dexp->packet[datalen],datalen,strlen((char *)&dexp->packet[datalen]));
retstr = dpow_importaddress(myinfo,coin,(char *)&dexp->packet[datalen]);
}
} }
if ( retstr == 0 ) if ( retstr == 0 )
return(clonestr("{\"error\":\"null return\"}")); return(clonestr("{\"error\":\"null return\"}"));
@ -343,6 +348,22 @@ char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *si
return(retstr); return(retstr);
} }
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);
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);
}
int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32) int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32)
{ {
int32_t i,firstz = -1; int32_t i,firstz = -1;

12
iguana/dpow/dpow_rpc.c

@ -413,6 +413,18 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
} }
} }
char *dpow_importaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{
char buf[128],*retstr;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"[\"%s\"]",address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"importaddress",buf);
return(retstr);
}
else return(0);
}
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin) int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin)
{ {
int32_t n,i,height = -1,maxtx = *numtxp; bits256 besthash,oldhash; cJSON *array,*json; int32_t n,i,height = -1,maxtx = *numtxp; bits256 besthash,oldhash; cJSON *array,*json;

4
iguana/iguana_notary.c

@ -538,6 +538,10 @@ TWO_STRINGS(dex,sendrawtransaction,symbol,signedtx)
return(_dex_sendrawtransaction(myinfo,symbol,signedtx)); return(_dex_sendrawtransaction(myinfo,symbol,signedtx));
} }
TWO_STRINGS(dex,importaddress,symbol,address)
{
return(_dex_importaddress(myinfo,symbol,address));
}
#include "../includes/iguana_apiundefs.h" #include "../includes/iguana_apiundefs.h"

2
iguana/tests/deximportaddress

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

1
includes/iguana_apideclares.h

@ -28,6 +28,7 @@ STRING_AND_INT(dex,getblockhash,symbol,height);
HASH_AND_STRING(dex,getblock,hash,symbol); HASH_AND_STRING(dex,getblock,hash,symbol);
TWO_STRINGS(dex,sendrawtransaction,symbol,signedtx); TWO_STRINGS(dex,sendrawtransaction,symbol,signedtx);
HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout); HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout);
TWO_STRINGS(dex,importaddress,symbol,address);
TWO_STRINGS(zcash,passthru,function,hex); TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex); TWO_STRINGS(komodo,passthru,function,hex);

Loading…
Cancel
Save