Add encodeForSigning

This commit is contained in:
Nicholas Dudfield
2015-10-02 10:49:37 +07:00
parent d6805e597b
commit ab9ced8344

View File

@@ -2,10 +2,14 @@
const assert = require('assert');
const coreTypes = require('@niq/ripple-core-types');
const {binary: {bytesToHex, binaryToJSON, serializeObject}} = coreTypes;
const {binary: {bytesToHex,
signingData,
multiSigningData,
binaryToJSON,
serializeObject}} = coreTypes;
exports.decode = function(binary) {
assert(typeof binary === 'string');
assert(typeof binary === 'string', 'binary must be a hex string');
return binaryToJSON(binary);
};
@@ -13,3 +17,13 @@ exports.encode = function(json) {
assert(typeof json === 'object');
return bytesToHex(serializeObject(json));
};
exports.encodeForSigning = function(json) {
assert(typeof json === 'object');
return bytesToHex(signingData(json));
};
exports.encodeForMultisigning = function(json, signer) {
assert(typeof json === 'object');
return bytesToHex(multiSigningData(json, signer));
};