bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reactnative generate address error

jiegege10 opened this issue · comments

commented

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?

What version are you using?

If not the latest, try using the latest.

commented

What version are you using?

If not the latest, try using the latest.

I'm using the latest version

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

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.

You are using v6.1.5?

commented

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

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