Misc Primitive Fixes

This commit is contained in:
Jim Hamill
2025-01-15 03:05:53 +00:00
parent 9348648584
commit a51da6770f
15 changed files with 119 additions and 109 deletions
+5 -5
View File
@@ -47,8 +47,8 @@ export class BlockHeader {
*/
public static from(blockHeader: Uint8Array | string) {
return blockHeader instanceof Uint8Array
? BlockHeader.fromBytes(blockHeader)
: BlockHeader.fromHex(blockHeader);
? this.fromBytes(blockHeader)
: this.fromHex(blockHeader);
}
/**
@@ -85,7 +85,7 @@ export class BlockHeader {
throw new Error('The given string is not valid hexadecimal.');
}
return BlockHeader.fromBytes(hexToBin(hex));
return this.fromBytes(hexToBin(hex));
}
/**
@@ -97,7 +97,7 @@ export class BlockHeader {
* @returns A new BlockHeader instance
*/
static fromRaw(obj: BlockHeaderRaw): BlockHeader {
return new BlockHeader(
return new this(
obj.version,
obj.previousBlockHash,
obj.merkleRoot,
@@ -116,7 +116,7 @@ export class BlockHeader {
*/
public static isValid(blockHeader: Uint8Array | string): boolean {
try {
BlockHeader.from(blockHeader);
this.from(blockHeader);
} catch (_error) {
return false;
}