bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.59k stars 2.07k forks source link

reactnative generate address error #2085

Open jiegege10 opened 2 months ago

jiegege10 commented 2 months ago

const seed = await bip39.mnemonicToSeed(mnemonic) const root = bip32.fromSeed(seed); const path = "m/44'/0'/0'/0/0" const child = root.derivePath(path) const bean = await payments.p2pkh({pubkey: child.publicKey})

The address generated in the vue project is correct and the same code. I changed the encryption to crypto-browserify. The address signature is correct, but the last six digits are wrong. How should I solve this problem?

junderw commented 2 months ago

What version are you using?

If not the latest, try using the latest.

jiegege10 commented 2 months ago

What version are you using?

If not the latest, try using the latest.

I'm using the latest version

junderw commented 2 months ago

What does this mean: "I changed the encryption to crypto-browserify"

junderw commented 2 months ago

crypto-browserify has nothing to do with address creation... we don't use it. We don't use the NodeJS crypto API for hashes. We use noble.

junderw commented 2 months ago

You are using v6.1.5?

jiegege10 commented 2 months ago

You are using v6.1.5?

yes,But in my vue project, the generated address is correct. But the address generated in Reactnative is wrong. The code is the same

jasonandjay commented 1 month ago

You are using v6.1.5?

yes,But in my vue project, the generated address is correct. But the address generated in Reactnative is wrong. The code is the same

@jiegege10 What does "the last six digits are wrong" mean? Are you referring to the bean.address of P2PKH? I suggest you print root.fingerprint to see if xpub is the same as expected in both environments