Skip to content

Commit

Permalink
Merge pull request #654 from aionnetwork/apiserver_bugfix2
Browse files Browse the repository at this point in the history
Put Zero address if no from address supplied
  • Loading branch information
AionJayT authored Sep 27, 2018
2 parents 26b9e19 + 7adc455 commit 840bf7c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modAion/src/org/aion/zero/types/AionTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions modAionBase/src/org/aion/base/type/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
}
2 changes: 1 addition & 1 deletion modAionImpl/src/org/aion/zero/impl/AionBlockchainImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions modApiServer/src/org/aion/api/server/ApiAion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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("<send-transaction msg=invalid-from-address>");
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 840bf7c

Please sign in to comment.