Browse Source

Add ETH/ERC20 balance to few API methods.

patch-3
Artem Pikulin 7 years ago
parent
commit
f036d8cee5
  1. 7
      iguana/exchanges/LP_coins.c
  2. 14
      iguana/exchanges/LP_etomic.c
  3. 2
      iguana/exchanges/LP_etomic.h
  4. 6
      iguana/exchanges/LP_portfolio.c
  5. 6
      iguana/exchanges/LP_utxo.c

7
iguana/exchanges/LP_coins.c

@ -236,6 +236,13 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
jaddnum(item,"balance",dstr(balance));
jaddnum(item,"KMDvalue",dstr(LP_KMDvalue(coin,balance)));
}
#ifndef NOTETOMIC
else if (coin->etomic[0] != 0) {
balance = LP_etomic_get_balance(coin, coin->smartaddr);
jaddnum(item,"height",-1);
jaddnum(item,"balance",dstr(balance));
}
#endif
else
{
jaddnum(item,"height",-1);

14
iguana/exchanges/LP_etomic.c

@ -697,3 +697,17 @@ uint8_t LP_etomic_is_empty_tx_id(char *txId)
}
return 0;
}
uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr)
{
if (coin->etomic[0] == 0) {
printf("Trying to get etomic balance for non-etomic coin %s!", coin->symbol);
return 0;
}
if (strcmp(coin->symbol, "ETH") == 0) {
return getEthBalance(coinaddr);
} else {
return getErc20BalanceSatoshi(coinaddr, coin->etomic);
}
}

2
iguana/exchanges/LP_etomic.h

@ -49,4 +49,6 @@ int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]);
uint8_t LP_etomic_is_empty_tx_id(char *txId);
uint64_t LP_etomic_get_balance(struct iguana_info *coin, char *coinaddr);
#endif //SUPERNET_LP_ETOMIC_H

6
iguana/exchanges/LP_portfolio.c

@ -95,6 +95,12 @@ uint64_t LP_balance(uint64_t *valuep,int32_t iambob,char *symbol,char *coinaddr)
cJSON *array,*item; bits256 zero; int32_t i,n; uint64_t valuesum,satoshisum,value;
valuesum = satoshisum = 0;
memset(zero.bytes,0,sizeof(zero));
#ifndef NOTETOMIC
struct iguana_info *coin = LP_coinfind(symbol);
if (coin->etomic[0] != 0) {
valuesum = LP_etomic_get_balance(coin, coinaddr);
} else
#endif
if ( (array= LP_listunspent(symbol,coinaddr,zero,zero)) != 0 )
{
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )

6
iguana/exchanges/LP_utxo.c

@ -628,11 +628,7 @@ cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electr
memset(zero.bytes,0,sizeof(zero));
#ifndef NOTETOMIC
if (coin->etomic[0] != 0) {
if (strcmp(coin->symbol, "ETH") == 0) {
balance = getEthBalance(coinaddr);
} else {
balance = getErc20BalanceSatoshi(coinaddr, coin->etomic);
}
balance = LP_etomic_get_balance(coin, coinaddr);
} else
#endif
if ( coin->electrum == 0 )

Loading…
Cancel
Save