Skip to content

How to derive child from ParentPublicKey? #3

Description

Here is my code:

    /**
     * Derive a child from an Xpub using a string for derivation
     *
     * See: https://github.com/monkeylord/bitcoin-ibe#derive-public-key-with-parent-public-key
     *
     * @param xpub Xpub string (ex: xpub123....
     * @param derive arbitrary derivation string (ex: "some string")
     */
    public deriveChildFromXpub(xpub: string, derive: string): string {
        const pubKey = new bsv.HDPublicKey(xpub);
        const childPublicKey = ibe.CKDpub(pubKey, derive); // ERROR HERE!
        const bsvAddres = new bsv.Address(childPublicKey.publicKey);
        return bsvAddres.toString();
    }

Here is the error I get with the latest version of bsv.js

First argument is an unrecognized data format.\n
at PublicKey._classifyArgs (/Users/user/git/me/api/node_modules/bsv/lib/publickey.js:86:11) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions