Repository
https://github.com/btcsuite/btcd
What Will I Learn?
- Installing golang on Ubuntu
- Installing btcd
- Checking bitcoin address history with btcctl
Requirements
- Ubuntu VPS or local VM
- 200+GB block storage
- Unmetered internet connection
Difficulty
- Intermediate
Why BTCD
bitcoind (default Bitcoin Core full node) doesn’t support address lookup for past transactions, I’m building web applications that require bitcoin address monitoring and doing transaction notifications. Starting btcd with --addrindex gives you this feature.
I’m writing how to monitor any bitcoin address (not just your wallet) and sending transaction notifications in a separate post.
Let’s start
I don’t suggest running a bitcoin node on your laptop, but if you have 200GB+ space and unmetered internet bandwidth you can do it in a local virtual machine.
It’s better to spin up a cheap Ubuntu VPS with 200GB+ block storage, I recommend DigitalOcean or AWS. After creating your VPS, we’ll install btcd.
First, we need to install golang to our new ubuntu instance:
$ sudo apt install golang
$ echo 'export GOPATH=$HOME/go' >> ~/.bashrc
$ echo 'export PATH=${PATH}:${GOPATH}/bin' >> ~/.bashrc
$ source ~/.bashrc
Check the go version, we need at least 1.8 to use btcd.
$ go version
go version go1.10.1 linux/amd64
Now we can download btcd.
$ go get -u github.com/Masterminds/glide
$ git clone https://github.com/btcsuite/btcd $GOPATH/src/github.com/btcsuite/btcd
$ cd $GOPATH/src/github.com/btcsuite/btcd
$ glide install$ go install . ./cmd/...
Now btcd and btcctl installed, but before starting btcd, make sure we set config options, otherwise btcd creates rpc.cert only for localhost. We’ll need rpc.cert when we start developing our applications that connects JSON-RPC service of this node.
.btcd/btcd.conf configuration file
[Application Options]
rpcuser=myuser
rpcpass=SomeDecentp4ssw0rd
rpclisten=:8334
.btcd/btcctl.conf configuration file
[Application Options]
rpcuser=myuser
rpcpass=SomeDecentp4ssw0rd
We need to use --addrindex flag to create address index while blockchain history is synchronizing.
$ cd $GOPATH/bin
$ ./btcd --addrindex
This may take 1-3 days, depending on your connection and machine specs. But you can start testing on past blockchain data while it’s synchronizing.
You may also want to use bitcoin testnet by adding --testnet flag to btcd. This way you can easily test transactions with testnet coins.
You can check btcd documentation for more info.
Let’s try that address lookup:
$ cd $GOPATH/bin
$btcctl searchrawtransactions "12ib7dApVFvg82TXKycWBNpN8kFyiAN1dr"
If you get a large JSON response, you are good to go. Now we can start developing our apps that uses searchrawtransactions method.
Feel free to ask any questions. Thank you.
It requires so much free space on disk. Syncing the whole database seems like forever running process. Why is it so slow?
This is bitcoin full node with address index, which takes more space then regular bitcoin full node. If you play with both testnet and mainnet I recommend use 1TB disk space for future expansion.
First sync is slow, because it needs to download and create indexes for historical data. SSD disks and fast connection helps.
✅ @hdz, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!
Please also take a moment to read this post regarding bad behavior on Steemit.
Thank you for your contribution.
While I liked the content of your contribution, I would still like to extend few advices for your upcoming contributions:
See in this link an example of a good tutorial.
Looking forward to your upcoming tutorials.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Congratulations @hdz! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
You published your First Post
You got a First Vote
Click on any badge to view your Board of Honor.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Hey @hdz
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
Congratulations @hdz! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes received
Click on any badge to view your Board of Honor.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Congratulations @hdz!
Your post was mentioned in the Steemit Hit Parade for newcomers in the following category:
I also upvoted your post to increase its reward
If you like my work to promote newcomers and give them more visibility on Steemit, consider to vote for my witness!
Congratulations @hdz! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!