[{"data":1,"prerenderedAt":691},["ShallowReactive",2],{"navigation_docs":3,"-blockchains-bitcoincash":108,"-blockchains-bitcoincash-surround":686},[4,32],{"title":5,"path":6,"stem":7,"children":8,"icon":31},"Guide","\u002Fguide","1.guide\u002F1.index",[9,11,15,19,23,27],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Working with Keys","\u002Fguide\u002Fkeys","1.guide\u002F2.keys",{"title":16,"path":17,"stem":18},"Working with Addresses","\u002Fguide\u002Faddresses","1.guide\u002F3.addresses",{"title":20,"path":21,"stem":22},"Generating Wallets","\u002Fguide\u002Fwallets","1.guide\u002F4.wallets",{"title":24,"path":25,"stem":26},"Working with EVM Chains","\u002Fguide\u002Fevm","1.guide\u002F5.evm",{"title":28,"path":29,"stem":30},"Creating Custom Blockchains","\u002Fguide\u002Fcustom","1.guide\u002F6.custom","i-lucide-book-open",{"title":33,"path":34,"stem":35,"children":36,"icon":107},"Blockchains","\u002Fblockchains","2.blockchains\u002F0.index",[37,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95,99,103],{"title":38,"path":34,"stem":35},"Overview",{"title":40,"path":41,"stem":42},"Aptos","\u002Fblockchains\u002Faptos","2.blockchains\u002Faptos",{"title":44,"path":45,"stem":46},"Base","\u002Fblockchains\u002Fbase","2.blockchains\u002Fbase",{"title":48,"path":49,"stem":50},"Bitcoin","\u002Fblockchains\u002Fbitcoin","2.blockchains\u002Fbitcoin",{"title":52,"path":53,"stem":54},"Bitcoin Cash","\u002Fblockchains\u002Fbitcoincash","2.blockchains\u002Fbitcoincash",{"title":56,"path":57,"stem":58},"Bitcoin Gold","\u002Fblockchains\u002Fbitcoingold","2.blockchains\u002Fbitcoingold",{"title":60,"path":61,"stem":62},"Bitcoin SV","\u002Fblockchains\u002Fbitcoinsv","2.blockchains\u002Fbitcoinsv",{"title":64,"path":65,"stem":66},"Cardano","\u002Fblockchains\u002Fcardano","2.blockchains\u002Fcardano",{"title":68,"path":69,"stem":70},"Dash","\u002Fblockchains\u002Fdash","2.blockchains\u002Fdash",{"title":72,"path":73,"stem":74},"Decred","\u002Fblockchains\u002Fdecred","2.blockchains\u002Fdecred",{"title":76,"path":77,"stem":78},"Dogecoin","\u002Fblockchains\u002Fdogecoin","2.blockchains\u002Fdogecoin",{"title":80,"path":81,"stem":82},"Ethereum","\u002Fblockchains\u002Fethereum","2.blockchains\u002Fethereum",{"title":84,"path":85,"stem":86},"Litecoin","\u002Fblockchains\u002Flitecoin","2.blockchains\u002Flitecoin",{"title":88,"path":89,"stem":90},"Solana","\u002Fblockchains\u002Fsolana","2.blockchains\u002Fsolana",{"title":92,"path":93,"stem":94},"Stellar","\u002Fblockchains\u002Fstellar","2.blockchains\u002Fstellar",{"title":96,"path":97,"stem":98},"Sui","\u002Fblockchains\u002Fsui","2.blockchains\u002Fsui",{"title":100,"path":101,"stem":102},"TRON","\u002Fblockchains\u002Ftron","2.blockchains\u002Ftron",{"title":104,"path":105,"stem":106},"Zcash","\u002Fblockchains\u002Fzcash","2.blockchains\u002Fzcash","i-lucide-boxes",{"id":109,"title":52,"body":110,"description":679,"extension":680,"links":681,"meta":682,"navigation":184,"path":53,"seo":684,"stem":54,"__hash__":685},"docs\u002F2.blockchains\u002Fbitcoincash.md",{"type":111,"value":112,"toc":671},"minimark",[113,120,125,262,270,274,281,331,422,429,454,458,529,540,543,547,554,616,627,631,646,650,667],[114,115],"chain-facts",{"coin":116,"curve":117,"driver":118,"formats":119},"145","secp256k1","bitcoincash","legacy P2PKH in CashAddr",[121,122,124],"h2",{"id":123},"load-it","Load it",[126,127,132],"pre",{"className":128,"code":129,"language":130,"meta":131,"style":131},"language-js shiki shiki-themes github-light github-light poimandres","import { useBlockchain, blockchains } from \"@agntn\u002Fkeys\";\n\nconst bchChain = useBlockchain(await blockchains.bitcoincash()());\nconst testnet = useBlockchain(await blockchains.bitcoincash({ network: \"testnet\" })());\n","js","",[133,134,135,179,186,221],"code",{"__ignoreMap":131},[136,137,140,144,148,152,155,158,161,165,169,173,176],"span",{"class":138,"line":139},"line",1,[136,141,143],{"class":142},"sP0CR","import",[136,145,147],{"class":146},"sKlNE"," {",[136,149,151],{"class":150},"snHMy"," useBlockchain",[136,153,154],{"class":146},",",[136,156,157],{"class":150}," blockchains",[136,159,160],{"class":146}," }",[136,162,164],{"class":163},"stCPd"," from",[136,166,168],{"class":167},"scVjq"," \"",[136,170,172],{"class":171},"sQ7BG","@agntn\u002Fkeys",[136,174,175],{"class":167},"\"",[136,177,178],{"class":146},";\n",[136,180,182],{"class":138,"line":181},2,[136,183,185],{"emptyLinePlaceholder":184},true,"\n",[136,187,189,193,197,200,203,206,210,213,216,218],{"class":138,"line":188},3,[136,190,192],{"class":191},"s1TYA","const",[136,194,196],{"class":195},"saoiD"," bchChain",[136,198,199],{"class":191}," =",[136,201,151],{"class":202},"sULi6",[136,204,205],{"class":146},"(",[136,207,209],{"class":208},"sZW6a","await",[136,211,157],{"class":212},"spVlQ",[136,214,215],{"class":146},".",[136,217,118],{"class":202},[136,219,220],{"class":146},"()());\n",[136,222,224,226,229,231,233,235,237,239,241,243,246,249,252,254,257,259],{"class":138,"line":223},4,[136,225,192],{"class":191},[136,227,228],{"class":195}," testnet",[136,230,199],{"class":191},[136,232,151],{"class":202},[136,234,205],{"class":146},[136,236,209],{"class":208},[136,238,157],{"class":212},[136,240,215],{"class":146},[136,242,118],{"class":202},[136,244,245],{"class":146},"({",[136,247,248],{"class":150}," network",[136,250,251],{"class":146},":",[136,253,168],{"class":167},[136,255,256],{"class":171},"testnet",[136,258,175],{"class":167},[136,260,261],{"class":146}," })());\n",[263,264,265,266,269],"p",{},"Mainnet and testnet only, anything else throws in the constructor. Testnet3, testnet4, scalenet and chipnet all use the same ",[133,267,268],{},"bchtest"," prefix, so one testnet driver covers them.",[121,271,273],{"id":272},"the-address","The address",[263,275,276,277,280],{},"The hash is Bitcoin's, ",[133,278,279],{},"RIPEMD160(SHA256(pubkey))",", byte for byte. Only the writing changes. A version byte goes in front, the whole thing is regrouped into 5-bit digits, and CashAddr adds a 40-bit checksum taken over the prefix too.",[282,283,284,300],"table",{},[285,286,287],"thead",{},[288,289,290,294,297],"tr",{},[291,292,293],"th",{},"Network",[291,295,296],{},"Prefix",[291,298,299],{},"Starts with",[301,302,303,318],"tbody",{},[288,304,305,309,313],{},[306,307,308],"td",{},"mainnet",[306,310,311],{},[133,312,118],{},[306,314,315],{},[133,316,317],{},"bitcoincash:q",[288,319,320,322,326],{},[306,321,256],{},[306,323,324],{},[133,325,268],{},[306,327,328],{},[133,329,330],{},"bchtest:q",[126,332,334],{"className":128,"code":333,"language":130,"meta":131,"style":131},"const privateKey = \"0000000000000000000000000000000000000000000000000000000000000001\";\nconst publicKey = bchChain.getKeyPublic(privateKey);\n\nbchChain.getAddress(publicKey); \u002F\u002F bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h\ntestnet.getAddress(publicKey); \u002F\u002F bchtest:qp63uahgrxged4z5jswyt5dn5v3lzsem6cq85x00dt\n",[133,335,336,354,378,382,404],{"__ignoreMap":131},[136,337,338,340,343,345,347,350,352],{"class":138,"line":139},[136,339,192],{"class":191},[136,341,342],{"class":195}," privateKey",[136,344,199],{"class":191},[136,346,168],{"class":167},[136,348,349],{"class":171},"0000000000000000000000000000000000000000000000000000000000000001",[136,351,175],{"class":167},[136,353,178],{"class":146},[136,355,356,358,361,363,365,367,370,372,375],{"class":138,"line":181},[136,357,192],{"class":191},[136,359,360],{"class":195}," publicKey",[136,362,199],{"class":191},[136,364,196],{"class":212},[136,366,215],{"class":146},[136,368,369],{"class":202},"getKeyPublic",[136,371,205],{"class":146},[136,373,374],{"class":212},"privateKey",[136,376,377],{"class":146},");\n",[136,379,380],{"class":138,"line":188},[136,381,185],{"emptyLinePlaceholder":184},[136,383,384,387,389,392,394,397,400],{"class":138,"line":223},[136,385,386],{"class":212},"bchChain",[136,388,215],{"class":146},[136,390,391],{"class":202},"getAddress",[136,393,205],{"class":146},[136,395,396],{"class":212},"publicKey",[136,398,399],{"class":146},"); ",[136,401,403],{"class":402},"sjhu3","\u002F\u002F bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h\n",[136,405,407,409,411,413,415,417,419],{"class":138,"line":406},5,[136,408,256],{"class":212},[136,410,215],{"class":146},[136,412,391],{"class":202},[136,414,205],{"class":146},[136,416,396],{"class":212},[136,418,399],{"class":146},[136,420,421],{"class":402},"\u002F\u002F bchtest:qp63uahgrxged4z5jswyt5dn5v3lzsem6cq85x00dt\n",[263,423,424,425,428],{},"That's ",[133,426,427],{},"1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH"," on Bitcoin, same key, same hash. The prefix is always written out, because that's the form wallets and explorers print.",[263,430,431,434,435,438,439,442,443,445,446,449,450,453],{},[133,432,433],{},"legacy"," is the only type and it means pay to pubkey hash. It doesn't mean base58: the base58 form of that hash is a Bitcoin address, so the driver never produces it. Ask for ",[133,436,437],{},"\"p2sh\"",", ",[133,440,441],{},"\"segwit\""," or anything else and ",[133,444,391],{}," throws a ",[133,447,448],{},"RangeError",". Bitcoin's ",[133,451,452],{},"p2sh"," type wraps a segwit program, and there's no segwit on Bitcoin Cash, so a quiet fallback here could only lose money.",[121,455,457],{"id":456},"validation","Validation",[126,459,461],{"className":128,"code":460,"language":130,"meta":131,"style":131},"bchChain.validateAddress(\"bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h\"); \u002F\u002F true\nbchChain.validateAddress(\"qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h\"); \u002F\u002F true, prefix left off\nbchChain.validateAddress(\"1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH\"); \u002F\u002F false, base58\n",[133,462,463,486,508],{"__ignoreMap":131},[136,464,465,467,469,472,474,476,479,481,483],{"class":138,"line":139},[136,466,386],{"class":212},[136,468,215],{"class":146},[136,470,471],{"class":202},"validateAddress",[136,473,205],{"class":146},[136,475,175],{"class":167},[136,477,478],{"class":171},"bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h",[136,480,175],{"class":167},[136,482,399],{"class":146},[136,484,485],{"class":402},"\u002F\u002F true\n",[136,487,488,490,492,494,496,498,501,503,505],{"class":138,"line":181},[136,489,386],{"class":212},[136,491,215],{"class":146},[136,493,471],{"class":202},[136,495,205],{"class":146},[136,497,175],{"class":167},[136,499,500],{"class":171},"qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h",[136,502,175],{"class":167},[136,504,399],{"class":146},[136,506,507],{"class":402},"\u002F\u002F true, prefix left off\n",[136,509,510,512,514,516,518,520,522,524,526],{"class":138,"line":188},[136,511,386],{"class":212},[136,513,215],{"class":146},[136,515,471],{"class":202},[136,517,205],{"class":146},[136,519,175],{"class":167},[136,521,427],{"class":171},[136,523,175],{"class":167},[136,525,399],{"class":146},[136,527,528],{"class":402},"\u002F\u002F false, base58\n",[263,530,531,532,535,536,539],{},"It reads CashAddr the way Bitcoin Cash Node does. The prefix is optional. Upper or lower case works, a mix of both doesn't. The checksum is always computed under the driver's own prefix, so a testnet or eCash address fails like a typo would. Past the checksum, the version byte has to agree with the hash length, and the type and length have to be ones the node pays to: pubkey hashes over 20 bytes, script hashes over 20 or 32, plus the token-aware twins CashTokens added (",[133,533,534],{},"z..."," and ",[133,537,538],{},"r...",").",[263,541,542],{},"Base58 is refused even though the node still takes it. Its bytes say Bitcoin, and agntn\u002Fchains draws the same line.",[121,544,546],{"id":545},"mnemonics","Mnemonics",[263,548,549,550,553],{},"BIP32 on ",[133,551,552],{},"m\u002F44'\u002F145'\u002Faccount'\u002Fchange\u002Findex",". The purpose level doesn't pick a format here the way it does on Bitcoin, since there's only one.",[126,555,557],{"className":128,"code":556,"language":130,"meta":131,"style":131},"const mnemonic = \"all all all all all all all all all all all all\";\n\nbchChain.deriveHDWallet(mnemonic, \"m\u002F44'\u002F145'\u002F0'\u002F0\u002F0\").address;\n\u002F\u002F bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv, what a Trezor shows for that seed\n",[133,558,559,577,581,611],{"__ignoreMap":131},[136,560,561,563,566,568,570,573,575],{"class":138,"line":139},[136,562,192],{"class":191},[136,564,565],{"class":195}," mnemonic",[136,567,199],{"class":191},[136,569,168],{"class":167},[136,571,572],{"class":171},"all all all all all all all all all all all all",[136,574,175],{"class":167},[136,576,178],{"class":146},[136,578,579],{"class":138,"line":181},[136,580,185],{"emptyLinePlaceholder":184},[136,582,583,585,587,590,592,595,597,599,602,604,606,609],{"class":138,"line":188},[136,584,386],{"class":212},[136,586,215],{"class":146},[136,588,589],{"class":202},"deriveHDWallet",[136,591,205],{"class":146},[136,593,594],{"class":212},"mnemonic",[136,596,438],{"class":146},[136,598,175],{"class":167},[136,600,601],{"class":171},"m\u002F44'\u002F145'\u002F0'\u002F0\u002F0",[136,603,175],{"class":167},[136,605,539],{"class":146},[136,607,608],{"class":212},"address",[136,610,178],{"class":146},[136,612,613],{"class":138,"line":223},[136,614,615],{"class":402},"\u002F\u002F bitcoincash:qr08q88p9etk89wgv05nwlrkm4l0urz4cyl36hh9sv, what a Trezor shows for that seed\n",[263,617,618,619,622,623,626],{},"WIF is Bitcoin's too, prefix ",[133,620,621],{},"0x80",". ",[133,624,625],{},"encodeWIF(privateKey, { chain: \"bitcoin\" })"," gives the string a Bitcoin Cash wallet imports.",[121,628,630],{"id":629},"signing","Signing",[263,632,633,634,637,638,641,642,645],{},"Bitcoin Cash Node kept Bitcoin's ",[133,635,636],{},"\"\\x18Bitcoin Signed Message:\\n\"",", so the digest is identical: compact size lengths, double SHA-256, secp256k1. A Bitcoin Cash signature and a Bitcoin signature over the same key and message are the same 64 bytes of ",[133,639,640],{},"r||s"," hex. Like Bitcoin, ",[133,643,644],{},"{ recovered: true }"," throws, because the node's recoverable form is base64 with a header byte.",[121,647,649],{"id":648},"where-it-lives","Where it lives",[263,651,652,655,656,659,660,663,664,215],{},[133,653,654],{},"src\u002Fblockchains\u002Fbitcoincash.ts"," has the prefixes and the address rules. It extends ",[133,657,658],{},"AbstractBitcoinMessageBlockchain"," in ",[133,661,662],{},"src\u002Futils\u002Fbitcoin.ts",", the part of the Bitcoin base with keys and signed messages and none of the address formats. The CashAddr codec is in ",[133,665,666],{},"src\u002Futils\u002Fcashaddr.ts",[668,669,670],"style",{},"html pre.shiki code .sP0CR, html code.shiki .sP0CR{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7}html pre.shiki code .sKlNE, html code.shiki .sKlNE{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#A6ACCD}html pre.shiki code .snHMy, html code.shiki .snHMy{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#ADD7FF}html pre.shiki code .stCPd, html code.shiki .stCPd{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#A6ACCD}html pre.shiki code .scVjq, html code.shiki .scVjq{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#A6ACCD}html pre.shiki code .sQ7BG, html code.shiki .sQ7BG{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#5DE4C7}html pre.shiki code .s1TYA, html code.shiki .s1TYA{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#91B4D5}html pre.shiki code .saoiD, html code.shiki .saoiD{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#E4F0FB}html pre.shiki code .sULi6, html code.shiki .sULi6{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#E4F0FBD0}html pre.shiki code .sZW6a, html code.shiki .sZW6a{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7C0}html pre.shiki code .spVlQ, html code.shiki .spVlQ{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E4F0FB}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sjhu3, html code.shiki .sjhu3{--shiki-light:#6A737D;--shiki-light-font-style:inherit;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#767C9DB0;--shiki-dark-font-style:italic}",{"title":131,"searchDepth":181,"depth":181,"links":672},[673,674,675,676,677,678],{"id":123,"depth":181,"text":124},{"id":272,"depth":181,"text":273},{"id":456,"depth":181,"text":457},{"id":545,"depth":181,"text":546},{"id":629,"depth":181,"text":630},{"id":648,"depth":181,"text":649},"Bitcoin's key and hash written as CashAddr. One address type and Bitcoin's message preamble. Base58 stays out on purpose.","md",null,{"icon":683},"i-token-bch",{"title":52,"description":679},"adQfS4D82T0qLgXlPKyMO8bZvSzymOpW18Q3Yptlu2g",[687,689],{"title":48,"path":49,"stem":50,"description":688,"children":-1},"secp256k1 with five address formats from legacy to taproot on mainnet and testnet.",{"title":56,"path":57,"stem":58,"description":690,"children":-1},"Bitcoin's driver with Bitcoin Gold's prefixes and preamble. Four address formats on mainnet and testnet and no taproot at all.",1790282411352]