{"id":18542744,"url":"https://github.com/coinbase/mesh-bitcoin","last_synced_at":"2025-04-07T10:29:02.570Z","repository":{"id":37663391,"uuid":"294227464","full_name":"coinbase/mesh-bitcoin","owner":"coinbase","description":"Bitcoin Mesh API Implementation","archived":false,"fork":false,"pushed_at":"2024-08-01T16:49:45.000Z","size":373,"stargazers_count":115,"open_issues_count":25,"forks_count":122,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-31T08:09:09.061Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-09T20:55:09.000Z","updated_at":"2025-03-10T14:20:33.000Z","dependencies_parsed_at":"2024-06-18T21:30:20.459Z","dependency_job_id":"45a84bb6-ef86-4ade-a06e-4947ab9be1af","html_url":"https://github.com/coinbase/mesh-bitcoin","commit_stats":null,"previous_names":["coinbase/mesh-bitcoin","coinbase/rosetta-bitcoin"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fmesh-bitcoin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fmesh-bitcoin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fmesh-bitcoin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fmesh-bitcoin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/mesh-bitcoin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247635125,"owners_count":20970674,"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":"2024-11-06T20:10:21.281Z","updated_at":"2025-04-07T10:29:02.551Z","avatar_url":"https://github.com/coinbase.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003ch3 align=\"center\"\u003e\n   Mesh Bitcoin\n\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://circleci.com/gh/coinbase/mesh-bitcoin/tree/master\"\u003e\u003cimg src=\"https://circleci.com/gh/coinbase/mesh-bitcoin/tree/master.svg?style=shield\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/coinbase/mesh-bitcoin\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/coinbase/mesh-bitcoin/badge.svg\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/coinbase/mesh-bitcoin\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/coinbase/mesh-bitcoin\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/coinbase/mesh-bitcoin/blob/master/LICENSE.txt\"\u003e\u003cimg src=\"https://img.shields.io/github/license/coinbase/mesh-bitcoin.svg\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/coinbase/mesh-bitcoin?tab=overview\"\u003e\u003cimg src=\"https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=shield\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cb\u003e\nMESH-BITCOIN IS CONSIDERED \u003ca href=\"https://en.wikipedia.org/wiki/Software_release_life_cycle#Alpha\"\u003eALPHA SOFTWARE\u003c/a\u003e.\nUSE AT YOUR OWN RISK.\u003c/b\u003e\u003cp\u003e\n\u003cp align=\"center\"\u003eThis project is available open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).\u003c/p\u003e\n\n## Overview\n\nThe `mesh-bitcoin` repository provides a reference implementation of the Mesh API for Bitcoin in Golang. This repository was created for developers of Bitcoin-like (a.k.a., UTXO) blockchains, who may find it easier to fork this reference implementation than write one from scratch.\n\n[Mesh](https://docs.cdp.coinbase.com/mesh/docs/welcome/) is an open-source specification and set of tools that makes integrating with blockchains simpler, faster, and more reliable. The Mesh API is specified in the [OpenAPI 3.0 format](https://www.openapis.org).\n\nRequests and responses can be crafted with auto-generated code using [Swagger Codegen](https://swagger.io/tools/swagger-codegen) or [OpenAPI Generator](https://openapi-generator.tech), are human-readable (easy to debug and understand), and can be used in servers and browsers.\n\n## Features\n\n* Mesh API implementation (both Data API and Construction API)\n* UTXO cache for all accounts (accessible using the Mesh `/account/balance` API)\n* Stateless, offline, curve-based transaction construction from any SegWit-Bech32 Address\n* Automatically prune bitcoind while indexing blocks\n* Reduce sync time with concurrent block indexing\n* Use [Zstandard compression](https://github.com/facebook/zstd) to reduce the size of data stored on disk without needing to write a manual byte-level encoding\n\n## System Requirements\n\nThe `mesh-bitcoin` implementation has been tested on an [AWS c5.2xlarge instance](https://aws.amazon.com/ec2/instance-types/c5). This instance type has 8 vCPU and 16 GB of RAM.\n\n## Getting Started\n\n1. Adjust your [network settings](#network-settings) to the recommended connections.\n2. Install and run Docker as directed in the [Deployment](#deployment) section below.\n3. Run the [`Testnet:Online`](#testnetonline) command.\n\n### Network Settings\n\nTo increase the load that `mesh-bitcoin` can handle, we recommend tunning your OS settings to allow for more connections. On a linux-based OS, you can run these commands ([source](http://www.tweaked.io/guide/kernel)):\n\n```text\nsysctl -w net.ipv4.tcp_tw_reuse=1\nsysctl -w net.core.rmem_max=16777216\nsysctl -w net.core.wmem_max=16777216\nsysctl -w net.ipv4.tcp_max_syn_backlog=10000\nsysctl -w net.core.somaxconn=10000\nsysctl -p (when done)\n```\n_We have not tested `mesh-bitcoin` with `net.ipv4.tcp_tw_recycle` and do not recommend enabling it._\n\nYou should also modify your open file settings to `100000`. This can be done on a linux-based OS with the command: `ulimit -n 100000`.\n\n### Memory-Mapped Files\n\n`mesh-bitcoin` uses [memory-mapped files](https://en.wikipedia.org/wiki/Memory-mapped_file) to persist data in the `indexer`. As a result, you **must** run `mesh-bitcoin` on a 64-bit architecture (the virtual address space easily exceeds 100s of GBs).\n\nIf you receive a kernel OOM, you may need to increase the allocated size of swap space on your OS. There is a great tutorial for how to do this on Linux [here](https://linuxize.com/post/create-a-linux-swap-file/).\n\n## Development\n\nWhile working on improvements to this repository, we recommend that you use these commands to check your code:\n\n* `make deps` to install dependencies\n* `make test` to run tests\n* `make lint` to lint the source code\n* `make salus` to check for security concerns\n* `make build-local` to build a Docker image from the local context\n* `make coverage-local` to generate a coverage report\n\n#### Image Installation\n\nRunning these commands will create a Docker image called `mesh-bitcoin:latest`.\n\n##### Installing from GitHub\n\nTo download the pre-built Docker image from the latest release, run:\n\n```text\ncurl -sSfL https://raw.githubusercontent.com/coinbase/mesh-bitcoin/master/install.sh | sh -s\n```\n_Do not try to install mesh-bitcoin using GitHub Packages!_\n\n##### Installing from Source\n\nAfter cloning this repository, run:\n\n```text\nmake build-local\n```\n\n#### Run Docker\n\nRunning these commands will start a Docker container in [detached mode](https://docs.docker.com/engine/reference/run/#detached--d) with a data directory at `\u003cworking directory\u003e/bitcoin-data` and the Mesh API accessible at port `8080`.\n\n##### Required Arguments\n\n**`MODE`** - Determines whether Mesh can make outbound connections.\n- **Type:** `String`\n- **Options:** `ONLINE`, `OFFLINE`\n- **Default:** None\n\n**`NETWORK`** - The Ethereum network to launch or communicate with.\n- **Type:** `String`\n- **Options:** `MAINNET`, `ROPSTEN`, `RINKEBY`, `GOERLI` or `TESTNET`\n- **Default:** `ROPSTEN`, but only for backwards compatibility if you use `TESTNET`\n\n**`PORT`** - The port to use for Mesh.\n- **Type:** `Integer`\n- **Options:** `8080`, any compatible port number.\n- **Default:** None\n\n##### Command Examples\n\nYou can run these commands from the command line. If you cloned the repository, you can use the `make` commands shown after the examples.\n\n###### **Mainnet:Online**\n\nUncloned repo:\n```text\ndocker run -d --rm --ulimit \"nofile=100000:100000\" -v \"$(pwd)/bitcoin-data:/data\" -e \"MODE=ONLINE\" -e \"NETWORK=MAINNET\" -e \"PORT=8080\" -p 8080:8080 -p 8333:8333 mesh-bitcoin:latest\n```\nCloned repo:\n```text\nmake run-mainnet-online\n```\n\n###### **Mainnet:Offline**\n\nUncloned repo:\n```text\ndocker run -d --rm -e \"MODE=OFFLINE\" -e \"NETWORK=MAINNET\" -e \"PORT=8081\" -p 8081:8081 mesh-bitcoin:latest\n```\nCloned repo:\n```text\nmake run-mainnet-offline\n```\n\n###### **Testnet:Online**\n\nUncloned repo:\n```text\ndocker run -d --rm --ulimit \"nofile=100000:100000\" -v \"$(pwd)/bitcoin-data:/data\" -e \"MODE=ONLINE\" -e \"NETWORK=TESTNET\" -e \"PORT=8080\" -p 8080:8080 -p 18333:18333 mesh-bitcoin:latest\n```\n\nCloned repo: \n```text\nmake run-testnet-online\n```\n\n###### **Testnet:Offline**\n\nUncloned repo:\n```text\ndocker run -d --rm -e \"MODE=OFFLINE\" -e \"NETWORK=TESTNET\" -e \"PORT=8081\" -p 8081:8081 mesh-bitcoin:latest\n```\n\nCloned repo: \n```text\nmake run-testnet-offline\n```\n\n## Architecture\n\n`mesh-bitcoin` uses the `syncer`, `storage`, `parser`, and `server` package from [`mesh-sdk-go`](https://github.com/coinbase/mesh-sdk-go) instead of a new Bitcoin-specific implementation of packages of similar functionality. Below you can find an overview of how everything fits together:\n\n### Concurrent Block Syncing\n\nTo speed up indexing, `mesh-bitcoin` uses concurrent block processing with a \"wait free\" design (using [the channels function](https://golangdocs.com/channels-in-golang) instead of [the sleep function](https://pkg.go.dev/time#Sleep) to signal which threads are unblocked). This allows `mesh-bitcoin` to fetch multiple inputs from disk while it waits for inputs that appeared in recently processed blocks to save to disk.\n\n## Test the Implementation with the mesh-cli Tool\n\nTo validate `mesh-bitcoin`, [install `mesh-cli`](https://github.com/coinbase/mesh-cli#install) and run one of these commands:\n\n* `mesh-cli check:data --configuration-file mesh-cli-conf/testnet/config.json` - This command validates that the Data API information in the `testnet` network is correct. It also ensures that the implementation does not miss any balance-changing operations.\n* `mesh-cli check:construction --configuration-file mesh-cli-conf/testnet/config.json` - This command validates the blockchain’s construction, signing, and broadcasting.\n* `mesh-cli check:data --configuration-file mesh-cli-conf/mainnet/config.json` - This command validates that the Data API information in the `mainnet` network is correct. It also ensures that the implementation does not miss any balance-changing operations.\n\nRead the [How to Test your Mesh Implementation](https://docs.cdp.coinbase.com/mesh/docs/mesh-test/) documentation for additional details.\n\n## Contributing\n\nYou may contribute to the `mesh-bitcoin` project in various ways:\n\n* [Asking Questions](CONTRIBUTING.md/#asking-questions)\n* [Providing Feedback](CONTRIBUTING.md/#providing-feedback)\n* [Reporting Issues](CONTRIBUTING.md/#reporting-issues)\n\nRead our [Contributing](CONTRIBUTING.MD) documentation for more information.\n\nYou can also find community implementations for a variety of blockchains in the [mesh-ecosystem](https://github.com/coinbase/mesh-ecosystem) repository.\n\n## Documentation\n\nYou can find the Mesh API documentation [here](https://docs.cdp.coinbase.com/mesh/docs/welcome/). \n\nCheck out the [Getting Started](https://docs.cdp.coinbase.com/mesh/docs/getting-started/) section to start diving into Mesh. \n\n\n## Related Projects\n\n* [mesh-sdk-go](https://github.com/coinbase/mesh-sdk-go) — The `mesh-sdk-go` SDK provides a collection of packages used for interaction with the Mesh API specification. \n* [mesh-specifications](https://github.com/coinbase/mesh-specifications) — Much of the SDK code is generated from this repository.\n* [mesh-cli](https://github.com/coinbase/mesh-ecosystem) — Use the `mesh-cli` tool to test your Mesh API implementation. The tool also provides the ability to look up block contents and account balances.\n\n### Sample Implementations\n\nYou can find community implementations for a variety of blockchains in the [mesh-ecosystem](https://github.com/coinbase/mesh-ecosystem) repository. \n\n## License\nThis project is available open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).\n\n© 2022 Coinbase","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fmesh-bitcoin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Fmesh-bitcoin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fmesh-bitcoin/lists"}