chainsql-address-codec

encodes/decodes base58 encoded ripple identifiers

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
chainsql-address-codec
2202.0.5a year ago5 years agoMinified + gzip package size for chainsql-address-codec in KB

Readme

chainsql-address-codec NPM Build Status codecov.io

API

```js
var api = require('chainsql-address-codec');
api.decodeSeed('xxWFBu6veVgMnAqNf6YFRV2UENRd3')
{ version: 1, 225, 75 , bytes: 76, 58, 29, 33, 63, 189, 251, 20, 199, 194, 141, 96, 148, 105, 179, 65 , type: 'ed25519' }
api.decodeSeed('xxWFBu6veVgMnAqNf6YFRV2UENRd3')
{ version: 33, bytes: 207, 45, 227, 120, 251, 221, 126, 46, 232, 125, 72, 109, 251, 90, 123, 255 , type: 'secp256k1' }
api.decodeAccountID('z9VF7yQPLcKgUoHwMbzmQBjvPsyMy19ubs')
186, 142, 120, 98, 110, 228, 44, 65, 180, 109, 70, 195, 4, 141, 243, 161, 195, 200, 112, 114 ```

And ?? There's more to the wonderful world then chainsql

We give you the kitchen sink. ```js
console.log(api)
{ 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 } },
chainsql:
{ alphabet: 'zpxhncf39wBUDNEGHJKLM4PQRST7VWXYZ2badeCg65jkm8oFqi1tuvAsyr',
codec: [Object],
base: 58 },
decode: Function: decode, encode: Function: encode, decodeEdSeed: Function, encodeEdSeed: Function, isValidEdSeed: Function, decodeSeed: Function, encodeSeed: Function, isValidSeed: Function, decodeAccountID: Function, encodeAccountID: Function, isValidAccountID: Function, decodeAddress: Function, encodeAddress: Function, isValidAddress: Function, decodeNodePublic: Function, encodeNodePublic: Function, isValidNodePublic: Function, decodeNodePrivate: Function, encodeNodePrivate: Function, isValidNodePrivate: Function, decodeK256Seed: Function, encodeK256Seed: Function, isValidK256Seed: Function } ```
Decode a bip32 bitcoin public key
```js var pubVersion = 0x04, 0x88, 0xB2, 0x1E; var options = {version: pubVersion, alphabet: 'bitcoin'}; var key = 'xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB'; var decoded = api.decode(key, options); var reencoded = api.encode(decoded, options); console.log(key); // 'xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB' console.log(reencoded); // 'xpub661MyMwAqRbcEYS8w7XLSVeEsBXy79zSzH1J8vCdxAZningWLdN3zgtU6LBpB85b3D2yc8sfvZU521AAwdZafEz7mnzBBsz4wKY5e4cp9LB' ```