Full bitcoin solution written in Go (golang)


About Gocoin

Gocoin is a full Bitcoin solution written in Go language (golang).

The software architecture is focused on maximum performance of the node and cold storage security of the wallet.

The wallet is designed to be used offline. It is deterministic and password seeded. As long as you remember the password, you do not need any backups ever. Wallet can be used without the client, but with the provided balio tool instead.

The client (p2p node) is an application independent from the wallet. It keeps the entire UTXO set in RAM, providing an instant access to all its records.

System memory and time needed to sync BTC block chain up to the given block number:

SyncChart The data above is from Gocoin 1.10.0 running on Xeon E3-1270 v3 CPU.
For more performance results see gocoin.pl website.




  • 64-bit architecture OS and Go compiler.
  • File system supporting files larger than 4GB.
  • At least 16GB of system RAM.


  • Any platform that you can make your Go (cross)compiler to build for (Raspberry Pi works).
  • For security reasons make sure to use encrypted swap file (if there is a swap file).
  • If you decide to store your password in a file, have the disk encrypted (in case it gets stolen).

Operating System

Having hardware requirements met, any target OS supported by your Go compiler will do. Currently that can be at least one of the following:

  • Windows
  • Linux
  • OS X
  • Free BSD

Build environment

In order to build Gocoin yourself, you will need the following tools installed in your system:

If the tools mentioned above are all properly installed, you should be able to execute go and git from your OS's command prompt without a need to specify full path to the executables.

Getting sources

Download the source code from github to a local folder of your choice, e.g. by executing:

git clone https://github.com/piotrnar/gocoin.git


Client node

Go to the client/ folder and execute go build there.


Go to the wallet/ folder and execute go build there.


Go to the tools/ folder and execute:

go build btcversig.go

Repeat the go build for each source file of the tool you want to build.


Windows or Linux (amd64) binaries can be downloaded from

Please note that the binaries are usually not up to date. I strongly encourage everyone to build the binaries himself.


Although it is an open source project, I am sorry to inform you that I will not merge in any pull requests. The reason is that I want to stay an explicit author of this software, to keep a full control over its licensing. If you are missing some functionality, just describe me your needs and I will see what I can do for you. But if you want your specific code in, please fork and develop your own repo.


The official web page of the project is served at gocoin.pl where you can find extended documentation, including User Manual.

