bitcoinjs / bip32

A BIP32 compatible library.
MIT License
178 stars 127 forks source link

ecc.isPoint is not a function #73

Open skullpunks opened 1 year ago

skullpunks commented 1 year ago

Hi All,

`const ecc = require('tiny-secp256k1'); console.log(ecc.isPoint) const { BIP32Factory } = require('bip32'); // You must wrap a tiny-secp256k1 compatible implementation const bip32 = BIP32Factory(ecc); const bip39 = require('bip39'); const bitcoin = require('bitcoinjs-lib');

export function generateBitcoinTestAddress(mnemonic) { //const bip32 = BIP32Factory.default(ecc); const seed = bip39.mnemonicToSeedSync(mnemonic); const root = bip32.fromSeed(seed);

const path = "m/49'/1'/0'/0/0"; const child = root.derivePath(path);

const { address } = bitcoin.payments.p2sh({ redeem: bitcoin.payments.p2wpkh({ pubkey: child.publicKey, network: bitcoin.networks.testnet, }), network: bitcoin.networks.testnet, }); console.log(address, "address"); }

export function generateBitcoinMainAddress(mnemonic) { //const bip32 = BIP32Factory.default(ecc); const seed = bip39.mnemonicToSeedSync(mnemonic); const root = bip32.fromSeed(seed);

const path = "m/49'/0'/0'/0"; const child = root.derivePath(path);

const { address } = bitcoin.payments.p2sh({ redeem: bitcoin.payments.p2wpkh({ pubkey: child.publicKey, network: bitcoin.networks.bitcoin, }), network: bitcoin.networks.bitcoin, }); } `

I could not able to bip32 throws following error Unhandled Runtime Error TypeError: ecc.isPoint is not a function

Source Object.testEcc node_modules\bip32\src\testecc.js (5:0) BIP32Factory node_modules\bip32\src\bip32.js (9:0)

` pages\api\Utilities.js (5:14) @ BIP32Factory

3 | const { BIP32Factory } = require('bip32'); 4 | // You must wrap a tiny-secp256k1 compatible implementation

5 | const bip32 = BIP32Factory(ecc); `

nospher3x2 commented 7 months ago

I'm having the same issue

\node_modules\.pnpm\bip32@4.0.0\node_modules\bip32\src\testecc.js:6 assert(ecc.isPoint(h('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'))); ^ TypeError: Cannot read properties of undefined (reading 'isPoint')

EDIT: I fixed using import * as ecc from 'tiny-secp256k1';