MultiversX Tracker is Live!

How to get one block at a time with bitcoinj?

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 179 Views

My ultimate goal is to find a bitcoin client that I can use to download specific blocks. I don't need a wallet right now, maybe in the future. But right now, I just need something that I can use to download one block at a time.

I downloaded and installed bitcoinj. This is the code I have so far:

NetworkParameters network_parameters = MainNetParams.get ();
PeerGroup peer_group = new PeerGroup (network_parameters);
peer_group.setUserAgent ("Test", "1.0");
peer_group.setFastCatchupTimeSecs (1645012000L);
DnsDiscovery dns_discovery = new DnsDiscovery (network_parameters);
List<InetSocketAddress> peers = dns_discovery.getPeers ((long) VersionMessage.NODE_NETWORK, 60L, TimeUnit.SECONDS);
peer_group.addPeerDiscovery (dns_discovery);
ForkJoinPool executor = new ForkJoinPool ();
ListenableFuture start_future = peer_group.startAsync ();
start_future.addListener (new Runnable () { public void run () { peer_group.downloadBlockChain (); }}, executor);

The ForkJoinPool seems to be causing some problem. I have no idea what to pass for the executor parameter to addListener. I'm not even sure if I am going about this in the right way, but I can't find any examples anywhere on the Internet. Is bitcoinj still maintained? Are there examples of how to get blocks from the blockchain anywhere?

Is there any other library that can be used to get individual blocks? Bitcoinj is the best thing I can find, but the examples don't seem to exist and there doesn't seem to be any documentation to explain how to do anything. I'm getting nowhere with it.


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments