How to get notified of a new block using bitcoinj?

56 views
Skip to first unread message

ringti...@gmail.com

unread,
Nov 7, 2017, 5:24:27 AM11/7/17
to bitcoinj

Hi,

Am looking on how to get notified of the arrival of a new block. Can this be done? will it contain the block height info and the relay as well as timestamp?

thanks

Andreas Schildbach

unread,
Nov 8, 2017, 11:46:52 AM11/8/17
to bitc...@googlegroups.com
Have a look at NewBestBlockListener and the
org.bitcoinj.core.AbstractBlockChain.addNewBestBlockListener() method.
If you prefer an example, the BuildCheckpoints tool (in the tools
subproject) has some code that does this.

Nana

unread,
Nov 8, 2017, 12:18:05 PM11/8/17
to bitc...@googlegroups.com
great thanks appreciate it!




--
You received this message because you are subscribed to a topic in the Google Groups "bitcoinj" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bitcoinj/Y4Z-v782D04/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bitcoinj+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
massacre

Nana

unread,
Nov 8, 2017, 11:51:13 PM11/8/17
to bitc...@googlegroups.com
Hi Andreas,

A few more things then i promise i wont bother again

1. how does one know if a new block is marked as "orphaned"?
2. through bitcoinj, can you get all block details, well height and then the timestamp? are these timestamps all UTC timezone? or the timezone of who finds the block?

Great thanks

Regards,
Neil

--
massacre

Nana

unread,
Nov 10, 2017, 1:30:00 AM11/10/17
to bitc...@googlegroups.com
Hi

Am stuck

import org.bitcoinj.net.discovery.DnsDiscovery; //cant find this

my pom file
<dependency>
    <groupId>org.bitcoinj</groupId>
    <artifactId>bitcoinj-core</artifactId>
    <version>0.14.5</version>
</dependency>
<dependency>
    <groupId>net.sf.jopt-simple</groupId>
    <artifactId>jopt-simple</artifactId>
    <version>4.3</version>
</dependency>
<dependency>
    <groupId>org.bitcoinj</groupId>
    <artifactId>bitcoinj-tools</artifactId>
    <version>0.14.5</version>
</dependency>

any help please?


--
massacre

Andreas Schildbach

unread,
Nov 13, 2017, 2:36:48 PM11/13/17
to bitc...@googlegroups.com
1. There is a second listener called ReorganizeListener. Orphaned blocks
will be in "oldBlocks".

2. Have a look at the "Block" class. The timestamp is UTC, but be aware
it can drift quite a bit (up to 2 hours) according to consensus.


On 11/09/2017 05:51 AM, Nana wrote:
> Hi Andreas,
>
> A few more things then i promise i wont bother again
>
> 1. how does one know if a new block is marked as "orphaned"?
> 2. through bitcoinj, can you get all block details, well height and then
> the timestamp? are these timestamps all UTC timezone? or the timezone of
> who finds the block?
>
> Great thanks
>
> Regards,
> Neil
>
>
> On Wed, Nov 8, 2017 at 7:18 PM, Nana <ringti...@gmail.com
> <mailto:ringti...@gmail.com>> wrote:
>
> great thanks appreciate it!
>
>
> On Wed, Nov 8, 2017 at 6:46 PM, Andreas Schildbach
> <and...@schildbach.de <mailto:and...@schildbach.de>> wrote:
>
> Have a look at NewBestBlockListener and the
> org.bitcoinj.core.AbstractBlockChain.addNewBestBlockListener()
> method.
> If you prefer an example, the BuildCheckpoints tool (in the tools
> subproject) has some code that does this.
>
>
> On 11/07/2017 11:24 AM, ringti...@gmail.com
> <mailto:ringti...@gmail.com> wrote:
> >
> > Hi,
> >
> > Am looking on how to get notified of the arrival of a new
> block. Can this
> > be done? will it contain the block height info and the relay
> as well as
> > timestamp?
> >
> > thanks
> >
>
>
> --
> You received this message because you are subscribed to a topic
> in the Google Groups "bitcoinj" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/bitcoinj/Y4Z-v782D04/unsubscribe
> <https://groups.google.com/d/topic/bitcoinj/Y4Z-v782D04/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email
> to bitcoinj+u...@googlegroups.com
> <mailto:bitcoinj%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
> massacre
>
>
>
>
> --
> massacre
>
> --
> 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 bitcoinj+u...@googlegroups.com
> <mailto:bitcoinj+u...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages