{"id":13584686,"url":"https://github.com/dan-da/hd-wallet-addrs","last_synced_at":"2025-04-08T03:11:18.461Z","repository":{"id":50928186,"uuid":"48829052","full_name":"dan-da/hd-wallet-addrs","owner":"dan-da","description":"A command-line tool that performs Bitcoin wallet address discovery.","archived":false,"fork":false,"pushed_at":"2024-06-04T04:48:36.000Z","size":101,"stargazers_count":133,"open_issues_count":1,"forks_count":40,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-31T17:21:17.569Z","etag":null,"topics":["bip32","bip44","bitcoin","commandline","discovery","hd-wallet","hdwallet","shell","wallet"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/dan-da.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}},"created_at":"2015-12-31T02:29:19.000Z","updated_at":"2025-01-20T09:03:50.000Z","dependencies_parsed_at":"2024-12-03T23:12:40.095Z","dependency_job_id":null,"html_url":"https://github.com/dan-da/hd-wallet-addrs","commit_stats":{"total_commits":85,"total_committers":6,"mean_commits":"14.166666666666666","dds":"0.17647058823529416","last_synced_commit":"cf6e1f0f3a2cb41fd2beadd39ec87f5f7ea1923a"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-addrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-addrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-addrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fhd-wallet-addrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-da","download_url":"https://codeload.github.com/dan-da/hd-wallet-addrs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"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":["bip32","bip44","bitcoin","commandline","discovery","hd-wallet","hdwallet","shell","wallet"],"created_at":"2024-08-01T15:04:26.817Z","updated_at":"2025-04-08T03:11:18.441Z","avatar_url":"https://github.com/dan-da.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# hd-wallet-addrs\n\nA command-line  tool for finding bitcoin hd-wallet addresses that have received funds.\n\nThis tool does two primary things:\n\n1. derive hd-wallet addresses (both change and receive) according to bip32 rules.\n2. examines the blockchain to find the addresses that have actually been used.  (received funds at least once)\n\nA web frontend for this tool is available at:\nhttps://mybitprices.info/hd-wallet-addrs.html\n\nBoth regular HD wallets (single address) and multi-sig wallets (eg Copay) are\nsupported.\n\nSegwit addresses are generated if a ypub or zpub key is provided.\n(ypub: segwit-p2sh, zpub: bech32)\n\nReports are available in json, plaintext, and html.  Columns can be\nchanged or re-ordered via command-line.\n\nhd-wallet-addrs is general purpose for anyone needing to discover which addresses\nare actually used in their wallet, including change addresses.\n\nThe motivation for building this tool was to simplify extracting used wallet\naddresses for accounting purposes.  In particular for use with:\n* \u003ca href=\"http://github.com/dan-da/bitprices\"\u003ebitprices\u003c/a\u003e - a command line utility for wallet pricing history and cost-based accounting.\n* \u003ca href=\"http://mybitprices.info\"\u003emybitprices.info\u003c/a\u003e - an easy-to-use web frontend to bitprices.\n\nSee also: [hd-wallet-derive](https://github.com/dan-da/hd-wallet-derive) -- a tool that derives bip32 addresses and private keys.\n\n# Let's see some examples.\n\n```\n$ ./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --logfile=/tmp/log.txt\n\n --- Wallet Discovery Report ---\n\nFound 3 Receive addresses and 2 Change addresses.\n  Receive --  Used: 3   Unused: 0\n  Change  --  Used: 2   Unused: 0\n\n+------------------------------------+---------+----------------+------------+------------+---------+\n| addr                               | type    | total_received | total_sent | balance    | relpath |\n+------------------------------------+---------+----------------+------------+------------+---------+\n| 1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK | Receive |     0.00120000 | 0.00100000 | 0.00020000 | 0/0     |\n| 1NVsB73WmDGXSxv77sh9PZENH2x3RRnkDY | Receive |     0.00130000 | 0.00100000 | 0.00030000 | 0/1     |\n| 1BkgqiHcvfnQ2wrPN5D2ycrvZas3nibMjC | Receive |     0.00040000 | 0.00000000 | 0.00040000 | 0/2     |\n| 12SisoiXLUEbkytL5Pzia1jBY8gJP5XN8D | Change  |     0.00184874 | 0.00000000 | 0.00184874 | 1/0     |\n| 1CkvACVpFwkPnMG13w9kXXE9YcsiyL4pcY | Change  |     0.00194876 | 0.00000000 | 0.00194876 | 1/1     |\n+------------------------------------+---------+----------------+------------+------------+---------+\n```\n\nWe can change up the fields and specify to use bip44 derivation to generate an absolute path.\n\nTip: The abspath column is empty when --derivation=relative, which is the default.\n\n```\n$ ./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --cols=type,abspath,relpath,addr --derivation=bip44 --logfile=/tmp/log.txt\n\n --- Wallet Discovery Report ---\n\nFound 3 Receive addresses and 2 Change addresses.\n  Receive --  Used: 3   Unused: 0\n  Change  --  Used: 2   Unused: 0\n\n+---------+--------------+---------+------------------------------------+\n| type    | abspath      | relpath | addr                               |\n+---------+--------------+---------+------------------------------------+\n| Receive | m/44/0/0/0/0 | 0/0     | 1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK |\n| Receive | m/44/0/0/0/1 | 0/1     | 1NVsB73WmDGXSxv77sh9PZENH2x3RRnkDY |\n| Receive | m/44/0/0/0/2 | 0/2     | 1BkgqiHcvfnQ2wrPN5D2ycrvZas3nibMjC |\n| Change  | m/44/0/0/1/0 | 1/0     | 12SisoiXLUEbkytL5Pzia1jBY8gJP5XN8D |\n| Change  | m/44/0/0/1/1 | 1/1     | 1CkvACVpFwkPnMG13w9kXXE9YcsiyL4pcY |\n+---------+--------------+---------+------------------------------------+\n```\n\nOr get a list for easy copy/paste.\n\n```\n$ ./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --format=addrlist --logfile=/tmp/log.txt\n\n --- Wallet Discovery Report ---\n\nFound 3 Receive addresses and 2 Change addresses.\n  Receive --  Used: 3   Unused: 0\n  Change  --  Used: 2   Unused: 0\n\n1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK\n1NVsB73WmDGXSxv77sh9PZENH2x3RRnkDY\n1BkgqiHcvfnQ2wrPN5D2ycrvZas3nibMjC\n12SisoiXLUEbkytL5Pzia1jBY8gJP5XN8D\n1CkvACVpFwkPnMG13w9kXXE9YcsiyL4pcY\n```\n\nOr JSON\n\n```\n./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --cols=type,abspath,relpath,addr --format=jsonpretty  --derivation=bip44 --logfile=/tmp/log.txt\n[\n    {\n        \"type\": \"Receive\",\n        \"abspath\": \"m\\/44\\/0\\/0\\/0\\/0\",\n        \"relpath\": \"0\\/0\",\n        \"addr\": \"1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK\"\n    },\n    ...\n]\n```\n\nOr CSV\n\n```\n./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --cols=type,abspath,relpath,addr --format=csv  --derivation=bip44 --logfile=/tmp/log.txt\ntype,abspath,relpath,addr\nReceive,m/44/0/0/0/0,0/0,1Ge6rDuyCdYVGhXZjcK4251q67GXMKx6xK\nReceive,m/44/0/0/0/1,0/1,1NVsB73WmDGXSxv77sh9PZENH2x3RRnkDY\nReceive,m/44/0/0/0/2,0/2,1BkgqiHcvfnQ2wrPN5D2ycrvZas3nibMjC\nChange,m/44/0/0/1/0,1/0,12SisoiXLUEbkytL5Pzia1jBY8gJP5XN8D\nChange,m/44/0/0/1/1,1/1,1CkvACVpFwkPnMG13w9kXXE9YcsiyL4pcY\n```\n\n# multi-sig examples.\n\nSo far multi-sig has been tested with copay (bip44 and bip45) only.\nOlder versions of Copay using bip45 require the --derivation=copaylegacy flag.\n\nmultisig requires multiple xpub keys and use of the --numsig flag to indicate\nthe required number of signers.  (m of n)\n\n## discovering an empty Copay 1.6.3+ (bip44) 2 of 3 wallet.\n\nThis test wallet has no funds, so we use --include-unused to obtain the initial addresses up to the\ngap limit.  The gap limit default is 20, but we use 2 here for brevity.\n```\n$ ./hd-wallet-addrs.php -g --numsig=2 --gap-limit=2  --xpub=xpub6CZte6DfeMoVwxv3ShiMwQjET47nRENqrkZaSXTcP7Yaja6sxyRbiyqPD7kfy4W2dTTuTdV4jHMmSe1k1qteTMN7qDLndt1RfQ8RLM3pjzb,xpub6DUGj5hRwp7t3DoH554Ce7p3KLepccYfG5BVbvyPSArTepacc3aPRDTMz3GSdoX1HgVYKBSaR6fFDm1daEtSQFBSNTq4X93pd8dBFyPW2gz,xpub6DRFPDtHueJ5sfqzcLSyoKL6TQZMofvjpLzsVXsWqjgYuAtUtdU8YjWFvpa2xegWLFeLQ38KLJzWdKQ3CsAQQLoMYnBsQy3FCeTDuxgcsfK --include-unused --logfile=/tmp/out.txt\n\n --- Wallet Discovery Report ---\n\nFound 2 Receive addresses and 2 Change addresses.\n  Receive --  Used: 0   Unused: 2\n  Change  --  Used: 0   Unused: 2\n\n+------------------------------------+---------+----------------+------------+------------+---------+\n| addr                               | type    | total_received | total_sent | balance    | relpath |\n+------------------------------------+---------+----------------+------------+------------+---------+\n| 339H3pYP9AKiEo74D1BWiSK8jhWXsrJ3yk | Receive |     0.00000000 | 0.00000000 | 0.00000000 | 0/0     |\n| 3NcBBWtDscKchgkUCY3eEQZgYh8STtcona | Receive |     0.00000000 | 0.00000000 | 0.00000000 | 0/1     |\n| 3QtjkbY8Km4v5KCgTZxD7VW2vPCsBqkV3V | Change  |     0.00000000 | 0.00000000 | 0.00000000 | 1/0     |\n| 3B7xNx7dCT6ydcVF1xQpEtG8UFeeh2PyAk | Change  |     0.00000000 | 0.00000000 | 0.00000000 | 1/1     |\n+------------------------------------+---------+----------------+------------+------------+---------+\n```\n\n## discovering an empty Copay 1.1.x (bip45) 1 of 1 wallet.\n\nLegacy versions of Copay used bip45 in a special way that the tool cannot detect without help.\n\nNote the use of --derivation=copaylegacy\n\n(Copay 1.6.3+ 1 of 1 wallets use bip44 derivation and do not require any special arguments.)\n\n\n```\n$ ./hd-wallet-addrs.php -g --derivation=copaylegacy --gap-limit=2  --xpub=xpub697odnriKgTgWE4my6au8nd8haUfAMzLGFpDemAkRbCMgGVxANuj9DffNLgDjPA1dnxzi8oFmM79ZPgKVfCV7Saj8sQUL7tJfeZDuyQNGDm --include-unused --logfile=/tmp/out.txt\n\n --- Wallet Discovery Report ---\n\nFound 2 Receive addresses and 2 Change addresses.\n  Receive --  Used: 0   Unused: 2\n  Change  --  Used: 0   Unused: 2\n\n+------------------------------------+---------+----------------+------------+------------+----------------+\n| addr                               | type    | total_received | total_sent | balance    | relpath        |\n+------------------------------------+---------+----------------+------------+------------+----------------+\n| 3LHgjejeCnQEhLGpmc1q4RmPXypKhjbgpY | Receive |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/0/0 |\n| 3Jdd25xHSCDFrMeCoW62963vf22UoKBmtP | Receive |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/0/1 |\n| 3JZ3YR6sgyqq6xcGtpcAvYBCX7gM9cPU3c | Change  |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/1/0 |\n| 32KNwkcQzBHYejvnJpWDwUWMbHGZd4Q6fH | Change  |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/1/1 |\n+------------------------------------+---------+----------------+------------+------------+----------------+\n```\n\n### Warning for users of Copay 1.6.2 and below\n\nOlder Copay versions made it possible to generate gaps larger than 20. This is\nbecause it would generate a new address each time the receive screen was viewed\nand did not respect the standard gap-limit of 20.\n\nChecking only 20 addresses could possibly leave you without discovering funds.\nIf you suspect this may be happening, a workaround is to specify a larger gap\nlimit such as 100 via the gap-limit argument.\n\n\n\n## discovering an empty Copay 1.1.x (bip45) 2 of 2 wallet.\n\nAgain we must use --derivation=copaylegacy\n\n```\n$ ./hd-wallet-addrs.php --derivation=copaylegacy -g --gap-limit=2  --xpub=xpub68bjYyPhqAwK4T8WtXuGvruSQoJu1vdLD7DYc591MkFCR7wD9gyzteFYmzRyytWJ2SzTqZNTgggvPEyqEy9oArjLF7xhte5js1Lp1EPipwJ,xpub68ufoGjY41tQqP4LpeyYornuNxm8DNy2Rn7KAPUTAwFouj821eqcVpWw1jonrm2Xg5jnnSrd1QPQzGve3f66ZLf6Ni9VY6aN3AjYa4e7XTE --numsig=2 --include-unused --logfile=/tmp/out.txt\n\n --- Wallet Discovery Report ---\n\nFound 2 Receive addresses and 2 Change addresses.\n  Receive --  Used: 0   Unused: 2\n  Change  --  Used: 0   Unused: 2\n\n+------------------------------------+---------+----------------+------------+------------+----------------+\n| addr                               | type    | total_received | total_sent | balance    | relpath        |\n+------------------------------------+---------+----------------+------------+------------+----------------+\n| 35uhrWpDTj3Y7EwR9AWjACGfT47txtpH1v | Receive |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/0/0 |\n| 3BnXxkW9CVCLn1EboGDJ8434eKFWZGHsjn | Receive |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/0/1 |\n| 38dzdCQXatNdT9nWG7thpGC9KjBVLphZRP | Change  |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/1/0 |\n| 3CfbgQ5BxWRFBYXJxEVAmVCZsatdJfc2rS | Change  |     0.00000000 | 0.00000000 | 0.00000000 | 2147483647/1/1 |\n+------------------------------------+---------+----------------+------------+------------+----------------+\n```\n\n# How discovery works\n\nIn plain english, discovery works by mathematically deriving the addresses\nfor your wallet in order and checking if each one has been used or not.\n\nA slightly more technical description of the process:\n* starting from the extended public key (xpub)\n* for receive addresses, then change addresses\n  * derive batches of xpub child addresses (bip32: 0/*)\n  * for each batch\n    * check if each address has received funds  (API call to oracle/server)\n    * until 20 (default) unused addresses in a row are found.\n\n# Privacy implications\n\nAn important thing to recognize is that unless you are running a toshi or\ninsight server locally, the discovery process will send your public addresses\nto a third party.  ie: BlockChain.info, BitPay (insight), or CoinBase (toshi)\n\nThe third party will have no way to spend your funds.\n\nThe third party could track your requests and guess/assume that your addresses\nare associated with your IP, or are associated with eachother.\n\nIf that is something you care about, then you should investigate how to run\ntoshi or insight locally and use the --toshi or --insight flags to specify\nthe local server URL.\n\nThere is now a feature that helps to improve privacy when using third-party\nAPI servers.  The **--api=roundrobin** flag will cycle through the available\nblockchain providers and send individual addresses to each.  In this way, no\nsingle provider will have access to all the queried wallet addresses.\n\nQuerying for individual addresses is slow.  The --batch-size flag may be used\nto increase the number of addresses sent to each provider.\n\n\n# Use at your own risk.\n\nThe author makes no claims or guarantees of correctness.\n\n\n# Output formats\n\nThe report may be printed in the following formats:\n* plain  - an ascii formatted table, as above.  intended for humans.\n* csv - CSV format.  For spreadsheet programs.\n* json - raw json format.  for programs to read easily.\n* jsonpretty - pretty json format.  for programs or humans.\n* addrlist - single column address list. for easy cut/paste.\n\nAdditionally, the report may contain incoming transactions only, outgoing\ntransactions only, or both types.\n\n# Usage\n\n```\n$ ./hd-wallet-addrs.php\n\n   hd-wallet-addrs.php\n\n   This script discovers bitcoin HD wallet addresses that have been used.\n\n   Options:\n\n    -g                   go!  ( required )\n\n    --xpub=\u003ccsv\u003e         comma separated list of xpub keys\n    --xpubfile=\u003cpath\u003e    file containing xpub keys, one per line.\n                           note: multiple keys implies multisig m of n.\n\n    --derivation=\u003ctype\u003e  bip32|bip44|bip45|copaylegacy|relative.\n                           default=relative\n    --numsig=\u003cint\u003e       number of required signers for m-of-n multisig wallet.\n                           (required for multisig)\n\n    --gap-limit=\u003cint\u003e    bip32 unused addr gap limit. default=20\n    --include=\u003ctype\u003e     include which addresses.  one of [used, unused, both]\n                         note that unused addresses are subject to --gap-limit\n    --include-unused     equivalent to --include=both\n\n    --gen-only=\u003cn\u003e      will generate n receive addresses and n change addresses\n                          but will not query the blockchain to determine if they\n                          have been used.\n\n    --type=\u003ctype\u003e       receive|change|both.  default=both\n\n    --api=\u003capi\u003e          toshi|insight|blockchaindotinfo|btcd|roundrobin\n                           default = blockchaindotinfo  (fastest)\n                           roundrobin will use a different API for each batch\n                            to improve privacy.  It also sets --batch-size to\n                            1 if set to auto.\n\n    --batch-size=\u003cn\u003e    integer|auto   default=auto.\n                          The number of addresses to lookup in each batch.\n\n    --cols=\u003ccols\u003e        a csv list of columns, or \"all\"\n                         all:\n                          (addr,type,total_received,total_sent,balance,relpath,abspath,xpub)\n                         default:\n                          (addr,type,total_received,total_sent,balance,relpath)\n\n    --outfile=\u003cpath\u003e     specify output file path.\n    --format=\u003cformat\u003e    txt|csv|json|jsonpretty|html|addrlist|all   default=txt\n\n                         if all is specified then a file will be created\n                         for each format with appropriate extension.\n                         only works when outfile is specified.\n\n    --toshi=\u003curl\u003e       toshi server. defaults to https://bitcoin.toshi.io\n    --insight=\u003curl\u003e     insight server. defaults to https://insight.bitpay.com/api\n\n    --blockchaindotinfo=\u003curl\u003e\n                        blockchain.info server.  defaults to https://blockchain.info\n\n    --btcd=\u003curl\u003e        btcd rpc server.  specify as http://user:pass@host:port.  https ok also\n                          btcd does not return balance or total sent/received.\n\n    --oracle-raw=\u003cp\u003e    path to save raw server response, optional.\n    --oracle-json=\u003cp\u003e   path to save formatted server response, optional.\n\n    --logfile=\u003cfile\u003e    path to logfile. if not present logs to stdout.\n    --loglevel=\u003clevel\u003e  debug,info,specialinfo,warning,exception,fatalerror\n                          default = info\n```\n\n\n# Installation and Running.\n\nPHP's gmp extension is required.  Here's how to install on ubuntu.\n```\n sudo apt-get install php-cli php-gmp composer\n```\n\nBasics\n```\n git clone https://github.com/dan-da/hd-wallet-addrs\n cd hd-wallet-addrs\n composer install\n```\n\nTry an example\n```\n./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR\n```\n\nOr to hide log messages\n```\n./hd-wallet-addrs.php -g --xpub=xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR --logfile=/tmp/log.txt\n```\n\nRun Test cases\n```\n cd tests\n ./test_runner.php\n```\n\nIt is really slow to generate keys in PHP.  For a huge speedup, you can install\nthe secp256k1 extension from:\n\n\u003ca href=\"https://github.com/Bit-Wasp/secp256k1-php\"\u003ehttps://github.com/Bit-Wasp/secp256k1-php\u003c/a\u003e\n\n\n# Blockchain API provider notes.\n\ntip!  use the --api flag to switch between blockchain API providers.\n\nEach API has strengths and weaknesses. Some are faster than others,\nor easier/harder to run locally. The blockchain.info service is recommended\nbecause it presently has the fastest API, and it is the default.\n\nFor best privacy, one should query an oracle that is running locally.\nEsplora, Insight, toshi, and btcd can be operated this way.\n\n# [blockchain.info](https://www.blockchain.com/api/blockchain_api)\n\nas of 2024-06-03: tested WORKING.\n\nas of 2015-12-30:\n\n- supports multi address lookup in a single call.\n- max addrs per call: unknown.\n- returns extra un-needed info such as last 50 tx.\n- returns addresses in different order than requested.\n\n# [esplora](https://github.com/Blockstream/esplora) (by blockstream.info)\n\nas of 2024-6-03: tested WORKING.\n\nas of 2019-08-06:\n\n- does NOT support multi address lookup in a single call. [feature requested](https://github.com/Blockstream/esplora/issues/27).\n- open source, can be run locally.\n\n\n## [btc.com](https://btc.com/api-doc)\n\nas of 2024-6-03: tested NOT WORKING.\n\nas of 2019-08-06\n\n* API is returning 403 forbidden error except when requested via web browser.  ymmv.\n\nas of 2018-07-23:\n\n* supports multi address lookup in a single call.\n* max addrs per call: unknown.\n* returns an index with NULL value for any addresses without received funds.\n\n## [bitcoin-core](https://github.com/bitcoin/bitcoin)\n\nas of 2019-08-06:\n\n* still does not support address index or API.\n* There is a chance [this pull request](https://github.com/bitcoin/bitcoin/pull/14053) might get merged.\n\nas of 2015-12-30:\n\n* does not provide a suitable API for querying address total_received\n* does not have a public address index.  Implementing an API would be difficult.\n* some 3rd party party patches or external solutions exist for creating an address index.\n* not supported by hd-wallet-addrs (sadly).\n\n## [blockcypher.com](https://www.blockcypher.com/dev/bitcoin/)\n\nas of 2024-6-03: tested NOT WORKING.\n\nas of 2018-07-23:\n\n* does support multi address lookup in a single call via batching.\n* max addrs per batched call is 100.  however:\n* each address is counted as a request internally, and more than\n3 triggers the rate limiting, so the request fails.  Thus, 100\ncan only be achieved with an API key, and the limit for free\nusage is effectively 3.\n* See https://github.com/blockcypher/explorer/issues/245\n\n## [Insight](https://github.com/bitpay/insight)\n\nas of 2024-06-03: tested NOT WORKING.\n\nas of 2019-08-06\n\n* [project page](https://github.com/bitpay/insight) states insight has been replaced by [bitcore-node](https://github.com/bitpay/bitcore)\n* insight [public API](https://insight.bitpay.com/api) is still working.\n\nas of 2015-12-30:\n\n* does NOT support multi address lookup in a single call.\n* each candidate address must be queried separately.\n\n\n## blockr.io\n\nas of 2017-09-04:\n\n* Dead.  Killed by Coinbase.com.\n* Read the [obituary](https://www.ccn.com/blockr-io-shuttered-by-coinbase/).\n* R.I.P. blockr\n\nas of 2016-02-16:\n\n* supports multi address lookup in a single call.\n* limits number of addresses per call to 20.\n* does not return un-needed tx data.\n\n\n## [btcd](https://github.com/btcsuite/btcd)\n\nas of 2017-05-21:\n\n* btcd can now be queried from hd-wallet-addrs to find used wallet addresses, but values for balance/sent/received are empty.\n* does not support multi address lookup, so is not that fast.\n* is probably the simplest way to run a local oracle.\n* See [this issue](https://github.com/btcsuite/btcd/issues/949).\n\nas of 2015-12-30:\n\n* does not provide a suitable API for querying address total_received or balance.\n* does have a public address index that should make such an API possible, if not performant.\n\n## [Toshi](https://github.com/martindale/toshi)\n\nas of 2019-08-06:\n\n* coinbase/toshi [project page](https://github.com/coinbase/toshi/) not found on github.  Maybe try [here](https://github.com/martindale/toshi).\n\nas of 2017-05-21:\n\n* toshi.io no longer exists since Dec 31, 2016.\n* toshi can still be run locally by installing from github.\n* See the Coinbase announcement [here](https://developers.coinbase.com/blog/2016/10/31/sunsetting-toshi).\n\nas of 2015-12-30:\n\n* does NOT support multi address lookup in a single call.\n* each candidate address must be queried separately.\n\n\n# Embed in your own PHP project\n\nHere's a quick example how you one can access the API directly without invoking\nthe CLI program.\n\nin your project's composer.json:\n\n```\n{\n    \"require\": {\n         \"dan-da/hd-wallet-addrs\": \"0.2.0\"\n    }\n}\n```\n\nyourproject.php\n```php\nrequire_once 'vendor/autoload.php';\n\n// normally a single xpub is used.  multiple can be provided for multisig key generation.\n$xpub_list = ['xpub6BfKpqjTwvH21wJGWEfxLppb8sU7C6FJge2kWb9315oP4ZVqCXG29cdUtkyu7YQhHyfA5nt63nzcNZHYmqXYHDxYo8mm1Xq1dAC7YtodwUR'];\n\n$params = walletaddrs::default_params();\n// modify params here if you need to.  see default_params() for keys.\n\n$wa = new walletaddrs($params);\n$data = $wa-\u003ediscover_wallet_addrs( $xpub_list );\n\necho json_encode($data, JSON_PRETTY_PRINT);\n\n// or for fancier printing, you could use:\n// walletaddrsreport::print_results($wa-\u003eget_params(), $data);\n```\n\n\n# Thanks\n\nA big thank-you to the author of bitwasp/bitcoin-php.  This library does the\nheavy lifting of dealing with deterministic keys and multisig, amongst other\nthings.\n\n# Todos\n\n* add option to return only Receive or Change instead of both.\n* test with additional wallet software.\n* Add bip39 support to obtain xpub from secret words.  maybe?\n* Add suitable API to btcd.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fhd-wallet-addrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-da%2Fhd-wallet-addrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fhd-wallet-addrs/lists"}