send-crypto icon indicating copy to clipboard operation
send-crypto copied to clipboard

BTC account using bip84 private key

Open rkyshz opened this issue 4 years ago • 1 comments

  • I'm submitting a ... [ ] bug report [ ] feature request [ ] question about the decisions made in the repository [x] question about how to use this project

  • Summary

How do I use a bip84 private key generated from a seed phrase generated here. I get invalid private key buffer error.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

rkyshz avatar Oct 02 '21 07:10 rkyshz

First of all this library operates on BIP 44 so while interacting with it you might not get accurate results.. So i will advise you to use BIP44 if you want to use this library..

About the invalid private key buffer i believe you're pasting a WIF or hex key and it's expecting a Buffer one way to solve this is to use ECPair to convert the key to Keypar then pass the private key here a sample

// If private key is a WIF
const keyPair = ECPair.fromWIF('L1jbWJZUKyuVDyjqYiU4e4BxWj5mxrzXkYC4pyvX2MVAAaTu88Sx');
const account = new CryptoAccount(keyPair.privateKey);
// If private key is hex 
// Remove the first 0x on the hex 
const keyPair = ECPair.fromPrivateKey(
    Buffer.from(
      '394cf5961b2a0136d7b69b676c45bcc9dcc929b66f8380b7253ef60284cde13cf',
      'hex'
    )
  );

const account = new CryptoAccount(keyPair.privateKey);

iamnotstatic avatar Jul 03 '22 15:07 iamnotstatic