mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
Update x-address-codec dependency
This commit is contained in:
@@ -7,42 +7,24 @@ var ACCOUNT_ID = 0;
|
||||
var FAMILY_SEED = 33;
|
||||
var ED25519_SEED = [0x01, 0xE1, 0x4B];
|
||||
|
||||
var VERSIONS = {
|
||||
EdSeed : {
|
||||
expectedLength: 16,
|
||||
version: ED25519_SEED
|
||||
module.exports = apiFactory({
|
||||
sha256: function (bytes) {
|
||||
return hashjs.sha256().update(bytes).digest();
|
||||
},
|
||||
AccountID: {version: ACCOUNT_ID },
|
||||
NodePublic: {version: NODE_PUBLIC },
|
||||
NodePrivate: {version: NODE_PRIVATE },
|
||||
K256Seed : {version: FAMILY_SEED }
|
||||
};
|
||||
|
||||
function sha256(bytes) {
|
||||
return hashjs.sha256().update(bytes).digest();
|
||||
}
|
||||
|
||||
var api = apiFactory({sha256: sha256, defaultAlphabet: 'ripple'});
|
||||
|
||||
function addVersion(name, args) {
|
||||
function add(operation) {
|
||||
api[operation + name] = function(string) {
|
||||
return api[operation](string, args);
|
||||
}
|
||||
defaultAlphabet: 'ripple',
|
||||
codecMethods: {
|
||||
EdSeed : {
|
||||
expectedLength: 16,
|
||||
version: ED25519_SEED
|
||||
},
|
||||
Seed: {
|
||||
versionTypes: ['EdSeed', 'K256Seed'],
|
||||
versions: [ED25519_SEED, FAMILY_SEED],
|
||||
expectedLength: 16
|
||||
},
|
||||
AccountID: {version: ACCOUNT_ID },
|
||||
NodePublic: {version: NODE_PUBLIC },
|
||||
NodePrivate: {version: NODE_PRIVATE },
|
||||
K256Seed : {version: FAMILY_SEED }
|
||||
}
|
||||
add('encode');
|
||||
add('decode');
|
||||
}
|
||||
|
||||
api.decodeSeed = function(seed) {
|
||||
var args = {versions: [ED25519_SEED, FAMILY_SEED], expectedLength: 16};
|
||||
var decoded = api.decode(seed, args);
|
||||
decoded.type = decoded.versionIx === 0 ? 'EdSeed' : 'K256Seed';
|
||||
return decoded;
|
||||
};
|
||||
|
||||
for (var k in VERSIONS) {
|
||||
addVersion(k, VERSIONS[k]);
|
||||
}
|
||||
|
||||
module.exports = api;
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ripple-address-codec",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"description": "encodes/decodes base58 encoded ripple identifiers",
|
||||
"main": "index.js",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"hash.js": "^1.0.3",
|
||||
"x-address-codec": "^0.2.0"
|
||||
"x-address-codec": "^0.3.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*-test.js"
|
||||
|
||||
Reference in New Issue
Block a user