{"id":19178065,"url":"https://github.com/cmdruid/core-cmd","last_synced_at":"2025-08-18T21:14:06.325Z","repository":{"id":189031229,"uuid":"679885012","full_name":"cmdruid/core-cmd","owner":"cmdruid","description":"A suite of CI/CD friendly tools that plug into bitcoin core and help you interact with the blockchain.","archived":false,"fork":false,"pushed_at":"2024-08-20T14:05:19.000Z","size":15958,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-12T22:41:12.312Z","etag":null,"topics":["bitcoin","cicd","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/cmdruid.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-17T20:54:47.000Z","updated_at":"2025-02-26T19:41:57.000Z","dependencies_parsed_at":"2023-08-18T00:11:34.734Z","dependency_job_id":"dee30d1e-3c5d-44c7-a403-5e5f80fd192c","html_url":"https://github.com/cmdruid/core-cmd","commit_stats":null,"previous_names":["cmdruid/core-cmd","cmdruid/core-orm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cmdruid/core-cmd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fcore-cmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fcore-cmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fcore-cmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fcore-cmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmdruid","download_url":"https://codeload.github.com/cmdruid/core-cmd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fcore-cmd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271061320,"owners_count":24692508,"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","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bitcoin","cicd","testing"],"created_at":"2024-11-09T10:36:50.760Z","updated_at":"2025-08-18T21:14:06.247Z","avatar_url":"https://github.com/cmdruid.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Core Command\n\nA suite of CI/CD friendly tools that plug into bitcoin core.\n\nThis library is designed for writing test cases that interact with the bitcoin blockchain.\n\n## How to Install\n\n```sh\n# Using NPM\nnpm i --save-dev @cmdcode/core-cmd\n# Using Yarn\nyarn add --dev @cmdcode/core-cmd\n```\n\n## How to Use\n\nThe `CoreDaemon` class is designed to connect to an existing core node, or spawn a new one.\n\nBy default, the startup script will search for a running process of `bitcoind` or `bitcoin-qt`, and connect to it.\n\nIf no bitcoin core process is running, the startup script will spawn a new one.\n\nThe shutdown script will gracefully shut down any bitcoin core process started by the startup script. It will not affect any existing running process of bitcoin core.\n\n```ts\nimport { CoreDaemon } from '@cmdcode/core-cmd'\n\nconst config : {\n  cookiepath  ?: string    // Path to your cookie file (if different than datapath).\n  corepath    ?: string    // Path to your bitcoind binary (if not available in PATH).\n  clipath     ?: string    // Path to your bitcoin-cli (if not available in PATH).\n  confpath    ?: string    // Path to your bitcoin.conf file (if exists).\n  datapath    ?: string    // Path to your bitcoin data directory.\n  params      ?: string[]  // Additional params to use when starting bitcoind and bitcoin-cli.\n  core_params ?: string[]  // Additional params to use when starting bitcoind.\n  cli_params  ?: string[]  // Additional params to use when starting bitcoin-cli.\n  debug       ?: boolean   // Provides addition console output for debugging.\n  isolated    ?: boolean   // Starts bitcoind with random ports so it doesn't conflict with an existing process.\n  network     ?: string    // Network to use (default is regetest).\n  throws      ?: boolean   // Ensure client and core process always throws an exception on error.\n  verbose     ?: boolean   // Provides additional verbosity to console output.\n} = {}\n\n// Create a new daemon instance (with optional config).\nconst core = new CoreDaemon(config)\n```\n\nThe basic way to run a script through bitcoin core is to use the `startup` and `shutdown` methods. These methods help ensure that bitcoin core is cleaned up properly once the test completes.\n\n```ts\nconst core   = new CoreDaemon({ datapath: `${process.env.HOME}/.bitcoin` })\nconst client = await core.startup()\n\nconsole.log(await client.get_info)\ncore.shutdown()\n```\n\nTo auto-magically wrap your code with `startup` and `shutdown`, you can use the `run` method.\n\nThe `run` method will take any number of callback methods, and pass a `CoreClient` object into each one.\n\n```ts\nawait core.run(async (client : CoreClient) =\u003e {\n  // Load a wallet for Alice and generate an address.\n  const alice_wallet = await client.get_wallet('alice_wallet')\n  const alice_recv   = await alice_wallet.newaddress\n  console.log('receive address:', alice_recv.address)\n  // Create a tx template that pays to Alice.\n  const template = {\n    vout : [{\n      value : 800_000,\n      scriptPubKey : alice_recv.scriptPubKey\n    }]\n  }\n  // Load a wallet for Bob and ensure it has funds.\n  const bob_wallet = await client.get_wallet('bob_wallet')\n  await bob_wallet.ensure_funds(1_000_000)\n  // Fund the tx from Alice using Bob's wallet\n  const txdata = await bob_wallet.fund_tx(template)\n  // Print the txdata to console.\n  console.log('txdata:', txdata)\n  // Publish the tx.\n  const txid = await client.publish_tx(txdata)\n  // Mine a few blocks to confirm the tx.\n  await client.mine_blocks(1)\n  // Print the txid to console.\n  console.log('txid:', txid)\n})\n```\n\nFor better flow control, you may want to use the `ready` event to execute code.\n\nThe `ready` event will emit after a sucessful run of the `startup` script.\n\n```ts\n// When core is started, it will emit a 'ready' event with a client object.\ncore.on('ready', async (client) =\u003e {\n  // You can use the client to run commands.\n  console.log(await client.cmd('getblockchaininfo'))\n  // The client can load/create a wallet.\n  const wallet = await client.get_wallet('test_wallet')\n  // You can use the wallet to perform wallet-specific features.\n  const addr = await wallet.newaddress\n  console.log('addr:', addr)\n  // Once your script is finished, you can gracefully shut down the daemon.\n  await core.shutdown()\n})\n// To kick-off the above logic, start up core.\nawait core.startup()\n```\n\n## CI/CD Testing\n\nThe included `test` and `.github` folders are a showcase and example of how to use this library with github actions.\n\nThe example test located in `test/src/base.test.ts` uses a basic testing library called `tape`.\n\nFeel free to copy this code and apply it to your own testing framework and CI/CD pipeline.\n\n## Bugs / Issues\n\nPlease post any questions or bug reports on the issues page.\n\nThere will likely be a number of cross-platform issues since I only have access to a linux machine for development. I will greatly appreciate any help and feedback from devs running into issues on Windows and OSX!\n\n## Development \u0026 Testing\n\nThis project uses `typescript` for development and `tape` for testing.\n\n```bash\nyarn install \u0026\u0026 yarn test\nnpm  install \u0026\u0026 npm run test\n```\n\n## Contributions\n\nAll contributions are welcome!\n\n## License\n\nUse this code however you like! No warranty!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmdruid%2Fcore-cmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmdruid%2Fcore-cmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmdruid%2Fcore-cmd/lists"}