jl777 7 years ago
parent
commit
4a3172ee06
  1. 1
      iguana/exchanges/LP_include.h
  2. 7
      iguana/exchanges/LP_rpc.c
  3. 2
      iguana/exchanges/LP_socket.c
  4. 42
      iguana/exchanges/LP_utxo.c

1
iguana/exchanges/LP_include.h

@ -303,6 +303,7 @@ int32_t LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter);
int32_t LP_mempoolscan(char *symbol,bits256 searchtxid); int32_t LP_mempoolscan(char *symbol,bits256 searchtxid);
int32_t LP_txheight(struct iguana_info *coin,bits256 txid); int32_t LP_txheight(struct iguana_info *coin,bits256 txid);
void LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight); void LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrumret);
#endif #endif

7
iguana/exchanges/LP_rpc.c

@ -425,12 +425,7 @@ cJSON *LP_listunspent(char *symbol,char *coinaddr)
{ {
sprintf(buf,"[0, 99999999, [\"%s\"]]",coinaddr); sprintf(buf,"[0, 99999999, [\"%s\"]]",coinaddr);
return(bitcoin_json(coin,"listunspent",buf)); return(bitcoin_json(coin,"listunspent",buf));
} } else return(LP_address_utxos(coin,coinaddr,0));
else
{
printf("return local RAM listunspent\n");
return(0);
}
} else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr)); } else return(electrum_address_listunspent(symbol,coin->electrum,&retjson,coinaddr));
} }

2
iguana/exchanges/LP_socket.c

@ -470,7 +470,7 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON
strcpy(coin->lastunspent,addr); strcpy(coin->lastunspent,addr);
coin->unspenttime = (uint32_t)time(NULL); coin->unspenttime = (uint32_t)time(NULL);
} }
} } else retjson = LP_address_utxos(coin,addr,1);
return(retjson); return(retjson);
} }

42
iguana/exchanges/LP_utxo.c

@ -34,7 +34,7 @@ uint64_t LP_value_extract(cJSON *obj)
if ( (val= jdouble(obj,"amount")) < SMALLVAL ) if ( (val= jdouble(obj,"amount")) < SMALLVAL )
val = jdouble(obj,"value"); val = jdouble(obj,"value");
if ( val > SMALLVAL ) if ( val > SMALLVAL )
value = (val * SATOSHIDEN + 0.0000000049); value = ((val + jdouble(obj,"interest")) * SATOSHIDEN + 0.0000000049);
else value = 0; else value = 0;
return(value); return(value);
} }
@ -120,6 +120,44 @@ void LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int
portable_mutex_unlock(&coin->txmutex); portable_mutex_unlock(&coin->txmutex);
} }
cJSON *LP_address_item(struct iguana_info *coin,struct LP_address_utxo *up,int32_t electrumret)
{
cJSON *item = cJSON_CreateObject();
if ( electrumret == 0 )
{
jaddbits256(item,"txid",up->U.txid);
jaddnum(item,"vout",up->U.vout);
jaddnum(item,"confirmations",coin->height - up->U.height);
jaddnum(item,"amount",dstr(up->U.value));
jaddstr(item,"scriptPubKey","");
}
else
{
jaddbits256(item,"tx_hash",up->U.txid);
jaddnum(item,"tx_pos",up->U.vout);
jaddnum(item,"height",up->U.height);
jadd64bits(item,"value",up->U.value);
}
return(item);
}
cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrumret)
{
cJSON *array; struct LP_address *ap; struct LP_address_utxo *up,*tmp;
array = cJSON_CreateArray();
portable_mutex_lock(&coin->txmutex);
if ( (ap= _LP_addressfind(coin,coinaddr)) != 0 )
{
DL_FOREACH_SAFE(ap->utxos,up,tmp)
{
if ( up->spendheight <= 0 )
jaddi(array,LP_address_item(up,electrumret));
}
}
portable_mutex_unlock(&coin->txmutex);
return(array);
}
/*void LP_address_monitor(struct LP_pubkeyinfo *pubp) /*void LP_address_monitor(struct LP_pubkeyinfo *pubp)
{ {
struct iguana_info *coin,*tmp; char coinaddr[64]; cJSON *retjson; struct LP_address *ap; struct iguana_info *coin,*tmp; char coinaddr[64]; cJSON *retjson; struct LP_address *ap;
@ -423,7 +461,7 @@ uint64_t LP_txvalue(char *coinaddr,char *symbol,bits256 txid,int32_t vout)
{ {
if ( (txobj= LP_gettxout(coin->symbol,txid,vout)) != 0 ) if ( (txobj= LP_gettxout(coin->symbol,txid,vout)) != 0 )
{ {
value = SATOSHIDEN * jdouble(txobj,"value"); value = SATOSHIDEN * (jdouble(txobj,"value") + jdouble(txobj,"interest"));
if ( coinaddr == 0 ) if ( coinaddr == 0 )
coinaddr = _coinaddr; coinaddr = _coinaddr;
LP_destaddr(coinaddr,txobj); LP_destaddr(coinaddr,txobj);

Loading…
Cancel
Save