Search in sources :

Example 1 with BtcdDaemonImpl

use of com.neemre.btcdcli4j.daemon.BtcdDaemonImpl in project bisq-core by bisq-network.

the class RpcService method setup.

public void setup() throws BsqBlockchainException {
    try {
        long startTs = System.currentTimeMillis();
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        CloseableHttpClient httpProvider = HttpClients.custom().setConnectionManager(cm).build();
        Properties nodeConfig = new Properties();
        nodeConfig.setProperty("node.bitcoind.rpc.protocol", "http");
        nodeConfig.setProperty("node.bitcoind.rpc.host", "127.0.0.1");
        nodeConfig.setProperty("node.bitcoind.rpc.auth_scheme", "Basic");
        nodeConfig.setProperty("node.bitcoind.rpc.user", rpcUser);
        nodeConfig.setProperty("node.bitcoind.rpc.password", rpcPassword);
        nodeConfig.setProperty("node.bitcoind.rpc.port", rpcPort);
        nodeConfig.setProperty("node.bitcoind.notification.block.port", rpcBlockPort);
        nodeConfig.setProperty("node.bitcoind.notification.alert.port", "64647");
        nodeConfig.setProperty("node.bitcoind.notification.wallet.port", "64648");
        nodeConfig.setProperty("node.bitcoind.http.auth_scheme", "Basic");
        BtcdClientImpl client = new BtcdClientImpl(httpProvider, nodeConfig);
        daemon = new BtcdDaemonImpl(client);
        log.info("Setup took {} ms", System.currentTimeMillis() - startTs);
        this.client = client;
    } catch (BitcoindException | CommunicationException e) {
        if (e instanceof CommunicationException)
            log.error("Probably Bitcoin core is not running or the rpc port is not set correctly. rpcPort=" + rpcPort);
        log.error(e.toString());
        e.printStackTrace();
        log.error(e.getCause() != null ? e.getCause().toString() : "e.getCause()=null");
        throw new BsqBlockchainException(e.getMessage(), e);
    } catch (Throwable e) {
        log.error(e.toString());
        e.printStackTrace();
        throw new BsqBlockchainException(e.toString(), e);
    }
}
Also used : BsqBlockchainException(bisq.core.dao.blockchain.exceptions.BsqBlockchainException) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) CommunicationException(com.neemre.btcdcli4j.core.CommunicationException) BtcdClientImpl(com.neemre.btcdcli4j.core.client.BtcdClientImpl) BtcdDaemonImpl(com.neemre.btcdcli4j.daemon.BtcdDaemonImpl) BitcoindException(com.neemre.btcdcli4j.core.BitcoindException) Properties(java.util.Properties) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager)

Aggregations

BsqBlockchainException (bisq.core.dao.blockchain.exceptions.BsqBlockchainException)1 BitcoindException (com.neemre.btcdcli4j.core.BitcoindException)1 CommunicationException (com.neemre.btcdcli4j.core.CommunicationException)1 BtcdClientImpl (com.neemre.btcdcli4j.core.client.BtcdClientImpl)1 BtcdDaemonImpl (com.neemre.btcdcli4j.daemon.BtcdDaemonImpl)1 Properties (java.util.Properties)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)1