{"id":39016560,"url":"https://github.com/joakimofv/go-bitcoindclient","last_synced_at":"2026-01-17T17:25:19.059Z","repository":{"id":57647156,"uuid":"442835915","full_name":"joakimofv/go-bitcoindclient","owner":"joakimofv","description":"A client for connecting to bitcoind from Go code","archived":false,"fork":false,"pushed_at":"2022-05-05T12:47:05.000Z","size":269,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-21T19:06:51.696Z","etag":null,"topics":["bitcoin","bitcoind","client","go","golang","json-rpc","zmq"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joakimofv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-29T16:56:56.000Z","updated_at":"2022-07-07T15:30:05.000Z","dependencies_parsed_at":"2022-09-14T21:04:22.401Z","dependency_job_id":null,"html_url":"https://github.com/joakimofv/go-bitcoindclient","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/joakimofv/go-bitcoindclient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Fgo-bitcoindclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Fgo-bitcoindclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Fgo-bitcoindclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Fgo-bitcoindclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joakimofv","download_url":"https://codeload.github.com/joakimofv/go-bitcoindclient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimofv%2Fgo-bitcoindclient/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28512902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","bitcoind","client","go","golang","json-rpc","zmq"],"created_at":"2026-01-17T17:25:18.978Z","updated_at":"2026-01-17T17:25:19.045Z","avatar_url":"https://github.com/joakimofv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/joakimofv/go-bitcoindclient/v23.svg)](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23)\n\ngo-bitcoindclient\n=================\n\nA client for connecting to bitcoind from Go code.\nSafe for concurrent use.\nAll RPC methods are code-generated from the bitcoind help output.\n\n# Import\n\n```go\n\tbitcoindclient \"github.com/joakimofv/go-bitcoindclient/v23\"\n```\n\n# Dependencies\n\n## libzmq\n\nlibzmq must be installed in order to compile, because it is needed by [this import](https://github.com/pebbe/zmq4) that handles ZMQ.\nSee the instructions for your OS on the [ZMQ website](https://zeromq.org/download/).\n\n## bitcoind\n\nThe major version of this package tracks the major version of bitcoind (starting with v22).\nRunning the client against another version might or might not work, depending on specific changes to the RPC methods.\nThere is no explicit version check by default.\n\nYou don't need to have bitcoind installed in order to compile. To run the tests or re-generate the code you would need it.\n\n# Basic Usage\n\n### New\n\n```go\nbc, err := bitcoindclient.New(bitcoindclient.Config{\n\tRpcAddress:    \"localhost:8332\",\n\tRpcUser:       \"name\",\n\tRpcPassword:   \"password\",\n\tZmqPubAddress: \"tcp://localhost:12345\",\n})\nif err != nil {\n\t// Handle err\n}\n```\n\nSee [`Config`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#Config) for options.\n\n### Ready: Check Connection\n\n```go\nfor {\n\tif err := bc.Ready(); err != nil {\n\t\t// Inspect error, maybe give up\n\t} else {\n\t\t// Success!\n\t\tbreak\n\t}\n}\n```\n\nThere are also options that can be given to `Ready` to tell it to check the version or ZMQ messages received, see [`ReadyOption`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#ReadyOption).\n\n### Call RPC Methods\n\n```go\nresp, err := bc.GetBlock(ctx, GetBlockReq{\n\tBlockhash: \"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\",\n})\nif err != nil {\n\t// Handle err\n}\nfmt.Println(resp.Hex)\n```\n\nSee [pkg.go.dev](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#pkg-index) for the full list of methods. Or see [BitcoinCore RPC Docs](https://bitcoincore.org/en/doc/), the methods are the same (in camelcase). Input is always incapsulated in a struct called `\u003cMethod\u003eReq` (or empty) and output is always in a struct called `\u003cMethod\u003eResp` (or empty).\n\n### Close\n\n```go\nif err := bc.Close(); err != nil {\n\t// Handle err\n}\n```\n\n# ZMQ Messages\n\n### Subscribe\n\n```go\nch, cancel, err := bc.SubscribeHashBlock()\nif err != nil {\n\t// Handle err\n}\n```\n\nThere are [`SubscribeHashTx`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#BitcoindClient.SubscribeHashTx), [`SubscribeHashBlock`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#BitcoindClient.SubscribeHashBlock), [`SubscribeRawTx`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#BitcoindClient.SubscribeRawTx), [`SubscribeRawBlock`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#BitcoindClient.SubscribeRawBlock), and [`SubscribeSequence`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#BitcoindClient.SubscribeSequence).\n\n### Receive\n\n```go\nselect {\ncase msg, open := \u003c-ch:\n\tif !open {\n\t\t// return\n\t}\n\tfmt.Println(hex.EncodeToString(msg.Hash[:]))\n}\n```\n\nThe message types are [`HashMsg`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#HashMsg), [`RawMsg`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#RawMsg) or [`SequenceMsg`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#SequenceMsg).\n\n### Cancel\n\n```go\ncancel()\n```\n\nThis closes the channel and releases resources. Closing the client will do that too.\n\n# Error Handling\n\nThe RPC methods may return errors that are of the type [`*BitcoindError`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#BitcoindError), that means the connection was successful but bitcoind had something to complain about related to the user input.\n\n```go\nvar bErr *bitcoindclient.BitcoindError\nif errors.As(err, \u0026bErr) {\n\tfmt.Println(bErr.Code)\n\tfmt.Println(bErr.Message)\n}\n```\n\nOther expected errors are `*url.Error` if the connection failed, or `context.Canceled`/`context.DeadlineExceeded` if the context was cancelled/expired.\n\nIf running against a different version of bitcoind you might get an error of type [`*UnmarshalError`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#UnmarshalError) because the response format was not as expected. If you get this when running against the matching version then please report an issue.\n\n# Call Options\n\n### Connection Retries\n\n```go\nctx = bitcoindclient.UseConnectionRetries(ctx, 2)\n```\n\nEnable retry on connection error by modifying the context with [`UseConnectionRetries`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#UseConnectionRetries).\n\n### URI Path\n\n```go\nctx = bitcoindclient.UseUriPath(ctx, \"/wallet/mywallet\")\n```\n\nChange the URI path for a call by modifying the context with [`UseUriPath`](https://pkg.go.dev/github.com/joakimofv/go-bitcoindclient/v23#UseUriPath).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimofv%2Fgo-bitcoindclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoakimofv%2Fgo-bitcoindclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimofv%2Fgo-bitcoindclient/lists"}