Please do not log github issues when you only have questions concerning this software. Instead see Contact page at gocoin.pl website for possible ways of contacting me.

  • How to use wallet binary?

    How to use wallet binary?

    Sorry but what does it mean? It's very first run.

    Gocoin Wallet version 1.9.5
    This program comes with ABSOLUTELY NO WARRANTY
    Using config file wallet.cfg
    Seed file .secret not found
    Enter your wallet's seed password: ***
    ERROR: open balance/unspent.txt: The system cannot find the path specified.

    Am I supposed to make some thing prior to running wallet? Where can I see some documentation?

    opened by inliquid 10
  • Build fetchbal failed

    Build fetchbal failed

    Hey can't build fetchbal.go tool

    [email protected]:~/go/src/github.com/piotrnar/gocoin/tools$ go build fetchbal.go
    # command-line-arguments
    ./fetchbal.go:133: undefined: wallet.NewWallet
    opened by selivandex 9
  • importblocks.go error

    importblocks.go error

    I get the following when trying to build the import tool.

    #command-line-arguments .\importblocks.go:98: chain.Save undefined (type *chain.Chain has no field or method Save)

    opened by Azulan 9
  • secp256k1 implementation fails for certain inputs

    secp256k1 implementation fails for certain inputs

    copy and past the following unit tests as "misc_tests.go". Into /lib/secp255k1


    For some valid private keys, the generated public key fails "pubkey2.IsValid()". SIPA's library works for those private keys. A valid public key is not generated for a valid seckey (even through the public key appears to be valid according to sipa's implementation).

    About 1 in 1500 keys.

    also, for func Multiply(xy, k, out []byte) bool {..}

    Multiply(pubkey1, privatekey2) should equal Multiple(pubkey2, privatekey1), fails for these keys.

    SIPA said you ported an early version of the library. I cleaned up the library and improved interface, but cannot find the source of these errors.

    opened by haltingstate 6
  • crash upon completing initial sync

    crash upon completing initial sync

    I just ran a full sync with the following options:

    LastTrustedBlock:"00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048" AllBalances.AutoLoad:false UTXOSave.SecondsToTake:0

    After the sync had completed, gocoin crashed with:

    > panic: runtime error: integer divide by zero
    goroutine 1652364922 [running]:
    	/home/jameson/go/src/github.com/piotrnar/gocoin/lib/utxo/unspent_db.go:267 +0xc6e
    created by github.com/piotrnar/gocoin/lib/utxo.(*UnspentDB).Save
    	/home/jameson/go/src/github.com/piotrnar/gocoin/lib/utxo/unspent_db.go:446 +0x8e
    opened by jlopp 5
  • Question about addr handling

    Question about addr handling

    Hi! I'm proposing some changes to addr handling in Bitcoin Core, and trying to ensure there will not be negative consequences for other clients on the network. For more information about the changes, please see my mailing list post. The crux is that, if the changes are accepted, bitcoin core would stop sending addr messages to inbound peers who don't "indicate interest" aka initiate an addr-related message (addr, addrv2, getaddr, or sendaddrv2).

    I'd like to ensure that gocoin clients will initiate an addr related message to outbound peers. I've looked in the code and believe the software plays nice, and am looking for a +1 from someone more familiar with this project.

    My understanding: in response to a version message, a gocoin node will self-advertise its address (link), and often initiate a getaddr message (link). If this is right, there should be no compatibility issues with my proposed changes. Can someone confirm this understanding?

    Thanks in advance! Amiti

    opened by amitiuttarwar 4
  • panic in network.LimitRejectedSize()

    panic in network.LimitRejectedSize()

    Panic seen:

    > main panic recovered: runtime error: invalid memory address or nil pointer dereference
    goroutine 1 [running]:
    runtime/debug.Stack(0xd90dc0, 0xc000010018, 0xc1efef94b8)
            /usr/local/go/src/runtime/debug/stack.go:24 +0x9d
            /home/piotr/GOPATH/src/github.com/piotrnar/gocoin/client/main.go:282 +0x137
    panic(0x7fda20, 0x10fa230)
            /usr/local/go/src/runtime/panic.go:522 +0x1b5
            /home/piotr/GOPATH/src/github.com/piotrnar/gocoin/client/network/txpool_sort.go:206 +0x135
    github.com/piotrnar/gocoin/client/network.RejectTx(0xc1fb292120, 0xc000c325d5, 0xd5b1bb53dc3165ba)
            /home/piotr/GOPATH/src/github.com/piotrnar/gocoin/client/network/txpool_core.go:193 +0x11a
    github.com/piotrnar/gocoin/client/network.(*OneTxToSend).Delete(0xc15a3a5ad0, 0xc12c1cd500)
            /home/piotr/GOPATH/src/github.com/piotrnar/gocoin/client/network/txpool_core.go:607 +0x271
    github.com/piotrnar/gocoin/client/network.HandleNetTx(0xc0d4298300, 0x0, 0x1008e00)
            /home/piotr/GOPATH/src/github.com/piotrnar/gocoin/client/network/txpool_core.go:496 +0x1997
            /home/piotr/GOPATH/src/github.com/piotrnar/gocoin/client/main.go:470 +0xb94
    opened by piotrnar 4
  • add config parameter for last trusted block

    add config parameter for last trusted block

    it would be helpful if there was a config parameter that makes it easy to set the trusted block to the genesis block. Something similar to Bitcoin Core's "assumevalid=0"

    opened by jlopp 4
  • sign transaction and broadcast

    sign transaction and broadcast

    Hi, sorry for raise this issue, I just want to know how can I use gocoin to sign transaction and broadcast? especially when the account have muti utxos

    opened by huahuayu 4
  • Broken private key padding

    Broken private key padding

    HDWallet.Child is not guaranteed to always return 33-byte private key. Also your PR policy is absurd. You'd better but that disclaimer in bold on top of the readme, so no one will waste time on it.

    opened by awsum 4
  • Invalid memory address or nil pointer dereference on weird TxOut

    Invalid memory address or nil pointer dereference on weird TxOut


    I'm trying to parse the blockchain using gocoin, but I got a panic: runtime error: invalid memory address or nil pointer dereference when I try to decode address for weird TxOut.

    Here is my code (https://gist.github.com/tsileo/8008319), and here is the exception I'm getting:

    2013/12/17 17:56:54 128233
    2013/12/17 17:56:54 128234
    2013/12/17 17:56:54 128235
    2013/12/17 17:56:54 128236
    2013/12/17 17:56:54 128237
    2013/12/17 17:56:54 128238
    2013/12/17 17:56:54 128239
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xb code=0x1 addr=0x50 pc=0x44796a]
    goroutine 1 [running]:
    github.com/piotrnar/gocoin/btc.(*BtcAddr).String(0x0, 0x1a, 0x1a)
        /work/opensource/blockchain_playground_golang/src/github.com/piotrnar/gocoin/btc/addr.go:134 +0x2a
        /work/opensource/blockchain_playground_golang/dat2.go:75 +0x250e
    goroutine 2 [syscall]:
    exit status 2

    It happens on weird TxOut, when it can't decode/compute address, I found some explanations here and here.

    I see it at block:

    Even blockchain.info can't handle these TxOuts, I think it's missing some error checking, maybe it should return nil ?

    I just started learning Go, so let me know if I missed something,


    opened by tsileo 4
  • Evaluate if contributions are acceptable when the contributor signed a CLA

    Evaluate if contributions are acceptable when the contributor signed a CLA

    Did you evaluate the possibility of requiring a signed CLA (Contributors License Agreement) for contributions? I think that way you could set the terms under which contributions can be made and include under which license everything falls and that you have the full rights to the contribution etc.

    Many companies and foundations that maintain open source software require contributors to sign such CLAs, like the Eclipse Foundation, Canonical, Google, Microsoft and others.

    I think most open source CLAs have the purpose that the maintainers can be sure that contributors grant rights to the end-user and also allow project sublicensing, but I assume that can be modified to your needs.

    This might require some more research if you want to be on the safe side.

    • Info: https://en.wikipedia.org/wiki/Contributor_License_Agreement
    • Info: https://www.clahub.com/pages/why_cla
    • CLA Generator: http://contributoragreements.org/agreement-chooser.html
    • Service for managing CLAs for GitHub: https://www.clahub.com/
    • Service for managing CLAs for GitHub: https://cla-assistant.io/
    opened by philippgille 1
  • Add Godoc comments

    Add Godoc comments

    First of all: Amazing effort to write an independent Bitcoin implementation as an (as it seems) single contributor.

    I stumbled upon this thanks to this Tweet, which points to the same author's blog article comparing different Bitcoin node implementations' performance.

    I wanted to take a dive into the code, but realized that in many/most packages, for example github.com/piotrnar/gocoin/lib/btc, most exported types and functions don't have any Godoc comment. Some types/functions have comments, but don't adhere to the Godoc format (like beginning with the name of the type/function, as mentioned in this Go Blog article).

    See the Godoc of that package here: https://godoc.org/github.com/piotrnar/gocoin/lib/btc

    Examples of well documented packages:

    • https://godoc.org/github.com/gorilla/websocket
    • https://godoc.org/go.uber.org/zap

    Proper Godoc comments might be helpful for

    1. potential contributors who want to dive into and understand the code and
    2. package users who want to use your exported packages as a library for their own applications.

    To not export some packages at all you could use an internal directory, as explained in the Go 1.4 release notes.

    As a side note, the recently announced official https://go.dev website, which offers an updated / extended version of Godoc, for example to support versioned Go modules, seems to not be able to understand your LICENSE and thus thinks it's not allowed to show your Godoc at all. See https://pkg.go.dev/github.com/piotrnar/gocoin/lib/btc?tab=doc.

    “Doc” hidden due to license restrictions.

    opened by philippgille 2
