{"id":22700425,"url":"https://github.com/uncomputable/bitcoin-nix-tools","last_synced_at":"2025-03-29T19:11:37.185Z","repository":{"id":200721187,"uuid":"706133010","full_name":"uncomputable/bitcoin-nix-tools","owner":"uncomputable","description":"Tools for easy Bitcoin Core development using nix.","archived":false,"fork":false,"pushed_at":"2023-12-18T16:52:12.000Z","size":26,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-04T19:46:38.589Z","etag":null,"topics":["bitcoin","bitcoind","liquid-network","nix","nixos","tutorial"],"latest_commit_sha":null,"homepage":"https://bitcoincore.org","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uncomputable.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-17T11:16:10.000Z","updated_at":"2024-04-17T04:53:44.000Z","dependencies_parsed_at":"2024-12-10T06:22:13.923Z","dependency_job_id":null,"html_url":"https://github.com/uncomputable/bitcoin-nix-tools","commit_stats":null,"previous_names":["uncomputable/bitcoin-nix-tools"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncomputable%2Fbitcoin-nix-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncomputable%2Fbitcoin-nix-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncomputable%2Fbitcoin-nix-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncomputable%2Fbitcoin-nix-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uncomputable","download_url":"https://codeload.github.com/uncomputable/bitcoin-nix-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246230541,"owners_count":20744349,"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":["bitcoin","bitcoind","liquid-network","nix","nixos","tutorial"],"created_at":"2024-12-10T06:12:09.966Z","updated_at":"2025-03-29T19:11:37.167Z","avatar_url":"https://github.com/uncomputable.png","language":"Nix","readme":"# Bitcoin Nix Tools\n\n\"The only reason why I'm not a Core developer yet is because the setup is too hard.\"\n\nNix derivations to locally build and test Bitcoin Core and Elements Core.\n\nNo more complicated configuration.\n\nLet's make Bitcoin Core development as easy as possible!\n\n## Spread the nix\n\nStep zero is to clone this repo and the repo you want to infect with nix.\n\nIn this example, we use Bitcoin Core.\n\n```bash\ngit clone git@github.com:uncomputable/bitcoin-nix-tools.git\ngit clone git@github.com:bitcoin/bitcoin.git\n```\n\nThen copy the nix files over.\n\n```bash\ncp bitcoin-nix-tools/*.nix bitcoin\n```\n\nYou have successfully spread the nix.\n\n## Test Bitcoin Core\n\n### Enter the development environment\n\nOpen a nix shell.\n\n```bash\nnix-shell # use \"--arg withGui true\" to include GUI\n```\n\n### Build Bitcoin Core\n\nRun the automake commands.\n\n```bash\n./autogen.sh\n./configure $configureFlags\nmake # use \"-j N\" for N parallel jobs\n```\n\nThe configure script lists the available options and default values.\n\n```bash\n./configure --help\n```\n\n### Read more about building\n\nRead the [official README](https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md).\n\n### Run the unit tests\n\nUse make to run the boost unit tests.\n\n```bash\nmake test # use \"-j N\" for N parallel jobs\n```\n\n### Run the functional tests\n\nUse python to run the functional tests.\n\n```bash\npython3 test/functional/test_runner.py # use \"-j N\" for N parallel jobs # use \"--extended\" to include ignored tests\n```\n\n### Run the QA asset unit tests\n\nDownload the [QA assets](https://github.com/bitcoin-core/qa-assets).\n\n```bash\ngit clone git@github.com:bitcoin-core/qa-assets.git\n```\n\nUse the test runner to run the QA asset unit tests.\n\n```bash\nDIR_UNIT_TEST_DATA=qa-assets/unit_test_data ./src/test/test_bitcoin --log_level=warning --run_test=script_tests\n```\n\nThe variable `DIR_UNIT_TEST_DATA` selects the directory in which the file `script_assets_test.json` is located.\n\n### Read more about testing\n\nRead the [official README](https://github.com/bitcoin/bitcoin/blob/master/test/README.md).\n\n## Fuzz Bitcoin Core\n\n### Enter the development environment\n\nOpen a nix shell.\n\n```bash\nnix-shell # use \"--arg withGui true\" to include GUI\n```\n\n### Build Bitcoin Core\n\nRun the automake commands with fuzzing and sanitizers enabled.\n\n```bash\n./autogen.sh\n./configure $configureFlags --enable-fuzz --with-sanitizers=address,fuzzer,undefined\nmake # use \"-j N\" for N parallel jobs\n```\n\n### Run a fuzzing target\n\nUse the compiled fuzzer binary to run a fuzzing target.\n\n```bash\nFUZZ=process_message src/test/fuzz/fuzz\n```\n\nThe variable `FUZZ` selects the fuzzing target.\n\nRun the following command to list all targets.\n\n```bash\ngrep -rl '^FUZZ_TARGET' src/test/fuzz | xargs -I {} basename {} .cpp\n```\n\n### Fuzz using the QA asset seed corpus\n\nDownload the [QA assets](https://github.com/bitcoin-core/qa-assets) for a massive headstart in code coverage.\n\n```bash\ngit clone git@github.com:bitcoin-core/qa-assets.git\n```\n\nPass the corpus directory of the respective target to the fuzzer binary.\n\nThe `FUZZ` variable and the folder in the corpus must be the same.\n\n```bash\nFUZZ=process_message src/test/fuzz/fuzz qa-assets/fuzz_seed_corpus/process_message/\n```\n\n### Read more about fuzzing\n\nRead the [official README](https://github.com/bitcoin/bitcoin/blob/master/doc/fuzzing.md).\n\n## Generate QA asset unit test data\n\n### Generate unit tests dumps\n\n[Build Bitcoin Core for testing](https://github.com/uncomputable/bitcoin-nix-tools/tree/master#test-bitcoin-core).\n\nThen run the Taproot tests a couple of times and dump the output in a directory.\n\n```bash\nmkdir dump\nfor N in $(seq 1 10); do TEST_DUMP_DIR=dump test/functional/feature_taproot.py --dumptests; done\n```\n\n### Compress test dumps via fuzz merging\n\n[Build Bitcoin Core for fuzzing](https://github.com/uncomputable/bitcoin-nix-tools/tree/master#fuzz-bitcoin-core).\n\nThen run the `script_assets_test_minimizer` fuzz test in merge mode and dump the output in another directory.\n\nUse shell commands to create a .json file.\n\n```bash\nmkdir dump-min\nFUZZ=script_assets_test_minimizer ./src/test/fuzz/fuzz -merge=1 -use_value_profile=1 dump-min/ dump/\n(echo -en '[\\n'; cat dump-min/* | head -c -2; echo -en '\\n]') \u003e script_assets_test.json\n```\n\n## Test code coverage of Bitcoin Core\n\n### Enter the development environment\n\nOpen a nix shell.\n\n```bash\nnix-shell # use \"--arg withGui true\" to include GUI\n```\n\n### Build Bitcoin Core\n\nRun the automake commands with line and branch coverage enabled.\n\nDisable BDB to avoid compiling and testing the legacy wallet.\n\n```bash\n./autogen.sh\n./configure $configureFlags --enable-lcov --enable-lcov-branch-coverage --disable-bdb\nmake # use \"-j N\" for N parallel jobs\n```\n\nThe compiled binaries will log their coverage in separate files each time they are run.\n\n### Test unit test coverage\n\nUse make to run the unit tests and to compile an HTML coverage report.\n\n```bash\nmake test_bitcoin.coverage/.dirstamp # use \"-j N\" for N parallel jobs\n```\n\nOpen the report in your browser.\n\n```bash\nfirefox test_bitcoin.coverage/src/index.html\n```\n\n### Test total coverage\n\nUse make to run the unit and functional tests, and to compile an HTML coverage report.\n\n```bash\nmake cov # use \"-j N\" for N parallel jobs\n```\n\nOpen the report in your browser.\n\n```bash\nfirefox test_bitcoin.coverage/src/index.html\n```\n\n## Elements Core\n\nYou can build, test and fuzz Elements Core exactly the same way as Bitcoin Core :)\n\nFor completeness, I will link the READMEs on [building](https://github.com/ElementsProject/elements/blob/master/doc/build-unix.md) and [testing](https://github.com/ElementsProject/elements/blob/master/test/README.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funcomputable%2Fbitcoin-nix-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funcomputable%2Fbitcoin-nix-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funcomputable%2Fbitcoin-nix-tools/lists"}