x-address-codec
This is a meta package, that exposes an api factory. It's really not as boring as it sounds. We only ask you bring your own hash (create-hash, crypto) to the party, as we already provide a free base-x codec for your heavy lifting pleasure.
What, what? This does what exactly ?
At the party, mostly people just stand around and encode/decode crypto coin address strings to bytes and back. Thrilling right?
Alphabet Soup
We currently serve these alphabets. Make a pull request if you'd like to add one to the menu.
- ripple
- tipple
- bitcoin
- stellar
API
var apiFactory = ;var createHash = ; var api = ; var buf = "00000000000000000000000000000000" 'hex';// It can encode a Buffervar encoded = api;// It returns Array<Number>var decoded = api;// It can of course encode an Array<Number> toovar reencoded = api console;console;// ps6JS7f14BuwFY8Mw6bTtLKWauoUp// ps6JS7f14BuwFY8Mw6bTtLKWauoUp console;// [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
We could actually encode the seed as a ripple one if we chose :)
console;// sp6JS7f14BuwFY8Mw6bTtLKWauoUs
Wait, what if we wanted to create a prefix for the new nifty spaceMan secrets?
var prefix = apicodecsstellar;var spacey = api;console;// spaceMan7qBfYEUBHSWDsZjJHctnNQi2pCTnconsole;// [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
You may as well make a little mini module, and export it :)
moduleexports = api;
Hell, you could even npm publish it :)
$ npm publish
Anway, what is actually exported here?
console/*{ Codec: [Function: AddressCodec], codecs: { bitcoin: { alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz', codec: [Object], base: 58 }, ripple: { alphabet: 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz', codec: [Object], base: 58 }, tipple: { alphabet: 'RPShNAF39wBUDnEGHJKLM4pQrsT7VWXYZ2bcdeCg65jkm8ofqi1tuvaxyz', codec: [Object], base: 58 }, stellar: { alphabet: 'gsphnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCr65jkm8oFqi1tuvAxyz', codec: [Object], base: 58 } }, decode: [Function: decode], encode: [Function: encode], decodeAccountID: [Function], encodeAccountID: [Function], decodeSeed: [Function], encodeSeed: [Function] }*/