diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 54bead88a..d7f78a5b1 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -193,6 +193,7 @@ int32_t dex_rwrequest(int32_t rwflag,uint8_t *serialized,struct dex_request *dex 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); if ( rwflag != 0 ) { memcpy(&serialized[len],dexreq->name,sizeof(dexreq->name)), len += sizeof(dexreq->name); @@ -261,7 +262,7 @@ char *dex_response(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp) char *_dex_sendrequest(struct supernet_info *myinfo,struct dex_request *dexreq) { - uint8_t packet[sizeof(dexreq)]; int32_t datalen; + uint8_t packet[sizeof(*dexreq)]; int32_t datalen; datalen = dex_rwrequest(1,packet,dexreq); return(dex_reqsend(myinfo,"request",packet,datalen)); } @@ -279,6 +280,7 @@ char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 t char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout) { struct dex_request dexreq; + char str[65]; printf("gettxout(%s %s %d)\n",symbol,bits256_str(str,txid),vout); memset(&dexreq,0,sizeof(dexreq)); safecopy(dexreq.name,symbol,sizeof(dexreq.name)); dexreq.hash = txid; diff --git a/iguana/iguana_json.c b/iguana/iguana_json.c index 14471dbc1..ca7a1fea3 100755 --- a/iguana/iguana_json.c +++ b/iguana/iguana_json.c @@ -128,6 +128,7 @@ cJSON *SuperNET_helpjson() #define IGUANA_HELP_HH(agent,name,hash,hash2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#hash2,"hash"))) #define IGUANA_HELP_HA(agent,name,hash,obj) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#obj,"array"))) #define IGUANA_HELP_HS(agent,name,hash,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray2(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#str,"str"))) +#define IGUANA_HELP_HSI(agent,name,hash,str,val) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#str,"str"),helpitem(#val,"int"))) #define IGUANA_HELP_HII(agent,name,hash,val,val2) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#val,"int"),helpitem(#val2,"int"))) #define IGUANA_HELP_HHS(agent,name,hash,hash2,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#hash2,"hash"),helpitem(#str,"str"))) #define IGUANA_HELP_HAS(agent,name,hash,obj,str) array = helpjson(IGUANA_ARGS,#agent,#name,helparray3(cJSON_CreateArray(),helpitem(#hash,"hash"),helpitem(#obj,"array"),helpitem(#str,"str"))) @@ -152,6 +153,7 @@ cJSON *SuperNET_helpjson() #define STRING_AND_INT IGUANA_HELP_SI #define STRING_AND_TWOINTS IGUANA_HELP_SII #define HASH_AND_STRING IGUANA_HELP_HS +#define HASH_AND_STRING_AND_INT IGUANA_HELP_HSI #define HASH_AND_INT IGUANA_HELP_HI #define HASH_AND_TWOINTS IGUANA_HELP_HII #define DOUBLE_ARG IGUANA_HELP_D @@ -960,6 +962,7 @@ char *SuperNET_parser(struct supernet_info *myinfo,char *agentstr,char *method,c #define IGUANA_DISPATCH_HH(agent,name,hash,hash2) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jbits256(json,#hash2))) #define IGUANA_DISPATCH_HA(agent,name,hash,array) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jobj(json,#array))) #define IGUANA_DISPATCH_HS(agent,name,hash,str) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jstr(json,#str))) +#define IGUANA_DISPATCH_HSI(agent,name,hash,str,val) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jstr(json,#str),jint(json,#val))) #define IGUANA_DISPATCH_HII(agent,name,hash,val,val2) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),juint(json,#val),juint(json,#val2))) #define IGUANA_DISPATCH_HHS(agent,name,hash,hash2,str) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jbits256(json,#hash2),jstr(json,#str))) #define IGUANA_DISPATCH_HAS(agent,name,hash,array,str) else if ( strcmp(#agent,agentstr) == 0 && strcmp(method,#name) == 0 ) return(agent ## _ ## name(IGUANA_ARGS,jbits256(json,#hash),jobj(json,#array),jstr(json,#str))) @@ -985,6 +988,7 @@ char *SuperNET_parser(struct supernet_info *myinfo,char *agentstr,char *method,c #define STRING_AND_TWOINTS IGUANA_DISPATCH_SII #define HASH_AND_INT IGUANA_DISPATCH_HI #define HASH_AND_STRING IGUANA_DISPATCH_HS +#define HASH_AND_STRING_AND_INT IGUANA_DISPATCH_HSI #define HASH_AND_TWOINTS IGUANA_DISPATCH_HII #define DOUBLE_ARG IGUANA_DISPATCH_D #define STRING_AND_ARRAY IGUANA_DISPATCH_SA diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 4d0979140..8a6bef6bd 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -508,6 +508,11 @@ HASH_AND_STRING(dex,gettransaction,txid,symbol) return(_dex_getrawtransaction(myinfo,symbol,txid)); } +HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout) +{ + return(_dex_gettxout(myinfo,symbol,txid,vout)); +} + STRING_ARG(dex,getinfo,symbol) { return(_dex_getinfo(myinfo,symbol)); diff --git a/iguana/tests/dexgetO b/iguana/tests/dexgetO new file mode 100755 index 000000000..6f87a475e --- /dev/null +++ b/iguana/tests/dexgetO @@ -0,0 +1,2 @@ +#!/bin/bash +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettxout\",\"vout\":0,\"txid\":\"aa82ebd1c5bd2a9e19214cbc959df1745378676fddfd6f4903930ac16485c7ae\",\"symbol\":\"BTC\"}" diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 05f28668e..4f291ecd0 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -27,6 +27,7 @@ STRING_ARG(dex,getbestblockhash,symbol); STRING_AND_INT(dex,getblockhash,symbol,height); HASH_AND_STRING(dex,getblock,hash,symbol); TWO_STRINGS(dex,sendrawtransaction,symbol,signedtx); +HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout); TWO_STRINGS(zcash,passthru,function,hex); TWO_STRINGS(komodo,passthru,function,hex); diff --git a/includes/iguana_apidefs.h b/includes/iguana_apidefs.h index 7668e1475..08013ef18 100755 --- a/includes/iguana_apidefs.h +++ b/includes/iguana_apidefs.h @@ -39,6 +39,7 @@ #define IGUANA_CFUNC_HI(agent,name,hash,val) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,int32_t val) #define IGUANA_CFUNC_H(agent,name,hash) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash) #define IGUANA_CFUNC_HS(agent,name,hash,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,char *str) +#define IGUANA_CFUNC_HSI(agent,name,hash,str,val) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,char *str,int32_t val) #define IGUANA_CFUNC_HA(agent,name,hash,array) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,cJSON *array) #define IGUANA_CFUNC_HH(agent,name,hash,hash2) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,bits256 hash2) #define IGUANA_CFUNC_HHS(agent,name,hash,hash2,str) char *agent ## _ ## name(IGUANA_ARGS,bits256 hash,bits256 hash2,char *str) @@ -65,6 +66,7 @@ #define STRING_AND_TWOINTS IGUANA_CFUNC_SII #define HASH_AND_INT IGUANA_CFUNC_HI #define HASH_AND_STRING IGUANA_CFUNC_HS +#define HASH_AND_STRING_AND_INT IGUANA_CFUNC_HSI #define TWOHASHES_AND_STRING IGUANA_CFUNC_HHS #define HASH_AND_TWOINTS IGUANA_CFUNC_HII #define DOUBLE_ARG IGUANA_CFUNC_D diff --git a/includes/iguana_apiundefs.h b/includes/iguana_apiundefs.h index 7f70ed381..0b793ee2d 100755 --- a/includes/iguana_apiundefs.h +++ b/includes/iguana_apiundefs.h @@ -12,6 +12,7 @@ #undef STRING_AND_INT #undef STRING_AND_TWOINTS #undef HASH_AND_STRING +#undef HASH_AND_STRING_AND_INT #undef HASH_AND_INT #undef HASH_AND_TWOINTS #undef DOUBLE_ARG