Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Support input of serialized string or buffer to utils.normalizeHeader (
Browse files Browse the repository at this point in the history
…#16)

* support string and buffer normalization

* update dashcore-lib dep

* bump version

* update package lock

* fix typo
  • Loading branch information
Cofresi authored Apr 5, 2019
1 parent bc6a0e5 commit f85859c
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 269 deletions.
7 changes: 7 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ module.exports = {
if (header instanceof dashcore.BlockHeader) {
return header;
}
if (Buffer.isBuffer(header) && header.length === 80) {
return new dashcore.BlockHeader(header);
}
if (typeof header === 'string' && header.length === 160) {
const buffer = Buffer.from(header, 'hex');
return new dashcore.BlockHeader(buffer);
}

const el = JSON.parse(JSON.stringify(header));

Expand Down
Loading

0 comments on commit f85859c

Please sign in to comment.