Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put Zero address if no from address supplied #654

Merged
merged 3 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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