Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Fix default privateFrom behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-richardson committed Jul 26, 2019
1 parent 9336302 commit b6b6857
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import tech.pegasys.pantheon.util.bytes.BytesValue;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -69,7 +70,7 @@ public static class Builder {
Address to;
BytesValue privateFrom;
Optional<BytesValue> privacyGroupId = Optional.empty();
Optional<List<BytesValue>> privateFor = Optional.empty();
Optional<List<BytesValue>> privateFor = Optional.of(new ArrayList<>());
SECP256K1.KeyPair keyPair;

public Builder nonce(final long nonce) {
Expand Down Expand Up @@ -136,11 +137,10 @@ public String build(final TransactionType type) {
.privateFrom(privateFrom)
.restriction(Restriction.RESTRICTED);

if (privateFor.isPresent()) {
builder = builder.privateFor(privateFor.get());
}
if (privacyGroupId.isPresent()) {
builder = builder.privacyGroupId(privacyGroupId.get());
} else {
builder = builder.privateFor(privateFor.get());
}

return RLP.encode(builder.signAndBuild(keyPair)::writeTo).toString();
Expand Down

0 comments on commit b6b6857

Please sign in to comment.