bip32 icon indicating copy to clipboard operation
bip32 copied to clipboard

ecc.isPoint is not a function

Open indexxai opened this issue 2 years ago • 2 comments

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); `

indexxai avatar Feb 14 '23 14:02 indexxai

I'm having the same issue

\node_modules\.pnpm\[email protected]\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';

nospher3x2 avatar Mar 01 '24 22:03 nospher3x2