Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | const useWallet = () => { | ||||
const deriveAccount = async (BCH, { masterHDNode, path }) => { | const deriveAccount = async (BCH, { masterHDNode, path }) => { | ||||
const node = BCH.HDNode.derivePath(masterHDNode, path); | const node = BCH.HDNode.derivePath(masterHDNode, path); | ||||
const publicKey = BCH.HDNode.toPublicKey(node).toString('hex'); | const publicKey = BCH.HDNode.toPublicKey(node).toString('hex'); | ||||
const cashAddress = BCH.HDNode.toCashAddress(node); | const cashAddress = BCH.HDNode.toCashAddress(node); | ||||
const hash160 = BCH.Address.toHash160(cashAddress); | const hash160 = BCH.Address.toHash160(cashAddress); | ||||
const slpAddress = BCH.SLP.Address.toSLPAddress(cashAddress); | const slpAddress = BCH.SLP.Address.toSLPAddress(cashAddress); | ||||
// temporary comparison between BCH-JS' toPublicKey output to the local impl | |||||
const localPublicKey = node.getPublicKeyBuffer().toString('hex'); | |||||
if (publicKey === localPublicKey) { | |||||
console.log( | |||||
path + ': BCH-JS publicKey output matches localPublicKey', | |||||
); | |||||
} | |||||
return { | return { | ||||
publicKey, | publicKey, | ||||
hash160, | hash160, | ||||
cashAddress, | cashAddress, | ||||
slpAddress, | slpAddress, | ||||
fundingWif: BCH.HDNode.toWIF(node), | fundingWif: BCH.HDNode.toWIF(node), | ||||
fundingAddress: BCH.SLP.Address.toSLPAddress(cashAddress), | fundingAddress: BCH.SLP.Address.toSLPAddress(cashAddress), | ||||
legacyAddress: BCH.SLP.Address.toLegacyAddress(cashAddress), | legacyAddress: BCH.SLP.Address.toLegacyAddress(cashAddress), | ||||
▲ Show 20 Lines • Show All 1,370 Lines • Show Last 20 Lines |