Viacoin:[RPC] getCryptoAddress fix

This commit is contained in:
romanornr 2017-11-18 23:47:45 +01:00
parent 3f5f0d7665
commit ed72b2b849
No known key found for this signature in database
GPG Key ID: 3F92368F0D21A206
1 changed files with 12 additions and 7 deletions

View File

@ -74,17 +74,22 @@ public class ViacoindRPCWallet implements IWallet{
}
@Override
public String getCryptoAddress(String cryptoCurrency){
if(!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)){
public String getCryptoAddress(String cryptoCurrency) {
if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) {
log.error("Viacoind wallet error: unknown cryptocurrency.");
return null;
}
try{
double balance = getClient(rpcURL).getBalance(accountName);
return new BigDecimal(balance);
}catch(BitcoinException e){
try {
List<String> addressesByAccount = getClient(rpcURL).getAddressesByAccount(accountName);
if (addressesByAccount == null || addressesByAccount.size() == 0) {
return null;
}else{
return addressesByAccount.get(0);
}
} catch (BitcoinException e) {
e.printStackTrace();
return null
return null;
}
}