org.bitcoinj.core.PeerAddress Java Examples

The following examples show how to use org.bitcoinj.core.PeerAddress. 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: BlockChain.java    From polling-station-app with GNU Lesser General Public License v3.0 7 votes vote down vote up
public void startDownload() {
    BriefLogFormatter.init();
    String filePrefix = "voting-wallet";
    File walletFile = new File(Environment.getExternalStorageDirectory() + "/" + Util.FOLDER_DIGITAL_VOTING_PASS);
    if (!walletFile.exists()) {
        walletFile.mkdirs();
    }
    kit = new WalletAppKit(params, walletFile, filePrefix);

    //set the observer
    kit.setDownloadListener(progressTracker);

    kit.setBlockingStartup(false);

    PeerAddress peer = new PeerAddress(params, peeraddr);
    kit.setPeerNodes(peer);
    kit.startAsync();
}
 
Example #2
Source File: PeerAddressesRepositoryTest.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGetPeerAddressesWhenProxyAndClearNodes() {
    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    BtcNode onionNode = mock(BtcNode.class);
    when(node.hasOnionAddress()).thenReturn(true);

    BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
    PeerAddressesRepository repository = new PeerAddressesRepository(converter,
            Lists.newArrayList(node, onionNode));

    List<PeerAddress> peers = repository.getPeerAddresses(mock(Socks5Proxy.class), true);

    assertEquals(2, peers.size());
}
 
Example #3
Source File: BtcNodesRepository.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public List<PeerAddress> getPeerAddresses(@Nullable Socks5Proxy proxy, boolean isUseClearNodesWithProxies) {
    List<PeerAddress> result;
    // We connect to onion nodes only in case we use Tor for BitcoinJ (default) to avoid privacy leaks at
    // exit nodes with bloom filters.
    if (proxy != null) {
        List<PeerAddress> onionHosts = getOnionHosts();
        result = new ArrayList<>(onionHosts);

        if (isUseClearNodesWithProxies) {
            // We also use the clear net nodes (used for monitor)
            List<PeerAddress> torAddresses = getClearNodesBehindProxy(proxy);
            result.addAll(torAddresses);
        }
    } else {
        result = getClearNodes();
    }
    return result;
}
 
Example #4
Source File: BtcNodeConverter.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Nullable
PeerAddress convertOnionHost(BtcNode node) {
    // no DNS lookup for onion addresses
    String onionAddress = Objects.requireNonNull(node.getOnionAddress());
    try {
        // OnionCatConverter.onionHostToInetAddress converts onion to ipv6 representation
        // inetAddress is not used but required for wallet persistence. Throws nullPointer if not set.
        InetAddress inetAddress = facade.onionHostToInetAddress(onionAddress);
        PeerAddress result = new PeerAddress(onionAddress, node.getPort());
        result.setAddr(inetAddress);
        return result;
    } catch (UnknownHostException e) {
        log.error("Failed to convert node", e);
        return null;
    }
}
 
Example #5
Source File: BtcNetworkConfig.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public void proposePeers(List<PeerAddress> peers) {
    if (!peers.isEmpty()) {
        log.info("You connect with peerAddresses: {}", peers);
        PeerAddress[] peerAddresses = peers.toArray(new PeerAddress[peers.size()]);
        delegate.setPeerNodes(peerAddresses);
    } else if (proxy != null) {
        if (log.isWarnEnabled()) {
            MainNetParams mainNetParams = MainNetParams.get();
            if (parameters.equals(mainNetParams)) {
                log.warn("You use the public Bitcoin network and are exposed to privacy issues " +
                        "caused by the broken bloom filters. See https://bisq.network/blog/privacy-in-bitsquare/ " +
                        "for more info. It is recommended to use the provided nodes.");
            }
        }
        // SeedPeers uses hard coded stable addresses (from MainNetParams). It should be updated from time to time.
        delegate.setDiscovery(new Socks5MultiDiscovery(proxy, parameters, socks5DiscoverMode));
    } else if (Config.baseCurrencyNetwork().isMainnet()) {
        log.warn("You don't use tor and use the public Bitcoin network and are exposed to privacy issues " +
                "caused by the broken bloom filters. See https://bisq.network/blog/privacy-in-bitsquare/ " +
                "for more info. It is recommended to use Tor and the provided nodes.");
    }
}
 
