jl777 8 years ago
parent
commit
969d518254
  1. 50
      iguana/exchanges/LP_rpc.c
  2. 8
      iguana/exchanges/LP_utxos.c

50
iguana/exchanges/LP_rpc.c

@ -351,19 +351,6 @@ cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout)
}
}
cJSON *LP_listunspent(char *symbol,char *coinaddr)
{
char buf[128]; cJSON *retjson; struct iguana_info *coin = LP_coinfind(symbol);
//printf("LP_listunspent.(%s %s)\n",symbol,coinaddr);
if ( coin == 0 || coin->inactive != 0 )
return(cJSON_Parse("{\"error\":\"no coin\"}"));
if ( coin->electrum == 0 )
{
sprintf(buf,"[0, 99999999, [\"%s\"]]",coinaddr);
return(bitcoin_json(coin,"listunspent",buf));
} else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr));
}
/*cJSON *LP_listtransactions(char *symbol,char *coinaddr,int32_t count,int32_t skip)
{
char buf[128]; struct iguana_info *coin = LP_coinfind(symbol);
@ -410,6 +397,43 @@ cJSON *LP_validateaddress(char *symbol,char *address)
}
}
int32_t LP_address_ismine(char *symbol,char *address)
{
int32_t doneflag = 0; cJSON *retjson;
if ( (retjson= LP_validateaddress(symbol,address)) != 0 )
{
if ( jobj(retjson,"ismine") != 0 && is_cJSON_True(jobj(retjson,"ismine")) != 0 )
{
doneflag = 1;
//printf("%s already ismine\n",address);
}
//printf("%s\n",jprint(retjson,0));
free_json(retjson);
}
return(doneflag);
}
cJSON *LP_listunspent(char *symbol,char *coinaddr)
{
char buf[128]; cJSON *retjson; struct iguana_info *coin = LP_coinfind(symbol);
//printf("LP_listunspent.(%s %s)\n",symbol,coinaddr);
if ( coin == 0 || coin->inactive != 0 )
return(cJSON_Parse("{\"error\":\"no coin\"}"));
if ( coin->electrum == 0 )
{
if ( LP_address_ismine(symbol,coinaddr) > 0 )
{
sprintf(buf,"[0, 99999999, [\"%s\"]]",coinaddr);
return(bitcoin_json(coin,"listunspent",buf));
}
else
{
printf("return local RAM listunspent\n");
return(0);
}
} else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr));
}
cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag)
{
static void *ctx;

8
iguana/exchanges/LP_utxos.c

@ -758,9 +758,9 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
//printf("array.%d\n",n);
while ( used < n-1 )
{
for (i=0; i<n; i++)
printf("%.8f ",dstr(values[i]));
printf("used.%d of n.%d\n",used,n);
//for (i=0; i<n; i++)
// printf("%.8f ",dstr(values[i]));
//printf("used.%d of n.%d\n",used,n);
if ( (i= LP_maxvalue(values,n)) >= 0 )
{
item = jitem(array,i);
@ -783,7 +783,7 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
else targetval = (depositval / 9) * 8 + 2*txfee;
if ( targetval < txfee*2 )
targetval = txfee*2;
printf("iambob.%d i.%d deposit %.8f min %.8f target %.8f\n",iambob,i,dstr(depositval),dstr((1+LP_MINSIZE_TXFEEMULT)*txfee),dstr(targetval));
//printf("iambob.%d i.%d deposit %.8f min %.8f target %.8f\n",iambob,i,dstr(depositval),dstr((1+LP_MINSIZE_TXFEEMULT)*txfee),dstr(targetval));
if ( depositval < (1+LP_MINSIZE_TXFEEMULT)*txfee )
continue;
i = -1;

Loading…
Cancel
Save