{"id":27253436,"url":"https://github.com/marselester/bitgo-v2","last_synced_at":"2025-10-06T23:30:00.021Z","repository":{"id":57533263,"uuid":"121768714","full_name":"marselester/bitgo-v2","owner":"marselester","description":"Go client for BitGo.com API v2","archived":false,"fork":false,"pushed_at":"2018-09-19T05:05:08.000Z","size":30,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T11:05:28.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/marselester.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":"2018-02-16T15:50:34.000Z","updated_at":"2018-09-19T05:04:15.000Z","dependencies_parsed_at":"2022-09-26T18:20:57.565Z","dependency_job_id":null,"html_url":"https://github.com/marselester/bitgo-v2","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marselester","download_url":"https://codeload.github.com/marselester/bitgo-v2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248324233,"owners_count":21084670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-04-11T01:27:35.630Z","updated_at":"2025-10-06T23:29:54.972Z","avatar_url":"https://github.com/marselester.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go client for [BitGo.com API v2](https://www.bitgo.com/api/v2/)\n\n[![Documentation](https://godoc.org/github.com/marselester/bitgo-v2?status.svg)](https://godoc.org/github.com/marselester/bitgo-v2)\n[![Go Report Card](https://goreportcard.com/badge/github.com/marselester/bitgo-v2)](https://goreportcard.com/report/github.com/marselester/bitgo-v2)\n[![Travis CI](https://travis-ci.org/marselester/bitgo-v2.png)](https://travis-ci.org/marselester/bitgo-v2)\n\nThis is unofficial API client. There are no plans to implement all resources.\n\n## [Consolidate Wallet Unspents](https://www.bitgo.com/api/v2/#consolidate-wallet-unspents)\n\nThis API call will consolidate Bitcoin Cash of `585951a5df8380e0e3063e9f` wallet using max `0.001` BCH unspents\nwith 5000 satoshis/kb fee rate. You can stop consolidation by cancelling a `ctx` context.\n\n```go\nc := bitgo.NewClient(\n\tbitgo.WithCoin(\"bch\"),\n\tbitgo.WithAccesToken(\"swordfish\"),\n)\ntx, err := c.Wallet.Consolidate(ctx, \"585951a5df8380e0e3063e9f\", \u0026bitgo.WalletConsolidateParams{\n\tWalletPassphrase: \"root\",\n\tMaxValue:         100000,\n\tFeeRate:          5000,\n})\nif err != nil {\n\tlog.Fatalf(\"Failed to coalesce unspents: %v\", err)\n}\nfmt.Printf(\"Consolidated transaction ID: %s\", tx.TxID)\n```\n\nThere is a CLI program to consolidate unspensts of a wallet.\n\n```sh\n$ go build ./cmd/consolidate/\n$ ./consolidate -token=swordfish -coin=bch -wallet=585951a5df8380e0e3063e9f -passphrase=root -max-value=0.001 -fee-rate=5000\n5885a7e6c7802206f69655ed763d14f101cf46501aef38e275c67c72cfcedb75\n```\n\nAlso you can perform periodic consolidation with `consolidated` just like you would do with `consolidate` program.\nIn this example consolidation runs every 12 hours.\n\n```sh\n$ go build ./cmd/consolidated/\n$ ./consolidated -schedule=12h -token=swordfish -coin=bch -wallet=585951a5df8380e0e3063e9f -passphrase=root -max-value=0.001 -fee-rate=5000\n5885a7e6c7802206f69655ed763d14f101cf46501aef38e275c67c72cfcedb75\n```\n\n## [List Wallet Unspents](https://www.bitgo.com/api/v2/#list-wallet-unspents)\n\nThis API call will retrieve the unspent transaction outputs (UTXOs) within a wallet.\nFor example, we want to request `58ae81a5df8380e0e307e876` wallet's confirmed unspents and\nprint amounts in BTC. You can stop pagination by cancelling a `ctx` context.\n\n```go\nc := bitgo.NewClient(\n\tbitgo.WithCoin(\"bch\"),\n\tbitgo.WithAccesToken(\"swordfish\"),\n)\nparams := url.Values{}\nparams.Set(\"minConfirms\", \"1\")\nerr := c.Wallet.Unspents(ctx, \"58ae81a5df8380e0e307e876\", params, func(list *bitgo.UnspentList) {\n\tfor _, utxo := range list.Unspents {\n\t\tfmt.Printf(\"%0.8f\\n\", toBitcoins(utxo.Value))\n\t}\n})\n```\n\nThere is a CLI program to list all unspensts of a wallet.\n\n```sh\n$ go build ./cmd/utxo/\n$ ./utxo -token=swordfish -coin=bch -wallet=58ae81a5df8380e0e307e876 -min-confirms=1\n0.00000117\n0.00000001\n0.00000001\n0.00000562\n0.00000001\n0.00000562\n```\n\nYou can use it to get a rough idea about unspents available in the wallet.\n\n```sh\n$ ./utxo -token=swordfish -coin=bch -wallet=58ae81a5df8380e0e307e876 \u003e unspents.txt\n$ sort unspents.txt | uniq -c | sort -n -r\n   3 0.00000001\n   2 0.00000562\n   1 0.00000117\n```\n\n## Error Handling\n\nDave Cheney recommends\n[asserting errors for behaviour](https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully), not type.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/marselester/bitgo-v2\"\n\t\"github.com/pkg/errors\"\n)\n\n// IsUnauthorized returns true if err caused by authentication problem.\nfunc IsUnauthorized(err error) bool {\n\te, ok := errors.Cause(err).(interface {\n\t\tIsUnauthorized() bool\n\t})\n\treturn ok \u0026\u0026 e.IsUnauthorized()\n}\n\nfunc main() {\n\terr := bitgo.Error{Type: bitgo.ErrorTypeAuthentication}\n\tfmt.Println(IsUnauthorized(err))\n\tfmt.Println(IsUnauthorized(fmt.Errorf(\"\")))\n\tfmt.Println(IsUnauthorized(nil))\n\t// Output: true\n\t// false\n\t// false\n}\n```\n\n## Testing\n\nQuick tutorial on [how to fuzz](https://medium.com/@dgryski/go-fuzz-github-com-arolek-ase-3c74d5a3150c) by Damian Gryski.\nCopy JSON files from `testdata` into `workdir/corpus` as sample inputs.\n\n```sh\n$ go-fuzz-build github.com/marselester/bitgo-v2\n$ go-fuzz -bin=bitgo-fuzz.zip -workdir=workdir\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbitgo-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarselester%2Fbitgo-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbitgo-v2/lists"}