Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# bip174
[![Build Status](https://travis-ci.org/bitcoinjs/bip174.png?branch=master)](https://travis-ci.org/bitcoinjs/bip174)
[![Build Status](https://github.com/bitcoinjs/bip174/actions/workflows/main_ci.yml/badge.svg)](https://github.com/bitcoinjs/bip174/actions/workflows/main_ci.yml)
[![NPM](https://img.shields.io/npm/v/bip174.svg)](https://www.npmjs.org/package/bip174)

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Expand Down
14 changes: 7 additions & 7 deletions src/lib/converter/shared/tapBip32Derivation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ function makeConverter(TYPE_BYTE) {
'masterFingerprint: Buffer; ' +
'pubkey: Buffer; ' +
'path: string; ' +
'leafHashes: Buffer[]; ' +
'leafHashes?: Buffer[]; ' +
'}';
function check(data) {
return (
Array.isArray(data.leafHashes) &&
data.leafHashes.every(
let leafHashesStatus = true;
if (data.leafHashes && data.leafHashes.length) {
leafHashesStatus = data.leafHashes.every(
leafHash => Buffer.isBuffer(leafHash) && leafHash.length === 32,
) &&
parent.check(data)
);
);
}
return leafHashesStatus && parent.check(data);
}
return {
decode,
Expand Down
15 changes: 8 additions & 7 deletions ts_src/lib/converter/shared/tapBip32Derivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ export function makeConverter(
'masterFingerprint: Buffer; ' +
'pubkey: Buffer; ' +
'path: string; ' +
'leafHashes: Buffer[]; ' +
'leafHashes?: Buffer[]; ' +
'}';
function check(data: any): data is TapBip32Derivation {
return (
Array.isArray(data.leafHashes) &&
data.leafHashes.every(
let leafHashesStatus = true;
if (data.leafHashes && data.leafHashes.length){
leafHashesStatus = data.leafHashes.every(
(leafHash: any) => Buffer.isBuffer(leafHash) && leafHash.length === 32,
) &&
parent.check(data)
);
)
}

return leafHashesStatus && parent.check(data)
}

return {
Expand Down