mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Add tests for encodeFor*Signing
This commit is contained in:
@@ -9,32 +9,42 @@ const {quality,
|
||||
binaryToJSON,
|
||||
serializeObject}} = coreTypes;
|
||||
|
||||
exports.decode = function(binary) {
|
||||
function decode(binary) {
|
||||
assert(typeof binary === 'string', 'binary must be a hex string');
|
||||
return binaryToJSON(binary);
|
||||
};
|
||||
}
|
||||
|
||||
exports.encode = function(json) {
|
||||
function encode(json) {
|
||||
assert(typeof json === 'object');
|
||||
return bytesToHex(serializeObject(json));
|
||||
};
|
||||
}
|
||||
|
||||
exports.encodeForSigning = function(json) {
|
||||
function encodeForSigning(json) {
|
||||
assert(typeof json === 'object');
|
||||
return bytesToHex(signingData(json));
|
||||
};
|
||||
}
|
||||
|
||||
exports.encodeForMultisigning = function(json, signer) {
|
||||
function encodeForMultisigning(json, signer) {
|
||||
assert(typeof json === 'object');
|
||||
assert.equal(json.SigningPubKey, '');
|
||||
return bytesToHex(multiSigningData(json, signer));
|
||||
};
|
||||
}
|
||||
|
||||
exports.encodeQuality = function(value) {
|
||||
function encodeQuality(value) {
|
||||
assert(typeof value === 'string');
|
||||
return bytesToHex(quality.encode(value));
|
||||
};
|
||||
}
|
||||
|
||||
exports.decodeQuality = function(value) {
|
||||
function decodeQuality(value) {
|
||||
assert(typeof value === 'string');
|
||||
return quality.decode(value).toString();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
decode,
|
||||
encode,
|
||||
encodeForSigning,
|
||||
encodeForMultisigning,
|
||||
encodeQuality,
|
||||
decodeQuality
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user