swan-bitcoin / xpub-tool

A JavaScript library to derive bitcoin addresses from extended public keys. Includes a web tool and CLI.
MIT License
47 stars 21 forks source link

Update purpose type to string and move it into its own file #10

Closed joernroeder closed 4 years ago

joernroeder commented 4 years ago

you’re were parsing purpose back to a number here https://github.com/give-bitcoin/xpub-tool/blob/64a3365eff84df3bae6bacdeba031c86119a925b/src/lib/xpub.js#L58

the reason for that is that the Purpose Map is a String: Int map and you’re trying to use the same values as keys here. Unfortunately according to the specs (and stackoverflow) object keys are always a string.

This PR changes the values to Strings, updates the AccountTypeMap and moves both into a separate file so we can incude it in both files (paths.js and xpub.js).