|
@ -1070,4 +1070,86 @@ INT_ARG(iguana,paxfiats,mask) |
|
|
komodo_assetcoins(1,mask); |
|
|
komodo_assetcoins(1,mask); |
|
|
return(clonestr("{\"result\":\"success\"}")); |
|
|
return(clonestr("{\"result\":\"success\"}")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int32_t utxocmp(cJSON *utxo,cJSON *utxo2) |
|
|
|
|
|
{ |
|
|
|
|
|
bits256 txid,txid2; int32_t vout=-1,vout2=-1; |
|
|
|
|
|
//printf("cmp (%s) vs (%s)\n",jprint(utxo,0),jprint(utxo2,0));
|
|
|
|
|
|
txid = jbits256(utxo,"txid"); |
|
|
|
|
|
vout = jint(utxo,"vout"); |
|
|
|
|
|
txid2 = jbits256(utxo2,"txid"); |
|
|
|
|
|
vout2 = jint(utxo2,"vout"); |
|
|
|
|
|
if ( bits256_cmp(txid,txid2) == 0 && vout == vout2 ) |
|
|
|
|
|
return(0); |
|
|
|
|
|
else return(-1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TWO_STRINGS(basilisk,refresh,symbol,address) |
|
|
|
|
|
{ |
|
|
|
|
|
cJSON *array=0,*array2=0,*array3,*item,*item2; char *retstr; int32_t i,j,n,m,vout; bits256 txid; |
|
|
|
|
|
if ( symbol != 0 && iguana_isnotarychain(symbol) >= 0 && address != 0 && address[0] != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( (retstr= _dex_listunspent(myinfo,symbol,address)) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
array = cJSON_Parse(retstr); |
|
|
|
|
|
free(retstr); |
|
|
|
|
|
} |
|
|
|
|
|
if ( (retstr= _dex_listunspent2(myinfo,symbol,address)) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( array == 0 ) |
|
|
|
|
|
array = cJSON_Parse(retstr); |
|
|
|
|
|
else array2 = cJSON_Parse(retstr); |
|
|
|
|
|
free(retstr); |
|
|
|
|
|
} |
|
|
|
|
|
if ( array != 0 && array2 != 0 ) // merge
|
|
|
|
|
|
{ |
|
|
|
|
|
m = cJSON_GetArraySize(array2); |
|
|
|
|
|
array3 = jduplicate(array); |
|
|
|
|
|
n = cJSON_GetArraySize(array3); |
|
|
|
|
|
//printf("MERGE %s and %s\n",jprint(array,0),jprint(array2,0));
|
|
|
|
|
|
for (j=0; j<m; j++) |
|
|
|
|
|
{ |
|
|
|
|
|
item2 = jitem(array2,j); |
|
|
|
|
|
for (i=0; i<n; i++) |
|
|
|
|
|
if ( utxocmp(jitem(array,i),item2) == 0 ) |
|
|
|
|
|
break; |
|
|
|
|
|
if ( i == n ) |
|
|
|
|
|
{ |
|
|
|
|
|
printf("FOUND NEW %s\n",jprint(item2,0)); |
|
|
|
|
|
jaddi(array3,jduplicate(item2)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
free_json(array); |
|
|
|
|
|
free_json(array2), array2 = 0; |
|
|
|
|
|
array = array3, array3 = 0; |
|
|
|
|
|
} |
|
|
|
|
|
if ( array != 0 ) // gettxout
|
|
|
|
|
|
{ |
|
|
|
|
|
n = cJSON_GetArraySize(array); |
|
|
|
|
|
array3 = cJSON_CreateArray(); |
|
|
|
|
|
for (i=0; i<n; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
item = jitem(array,i); |
|
|
|
|
|
txid = jbits256(item,"txid"); |
|
|
|
|
|
vout = jint(item,"vout"); |
|
|
|
|
|
if ( (retstr= _dex_gettxout(myinfo,symbol,txid,vout)) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( (item2= cJSON_Parse(retstr)) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( jdouble(item2,"value") > 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
//printf("%s, ",jprint(item2,0));
|
|
|
|
|
|
jaddi(array3,item2); |
|
|
|
|
|
} |
|
|
|
|
|
else free_json(item2); |
|
|
|
|
|
} |
|
|
|
|
|
free(retstr); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
free_json(array); |
|
|
|
|
|
return(jprint(array3,1)); |
|
|
|
|
|
} else return(clonestr("[]")); |
|
|
|
|
|
} |
|
|
|
|
|
return(clonestr("{\"error\":\"invalid coin or address specified\"}")); |
|
|
|
|
|
} |
|
|
#include "../includes/iguana_apiundefs.h" |
|
|
#include "../includes/iguana_apiundefs.h" |
|
|