Piotr Narewski
Piotr Narewski
A full node Bitcoin (BSV) implementation written in Go

bsvd bsvd is a full node Bitcoin (BSV) implementation written in Go (golang). This project is a port of the bchd codebase to Bitcoin (BSV). It provide

null 41 Feb 7, 2022
Bitcoin CPU miner written in Go.

CPU Miner Bitcoin CPU miner written in Go. Introduction This is a CPU miner written in Go. It is a proof of concept and is not intended for production

Yaroslav Gaponov 0 Jan 6, 2022
A curated Golang toolkit for creating Bitcoin SV powered apps

bsv A curated Golang toolkit for creating Bitcoin SV powered apps Table of Contents Installation Maintainers License Installation bsv requires a suppo

null 21 May 10, 2022
Btc-globe - Visualize Bitcoin node locations using golang

btc-globe Visualize Bitcoin nodes by location using Golang

null 0 Jan 19, 2022
A db for bitcoin-sv & BTC

Welcome to go-svdb Project =========== Boquan Team The Boquan is a team dedicated to promoting and developing true bitcoin. The team has successfully

mempool.com team 31 Sep 3, 2021
Moeing chain is an EVM&Web3 compatible sidechain for Bitcoin Cash

Full node client of smartBCH This repository contains the code of the full node client of smartBCH, an EVM&Web3 compatible sidechain for Bitcoin Cash.