Example #6
Source File: PeerAddressesRepositoryTest.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGetPeerAddressesWhenOnionNodesOnly() {
    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    BtcNode onionNode = mock(BtcNode.class);
    when(node.hasOnionAddress()).thenReturn(true);

    BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
    PeerAddressesRepository repository = new PeerAddressesRepository(converter,
            Lists.newArrayList(node, onionNode));

    List<PeerAddress> peers = repository.getPeerAddresses(mock(Socks5Proxy.class), false);

    assertEquals(1, peers.size());
}
 
Example #7
Source File: PeerAddressesRepositoryTest.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGetPeerAddressesWhenConverterReturnsNull() {
    BtcNodeConverter converter = mock(BtcNodeConverter.class);
    when(converter.convertClearNode(any())).thenReturn(null);

    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    PeerAddressesRepository repository = new PeerAddressesRepository(converter,
            Collections.singletonList(node));

    List<PeerAddress> peers = repository.getPeerAddresses(null, false);

    verify(converter).convertClearNode(any());
    assertTrue(peers.isEmpty());
}
 
Example #8
Source File: BtcNodeConverter.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
@Nullable
PeerAddress convertOnionHost(BtcNode node) {
    // no DNS lookup for onion addresses
    String onionAddress = Objects.requireNonNull(node.getOnionAddress());
    try {
        // OnionCat.onionHostToInetAddress converts onion to ipv6 representation
        // inetAddress is not used but required for wallet persistence. Throws nullPointer if not set.
        InetAddress inetAddress = facade.onionHostToInetAddress(onionAddress);
        PeerAddress result = new PeerAddress(onionAddress, node.getPort());
        result.setAddr(inetAddress);
        return result;
    } catch (UnknownHostException e) {
        log.error("Failed to convert node", e);
        return null;
    }
}
 
Example #9
Source File: BtcNodesRepositoryTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGetPeerAddressesWhenOnionNodesOnly() {
    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    BtcNode onionNode = mock(BtcNode.class);
    when(node.hasOnionAddress()).thenReturn(true);

    BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
    BtcNodesRepository repository = new BtcNodesRepository(converter,
            Lists.newArrayList(node, onionNode));

    List<PeerAddress> peers = repository.getPeerAddresses(mock(Socks5Proxy.class), false);

    assertEquals(1, peers.size());
}
 
Example #10
Source File: WalletNetworkConfig.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
void proposePeers(List<PeerAddress> peers) {
    if (!peers.isEmpty()) {
        log.info("You connect with peerAddresses: {}", peers);
        PeerAddress[] peerAddresses = peers.toArray(new PeerAddress[peers.size()]);
        delegate.setPeerNodes(peerAddresses);
    } else if (proxy != null) {
        if (log.isWarnEnabled()) {
            MainNetParams mainNetParams = MainNetParams.get();
            if (parameters.equals(mainNetParams)) {
                log.warn("You use the public Bitcoin network and are exposed to privacy issues " +
                        "caused by the broken bloom filters. See https://bisq.network/blog/privacy-in-bitsquare/ " +
                        "for more info. It is recommended to use the provided nodes.");
            }
        }
        // SeedPeers uses hard coded stable addresses (from MainNetParams). It should be updated from time to time.
        delegate.setDiscovery(new Socks5MultiDiscovery(proxy, parameters, socks5DiscoverMode));
    } else {
        log.warn("You don't use tor and use the public Bitcoin network and are exposed to privacy issues " +
                "caused by the broken bloom filters. See https://bisq.network/blog/privacy-in-bitsquare/ " +
                "for more info. It is recommended to use Tor and the provided nodes.");
    }
}
 
Example #11
Source File: BtcNodesRepositoryTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGetPeerAddressesWhenProxyAndClearNodes() {
    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    BtcNode onionNode = mock(BtcNode.class);
    when(node.hasOnionAddress()).thenReturn(true);

    BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
    BtcNodesRepository repository = new BtcNodesRepository(converter,
            Lists.newArrayList(node, onionNode));

    List<PeerAddress> peers = repository.getPeerAddresses(mock(Socks5Proxy.class), true);

    assertEquals(2, peers.size());
}
 
Example #12
Source File: PeerAddressesRepository.java    From bisq-core with GNU Affero General Public License v3.0 6 votes vote down vote up
List<PeerAddress> getPeerAddresses(@Nullable Socks5Proxy proxy, boolean isUseClearNodesWithProxies) {
    List<PeerAddress> result;
    // We connect to onion nodes only in case we use Tor for BitcoinJ (default) to avoid privacy leaks at
    // exit nodes with bloom filters.
    if (proxy != null) {
        List<PeerAddress> onionHosts = getOnionHosts();
        result = new ArrayList<>(onionHosts);

        if (isUseClearNodesWithProxies) {
            // We also use the clear net nodes (used for monitor)
            List<PeerAddress> torAddresses = getClearNodesBehindProxy(proxy);
            result.addAll(torAddresses);
        }
    } else {
        result = getClearNodes();
    }
    return result;
}
 
