{"id":18285903,"url":"https://github.com/exodusmovement/bitcoind-zmq","last_synced_at":"2025-04-05T08:30:37.092Z","repository":{"id":33229310,"uuid":"155604642","full_name":"ExodusMovement/bitcoind-zmq","owner":"ExodusMovement","description":"Get ZMQ notifications from bitcoin-like coins","archived":false,"fork":false,"pushed_at":"2022-02-12T08:40:53.000Z","size":76,"stargazers_count":20,"open_issues_count":6,"forks_count":7,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-10-29T00:42:53.757Z","etag":null,"topics":["bitcoind","btc","coin","crypto","js","nodejs","notifications","zmq"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ExodusMovement.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-31T18:21:48.000Z","updated_at":"2023-09-27T07:34:51.000Z","dependencies_parsed_at":"2022-08-07T20:16:59.113Z","dependency_job_id":null,"html_url":"https://github.com/ExodusMovement/bitcoind-zmq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fbitcoind-zmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fbitcoind-zmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fbitcoind-zmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExodusMovement%2Fbitcoind-zmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExodusMovement","download_url":"https://codeload.github.com/ExodusMovement/bitcoind-zmq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223174747,"owners_count":17100272,"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":["bitcoind","btc","coin","crypto","js","nodejs","notifications","zmq"],"created_at":"2024-11-05T13:18:08.673Z","updated_at":"2024-11-05T13:18:09.596Z","avatar_url":"https://github.com/ExodusMovement.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bitcoind-zmq\n\n[![NPM Version](https://img.shields.io/npm/v/bitcoind-zmq.svg)](https://www.npmjs.com/package/bitcoind-zmq)\n![node](https://img.shields.io/node/v/bitcoind-zmq.svg)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n\u003e Get ZMQ notifications from bitcoind-like coins\n\n## Install\n\n\u003e npm install --save bitcoind-zmq\n\nAnd make sure to run bitcoind or whatever btc-like coin (that support zmq) with his [zmq options](https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md).\n\n\u003e bitcoind -zmqpubhashtx=tcp://127.0.0.1:28332 -zmqpubhashblock=tcp://127.0.0.1:28332\n\n## Usage example\n\n```javascript\nconst BitcoindZmq = require('bitcoind-zmq')\n\nconst opts = { maxRetry: 20 }\n\nconst btcd = new BitcoindZmq({\n  // topic: \u003czmq node\u003e\n  hashtx: 'tcp://127.0.0.1:28332',\n  hashblock: 'tcp://127.0.0.1:28332',\n  rawtx: 'tcp://127.0.0.1:28334',\n  rawblock: 'tcp://127.0.0.1:28334'\n}, opts)\n\nbtcd.connect()\n\nbtcd.on('hashblock', (hash) =\u003e {\n  // hash \u003cBuffer ... /\u003e\n})\n\nbtcd.on('hashtx', (hash) =\u003e {\n  // hash \u003cBuffer ... /\u003e\n})\n\nbtcd.on('rawblock', (block) =\u003e {\n  // block \u003cBuffer ... /\u003e\n})\n\nbtcd.on('rawtx', (tx) =\u003e {\n  // tx \u003cBuffer ... /\u003e\n})\n\nbtcd.on('connect:*', (uri, type) =\u003e {\n  console.log(`socket ${type} connected to ${uri}`)\n})\n\nbtcd.on('retry:hashtx', (type, attempt) =\u003e {\n  console.log(`hashtx, connect retry attempt: ${attempt}`)\n})\n\nbtcd.on('error:*', (err, type) =\u003e {\n  console.error(`${type} had error:`, err)\n})\n```\n\n### API\n\nThe `BitcoindZMQ({...}, \u003copts\u003e)` Class accepts in his constructor `topic -\u003e zmq node` pairs. The only option available is `maxRetry` the maximum n. of attempt to connect to a zmq node.\n\n- `.add(\u003ctype\u003e, \u003curi\u003e)`: Add a `topic -\u003e zmq node` pair (ex. `.add('hashtx', 'tcp://127.0.0.1:28333')`).\n- `.on(\u003ceventName\u003e, \u003cfn\u003e)`: the event name could be a [EventEmitter2](https://github.com/EventEmitter2/EventEmitter2) pattern with namespaces (ex. `.on('connect:hashtx', () =\u003e console.log('watching hashtx'))`).\n- `.connect(\u003cnodeType\u003e)`: *nodeType* could be a **String**/**Array** of previously added topics to connect to. If none is provided it will connect to all the added nodes.\n- `.disconnect(\u003cnodeType\u003e)`: disconnect from the given nodes or from all nodes if no argument is provided.\n\nAlso refer to the example for usage.\n\n*Bitcoind* available events are these below. You can add new coins' events or get rid of those you don't need when instantiating the Class:\n\n- `hashblock`\n- `hashtx`\n- `rawblock`\n- `rawtx`\n\n**Reserved events and namespaces**:\n\n- `error:*` event fired with `Error`\n- `close:*`: event fired with `Error` if any, and `nodeType`.\n- `connect:*`: event fired with `Uri`, `nodeType`.\n- `retry:*`: event fired with `nodeType`, `attempt`\n\n*example*: `error:*` will catch every node error (`error:hashblock`, `error:hashtx`, and so on...)\n\n### Debug\n\n\u003e DEBUG=bitcoind-zmq\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fbitcoind-zmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexodusmovement%2Fbitcoind-zmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexodusmovement%2Fbitcoind-zmq/lists"}