Tag Archives: go

The Bitcoin Consensus Red Herring

Red Herring

Red Herring

In a recent post on bitcointalk, I stated that focusing solely on the forking risk created by alternative implementations is a red herring because, while there is certainly risk involved, it is merely a symptom of a more fundamental issue that all implementations, including Bitcoin Core itself, suffer. This statement seems to have confused a few people, so, in this blog post, I’d like to delve a little deeper into why this is the case, identify what the real underlying issue is, and offer a potential solution.

First, let’s establish a few baseline facts that, to my knowledge, everyone agrees with:

  • Every fully-validating node on the network must follow the exact same consensus rules or a fork will occur
  • The consensus rules are complex and contain various non-intuitive corner cases, some of which probably still have not been identified
  • Chain forks can be abused to create double spends and generally wreak havoc
  • Every new version of Bitcoin Core carries some level of forking risk (if there is any doubt about this, see the March 2013 fork that already happened)
  • Alternative implementations carry some level of forking risk

Continue reading

Introducing btcrpcclient — Bitcoin RPC Made Easy

Bitcoin JSON-RPC

Bitcoin JSON-RPC

Have you been looking for a robust and easy to use way to interface with Bitcoin through the JSON-RPC API? We’ve got you covered!

We’re excited to announce btcrpcclient, a new Websocket-enabled Bitcoin JSON-RPC client package written in Go. This package allows you to quickly create robust Bitcoin RPC clients in just a few minutes.

Major Features of the btcrpcclient Package

  • Supports Websockets (btcd and btcwallet) and HTTP POST mode (Bitcoin Core)
  • Provides callback and registration functions for btcd and btcwallet notifications
  • Supports btcd and btcwallet extensions
  • Translates to and from high-level statically-typed Go types
  • Offers a synchronous (blocking) and asynchronous (non-blocking) API
  • When running in Websockets mode (the default):
    • Provides automatic reconnect handling (can be disabled if desired)
    • Outstanding commands are automatically reissued on reconnect
    • Registered notifications are automatically re-registered on reconnect
    • Back-off support on reconnect attempts

Continue reading

Btcd + getwork + cgminer = profit



We are pleased to announce that btcd, our full-node bitcoind (bitcoin core) alternative written in Go, now has support for the getwork RPC which allows it to function with cgminer!

We have extensively tested the code on testnet. The following is a sampling of the latest blocks we’ve generated on testnet using btcd + cgminer: 226713 226830 227228 227390 227393.

If you are simply interested in learning how to configure btcd to work with cgminer, you can view the setup instructions on the btcd wiki, however if you’re interested to learn about some of the nuts and bolts that make it all work, read on.

Isn’t getwork deprecated?

Before I dig into some of the details, I would like to touch on a topic that I’m sure some astute readers will undoubtedly be asking, which is “Why implement getwork when it has been deprecated in favor of getblocktemplate (BIP0022 and BIP0023)?”

There are a few reasons why we chose to implement it first:

  • Supporting getwork was a lot less time consuming than getblocktemplate proposals and software such as cgminer still functions properly with getwork. This means we were able to release support for mining more quickly by supporting getwork first.
  • The bulk of the work involved was the code to create and manipulate block templates which is used by both getwork and getblocktemplate. Thus it helps pave the way to supporting getblocktemplate proposals while allowing getwork to function in the mean time.
  • The current reference implementation (bitcoin core) still supports getwork. Even though it will likely be removed in the next version, one of the goals of btcd is to be a drop-in alternative that can be used with existing infrastructures.

Continue reading

btcwallet and btcgui: Wallet handling for btcd

Today Conformal is announcing alpha releases of btcwallet and btcgui, the wallet components of btcd, written in Go. We announced in a recent blog post that btcd, our full node Bitcoin implementation, was ready for public testing. We also announced that wallet functionality was being implemented separately and would be coming in the near future. Although our wallet daemon and GUI interface are not yet ready for production use, we feel they have progressed to the point where early adopters can begin testing their functionality on the Bitcoin Testnet network.

Our btcd blog post briefly discussed why wallet functionality is not a part of btcd. It highlighted various reasons why we believe separating wallet handling from blockchain handling improves on the integrated wallet design used by bitcoind and bitcoin-qt. This post will continue on that topic, further exploring the details of why a multiprocess wallet design was chosen, how such a design is beneficial to the Bitcoin community as a whole, and the implementation details this design.
Continue reading

btcd: Not your mom’s Bitcoin daemon

We are pleased to announce that btcd, our full-node bitcoind alternative written in Go, is finally ready for public testing!

The installation instructions and source code can be found on github at:


A Brief History

Back in May, we first announced our plans to release btcd. A week later we released our first core package from btcd, btcwire, and announced our plans to continue releasing the component packages of btcd in a staggered fashion.

