mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-24 22:25:48 +00:00
More work on new serialization/parsing functions. Added more tests.
This commit is contained in:
@@ -5,8 +5,16 @@ var binformat = require('./binformat'),
|
||||
|
||||
var UInt256 = require('./uint256').UInt256;
|
||||
|
||||
var SerializedObject = function () {
|
||||
this.buffer = [];
|
||||
var SerializedObject = function (buf) {
|
||||
if (Array.isArray(buf)) {
|
||||
this.buffer = buf;
|
||||
} else if ("string" === typeof buf) {
|
||||
this.buffer = sjcl.codec.bytes.fromBits(sjcl.codec.hex.toBits(buf));
|
||||
} else if (!buf) {
|
||||
this.buffer = [];
|
||||
} else {
|
||||
throw new Error("Invalid buffer passed.");
|
||||
}
|
||||
this.pointer = 0;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user