Fix ContractCallDialog error

This commit is contained in:
nicksavers 2014-09-20 10:48:53 +02:00
parent e62c9d8e2a
commit 028cfe5ca3
2 changed files with 10 additions and 1 deletions

View File

@ -62,6 +62,10 @@ public class Utils {
}
return result.toString() + "·(" + "10^" + pow + ")";
}
public static boolean isValidAddress(byte[] addr) {
return addr != null && addr.length == 20;
}
/**
* @param addr length should be 20
@ -69,7 +73,7 @@ public class Utils {
*/
public static String getAddressShortString(byte[] addr) {
if (addr == null || addr.length != 20) throw new Error("not an address");
if (!isValidAddress(addr)) throw new Error("not an address");
String addrShort = Hex.toHexString(addr, 0, 3);

View File

@ -305,6 +305,11 @@ class ContractCallDialog extends JDialog implements MessageAwareDialog {
private void playContractCall() {
byte[] contractAddress = Hex.decode(contractAddrInput.getText());
if (!Utils.isValidAddress(contractAddress)) {
alertStatusMsg("Not a valid contract address");
return;
}
ContractDetails contractDetails = UIEthereumManager.ethereum.getRepository().getContractDetails(contractAddress);
if (contractDetails == null) {
alertStatusMsg("No contract for that address");