{"id":13772938,"url":"https://github.com/mappum/bitcoin-merkle-proof","last_synced_at":"2025-06-30T23:06:30.978Z","repository":{"id":143858440,"uuid":"50538593","full_name":"mappum/bitcoin-merkle-proof","owner":"mappum","description":":evergreen_tree: Build and verify Bitcoin Merkle proofs","archived":false,"fork":false,"pushed_at":"2017-05-11T13:23:43.000Z","size":36,"stargazers_count":12,"open_issues_count":30,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-24T01:15:08.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mappum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-01-27T21:20:27.000Z","updated_at":"2021-09-02T13:12:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3a54688-9124-4372-ba71-c9c1372c7039","html_url":"https://github.com/mappum/bitcoin-merkle-proof","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":0.07692307692307687,"last_synced_commit":"d478686449da747d663b385cf01bd51bd32561bb"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/mappum/bitcoin-merkle-proof","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Fbitcoin-merkle-proof","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Fbitcoin-merkle-proof/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Fbitcoin-merkle-proof/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Fbitcoin-merkle-proof/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mappum","download_url":"https://codeload.github.com/mappum/bitcoin-merkle-proof/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mappum%2Fbitcoin-merkle-proof/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262864132,"owners_count":23376455,"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-08-03T17:01:09.371Z","updated_at":"2025-06-30T23:06:30.951Z","avatar_url":"https://github.com/mappum.png","language":"JavaScript","funding_links":[],"categories":["List of content"],"sub_categories":["Utilities"],"readme":"# bitcoin-merkle-proof\n\n[![npm version](https://img.shields.io/npm/v/bitcoin-merkle-proof.svg)](https://www.npmjs.com/package/bitcoin-merkle-proof)\n[![Build Status](https://travis-ci.org/mappum/bitcoin-merkle-proof.svg?branch=master)](https://travis-ci.org/mappum/bitcoin-merkle-proof)\n[![Dependency Status](https://david-dm.org/mappum/bitcoin-merkle-proof.svg)](https://david-dm.org/mappum/bitcoin-merkle-proof)\n\n**Verify Bitcoin Merkle trees**\n\nBitcoin [BIP37](https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki) adds support for `merkleblock` messages, which allow clients to download blocks that only include transactions relevant to them. The transactions are selected via a Bloom Filter.\n\nThis module creates and verifies the Merkle proofs in a `merkleblock` message, and lists the included transactions which match the filter.\n\n## Usage\n\n`npm install bitcoin-merkle-proof`\n\n```js\nvar bmp = require('bitcoin-merkle-proof')\n\n// build merkle proof object (block #681135 in testnet)\nvar merkleProof = bmp.build({\n  hashes: [\n    new Buffer('52a893ef120d5e24aa38604ead9ada6628eea417df6d6096ef0dd7b73a89c0e9', 'hex'),\n    new Buffer('a76a1e1bffbbb254bd897e379298549eb8ff4aa57a4bb4c06637b36d76833207', 'hex'),\n    new Buffer('056b4e64697677788744a8ad23cc407cbc1c357ff889d9975edd431fb779466f', 'hex'),\n    new Buffer('3c51bfb4f9cdd2b8e3a5c47cb1b3bdbc8879a1c1b238d4123dcb572a00b2b80e', 'hex'),\n    new Buffer('d6d1f9ca0a4017050379a82ecccb050cf4218f2180087e9592110972a71e375c', 'hex')\n  ],\n  include: [\n    new Buffer('3c51bfb4f9cdd2b8e3a5c47cb1b3bdbc8879a1c1b238d4123dcb572a00b2b80e', 'hex'),\n    new Buffer('d6d1f9ca0a4017050379a82ecccb050cf4218f2180087e9592110972a71e375c', 'hex')\n  ]\n})\n// { flags: [ 235, 1 ],\n//   hashes:\n//    [ \u003cBuffer 19 d6 5e 9e 20 d4 55 db ae 6d 11 39 66 54 7a 1d 41 91 e3 cf eb 3c 4c 2a b9 0e d2 79 5f 39 c4 cc\u003e,\n//      \u003cBuffer 05 6b 4e 64 69 76 77 78 87 44 a8 ad 23 cc 40 7c bc 1c 35 7f f8 89 d9 97 5e dd 43 1f b7 79 46 6f\u003e,\n//      \u003cBuffer 3c 51 bf b4 f9 cd d2 b8 e3 a5 c4 7c b1 b3 bd bc 88 79 a1 c1 b2 38 d4 12 3d cb 57 2a 00 b2 b8 0e\u003e,\n//      \u003cBuffer d6 d1 f9 ca 0a 40 17 05 03 79 a8 2e cc cb 05 0c f4 21 8f 21 80 08 7e 95 92 11 09 72 a7 1e 37 5c\u003e ],\n//   numTransactions: 5,\n//   merkleRoot: \u003cBuffer b9 b4 50 02 94 c1 84 87 dc 32 a9 29 b5 87 47 5f bf 96 52 be b7 d7 30 10 ea 37 ee 04 83 e5 2e 58\u003e }\n\n// verify proof and return matched tx hashes\nvar hashes = bmp.verify(merkleProof)\nconsole.log('Matched transactions: ', hashes)\n```\n\n##### `var merkleProof = bmp.build(block)`\n\nConstruct proof object for transactions. Proof object:\n```js\n{\n  flags: number[],\n  hashes: Buffer[],\n  numTransactions: number,\n  merkleRoot: Buffer\n}\n```\n\n##### `var hashes = bmp.verify(merkleProof)`\n\nVerifies a Merkle proof object. An error will be thrown if the tree is not valid or does not match the expected Merkle root. Returns an array of txids (as `Buffer`s) which matched the Bloom filter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmappum%2Fbitcoin-merkle-proof","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmappum%2Fbitcoin-merkle-proof","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmappum%2Fbitcoin-merkle-proof/lists"}