|
@ -21,7 +21,22 @@ var BlockHeader = function BlockHeader(arg) { |
|
|
if (!(this instanceof BlockHeader)) { |
|
|
if (!(this instanceof BlockHeader)) { |
|
|
return new BlockHeader(arg); |
|
|
return new BlockHeader(arg); |
|
|
} |
|
|
} |
|
|
_.extend(this, BlockHeader._from(arg)); |
|
|
var info = BlockHeader._from(arg); |
|
|
|
|
|
this.version = info.version; |
|
|
|
|
|
this.prevHash = info.prevHash; |
|
|
|
|
|
this.merkleRoot = info.merkleRoot; |
|
|
|
|
|
this.time = info.time; |
|
|
|
|
|
this.timestamp = info.time; |
|
|
|
|
|
this.bits = info.bits; |
|
|
|
|
|
this.nonce = info.nonce; |
|
|
|
|
|
|
|
|
|
|
|
if (info.hash) { |
|
|
|
|
|
$.checkState( |
|
|
|
|
|
this.hash === info.hash, |
|
|
|
|
|
'Argument object hash property does not match block hash.' |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return this; |
|
|
return this; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -72,6 +87,7 @@ BlockHeader._fromObject = function _fromObject(data) { |
|
|
merkleRoot = BufferUtil.reverse(new Buffer(data.merkleRoot, 'hex')); |
|
|
merkleRoot = BufferUtil.reverse(new Buffer(data.merkleRoot, 'hex')); |
|
|
} |
|
|
} |
|
|
var info = { |
|
|
var info = { |
|
|
|
|
|
hash: data.hash, |
|
|
version: data.version, |
|
|
version: data.version, |
|
|
prevHash: prevHash, |
|
|
prevHash: prevHash, |
|
|
merkleRoot: merkleRoot, |
|
|
merkleRoot: merkleRoot, |
|
|