{"id":27253428,"url":"https://github.com/marselester/bitgo-v1","last_synced_at":"2025-04-11T01:27:31.508Z","repository":{"id":57586728,"uuid":"109552602","full_name":"marselester/bitgo-v1","owner":"marselester","description":"Go client for BitGo.com API v1","archived":false,"fork":false,"pushed_at":"2018-09-18T11:06:36.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T11:59:26.072Z","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":"2017-11-05T04:48:58.000Z","updated_at":"2018-09-18T11:06:37.000Z","dependencies_parsed_at":"2022-09-26T19:32:38.512Z","dependency_job_id":null,"html_url":"https://github.com/marselester/bitgo-v1","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marselester%2Fbitgo-v1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marselester","download_url":"https://codeload.github.com/marselester/bitgo-v1/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248324231,"owners_count":21084669,"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:29.231Z","updated_at":"2025-04-11T01:27:31.499Z","avatar_url":"https://github.com/marselester.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go client for [BitGo.com API v1](https://bitgo.github.io/bitgo-docs/)\n\n[![Documentation](https://godoc.org/github.com/marselester/bitgo-v1?status.svg)](https://godoc.org/github.com/marselester/bitgo-v1)\n[![Go Report Card](https://goreportcard.com/badge/github.com/marselester/bitgo-v1)](https://goreportcard.com/report/github.com/marselester/bitgo-v1)\n[![Travis CI](https://travis-ci.org/marselester/bitgo-v1.png)](https://travis-ci.org/marselester/bitgo-v1)\n\nThis is unofficial API client. There are no plans to implement all resources.\n\n## [List Wallet Unspents](https://bitgo.github.io/bitgo-docs/#list-wallet-unspents)\n\nGets a list of unspent input transactions for a wallet. For example, we want to request\n`2N91XzUxLrSkfDMaRcwQhe9DauhZMhUoxGr` wallet's unspents `250` per API request and\nprint amounts in BTC. You can stop pagination by cancelling a `ctx` context.\n\n```go\nc := bitgo.NewClient(\n    bitgo.WithAccesToken(\"swordfish\"),\n)\nparams := url.Values{}\nparams.Set(\"limit\", \"250\")\nerr := c.Wallet.Unspents(ctx, \"2N91XzUxLrSkfDMaRcwQhe9DauhZMhUoxGr\", params, func(list *bitgo.UnspentList) {\n    for _, utxo := range list.Unspents {\n        fmt.Printf(\"%0.8f\\n\", bitgo.ToBitcoins(utxo.Value))\n    }\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 -wallet=2N91XzUxLrSkfDMaRcwQhe9DauhZMhUoxGr -limit=250\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 -wallet=2N91XzUxLrSkfDMaRcwQhe9DauhZMhUoxGr \u003e unspents.txt\n$ cat unspents.txt | sort | uniq -c | sort -n -r\n   3 0.00000001\n   2 0.00000562\n   1 0.00000117\n```\n\n## [Consolidate Wallet Unspents](https://bitgo.github.io/bitgo-docs/#consolidate-unspents)\n\nThis API call will consolidate bitcoins of `2NB5G2jmqSswk7C427ZiHuwuAt1GPs5WeGa` wallet using max `0.001` BTC unspents\nwith 1000 satoshis/kilobyte fee rate. You can stop consolidation by cancelling a `ctx` context.\n\n```go\nc := bitgo.NewClient(\n\tbitgo.WithAccesToken(\"swordfish\"),\n)\ntt, err := c.Wallet.Consolidate(ctx, \"2NB5G2jmqSswk7C427ZiHuwuAt1GPs5WeGa\", \u0026bitgo.WalletConsolidateParams{\n\tWalletPassphrase: \"root\",\n\tMaxValue:         100000,\n\tFeeRate:          1000,\n})\nif err != nil {\n\tlog.Fatalf(\"Failed to coalesce unspents: %v\", err)\n}\nfor _, tx := range tt {\n\tfmt.Printf(\"Consolidated transaction ID: %s\", tx.TxID)\n}\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 -wallet=2NB5G2jmqSswk7C427ZiHuwuAt1GPs5WeGa -passphrase=root -max-value=0.001 -fee-rate=1000\n50430eeffdd1272ff39d0d3667cbc8e60de0a8ea6bb118e6236e0964389e6d19\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-v1\"\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\nUse [debug](https://dave.cheney.net/2014/09/28/using-build-to-switch-between-debug-and-release) tag\nto enable API response logging.\n\n```sh\n$ go test -tags debug\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbitgo-v1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarselester%2Fbitgo-v1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarselester%2Fbitgo-v1/lists"}