Move to checkTxRoots and warn checkMerkleRoot deprecation
This commit is contained in:
parent
581ab5f136
commit
e52abecee2
4 changed files with 27 additions and 11 deletions
ts_src
|
@ -208,14 +208,25 @@ export class Block {
|
|||
return this.toBuffer(headersOnly).toString('hex')
|
||||
}
|
||||
|
||||
checkTxRoots (): boolean {
|
||||
return this.__checkMerkleRoot() &&
|
||||
(this.hasWitnessCommit() ? this.__checkWitnessCommit() : true)
|
||||
}
|
||||
|
||||
checkMerkleRoot (): boolean {
|
||||
console.warn('Deprecation Warning: Block method checkMerkleRoot will be ' +
|
||||
'deprecated in v5. Please use checkTxRoots instead.')
|
||||
return this.checkTxRoots()
|
||||
}
|
||||
|
||||
__checkMerkleRoot (): boolean {
|
||||
if (!this.transactions) throw errorMerkleNoTxes
|
||||
|
||||
const actualMerkleRoot = Block.calculateMerkleRoot(this.transactions)
|
||||
return this.merkleRoot!.compare(actualMerkleRoot) === 0
|
||||
}
|
||||
|
||||
checkWitnessCommit (): boolean {
|
||||
__checkWitnessCommit (): boolean {
|
||||
if (!this.transactions) throw errorMerkleNoTxes
|
||||
if (!this.hasWitnessCommit()) throw errorWitnessNotSegwit
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue