org.fisco.bcos.web3j.protocol.core.methods.response.SendTransaction Java Examples

The following examples show how to use org.fisco.bcos.web3j.protocol.core.methods.response.SendTransaction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtendedRawTransactionManager.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Override
public SendTransaction sendTransaction(
        String signedTransaction, TransactionSucCallback callback)
        throws IOException, TxHashMismatchException {
    Request<?, SendTransaction> request = web3j.sendRawTransaction(signedTransaction);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(callback);

    request.sendOnly();

    return null;

    /*
    if (ethSendTransaction != null && !ethSendTransaction.hasError()) {
        String txHashLocal = Hash.sha3(signedTransaction);
        String txHashRemote = ethSendTransaction.getTransactionHash();
        if (!txHashVerifier.verify(txHashLocal, txHashRemote)) {
            throw new TxHashMismatchException(txHashLocal, txHashRemote);
        }
    }

    return ethSendTransaction;
    */
}
 
Example #2
Source File: RawTransactionManager.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Override
public SendTransaction sendTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        String data,
        BigInteger value,
        String extraData)
        throws IOException {

    Random r = new SecureRandom();
    BigInteger randomid = new BigInteger(250, r);
    BigInteger blockLimit = getBlockLimit();
    RawTransaction rawTransaction =
            RawTransaction.createTransaction(
                    randomid, gasPrice, gasLimit, blockLimit, to, value, data);

    return signAndSend(rawTransaction);
}
 
Example #3
Source File: RawTransactionManager.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
@Override
public SendTransaction sendTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        String data,
        BigInteger value,
        String extraData,
        TransactionSucCallback callback)
        throws IOException {
    Random r = new SecureRandom();
    BigInteger randomid = new BigInteger(250, r);
    BigInteger blockLimit = getBlockLimit();
    RawTransaction rawTransaction =
            RawTransaction.createTransaction(
                    randomid, gasPrice, gasLimit, blockLimit, to, value, data);

    return signAndSend(rawTransaction, callback);
}
 
Example #4
Source File: RawTransactionManager.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public SendTransaction signAndSend(RawTransaction rawTransaction) throws IOException {

        byte[] signedMessage;

        if (chainId > ChainId.NONE) {
            signedMessage = TransactionEncoder.signMessage(rawTransaction, chainId, credentials);
        } else {
            signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
        }

        String hexValue = Numeric.toHexString(signedMessage);
        SendTransaction sendTransaction = web3j.sendRawTransaction(hexValue).send();
        if (sendTransaction != null && !sendTransaction.hasError()) {
            String txHashLocal = Hash.sha3(hexValue);
            String txHashRemote = sendTransaction.getTransactionHash();
            if (!txHashVerifier.verify(txHashLocal, txHashRemote)) {
                throw new TxHashMismatchException(txHashLocal, txHashRemote);
            }
        }
        return sendTransaction;
    }
 
Example #5
Source File: RawTransactionManager.java    From web3sdk with Apache License 2.0 6 votes vote down vote up
public SendTransaction signAndSend(
        RawTransaction rawTransaction, TransactionSucCallback callback) throws IOException {

    byte[] signedMessage;

    if (chainId > ChainId.NONE) {
        signedMessage = TransactionEncoder.signMessage(rawTransaction, chainId, credentials);
    } else {
        signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
    }

    String hexValue = Numeric.toHexString(signedMessage);
    Request<?, SendTransaction> request = web3j.sendRawTransaction(hexValue);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(callback);
    request.sendOnly();

    return null;
}
 
Example #6
Source File: ManagedTransactionTester.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
void prepareTransactionRequest() throws IOException {
    SendTransaction sendTransaction = new SendTransaction();
    sendTransaction.setResult(TRANSACTION_HASH);

    Request<?, SendTransaction> rawTransactionRequest = mock(Request.class);
    when(rawTransactionRequest.send()).thenReturn(sendTransaction);
    when(web3j.sendRawTransaction(any(String.class)))
            .thenReturn((Request) rawTransactionRequest);
}
 
Example #7
Source File: TransService.java    From WeBASE-Front with Apache License 2.0 5 votes vote down vote up
/**
 * send message to node.
 *
 * @param signMsg signMsg
 * @param future future
 */
public void sendMessage(Web3j web3j, String signMsg,
        final CompletableFuture<TransactionReceipt> future) throws IOException {
    Request<?, SendTransaction> request = web3j.sendRawTransaction(signMsg);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(new TransactionSucCallback() {
        @Override
        public void onResponse(TransactionReceipt receipt) {
            log.info("onResponse receipt:{}", receipt);
            future.complete(receipt);
            return;
        }
    });
    request.send();
}
 
Example #8
Source File: JsonRpc2_0Web3j.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void sendRawTransactionAndGetProof(
        String signedTransactionData, TransactionSucCallback callback) throws IOException {
    Request<?, SendTransaction> request = sendRawTransactionAndGetProof(signedTransactionData);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(callback);

    request.sendOnly();
}
 
Example #9
Source File: JsonRpc2_0Web3j.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public Request<?, SendTransaction> sendRawTransactionAndGetProof(String signedTransactionData) {
    return new Request<>(
            "sendRawTransactionAndGetProof",
            Arrays.asList(groupId, signedTransactionData),
            web3jService,
            SendTransaction.class);
}
 
