use of org.web3j.protocol.eea.crypto.RawPrivateTransaction in project web3j by web3j.
the class PrivateTransactionManager method sendTransaction.
@Override
public EthSendTransaction sendTransaction(final BigInteger gasPrice, final BigInteger gasLimit, final String to, final String data, final BigInteger value, final boolean constructor) throws IOException {
final BigInteger nonce = besu.privGetTransactionCount(txSignService.getAddress(), privacyGroupId).send().getTransactionCount();
final RawPrivateTransaction transaction;
if (privateFor != null) {
transaction = RawPrivateTransaction.createTransaction(nonce, gasPrice, gasLimit, to, data, privateFrom, privateFor, restriction);
} else {
transaction = RawPrivateTransaction.createTransaction(nonce, gasPrice, gasLimit, to, data, privateFrom, privacyGroupId, restriction);
}
return signAndSend(transaction);
}
use of org.web3j.protocol.eea.crypto.RawPrivateTransaction in project web3j by web3j.
the class PrivateTransactionManager method sendEIP1559Transaction.
@Override
public EthSendTransaction sendEIP1559Transaction(long chainId, BigInteger maxPriorityFeePerGas, BigInteger maxFeePerGas, BigInteger gasLimit, String to, String data, BigInteger value, boolean constructor) throws IOException {
final BigInteger nonce = besu.privGetTransactionCount(txSignService.getAddress(), privacyGroupId).send().getTransactionCount();
final RawPrivateTransaction transaction;
if (privateFor != null) {
transaction = RawPrivateTransaction.createTransaction(chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, data, privateFrom, privateFor, restriction);
} else {
transaction = RawPrivateTransaction.createTransaction(chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, data, privateFrom, privacyGroupId, restriction);
}
return signAndSend(transaction);
}
use of org.web3j.protocol.eea.crypto.RawPrivateTransaction in project besu by hyperledger.
the class PrivacyRequestFactory method privxAddToPrivacyGroup.
public String privxAddToPrivacyGroup(final Base64String privacyGroupId, final PrivacyNode adder, final Credentials signer, final List<String> addresses) throws IOException {
final BigInteger nonce = besuClient.privGetTransactionCount(signer.getAddress(), privacyGroupId).send().getTransactionCount();
final Bytes payload = encodeAddToGroupFunctionCall(addresses.stream().map(Bytes::fromBase64String).collect(Collectors.toList()));
final RawPrivateTransaction privateTransaction = RawPrivateTransaction.createTransaction(nonce, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), FLEXIBLE_PRIVACY_PROXY.toHexString(), payload.toHexString(), Base64String.wrap(adder.getEnclaveKey()), privacyGroupId, org.web3j.utils.Restriction.RESTRICTED);
return besuClient.eeaSendRawTransaction(Numeric.toHexString(PrivateTransactionEncoder.signMessage(privateTransaction, signer))).send().getTransactionHash();
}
use of org.web3j.protocol.eea.crypto.RawPrivateTransaction in project besu by hyperledger.
the class PrivacyRequestFactory method privxCreatePrivacyGroup.
public PrivxCreatePrivacyGroupResponse privxCreatePrivacyGroup(final PrivacyNode creator, final String privateFrom, final List<String> addresses) throws IOException {
final byte[] bytes = new byte[32];
secureRandom.nextBytes(bytes);
final Bytes privacyGroupId = Bytes.wrap(bytes);
final Bytes payload = encodeAddToGroupFunctionCall(addresses.stream().map(Bytes::fromBase64String).collect(Collectors.toList()));
final RawPrivateTransaction privateTransaction = RawPrivateTransaction.createTransaction(BigInteger.ZERO, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), FLEXIBLE_PRIVACY_PROXY.toHexString(), payload.toHexString(), Base64String.wrap(privateFrom), Base64String.wrap(privacyGroupId.toArrayUnsafe()), org.web3j.utils.Restriction.RESTRICTED);
final Request<?, EthSendTransaction> ethSendTransactionRequest = besuClient.eeaSendRawTransaction(Numeric.toHexString(PrivateTransactionEncoder.signMessage(privateTransaction, Credentials.create(creator.getTransactionSigningKey()))));
final String transactionHash = ethSendTransactionRequest.send().getTransactionHash();
return new PrivxCreatePrivacyGroupResponse(privacyGroupId.toBase64String(), transactionHash);
}
use of org.web3j.protocol.eea.crypto.RawPrivateTransaction in project besu by hyperledger.
the class PrivacyRequestFactory method privxRemoveFromPrivacyGroup.
public String privxRemoveFromPrivacyGroup(final Base64String privacyGroupId, final String removerTenant, final Credentials signer, final String toRemove) throws IOException {
final BigInteger nonce = besuClient.privGetTransactionCount(signer.getAddress(), privacyGroupId).send().getTransactionCount();
final Bytes payload = encodeRemoveFromGroupFunctionCall(Bytes.fromBase64String(toRemove));
final RawPrivateTransaction privateTransaction = RawPrivateTransaction.createTransaction(nonce, BigInteger.valueOf(1000), BigInteger.valueOf(3000000), FLEXIBLE_PRIVACY_PROXY.toHexString(), payload.toHexString(), Base64String.wrap(removerTenant), privacyGroupId, org.web3j.utils.Restriction.RESTRICTED);
return besuClient.eeaSendRawTransaction(Numeric.toHexString(PrivateTransactionEncoder.signMessage(privateTransaction, signer))).send().getTransactionHash();
}
Aggregations