Example #13
Source File: BtcNodesRepositoryTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testGetPeerAddressesWhenConverterReturnsNull() {
    BtcNodeConverter converter = mock(BtcNodeConverter.class);
    when(converter.convertClearNode(any())).thenReturn(null);

    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    BtcNodesRepository repository = new BtcNodesRepository(converter,
            Collections.singletonList(node));

    List<PeerAddress> peers = repository.getPeerAddresses(null, false);

    verify(converter).convertClearNode(any());
    assertTrue(peers.isEmpty());
}
 
Example #14
Source File: BtcNodeConverterTest.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testConvertWithTor() throws DnsLookupException {
    InetAddress expected = mock(InetAddress.class);

    Facade facade = mock(Facade.class);
    when(facade.torLookup(any(), anyString())).thenReturn(expected);

    BtcNode node = mock(BtcNode.class);
    when(node.getHostNameOrAddress()).thenReturn("aaa.onion");

    PeerAddress peerAddress = new BtcNodeConverter(facade).convertWithTor(node, mock(Socks5Proxy.class));

    // noinspection ConstantConditions
    assertEquals(expected, peerAddress.getAddr());
}
 
Example #15
Source File: BtcNodeConverterTest.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
@Ignore
@Test
public void testConvertClearNode() {
    final String ip = "192.168.0.1";

    BtcNode node = mock(BtcNode.class);
    when(node.getHostNameOrAddress()).thenReturn(ip);

    PeerAddress peerAddress = new BtcNodeConverter().convertClearNode(node);
    // noinspection ConstantConditions
    InetAddress inetAddress = peerAddress.getAddr();
    assertEquals(ip, inetAddress.getHostName());
}
 
Example #16
Source File: SPV.java    From green_android with GNU General Public License v3.0 5 votes vote down vote up
private PeerAddress getPeerAddress(final String address) throws URISyntaxException, UnknownHostException {
    final URI uri = new URI("btc://" + address);
    final String host = uri.getHost();

    if (host == null)
        throw new UnknownHostException(address);

    final NetworkData networkData = mService.getNetwork();
    final int port = uri.getPort() == -1 ? networkData.getNetworkParameters().getPort() : uri.getPort();

    if (!isProxyEnabled() && !getTorEnabled())
        return new PeerAddress(networkData.getNetworkParameters(), InetAddress.getByName(host), port);

    return new PeerAddress(networkData.getNetworkParameters(), host, port) {
               @Override
               public InetSocketAddress toSocketAddress() {
                   return InetSocketAddress.createUnresolved(host, port);
               }

               @Override
               public String toString() {
                   return String.format("%s:%s", host, port);
               }

               @Override
               public int hashCode() {
                   return uri.hashCode();
               }
    };
}
 
Example #17
Source File: BtcNodeConverterTest.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testConvertOnionHost() throws UnknownHostException {
    BtcNode node = mock(BtcNode.class);
    when(node.getOnionAddress()).thenReturn("aaa.onion");

    InetAddress inetAddress = mock(InetAddress.class);

    Facade facade = mock(Facade.class);
    when(facade.onionHostToInetAddress(any())).thenReturn(inetAddress);

    PeerAddress peerAddress = new BtcNodeConverter(facade).convertOnionHost(node);
    // noinspection ConstantConditions
    assertEquals(inetAddress, peerAddress.getAddr());
}
 
Example #18
Source File: BtcNetworkConfigTest.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testProposePeersWhenPeersPresent() {
    BtcNetworkConfig config = new BtcNetworkConfig(delegate, mock(NetworkParameters.class), MODE,
            null);
    config.proposePeers(Collections.singletonList(mock(PeerAddress.class)));

    verify(delegate, never()).setDiscovery(any(Socks5MultiDiscovery.class));
    verify(delegate).setPeerNodes(any());
}
 
