Took me a while but I finally figured out how to iterate the blocks from 
the genesis block.  Here is the prototype code (in Kotlin) in case anyone 
is interested.  Thanks again for the help.

val networkParameters = TestNet3Params.get()
val blockStore = MemoryBlockStore(networkParameters)
val chain = BlockChain(networkParameters, blockStore)
val peerGroup = PeerGroup(networkParameters, chain)
val blockLimit = 10
var blockOrder = 0
var done =false
fun displayBlock(block:Block){
  println("[$blockOrder] ${block.hash}")
}
peerGroup.addBlocksDownloadedEventListener {
peer, block, filteredBlock, blocksLeft ->
if(!done) {
  blockOrder++
  displayBlock(block)
  if(blockOrder >= blockLimit-1) done = true
  if(blocksLeft == 0) done = true
  }
}
val dnsDiscovery = DnsDiscovery(networkParameters)
peerGroup.addPeerDiscovery(dnsDiscovery);
peerGroup.start()
val peer = peerGroup.waitForPeers(1).get()[0]
displayBlock(networkParameters.genesisBlock)
peer.startBlockChainDownload()
while(!done){
  Thread.sleep(1)
}

On Sunday, November 21, 2021 at 1:36:18 AM UTC-8 Andreas Schildbach wrote:

> There are a few examples and tools that operate with the protocol 
> directly, without any wallet.
>
> Classes to look at are Peer and PeerGroup, and the entire Message 
> hierarchy.
>
>
>
> On 21/11/2021 09.46, Sean Shubin wrote:
> > Just started looking at bitcoinj.  I am familiar with the bitcoin data 
> > structure, and want to write applications that analyze the blockchain 
> > data, so I am looking for a library that lets me interact with the 
> > bitcoin protocol directly.  Does bitcoinj have that capability or is it 
> > only a higher level library for managing wallets?  For my first 
> > prototype I intend to load the first 5000 blocks and compute for myself 
> > how many satoshi’s are at each address.  I have already found the 
> > getGenesisBlock method on the NetworkParameters class, but am having 
> > trouble finding out how to get the next block without creating a 
> > WalletAppKit and loading the previous 2,104,841 blocks off the test net 
> > from the BlockStore.  That seems like the wrong direction.  I am hoping 
> > someone already familiar with bitcoinj  can point me in the right 
> > direction regarding which classes I should be looking at first, without 
> > all the noise of capabilities I don’t need at the moment.
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "bitcoinj" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to [email protected] 
> > <mailto:[email protected]>.
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/bitcoinj/8a68259c-df2b-4e6f-956d-76929a61d5a9n%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/bitcoinj/8a68259c-df2b-4e6f-956d-76929a61d5a9n%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bitcoinj/de92e552-ffe6-41f7-a483-9ee672e0fa13n%40googlegroups.com.

Reply via email to