Java Code Examples for org.fisco.bcos.web3j.protocol.core.Request#setNeedTransCallback()

The following examples show how to use org.fisco.bcos.web3j.protocol.core.Request#setNeedTransCallback() . 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: 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 2
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 3
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 4
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 5
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;
}