|
@ -313,7 +313,7 @@ cJSON *LP_gettx(char *symbol,bits256 txid) |
|
|
|
|
|
|
|
|
cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout) |
|
|
cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout) |
|
|
{ |
|
|
{ |
|
|
char buf[128],str[65],coinaddr[64],*hexstr; uint64_t value,val; uint8_t *serialized; cJSON *sobj,*addresses,*item,*array,*hexobj,*retjson=0; int32_t i,n,v,len; bits256 t; struct iguana_info *coin; |
|
|
char buf[128],str[65],coinaddr[64],*hexstr; uint64_t value; uint8_t *serialized; cJSON *sobj,*addresses,*item,*array,*hexobj,*retjson=0; int32_t i,n,v,len; bits256 t; struct iguana_info *coin; |
|
|
if ( symbol == 0 || symbol[0] == 0 ) |
|
|
if ( symbol == 0 || symbol[0] == 0 ) |
|
|
return(cJSON_Parse("{\"error\":\"null symbol\"}")); |
|
|
return(cJSON_Parse("{\"error\":\"null symbol\"}")); |
|
|
coin = LP_coinfind(symbol); |
|
|
coin = LP_coinfind(symbol); |
|
@ -351,7 +351,7 @@ cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout) |
|
|
LP_swap_coinaddr(coin,coinaddr,&value,serialized,len,vout); |
|
|
LP_swap_coinaddr(coin,coinaddr,&value,serialized,len,vout); |
|
|
//printf("HEX.(%s) len.%d %s %.8f\n",hexstr+1,len,coinaddr,dstr(value));
|
|
|
//printf("HEX.(%s) len.%d %s %.8f\n",hexstr+1,len,coinaddr,dstr(value));
|
|
|
free(hexstr); |
|
|
free(hexstr); |
|
|
if ( (array= LP_listunspent(coin->symbol,coinaddr)) != 0 ) |
|
|
if ( (array= electrum_address_listunspent(coin->symbol,0,&array,coinaddr)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
//printf("array.(%s)\n",jprint(array,0));
|
|
|
//printf("array.(%s)\n",jprint(array,0));
|
|
|
if ( array != 0 && (n= cJSON_GetArraySize(array)) > 0 ) |
|
|
if ( array != 0 && (n= cJSON_GetArraySize(array)) > 0 ) |
|
@ -359,20 +359,8 @@ cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout) |
|
|
for (i=0; i<n; i++) |
|
|
for (i=0; i<n; i++) |
|
|
{ |
|
|
{ |
|
|
item = jitem(array,i); |
|
|
item = jitem(array,i); |
|
|
if ( coin->electrum == 0 ) |
|
|
t = jbits256(item,"tx_hash"); |
|
|
{ |
|
|
v = jint(item,"tx_pos"); |
|
|
t = jbits256(item,"txid"); |
|
|
|
|
|
v = jint(item,"vout"); |
|
|
|
|
|
val = LP_value_extract(item,0); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
t = jbits256(item,"tx_hash"); |
|
|
|
|
|
v = jint(item,"tx_pos"); |
|
|
|
|
|
val = j64bits(item,"value"); |
|
|
|
|
|
} |
|
|
|
|
|
if ( value != val ) |
|
|
|
|
|
printf("LP_gettxout: value %llu != %llu\n",(long long)value,(long long)val); |
|
|
|
|
|
if ( v == vout && bits256_cmp(t,txid) == 0 ) |
|
|
if ( v == vout && bits256_cmp(t,txid) == 0 ) |
|
|
{ |
|
|
{ |
|
|
retjson = cJSON_CreateObject(); |
|
|
retjson = cJSON_CreateObject(); |
|
@ -392,6 +380,8 @@ cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout) |
|
|
"version": 1, |
|
|
"version": 1, |
|
|
"coinbase": false |
|
|
"coinbase": false |
|
|
}*/ |
|
|
}*/ |
|
|
|
|
|
if ( value != j64bits(item,"value") ) |
|
|
|
|
|
printf("LP_gettxout: value %llu != %llu\n",(long long)value,(long long)j64bits(item,"value")); |
|
|
jaddnum(retjson,"value",dstr(value)); |
|
|
jaddnum(retjson,"value",dstr(value)); |
|
|
jaddbits256(retjson,"txid",t); |
|
|
jaddbits256(retjson,"txid",t); |
|
|
jaddnum(retjson,"vout",v); |
|
|
jaddnum(retjson,"vout",v); |
|
@ -502,11 +492,11 @@ cJSON *LP_listunspent(char *symbol,char *coinaddr) |
|
|
} else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr)); |
|
|
} else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void LP_listunspent_issue(char *symbol,char *coinaddr) |
|
|
int32_t LP_listunspent_issue(char *symbol,char *coinaddr) |
|
|
{ |
|
|
{ |
|
|
struct iguana_info *coin; cJSON *retjson=0; char *retstr=0,destip[64]; uint16_t destport; |
|
|
struct iguana_info *coin; int32_t n = 0; cJSON *retjson=0; char *retstr=0,destip[64]; uint16_t destport; |
|
|
if ( symbol == 0 || symbol[0] == 0 ) |
|
|
if ( symbol == 0 || symbol[0] == 0 ) |
|
|
return; |
|
|
return(0); |
|
|
if ( (coin= LP_coinfind(symbol)) != 0 ) |
|
|
if ( (coin= LP_coinfind(symbol)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
if ( coin->electrum != 0 ) |
|
|
if ( coin->electrum != 0 ) |
|
@ -525,6 +515,7 @@ void LP_listunspent_issue(char *symbol,char *coinaddr) |
|
|
} |
|
|
} |
|
|
if ( retjson != 0 ) |
|
|
if ( retjson != 0 ) |
|
|
{ |
|
|
{ |
|
|
|
|
|
n = cJSON_GetArraySize(retjson); |
|
|
if ( electrum_process_array(coin,0,coinaddr,retjson) != 0 ) |
|
|
if ( electrum_process_array(coin,0,coinaddr,retjson) != 0 ) |
|
|
LP_postutxos(symbol,coinaddr); // might be good to not saturate
|
|
|
LP_postutxos(symbol,coinaddr); // might be good to not saturate
|
|
|
} |
|
|
} |
|
@ -534,6 +525,7 @@ void LP_listunspent_issue(char *symbol,char *coinaddr) |
|
|
if ( retstr != 0 ) |
|
|
if ( retstr != 0 ) |
|
|
free(retstr); |
|
|
free(retstr); |
|
|
} |
|
|
} |
|
|
|
|
|
return(n); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag) |
|
|
cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag) |
|
|