Search in sources :

Example 1 with RawPrivateTransaction

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);
}
Also used : BigInteger(java.math.BigInteger) RawPrivateTransaction(org.web3j.protocol.eea.crypto.RawPrivateTransaction)

Example 2 with RawPrivateTransaction

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);
}
Also used : BigInteger(java.math.BigInteger) RawPrivateTransaction(org.web3j.protocol.eea.crypto.RawPrivateTransaction)

Example 3 with RawPrivateTransaction

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();
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) BigInteger(java.math.BigInteger) RawPrivateTransaction(org.web3j.protocol.eea.crypto.RawPrivateTransaction)

Example 4 with RawPrivateTransaction

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);
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) EthSendTransaction(org.web3j.protocol.core.methods.response.EthSendTransaction) Base64String(org.web3j.utils.Base64String) RawPrivateTransaction(org.web3j.protocol.eea.crypto.RawPrivateTransaction)

Example 5 with RawPrivateTransaction

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();
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) BigInteger(java.math.BigInteger) RawPrivateTransaction(org.web3j.protocol.eea.crypto.RawPrivateTransaction)

Aggregations

RawPrivateTransaction (org.web3j.protocol.eea.crypto.RawPrivateTransaction)8 BigInteger (java.math.BigInteger)6 Base64String (org.web3j.utils.Base64String)4 Bytes (org.apache.tuweni.bytes.Bytes)3 PrivateTransactionReceipt (org.web3j.protocol.besu.response.privacy.PrivateTransactionReceipt)3 PollingPrivateTransactionReceiptProcessor (org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor)2 Enclave (org.hyperledger.besu.enclave.Enclave)1 ReceiveResponse (org.hyperledger.besu.enclave.types.ReceiveResponse)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 RawTransaction (org.web3j.crypto.RawTransaction)1 Sign (org.web3j.crypto.Sign)1 PrivateTransactionWithPrivacyGroup (org.web3j.protocol.besu.response.privacy.PrivateTransactionWithPrivacyGroup)1 EthSendTransaction (org.web3j.protocol.core.methods.response.EthSendTransaction)1