diff --git a/modAion/src/org/aion/zero/types/AionTransaction.java b/modAion/src/org/aion/zero/types/AionTransaction.java index fe7eaba796..4867e0b010 100644 --- a/modAion/src/org/aion/zero/types/AionTransaction.java +++ b/modAion/src/org/aion/zero/types/AionTransaction.java @@ -284,7 +284,7 @@ public boolean isContractCreation() { if (!parsed) { rlpParse(); } - return (this.to == null || this.to.equals(Address.EMPTY_ADDRESS())); + return (this.to == null || this.to.isEmptyAddress()); } @Override diff --git a/modAionBase/src/org/aion/base/type/Address.java b/modAionBase/src/org/aion/base/type/Address.java index c94f649d07..2ec634b2b7 100644 --- a/modAionBase/src/org/aion/base/type/Address.java +++ b/modAionBase/src/org/aion/base/type/Address.java @@ -174,4 +174,8 @@ public static final Address ZERO_ADDRESS() { public static final Address EMPTY_ADDRESS() { return emptyAddr; } + + public final boolean isEmptyAddress() { return this.equals(emptyAddr); } + + public final boolean isZeroAddress() { return this.equals(zeroAddr); } } diff --git a/modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java b/modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java index 36621de7dc..344dbad37c 100644 --- a/modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java +++ b/modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java @@ -237,7 +237,7 @@ protected AionBlockchainImpl(final A0BCConfig config, this.minerCoinbase = this.config.getMinerCoinbase(); - if (minerCoinbase.equals(Address.EMPTY_ADDRESS())) { + if (minerCoinbase.isEmptyAddress()) { LOG.warn("No miner Coinbase!"); } diff --git a/modAionImpl/src/org/aion/zero/impl/blockchain/AionImpl.java b/modAionImpl/src/org/aion/zero/impl/blockchain/AionImpl.java index 98a559baf3..ff11b4fdd9 100644 --- a/modAionImpl/src/org/aion/zero/impl/blockchain/AionImpl.java +++ b/modAionImpl/src/org/aion/zero/impl/blockchain/AionImpl.java @@ -103,7 +103,7 @@ public IMineRunner getBlockMiner() { Address minerCoinbase = Address.wrap(this.cfg.getConsensus().getMinerAddress()); - if (minerCoinbase.equals(Address.EMPTY_ADDRESS())) { + if (minerCoinbase.isEmptyAddress()) { LOG_GEN.info("Miner address is not set"); return null; } diff --git a/modApiServer/src/org/aion/api/server/ApiAion.java b/modApiServer/src/org/aion/api/server/ApiAion.java index cc2e3f74c6..bcbece4e8b 100644 --- a/modApiServer/src/org/aion/api/server/ApiAion.java +++ b/modApiServer/src/org/aion/api/server/ApiAion.java @@ -461,8 +461,10 @@ protected byte[] doCall(ArgTxCall _params) { } protected long estimateNrg(ArgTxCall params) { - AionTransaction tx = new AionTransaction(params.getNonce().toByteArray(), params.getFrom(), params.getTo(), + Address fromAddr = (params.getFrom().isEmptyAddress()) ? Address.ZERO_ADDRESS() : params.getFrom(); + AionTransaction tx = new AionTransaction(params.getNonce().toByteArray(), fromAddr, params.getTo(), params.getValue().toByteArray(), params.getData(), params.getNrg(), params.getNrgPrice()); + AionTxReceipt receipt = this.ac.callConstant(tx, this.ac.getAionHub().getBlockchain().getBestBlock()); return receipt.getEnergyUsed(); } @@ -471,7 +473,7 @@ protected ContractCreateResult createContract(ArgTxCall _params) { Address from = _params.getFrom(); - if (from == null || from.equals(Address.EMPTY_ADDRESS())) { + if (from == null || from.isEmptyAddress()) { return null; } @@ -537,7 +539,7 @@ protected byte[] sendTransaction(ArgTxCall _params) { Address from = _params.getFrom(); - if (from == null || from.equals(Address.EMPTY_ADDRESS())) { + if (from == null || from.isEmptyAddress()) { LOG.error(""); return null; } diff --git a/modPrecompiled/src/org/aion/precompiled/contracts/AionAuctionContract.java b/modPrecompiled/src/org/aion/precompiled/contracts/AionAuctionContract.java index 81dd957879..1d0cba80f4 100644 --- a/modPrecompiled/src/org/aion/precompiled/contracts/AionAuctionContract.java +++ b/modPrecompiled/src/org/aion/precompiled/contracts/AionAuctionContract.java @@ -617,7 +617,7 @@ private boolean hasActiveParentDomain(String domainName){ } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - if (!parentAddr.equals(Address.ZERO_ADDRESS())) { + if (!parentAddr.isZeroAddress()) { if (isActiveDomain(parentAddr)) return true; } } diff --git a/modPrecompiled/src/org/aion/precompiled/contracts/AionNameServiceContract.java b/modPrecompiled/src/org/aion/precompiled/contracts/AionNameServiceContract.java index 14a7ae72e8..292f54ab49 100644 --- a/modPrecompiled/src/org/aion/precompiled/contracts/AionNameServiceContract.java +++ b/modPrecompiled/src/org/aion/precompiled/contracts/AionNameServiceContract.java @@ -655,7 +655,7 @@ public Address getRegisteredDomainAddress(String domainName){ byte[] addressFirstPart = this.track.getStorageValue(registeredDomainNameAddress, new DataWord(blake128(domainName.getBytes()))).getData(); byte[] addressSecondPart = this.track.getStorageValue(registeredDomainNameAddress, new DataWord(blake128(blake128(domainName.getBytes())))).getData(); Address domainAddress = Address.wrap(combineTwoBytes(addressFirstPart, addressSecondPart)); - if (domainAddress.equals(Address.ZERO_ADDRESS())) + if (domainAddress.isZeroAddress()) return null; return domainAddress; }