Example #10
Source File: JsonRpc2_0Web3j.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public void sendRawTransaction(String signedTransactionData, TransactionSucCallback callback)
        throws IOException {
    Request<?, SendTransaction> request = sendRawTransaction(signedTransactionData);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(callback);

    request.sendOnly();
}
 
Example #11
Source File: JsonRpc2_0Web3j.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public Request<?, SendTransaction> sendRawTransaction(String signedTransactionData) {
    return new Request<>(
            "sendRawTransaction",
            Arrays.asList(groupId, signedTransactionData),
            web3jService,
            SendTransaction.class);
}
 
Example #12
Source File: ExtendedRawTransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public SendTransaction signAndSend(
        ExtendedRawTransaction rawTransaction, TransactionSucCallback callback)
        throws IOException {
    String signedTransaction = sign(rawTransaction);
    SendTransaction result = sendTransaction(signedTransaction, callback);
    return result;
}
 
Example #13
Source File: ExtendedRawTransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public SendTransaction sendTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        String data,
        BigInteger value,
        String extraData,
        TransactionSucCallback callback)
        throws IOException {

    ExtendedRawTransaction rawTransaction =
            createTransaction(gasPrice, gasLimit, to, data, value, extraData);
    return signAndSend(rawTransaction, callback);
}
 
Example #14
Source File: ExtendedRawTransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public SendTransaction sendTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        String data,
        BigInteger value,
        String extraData)
        throws IOException {

    ExtendedRawTransaction rawTransaction =
            createTransaction(gasPrice, gasLimit, to, data, value, extraData);

    return signAndSend(rawTransaction);
}
 
Example #15
Source File: TransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Deprecated
private TransactionReceipt processResponse(SendTransaction transactionResponse)
        throws IOException, TransactionException {
    if (transactionResponse.hasError()) {
        throw new RuntimeException(
                "Error processing transaction request: "
                        + transactionResponse.getError().getMessage());
    }

    String transactionHash = transactionResponse.getTransactionHash();

    return null;
}
 
Example #16
Source File: TransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public SendTransaction sendTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        String data,
        BigInteger value,
        String extraData,
        TransactionSucCallback callback)
        throws IOException {
    return null;
}
 
Example #17
Source File: TransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
public abstract SendTransaction sendTransaction(
BigInteger gasPrice,
BigInteger gasLimit,
String to,
String data,
BigInteger value,
String extraData)
throws IOException;
 
Example #18
Source File: TransactionManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Deprecated
protected TransactionReceipt executeTransaction(
        BigInteger gasPrice,
        BigInteger gasLimit,
        String to,
        String data,
        BigInteger value,
        String extraData)
        throws IOException, TransactionException {

    SendTransaction sendTransaction =
            sendTransaction(gasPrice, gasLimit, to, data, value, extraData);
    return processResponse(sendTransaction);
}
 
Example #19
Source File: ExtendedRawTransactonAndGetProofManager.java    From web3sdk with Apache License 2.0 5 votes vote down vote up
@Override
public SendTransaction sendTransaction(
        String signedTransaction, TransactionSucCallback callback)
        throws IOException, TxHashMismatchException {
    Request<?, SendTransaction> request =
            getWeb3j().sendRawTransactionAndGetProof(signedTransaction);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(callback);

    request.sendOnly();

    return null;
}
 
Example #20
Source File: TransService.java    From WeBASE-Transaction with Apache License 2.0 5 votes vote down vote up
/**
 * send message to node.
 * 
 * @param signMsg signMsg
 * @param future future
 */
public void sendMessage(int groupId, String signMsg,
        final CompletableFuture<TransactionReceipt> future) throws IOException {
    Request<?, SendTransaction> request = web3jMap.get(groupId).sendRawTransaction(signMsg);
    request.setNeedTransCallback(true);
    request.setTransactionSucCallback(new TransactionSucCallback() {
        @Override
        public void onResponse(TransactionReceipt receipt) {
            log.info("onResponse receipt:{}", receipt);
            future.complete(receipt);
            return;
        }
    });
    request.send();
}
 
Example #21
Source File: TransactionManager.java    From web3sdk with Apache License 2.0 4 votes vote down vote up
public SendTransaction sendTransaction(
        String signedTransaction, TransactionSucCallback callback)
        throws IOException, TxHashMismatchException {
    return null;
}
 
Example #22
Source File: ExtendedRawTransactionManager.java    From web3sdk with Apache License 2.0 4 votes vote down vote up
public SendTransaction signAndSend(ExtendedRawTransaction rawTransaction) throws IOException {
    String signedTransaction = sign(rawTransaction);
    SendTransaction result = sendTransaction(signedTransaction);
    return result;
}
 
Example #23
Source File: TransactionManager.java    From web3sdk with Apache License 2.0 4 votes vote down vote up
public SendTransaction sendTransaction(String signedTransaction)
        throws IOException, TxHashMismatchException {
    return null;
}
 
Example #24
Source File: Ethereum.java    From web3sdk with Apache License 2.0 votes vote down vote up
Request<?, SendTransaction> sendRawTransaction(String signedTransactionData); 
Example #25
Source File: Ethereum.java    From web3sdk with Apache License 2.0 votes vote down vote up
Request<?, SendTransaction> sendRawTransactionAndGetProof(String signedTransactionData);