Example #19
Source File: WalletProtobufSerializerTest.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void oneTx() throws Exception {
    // Check basic tx serialization.
    Coin v1 = COIN;
    Transaction t1 = createFakeTx(UNITTEST, v1, myAddress);
    t1.getConfidence().markBroadcastBy(new PeerAddress(UNITTEST, InetAddress.getByName("1.2.3.4")));
    t1.getConfidence().markBroadcastBy(new PeerAddress(UNITTEST, InetAddress.getByName("5.6.7.8")));
    t1.getConfidence().setSource(TransactionConfidence.Source.NETWORK);
    myWallet.receivePending(t1, null);
    Wallet wallet1 = roundTrip(myWallet);
    assertEquals(1, wallet1.getTransactions(true).size());
    assertEquals(v1, wallet1.getBalance(Wallet.BalanceType.ESTIMATED));
    Transaction t1copy = wallet1.getTransaction(t1.getHash());
    assertArrayEquals(t1.unsafeBitcoinSerialize(), t1copy.unsafeBitcoinSerialize());
    assertEquals(2, t1copy.getConfidence().numBroadcastPeers());
    assertNotNull(t1copy.getConfidence().getLastBroadcastedAt());
    assertEquals(TransactionConfidence.Source.NETWORK, t1copy.getConfidence().getSource());

    Protos.Wallet walletProto = new WalletProtobufSerializer().walletToProto(myWallet);
    assertEquals(Protos.Key.Type.ORIGINAL, walletProto.getKey(0).getType());
    assertEquals(0, walletProto.getExtensionCount());
    assertEquals(1, walletProto.getTransactionCount());
    assertEquals(6, walletProto.getKeyCount());

    Protos.Transaction t1p = walletProto.getTransaction(0);
    assertEquals(0, t1p.getBlockHashCount());
    assertArrayEquals(t1.getHash().getBytes(), t1p.getHash().toByteArray());
    assertEquals(Protos.Transaction.Pool.PENDING, t1p.getPool());
    assertFalse(t1p.hasLockTime());
    assertFalse(t1p.getTransactionInput(0).hasSequence());
    assertArrayEquals(t1.getInputs().get(0).getOutpoint().getHash().getBytes(),
            t1p.getTransactionInput(0).getTransactionOutPointHash().toByteArray());
    assertEquals(0, t1p.getTransactionInput(0).getTransactionOutPointIndex());
    assertEquals(t1p.getTransactionOutput(0).getValue(), v1.value);
}
 
Example #20
Source File: SPV.java    From GreenBits with GNU General Public License v3.0 5 votes vote down vote up
private PeerAddress getPeerAddress(final String address) throws URISyntaxException, UnknownHostException {
    final URI uri = new URI("btc://" + address);
    final String host = uri.getHost();

    if (host == null)
        throw new UnknownHostException(address);

    final int port = uri.getPort() == -1? mService.getNetworkParameters().getPort() : uri.getPort();

    if (!mService.isProxyEnabled())
        return new PeerAddress(mService.getNetworkParameters(), InetAddress.getByName(host), port);

    return new PeerAddress(mService.getNetworkParameters(), host, port) {
        @Override
        public InetSocketAddress toSocketAddress() {
            return InetSocketAddress.createUnresolved(host, port);
        }

        @Override
        public String toString() {
            return String.format("%s:%s", host, port);
        }

        @Override
        public int hashCode() {
            return uri.hashCode();
        }
    };
}
 
