mirror of https://github.com/hyperledger/besu
[PAN-2910] Eea get private transaction fix (#1707)
Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>pull/2/head
parent
405405e4e6
commit
26c7e05948
@ -0,0 +1,53 @@ |
||||
/* |
||||
* Copyright 2019 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.privacy; |
||||
|
||||
import tech.pegasys.pantheon.ethereum.privacy.PrivateTransaction; |
||||
import tech.pegasys.pantheon.util.bytes.BytesValues; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonGetter; |
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
||||
|
||||
@JsonPropertyOrder({ |
||||
"from", |
||||
"gas", |
||||
"gasPrice", |
||||
"hash", |
||||
"input", |
||||
"nonce", |
||||
"to", |
||||
"value", |
||||
"v", |
||||
"r", |
||||
"s", |
||||
"privateFrom", |
||||
"privacyGroupId", |
||||
"restriction" |
||||
}) |
||||
/* |
||||
The original deserialised private transaction sent via eea_sendRawTransaction |
||||
This class is used if the original request was sent with privateFrom and privateFor |
||||
*/ |
||||
public class PrivateTransactionGroupResult extends PrivateTransactionResult { |
||||
private final String privacyGroupId; |
||||
|
||||
public PrivateTransactionGroupResult(final PrivateTransaction tx) { |
||||
super(tx); |
||||
this.privacyGroupId = BytesValues.asBase64String(tx.getPrivacyGroupId().get()); |
||||
} |
||||
|
||||
@JsonGetter(value = "privateFor") |
||||
public String getPrivacyGroupId() { |
||||
return privacyGroupId; |
||||
} |
||||
} |
@ -0,0 +1,59 @@ |
||||
/* |
||||
* Copyright 2019 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.privacy; |
||||
|
||||
import tech.pegasys.pantheon.ethereum.privacy.PrivateTransaction; |
||||
import tech.pegasys.pantheon.util.bytes.BytesValues; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonGetter; |
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
||||
|
||||
@JsonPropertyOrder({ |
||||
"from", |
||||
"gas", |
||||
"gasPrice", |
||||
"hash", |
||||
"input", |
||||
"nonce", |
||||
"to", |
||||
"value", |
||||
"v", |
||||
"r", |
||||
"s", |
||||
"privateFrom", |
||||
"privateFor", |
||||
"restriction" |
||||
}) |
||||
/* |
||||
The original deserialised private transaction sent via eea_sendRawTransaction |
||||
This class is used if the original request was sent with privateFrom and privateFor |
||||
*/ |
||||
public class PrivateTransactionLegacyResult extends PrivateTransactionResult { |
||||
private final List<String> privateFor; |
||||
|
||||
public PrivateTransactionLegacyResult(final PrivateTransaction tx) { |
||||
super(tx); |
||||
this.privateFor = |
||||
tx.getPrivateFor().get().stream() |
||||
.map(BytesValues::asBase64String) |
||||
.collect(Collectors.toList()); |
||||
} |
||||
|
||||
@JsonGetter(value = "privateFor") |
||||
public List<String> getPrivateFor() { |
||||
return privateFor; |
||||
} |
||||
} |
@ -0,0 +1,117 @@ |
||||
/* |
||||
* Copyright 2019 ConsenSys AG. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
||||
* specific language governing permissions and limitations under the License. |
||||
*/ |
||||
package tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.privacy; |
||||
|
||||
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.Quantity; |
||||
import tech.pegasys.pantheon.ethereum.privacy.PrivateTransaction; |
||||
import tech.pegasys.pantheon.util.bytes.BytesValue; |
||||
import tech.pegasys.pantheon.util.bytes.BytesValues; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonGetter; |
||||
|
||||
public abstract class PrivateTransactionResult { |
||||
private final String from; |
||||
private final String gas; |
||||
private final String gasPrice; |
||||
private final String hash; |
||||
private final String input; |
||||
private final String nonce; |
||||
private final String to; |
||||
private final String value; |
||||
private final String v; |
||||
private final String r; |
||||
private final String s; |
||||
private final String privateFrom; |
||||
private final String restriction; |
||||
|
||||
public PrivateTransactionResult(final PrivateTransaction tx) { |
||||
this.from = tx.getSender().toString(); |
||||
this.gas = Quantity.create(tx.getGasLimit()); |
||||
this.gasPrice = Quantity.create(tx.getGasPrice()); |
||||
this.hash = tx.hash().toString(); |
||||
this.input = tx.getPayload().toString(); |
||||
this.nonce = Quantity.create(tx.getNonce()); |
||||
this.to = tx.getTo().map(BytesValue::toString).orElse(null); |
||||
this.value = Quantity.create(tx.getValue()); |
||||
this.v = Quantity.create(tx.getV()); |
||||
this.r = Quantity.create(tx.getR()); |
||||
this.s = Quantity.create(tx.getS()); |
||||
this.privateFrom = BytesValues.asBase64String(tx.getPrivateFrom()); |
||||
this.restriction = BytesValues.asString(tx.getRestriction().getBytes()); |
||||
} |
||||
|
||||
@JsonGetter(value = "from") |
||||
public String getFrom() { |
||||
return from; |
||||
} |
||||
|
||||
@JsonGetter(value = "gas") |
||||
public String getGas() { |
||||
return gas; |
||||
} |
||||
|
||||
@JsonGetter(value = "gasPrice") |
||||
public String getGasPrice() { |
||||
return gasPrice; |
||||
} |
||||
|
||||
@JsonGetter(value = "hash") |
||||
public String getHash() { |
||||
return hash; |
||||
} |
||||
|
||||
@JsonGetter(value = "input") |
||||
public String getInput() { |
||||
return input; |
||||
} |
||||
|
||||
@JsonGetter(value = "nonce") |
||||
public String getNonce() { |
||||
return nonce; |
||||
} |
||||
|
||||
@JsonGetter(value = "to") |
||||
public String getTo() { |
||||
return to; |
||||
} |
||||
|
||||
@JsonGetter(value = "value") |
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
@JsonGetter(value = "v") |
||||
public String getV() { |
||||
return v; |
||||
} |
||||
|
||||
@JsonGetter(value = "r") |
||||
public String getR() { |
||||
return r; |
||||
} |
||||
|
||||
@JsonGetter(value = "s") |
||||
public String getS() { |
||||
return s; |
||||
} |
||||
|
||||
@JsonGetter(value = "privateFrom") |
||||
public String getPrivateFrom() { |
||||
return privateFrom; |
||||
} |
||||
|
||||
@JsonGetter(value = "restriction") |
||||
public String getRestriction() { |
||||
return restriction; |
||||
} |
||||
} |
Loading…
Reference in new issue