Over the next month, we released btcjson, btcdb, and btcscript. Then in mid-July we released btcchain at which time we announced btcd was next. At that point, btcd had most of the core bits and we figured we’d be releasing it within a few weeks. Well, as you have no doubt noticed, it is now 10 weeks later…
Continue reading

Coinvoice: Invoice in USD, receive BTC

Coinvoice logo

I am excited to announce Coinvoice, a new Bitcoin payment processing service that allows businesses to invoice for goods and services worldwide in U.S. Dollars (USD) and get paid in Bitcoins (BTC). Coinvoice makes it easy for any merchant to receive BTC without them or their customers having to worry about the infrastructure necessary to conduct and process these transactions. So long as the merchant’s customers can pay in USD via wire transfer, certified check or money order, Coinvoice will pay out to the merchant in BTC.

The idea for Coinvoice arose out of a handful of conversations I had regarding Bitcoins and receiving payment for invoices using cryptocurrencies more generally. I had remarked to one of my associates that “it would be great to take payment for invoices in BTC”, but I acknowledged that it was a serious pain point to dictate to all of your customers “now you need to go get BTC to pay me”. Then I went on to suggest I would be willing to give a discount on the invoice amount if they paid in BTC, and the seed for Coinvoice was sowed.

settle payments in BTC

settle payments in BTC

Beyond making a business out of the scenario I described above, Coinvoice is meant to fulfill a vital need in the Bitcoin economy: putting BTC in the hands of business owners with less friction. Enabling businesses to more easily access BTC is overall a positive thing for the Bitcoin economy, and it will have positive secondary effects, e.g. more customers for sites that accept direct BTC payments. More generically, Coinvoice is meant to enable payment settlement from USD to BTC, whereas most existing payment processing services are built to facilitate settlement from BTC to USD or solely in BTC.

Our target audience with Coinvoice is pretty much any business that wants to have customers pay in USD and ultimately receive BTC as payment for goods and services. A few examples of the kinds of businesses I’m talking about are:

  • IT contractor that invoices for their work at the end of each month
  • Chinese manufacturer that sells goods in the US
  • Vanuatu IBC that licenses intellectual property in the US

Coinvoice is meant to be used in a “traditional” business setting where invoices are issued and paid a number of days afterwards.

We are looking forward to enabling businesses to settle payments in BTC and helping grow the larger Bitcoin ecosystem. Coinvoice provides you with a safe, private, reliable and secure way for your business to receive BTC.

btcchain: The bitcoin chain package from btcd

As all of you following our blog are aware, we have previously released several bitcoin-related packages (btcwire, btcjson, btcutil, btcdb, btcec, and btcscript) on our way towards the full release of btcd.

We are happy to announce our next package from btcd. The package is named btcchain and it implements the bitcoin block handling and chain selection rules. The code can be reviewed on github here:


Overall Package Design

The bitcoin block handling and chain selection rules are an integral, and quite likely the most important, part of bitcoin. Unfortunately, at the time of this writing, these rules are also largely undocumented and had to be ascertained from the bitcoind source code. At its core, bitcoin is a distributed consensus of which blocks are valid and which ones will comprise the main block chain (public ledger) that ultimately determines accepted transactions, so it is extremely important that fully validating nodes agree on all rules.
Continue reading

gotk3: GTK3 the Go way!

Today marks the first release of gotk3, Conformal’s own GTK3 bindings for Go (available on Github here). These bindings were developed out of a frustration with other GTK bindings for Go either using ancient versions of GTK, not handling memory in a way a Go developer would expect, or simply not working at all on our developers’ OpenBSD and Bitrig machines. gotk3 is Conformal’s response to these issues and attempts to be the best solution for developing new GTK applications with Go.

One of the goals for developing gotk3 was to perform memory management in a very Go-like manner. Like many libraries which must handle memory management manually due to the language they are implemented with, GLib (and GTK which uses it) uses reference counting to determine when an object will never again be used and is ready to be freed, releasing the memory resources it required back to the operating system. However, GLib chooses not to use traditional reference counting, but instead uses a quirky variant called “floating references” to achieve this goal. The rest of this post will cover what floating references do, why they exist, and how gotk3 works around this design to handle memory the way a Go developer expects.

Continue reading

btcscript – the script package from btcd

Following up on our previous releases (btcwire, btcjson, btcutil, and btcdb) we are happy to announce btcscript, the script package from btcd:


btcscript provides code and data structures to parse and execute bitcoin scripts. The scripting system bitcoin uses is a stack-based, FORTH-like language. It is not turing complete by design (as adding a full turing complete language opens up all sorts of potential complications and problems), but it still provides a fair amount of power.

Continue reading