Example #21
Source File: WalletsSetup.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configPeerNodesForRegTestServer() {
    try {
        if (RegTestHost.HOST.endsWith(".onion")) {
            walletConfig.setPeerNodes(new PeerAddress(RegTestHost.HOST, params.getPort()));
        } else {
            walletConfig.setPeerNodes(new PeerAddress(InetAddress.getByName(RegTestHost.HOST), params.getPort()));
        }
    } catch (UnknownHostException e) {
        log.error(e.toString());
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
 
Example #22
Source File: WalletsSetup.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configPeerNodes(@Nullable Socks5Proxy proxy) {
    BtcNodesSetupPreferences btcNodesSetupPreferences = new BtcNodesSetupPreferences(preferences);

    List<BtcNode> nodes = btcNodesSetupPreferences.selectPreferredNodes(btcNodes);
    int minBroadcastConnections = btcNodesSetupPreferences.calculateMinBroadcastConnections(nodes);
    walletConfig.setMinBroadcastConnections(minBroadcastConnections);

    BtcNodesRepository repository = new BtcNodesRepository(nodes);
    boolean isUseClearNodesWithProxies = (useAllProvidedNodes || btcNodesSetupPreferences.isUseCustomNodes());
    List<PeerAddress> peers = repository.getPeerAddresses(proxy, isUseClearNodesWithProxies);

    BtcNetworkConfig networkConfig = new BtcNetworkConfig(walletConfig, params, socks5DiscoverMode, proxy);
    networkConfig.proposePeers(peers);
}
 
Example #23
Source File: WalletConfig.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
void setPeerNodesForLocalHost() {
    try {
        setPeerNodes(new PeerAddress(InetAddress.getLocalHost(), params.getPort()));
    } catch (UnknownHostException e) {
        log.error(e.toString());
        e.printStackTrace();
        // Borked machine with no loopback adapter configured properly.
        throw new RuntimeException(e);
    }
}
 
Example #24
Source File: BtcNodeConverter.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Nullable
PeerAddress convertClearNode(BtcNode node) {
    int port = node.getPort();

    PeerAddress result = create(node.getHostNameOrAddress(), port);
    if (result == null) {
        String address = node.getAddress();
        if (address != null) {
            result = create(address, port);
        } else {
            log.warn("Lookup failed, no address for node", node);
        }
    }
    return result;
}
 
Example #25
Source File: BtcNodeConverter.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Nullable
PeerAddress convertWithTor(BtcNode node, Socks5Proxy proxy) {
    int port = node.getPort();

    PeerAddress result = create(proxy, node.getHostNameOrAddress(), port);
    if (result == null) {
        String address = node.getAddress();
        if (address != null) {
            result = create(proxy, address, port);
        } else {
            log.warn("Lookup failed, no address for node", node);
        }
    }
    return result;
}
 
Example #26
Source File: BtcNodeConverter.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Nullable
private PeerAddress create(Socks5Proxy proxy, String host, int port) {
    try {
        // We use DnsLookupTor to not leak with DNS lookup
        // Blocking call. takes about 600 ms ;-(
        InetAddress lookupAddress = facade.torLookup(proxy, host);
        InetSocketAddress address = new InetSocketAddress(lookupAddress, port);
        return new PeerAddress(address.getAddress(), address.getPort());
    } catch (Exception e) {
        log.error("Failed to create peer address", e);
        return null;
    }
}
 
Example #27
Source File: BtcNodeConverter.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Nullable
private static PeerAddress create(String hostName, int port) {
    try {
        InetSocketAddress address = new InetSocketAddress(hostName, port);
        return new PeerAddress(address.getAddress(), address.getPort());
    } catch (Exception e) {
        log.error("Failed to create peer address", e);
        return null;
    }
}
 
Example #28
Source File: WalletsSetup.java    From bisq-core with GNU Affero General Public License v3.0 5 votes vote down vote up
private void configPeerNodes(@Nullable Socks5Proxy proxy) {
    WalletSetupPreferences walletSetupPreferences = new WalletSetupPreferences(preferences);

    List<BtcNode> nodes = walletSetupPreferences.selectPreferredNodes(bitcoinNodes);
    int minBroadcastConnections = walletSetupPreferences.calculateMinBroadcastConnections(nodes);
    walletConfig.setMinBroadcastConnections(minBroadcastConnections);

    PeerAddressesRepository repository = new PeerAddressesRepository(nodes);
    boolean isUseClearNodesWithProxies = (useAllProvidedNodes || walletSetupPreferences.isUseCustomNodes());
    List<PeerAddress> peers = repository.getPeerAddresses(proxy, isUseClearNodesWithProxies);

    WalletNetworkConfig networkConfig = new WalletNetworkConfig(walletConfig, params, socks5DiscoverMode, proxy);
    networkConfig.proposePeers(peers);
}
 
Example #29
Source File: BtcNodeConverterTest.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Ignore
@Test
public void testConvertClearNode() {
    final String ip = "192.168.0.1";

    BtcNode node = mock(BtcNode.class);
    when(node.getHostNameOrAddress()).thenReturn(ip);

    PeerAddress peerAddress = new BtcNodeConverter().convertClearNode(node);
    // noinspection ConstantConditions
    InetAddress inetAddress = peerAddress.getAddr();
    assertEquals(ip, inetAddress.getHostName());
}
 
Example #30
Source File: BtcNodesRepositoryTest.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testGetPeerAddressesWhenClearNodes() {
    BtcNode node = mock(BtcNode.class);
    when(node.hasClearNetAddress()).thenReturn(true);

    BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
    BtcNodesRepository repository = new BtcNodesRepository(converter,
            Collections.singletonList(node));

    List<PeerAddress> peers = repository.getPeerAddresses(null, false);

    assertFalse(peers.isEmpty());
}