Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSV Library Version | HD Keys Confussion #253

Open
imkrishnaagrawal opened this issue Oct 24, 2022 · 3 comments
Open

BSV Library Version | HD Keys Confussion #253

imkrishnaagrawal opened this issue Oct 24, 2022 · 3 comments

Comments

@imkrishnaagrawal
Copy link

Hi Everyone,

I am new to bsv ecosystem and have started a project using typescript/javascript. the obvious choice was bsv npm package as suggested by bsv official website and also followed along some courses however I am facing challenges understanding the versions , maintenance and future of bsv library. most of courses I followed at satolearn and other places are using old version of library which is 1.5.x and also moneybutton documentation is using 0.30.0 (https://about.moneybutton.com/docs/button/mb-crypto-operations). I am facing issue when creating HD Private and Public keys using Mnemonic. while looking at issues I found a solution however it is not working bsv.Mnemonic and bsv.HDPrivKey are undefined. I am using [email protected].

const mnemonic = new bsv.Mnemonic()
const hdPrivKey = bsv.HDPrivKey.fromSeed(mnemonic.toSeed())
const someKey = hdPrivKey.deriveChild("m/5/2/8") // Private key
const somePubkey = someKey.publicKey
const address = somePubkey.toAddress()
console.log(address);

Errors:

const mnemonic = new bsv.Mnemonic()
                 ^
TypeError: bsv.Mnemonic is not a constructor
const hdPrivKey = bsv.HDPrivKey.fromSeed(mnemonic.toSeed())
                                ^
TypeError: Cannot read properties of undefined (reading 'fromSeed')

I need suggestion to get some understanding around the issue. Other developers might be facing similar challenges.

@imkrishnaagrawal imkrishnaagrawal changed the title BSV Library Future Support BSV Library Version Confussion Oct 24, 2022
@imkrishnaagrawal imkrishnaagrawal changed the title BSV Library Version Confussion BSV Library Version | HD Keys Confussion Oct 24, 2022
@mathiasrw
Copy link
Contributor

I am facing challenges understanding the versions , maintenance and future of bsv library. most of courses I followed at satolearn and other places are using old version of library which is 1.5.x and also moneybutton documentation is using 0.30.0

Im with you on this one

@afomi
Copy link
Contributor

afomi commented Dec 21, 2022

The API has changed substantially between bsv-legacy and the updated [email protected]

const seed = bsvjs.Bip39.fromRandom().seed
const hdPrivKey = bsvjs.Bip32.fromSeed(seed)
const someKey = hdPrivKey.derive("m/5/2/8")
const somePubkey = someKey.pubKey
const address = bsvjs.Address.fromPubKey(somePubkey).toString()

console.log(address)

@Zhell1
Copy link

Zhell1 commented Apr 14, 2023

using bips as the naming scheme is really confusing to newcomers and fails at the target purpose of It should not be necessary to read the source code of a class or function to know how to use it / so that other developers find the code easy to understand.

developers, especially newcomers, should not have to learn by heart which BIP number corresponds to a well-known feature of any bitcoin library, the feature should be described by its name for clarity and ease of use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants