question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-native use RELEASE scheme crash, HDNode.fromSeedBuffer

See original GitHub issue

React-native, iOS, RELEASE

Hi, I got a crash on iOS platform only use release scheme.

function generatorBIP44() {
    const mnemonic = bip39.generateMnemonic();
    assert(bip39.validateMnemonic(mnemonic));

    const seed = bip39.mnemonicToSeed(mnemonic);
    const bitcoinNetwork = bitcoin.networks.bitcoin;
    const master = bitcoin.HDNode.fromSeedBuffer(seed, bitcoinNetwork);

    const derivePath = `m/44'/0'/0'/0/0`;
    const node = master.derivePath(derivePath);

    const keyPair = node.keyPair;

    const privateKey = keyPair.toWIF();

    const publicKeyBuffer = keyPair.getPublicKeyBuffer();
    const publicKey = publicKeyBuffer.toString('hex');

    const address = keyPair.getAddress();

    return {
        mnemonic,
        address,
        privateKey,
        publicKey,
    };
}

I found crash here

    const master = bitcoin.HDNode.fromSeedBuffer(seed, bitcoinNetwork);
    
    typeforce(types.tuple('ECPair', types.Buffer256bit), arguments)

If i remove typeforce check code, it’s OK.

It’s amazing when i run it OK on debug scheme, but always crash on release scheme. Someone please help me? Thx.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
yinchengvycommented, Feb 23, 2018

Thx, and I fixed this issue.

Modify node_modules/metro-bundler/src/JSTransformer/worker/minify.js

mangle: {
      toplevel: true,
      reserved: [
        'Buffer',
        'BigInteger',
        'Point',
        'ECPubKey',
        'ECKey',
        'sha512_asm',
        'asm',
        'ECPair',
        'HDNode'
      ]
    },
2reactions
dabura667commented, Feb 22, 2018

Read the README, please.

Add reserve rules to uglifyjs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native app crash on ios when running release or debug
P.S. The app is running without crashes with npx react-native run-ios or in xcode after build. However npx react-native run-ios --configuration= ...
Read more >
avalanche: Versions | Openbase
Introducing a new fetch based adapter for axios to make the library work inside service workers. Axios uses XMLHttpRequests by default which is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found