[{"data":1,"prerenderedAt":762},["ShallowReactive",2],{"navigation_docs":3,"-blockchains-ecash":112,"-blockchains-ecash-surround":757},[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":111},"Blockchains","\u002Fblockchains","2.blockchains\u002F0.index",[37,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95,99,103,107],{"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},"eCash","\u002Fblockchains\u002Fecash","2.blockchains\u002Fecash",{"title":84,"path":85,"stem":86},"Ethereum","\u002Fblockchains\u002Fethereum","2.blockchains\u002Fethereum",{"title":88,"path":89,"stem":90},"Litecoin","\u002Fblockchains\u002Flitecoin","2.blockchains\u002Flitecoin",{"title":92,"path":93,"stem":94},"Solana","\u002Fblockchains\u002Fsolana","2.blockchains\u002Fsolana",{"title":96,"path":97,"stem":98},"Stellar","\u002Fblockchains\u002Fstellar","2.blockchains\u002Fstellar",{"title":100,"path":101,"stem":102},"Sui","\u002Fblockchains\u002Fsui","2.blockchains\u002Fsui",{"title":104,"path":105,"stem":106},"TRON","\u002Fblockchains\u002Ftron","2.blockchains\u002Ftron",{"title":108,"path":109,"stem":110},"Zcash","\u002Fblockchains\u002Fzcash","2.blockchains\u002Fzcash","i-lucide-boxes",{"id":113,"title":80,"body":114,"description":750,"extension":751,"links":752,"meta":753,"navigation":188,"path":81,"seo":755,"stem":82,"__hash__":756},"docs\u002F2.blockchains\u002Fecash.md",{"type":115,"value":116,"toc":742},"minimark",[117,124,129,266,274,278,285,336,427,437,466,470,541,559,562,566,585,685,695,699,706,717,721,738],[118,119],"chain-facts",{"coin":120,"curve":121,"driver":122,"formats":123},"899","secp256k1","ecash","legacy P2PKH in CashAddr",[125,126,128],"h2",{"id":127},"load-it","Load it",[130,131,136],"pre",{"className":132,"code":133,"language":134,"meta":135,"style":135},"language-js shiki shiki-themes github-light github-light poimandres","import { useBlockchain, blockchains } from \"@agntn\u002Fkeys\";\n\nconst xecChain = useBlockchain(await blockchains.ecash()());\nconst testnet = useBlockchain(await blockchains.ecash({ network: \"testnet\" })());\n","js","",[137,138,139,183,190,225],"code",{"__ignoreMap":135},[140,141,144,148,152,156,159,162,165,169,173,177,180],"span",{"class":142,"line":143},"line",1,[140,145,147],{"class":146},"sP0CR","import",[140,149,151],{"class":150},"sKlNE"," {",[140,153,155],{"class":154},"snHMy"," useBlockchain",[140,157,158],{"class":150},",",[140,160,161],{"class":154}," blockchains",[140,163,164],{"class":150}," }",[140,166,168],{"class":167},"stCPd"," from",[140,170,172],{"class":171},"scVjq"," \"",[140,174,176],{"class":175},"sQ7BG","@agntn\u002Fkeys",[140,178,179],{"class":171},"\"",[140,181,182],{"class":150},";\n",[140,184,186],{"class":142,"line":185},2,[140,187,189],{"emptyLinePlaceholder":188},true,"\n",[140,191,193,197,201,204,207,210,214,217,220,222],{"class":142,"line":192},3,[140,194,196],{"class":195},"s1TYA","const",[140,198,200],{"class":199},"saoiD"," xecChain",[140,202,203],{"class":195}," =",[140,205,155],{"class":206},"sULi6",[140,208,209],{"class":150},"(",[140,211,213],{"class":212},"sZW6a","await",[140,215,161],{"class":216},"spVlQ",[140,218,219],{"class":150},".",[140,221,122],{"class":206},[140,223,224],{"class":150},"()());\n",[140,226,228,230,233,235,237,239,241,243,245,247,250,253,256,258,261,263],{"class":142,"line":227},4,[140,229,196],{"class":195},[140,231,232],{"class":199}," testnet",[140,234,203],{"class":195},[140,236,155],{"class":206},[140,238,209],{"class":150},[140,240,213],{"class":212},[140,242,161],{"class":216},[140,244,219],{"class":150},[140,246,122],{"class":206},[140,248,249],{"class":150},"({",[140,251,252],{"class":154}," network",[140,254,255],{"class":150},":",[140,257,172],{"class":171},[140,259,260],{"class":175},"testnet",[140,262,179],{"class":171},[140,264,265],{"class":150}," })());\n",[267,268,269,270,273],"p",{},"Mainnet and testnet only, anything else throws in the constructor. Regtest has its own ",[137,271,272],{},"ecregtest"," prefix, and there's no driver for it.",[125,275,277],{"id":276},"the-address","The address",[267,279,280,281,284],{},"eCash split off Bitcoin Cash in 2020 and kept the address format. The hash is Bitcoin's, ",[137,282,283],{},"RIPEMD160(SHA256(pubkey))",", the version byte and the 40-bit checksum are CashAddr's. What changes is the prefix, and since the checksum is taken over the prefix, the rest of the string changes with it.",[286,287,288,304],"table",{},[289,290,291],"thead",{},[292,293,294,298,301],"tr",{},[295,296,297],"th",{},"Network",[295,299,300],{},"Prefix",[295,302,303],{},"Starts with",[305,306,307,322],"tbody",{},[292,308,309,313,317],{},[310,311,312],"td",{},"mainnet",[310,314,315],{},[137,316,122],{},[310,318,319],{},[137,320,321],{},"ecash:q",[292,323,324,326,331],{},[310,325,260],{},[310,327,328],{},[137,329,330],{},"ectest",[310,332,333],{},[137,334,335],{},"ectest:q",[130,337,339],{"className":132,"code":338,"language":134,"meta":135,"style":135},"const privateKey = \"0000000000000000000000000000000000000000000000000000000000000001\";\nconst publicKey = xecChain.getKeyPublic(privateKey);\n\nxecChain.getAddress(publicKey); \u002F\u002F ecash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq\ntestnet.getAddress(publicKey); \u002F\u002F ectest:qp63uahgrxged4z5jswyt5dn5v3lzsem6cmn623003\n",[137,340,341,359,383,387,409],{"__ignoreMap":135},[140,342,343,345,348,350,352,355,357],{"class":142,"line":143},[140,344,196],{"class":195},[140,346,347],{"class":199}," privateKey",[140,349,203],{"class":195},[140,351,172],{"class":171},[140,353,354],{"class":175},"0000000000000000000000000000000000000000000000000000000000000001",[140,356,179],{"class":171},[140,358,182],{"class":150},[140,360,361,363,366,368,370,372,375,377,380],{"class":142,"line":185},[140,362,196],{"class":195},[140,364,365],{"class":199}," publicKey",[140,367,203],{"class":195},[140,369,200],{"class":216},[140,371,219],{"class":150},[140,373,374],{"class":206},"getKeyPublic",[140,376,209],{"class":150},[140,378,379],{"class":216},"privateKey",[140,381,382],{"class":150},");\n",[140,384,385],{"class":142,"line":192},[140,386,189],{"emptyLinePlaceholder":188},[140,388,389,392,394,397,399,402,405],{"class":142,"line":227},[140,390,391],{"class":216},"xecChain",[140,393,219],{"class":150},[140,395,396],{"class":206},"getAddress",[140,398,209],{"class":150},[140,400,401],{"class":216},"publicKey",[140,403,404],{"class":150},"); ",[140,406,408],{"class":407},"sjhu3","\u002F\u002F ecash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq\n",[140,410,412,414,416,418,420,422,424],{"class":142,"line":411},5,[140,413,260],{"class":216},[140,415,219],{"class":150},[140,417,396],{"class":206},[140,419,209],{"class":150},[140,421,401],{"class":216},[140,423,404],{"class":150},[140,425,426],{"class":407},"\u002F\u002F ectest:qp63uahgrxged4z5jswyt5dn5v3lzsem6cmn623003\n",[267,428,429,430,433,434,219],{},"Put that next to ",[137,431,432],{},"bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h",". The payload is the same up to the last eight characters, the checksum. Same key, same hash, and Bitcoin shows it as ",[137,435,436],{},"1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH",[267,438,439,442,443,446,447,450,451,453,454,457,458,461,462,465],{},[137,440,441],{},"legacy"," is the only type and it means pay to pubkey hash, written as CashAddr. Ask for ",[137,444,445],{},"\"p2sh\"",", ",[137,448,449],{},"\"segwit\""," or anything else and ",[137,452,396],{}," throws a ",[137,455,456],{},"RangeError",", for the same reason as on ",[459,460,52],"a",{"href":53},": Bitcoin's ",[137,463,464],{},"p2sh"," type wraps a segwit program, and there's no segwit here.",[125,467,469],{"id":468},"validation","Validation",[130,471,473],{"className":132,"code":472,"language":134,"meta":135,"style":135},"xecChain.validateAddress(\"ecash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq\"); \u002F\u002F true\nxecChain.validateAddress(\"qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq\"); \u002F\u002F true, prefix left off\nxecChain.validateAddress(\"bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h\"); \u002F\u002F false\n",[137,474,475,498,520],{"__ignoreMap":135},[140,476,477,479,481,484,486,488,491,493,495],{"class":142,"line":143},[140,478,391],{"class":216},[140,480,219],{"class":150},[140,482,483],{"class":206},"validateAddress",[140,485,209],{"class":150},[140,487,179],{"class":171},[140,489,490],{"class":175},"ecash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq",[140,492,179],{"class":171},[140,494,404],{"class":150},[140,496,497],{"class":407},"\u002F\u002F true\n",[140,499,500,502,504,506,508,510,513,515,517],{"class":142,"line":185},[140,501,391],{"class":216},[140,503,219],{"class":150},[140,505,483],{"class":206},[140,507,209],{"class":150},[140,509,179],{"class":171},[140,511,512],{"class":175},"qp63uahgrxged4z5jswyt5dn5v3lzsem6cacy2kzvq",[140,514,179],{"class":171},[140,516,404],{"class":150},[140,518,519],{"class":407},"\u002F\u002F true, prefix left off\n",[140,521,522,524,526,528,530,532,534,536,538],{"class":142,"line":192},[140,523,391],{"class":216},[140,525,219],{"class":150},[140,527,483],{"class":206},[140,529,209],{"class":150},[140,531,179],{"class":171},[140,533,432],{"class":175},[140,535,179],{"class":171},[140,537,404],{"class":150},[140,539,540],{"class":407},"\u002F\u002F false\n",[267,542,543,544,547,548,551,552,555,556,219],{},"It decodes CashAddr the same way the Bitcoin Cash driver does: optional prefix, one case over the whole string, checksum under the driver's own prefix. The difference is what counts as payable. Bitcoin ABC turns two things into a destination, a 20 byte key hash under type 0 and a 20 byte script hash under type 1, and nothing else. The token types and the 32 byte script hashes that CashTokens brought to Bitcoin Cash came after the split, so a ",[137,545,546],{},"z..."," or ",[137,549,550],{},"r..."," payload under ",[137,553,554],{},"ecash:"," checksums fine and still comes back ",[137,557,558],{},"false",[267,560,561],{},"Base58 is refused too. Its bytes say Bitcoin.",[125,563,565],{"id":564},"mnemonics","Mnemonics",[267,567,568,569,572,573,576,577,580,581,584],{},"BIP32 on ",[137,570,571],{},"m\u002F44'\u002F899'\u002Faccount'\u002Fchange\u002Findex",", the coin type SLIP-0044 gives XEC and the one Electrum ABC and Trezor use. Not every wallet agrees. Cashtab walks ",[137,574,575],{},"m\u002F44'\u002F1899'\u002F0'\u002F0\u002F0",", and wallets made before the split walk Bitcoin Cash's ",[137,578,579],{},"m\u002F44'\u002F145'",". ",[137,582,583],{},"deriveHDWallet"," takes whatever path you give it, so pass the one your wallet used.",[130,586,588],{"className":132,"code":587,"language":134,"meta":135,"style":135},"const mnemonic =\n  \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\";\n\nxecChain.deriveHDWallet(mnemonic, \"m\u002F44'\u002F899'\u002F0'\u002F0\u002F0\").address;\n\u002F\u002F ecash:qpluxjhhlxfjwsymf9nmctvsdrwzwygadsh2pq0ang\nxecChain.deriveHDWallet(mnemonic, \"m\u002F44'\u002F145'\u002F0'\u002F0\u002F0\").address;\n\u002F\u002F ecash:qqyx49mu0kkn9ftfj6hje6g2wfer34yfnqdxfumtxd, what bip_utils gives on that path\n",[137,589,590,600,612,616,646,651,679],{"__ignoreMap":135},[140,591,592,594,597],{"class":142,"line":143},[140,593,196],{"class":195},[140,595,596],{"class":199}," mnemonic",[140,598,599],{"class":195}," =\n",[140,601,602,605,608,610],{"class":142,"line":185},[140,603,604],{"class":171},"  \"",[140,606,607],{"class":175},"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",[140,609,179],{"class":171},[140,611,182],{"class":150},[140,613,614],{"class":142,"line":192},[140,615,189],{"emptyLinePlaceholder":188},[140,617,618,620,622,624,626,629,631,633,636,638,641,644],{"class":142,"line":227},[140,619,391],{"class":216},[140,621,219],{"class":150},[140,623,583],{"class":206},[140,625,209],{"class":150},[140,627,628],{"class":216},"mnemonic",[140,630,446],{"class":150},[140,632,179],{"class":171},[140,634,635],{"class":175},"m\u002F44'\u002F899'\u002F0'\u002F0\u002F0",[140,637,179],{"class":171},[140,639,640],{"class":150},").",[140,642,643],{"class":216},"address",[140,645,182],{"class":150},[140,647,648],{"class":142,"line":411},[140,649,650],{"class":407},"\u002F\u002F ecash:qpluxjhhlxfjwsymf9nmctvsdrwzwygadsh2pq0ang\n",[140,652,654,656,658,660,662,664,666,668,671,673,675,677],{"class":142,"line":653},6,[140,655,391],{"class":216},[140,657,219],{"class":150},[140,659,583],{"class":206},[140,661,209],{"class":150},[140,663,628],{"class":216},[140,665,446],{"class":150},[140,667,179],{"class":171},[140,669,670],{"class":175},"m\u002F44'\u002F145'\u002F0'\u002F0\u002F0",[140,672,179],{"class":171},[140,674,640],{"class":150},[140,676,643],{"class":216},[140,678,182],{"class":150},[140,680,682],{"class":142,"line":681},7,[140,683,684],{"class":407},"\u002F\u002F ecash:qqyx49mu0kkn9ftfj6hje6g2wfer34yfnqdxfumtxd, what bip_utils gives on that path\n",[267,686,687,688,580,691,694],{},"WIF is Bitcoin's, prefix ",[137,689,690],{},"0x80",[137,692,693],{},"encodeWIF(privateKey, { chain: \"bitcoin\" })"," gives the string an eCash wallet imports.",[125,696,698],{"id":697},"signing","Signing",[267,700,701,702,705],{},"This is where eCash and Bitcoin Cash part ways. Bitcoin ABC signs under ",[137,703,704],{},"\"\\x16eCash Signed Message:\\n\"",", not Bitcoin's preamble. The digest is built the usual way, compact size lengths and double SHA-256, but with a different preamble the hash is different. A Bitcoin Cash signature doesn't verify here and the other way around.",[267,707,708,709,712,713,716],{},"The signature is 64 bytes of ",[137,710,711],{},"r||s"," hex. A signature from ecash-lib verifies, but don't expect the same bytes from the same key, because ecash-lib picks a different nonce. ",[137,714,715],{},"{ recovered: true }"," throws, like on Bitcoin, since the node's recoverable form is base64 with a header byte.",[125,718,720],{"id":719},"where-it-lives","Where it lives",[267,722,723,726,727,730,731,734,735,219],{},[137,724,725],{},"src\u002Fblockchains\u002Fecash.ts"," has the prefixes, the hash lengths Bitcoin ABC pays to and the preamble. Everything else comes from ",[137,728,729],{},"AbstractCashAddrBlockchain"," in ",[137,732,733],{},"src\u002Futils\u002Fbitcoin.ts",", which it shares with Bitcoin Cash. The CashAddr codec is in ",[137,736,737],{},"src\u002Futils\u002Fcashaddr.ts",[739,740,741],"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":135,"searchDepth":185,"depth":185,"links":743},[744,745,746,747,748,749],{"id":127,"depth":185,"text":128},{"id":276,"depth":185,"text":277},{"id":468,"depth":185,"text":469},{"id":564,"depth":185,"text":565},{"id":697,"depth":185,"text":698},{"id":719,"depth":185,"text":720},"Bitcoin Cash's CashAddr under the ecash prefix and Bitcoin ABC's own message preamble. One address type and none of the CashTokens types.","md",null,{"icon":754},"i-token-xec",{"title":80,"description":750},"fn44CIdYS4xApUQ7GBXRoHWR9cTrTS9e2CkeG0s64ao",[758,760],{"title":76,"path":77,"stem":78,"description":759,"children":-1},"Bitcoin's P2PKH recipe behind a D, its own message preamble, and one address type, because the chain never got SegWit.",{"title":84,"path":85,"stem":86,"description":761,"children":-1},"secp256k1 with EIP-55 checksummed addresses and personal_sign message signatures.",1790447313486]