Skip to content

bruhanda/go-bitcoin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZMQ It is also possible to subscribe to a bitcoin node and be notified about new transactions and new blocks via the node's ZMQ interface.

First, create a ZMQ instance:

zmq := bitcoin.NewZMQ("localhost", 28332) Then create a buffered or unbuffered channel of strings and a goroutine to consume the channel:

ch := make(chan string)

go func() {
	for c := range ch {
		log.Println(c)
	}
}()

Finally, subscribe to "hashblock" or "hashtx" topics passing in your channel:

err := zmq.Subscribe("hashblock", ch)
if err != nil {
	log.Fatalln(err)
}

About

A simple library to interact with the Bitcoin RPC.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%