null 111 Jun 19, 2022
Store data on Bitcoin for 350 sats/KB up to 185 KB by using P2SH-P2WSH witness scripts

Bitcandle Store data on Bitcoin for 350 sats/KB up to 185 kB by using P2SH-P2WSH witness scripts. 225ed8bc432d37cf434f80717286fd5671f676f12b573294db72

Aurèle Oulès 10 Nov 14, 2021
A work-in-progress Bitcoin wallet based on Output Descriptors

go-wallet A work-in-progress Bitcoin wallet Descriptors go-wallet is designed around Bitcoin Descriptors. It implements a Output Script Descriptors la

Gustavo Chaín 5 May 4, 2022
The go-to Bitcoin Node (BN) Go library.

go-bitcoin Go wrapper for bitcoin RPC RPC services Start by creating a connection to a bitcoin node b, err := New("rcp host", rpc port, "rpc usernam

null 3 Feb 13, 2022
A fully validating Bitcoin node with Utreexo support

btcd btcd is an alternative full node bitcoin implementation written in Go (golang). This project is currently under active development and is in a Be

Utreexo 10 Mar 4, 2022
Bitcoin futures curve from Deribit as a JSON webservice

Curve Bitcoin futures curve from Deribit as a JSON webservice Building go build . Running ./curve Expiration date and annualised yield of each contr

Steven Wilkin 0 Dec 13, 2021
Bitcoin Core integration/staging tree

Bitcoin Core integration/staging tree https://bitcoincore.org For an immediately usable, binary version of the Bitcoin Core software, see https://bitc

Bitcoin 64.8k Jun 21, 2022
Mastering Bitcoin 2nd Edition - Programming the Open Blockchain

Code Examples: Mastering Bitcoin Mastering Bitcoin is a book for developers, although the first two chapters cover bitcoin at a level that is also app

Mastering Bitcoin 20k Jun 20, 2022
Bitcoin Improvement Proposals

People wishing to submit BIPs, first should propose their idea or document to the [email protected] mailing list (do not assign a

Bitcoin 6.9k Jun 22, 2022
A simple, concurrent bitcoin miner framework implemented in Go.

Bitcoin Miner A simple, concurrent bitcoin miner framework implemented in Go. Disclaimer: this is not a product intended to be used for real mining, s

null 4 May 30, 2022
Bitcoin address balance checker on steroids.

BTCSteroids Bitcoin address balance checker on steroids. Table of contents Quick start What's included Use Cases Thanks Copyright and license Quick st

null 7 Jun 2, 2022
Bitcoin UTXO & xPub Management Suite

BUX Bitcoin UTXO & xPub Management Suite Table of Contents About Installation Documentation Examples & Tests Benchmarks Code Standards Usage Contribut

BUX 11 Jun 8, 2022
A document encryption solution for the reMarkable 2 ePaper tablet.

Remarkable 2 Encryption This repository contains multiple tools to encrypt the home folder of the reMarkable 2 epaper tablet using gocryptfs. Detailed

RedTeam Pentesting GmbH 29 Jun 13, 2022
collection of tools to gleam insights from a full bitclout node's data

bitcloutscripts collection of tools to gleam insights from a full bitclout node's data bitcloutscripts $ ./bcs bcs posts # print all posts

Andrew Arrow 4 Jul 11, 2021