From 9f1ebf72a68fd3944195da361ad317b54c2786f4 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 10 Oct 2016 13:29:43 +1100 Subject: [PATCH] types: remove unused UInt2, BIP32 is capitals --- src/hdnode.js | 2 +- src/types.js | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/hdnode.js b/src/hdnode.js index 27228e9..3965ff1 100644 --- a/src/hdnode.js +++ b/src/hdnode.js @@ -294,7 +294,7 @@ HDNode.prototype.isNeutered = function () { } HDNode.prototype.derivePath = function (path) { - typeforce(types.Bip32Path, path) + typeforce(types.BIP32Path, path) var splitPath = path.split('/') if (splitPath[0] === 'm') { diff --git a/src/types.js b/src/types.js index 1dbdcc5..ab617a8 100644 --- a/src/types.js +++ b/src/types.js @@ -1,21 +1,19 @@ var typeforce = require('typeforce') var UINT31_MAX = Math.pow(2, 31) - 1 -function UInt2 (value) { return (value & 3) === value } function UInt31 (value) { return typeforce.UInt32(value) && value <= UINT31_MAX } +function BIP32Path (value) { + return typeforce.String(value) && value.match(/^(m\/)?(\d+'?\/)*\d+'?$/) +} + var SATOSHI_MAX = 2.1 * 1e15 function Satoshi (value) { return typeforce.UInt53(value) && value <= SATOSHI_MAX } -function Bip32Path (value) { - return typeforce.String(value) && - value.match(/^(m\/)?(\d+'?\/)*\d+'?$/) -} - // external dependent types var BigInt = typeforce.quacksLike('BigInteger') var ECPoint = typeforce.quacksLike('Point') @@ -37,6 +35,7 @@ var Network = typeforce.compile({ // extend typeforce types with ours var types = { BigInt: BigInt, + BIP32Path: BIP32Path, Buffer256bit: typeforce.BufferN(32), ECPoint: ECPoint, ECSignature: ECSignature, @@ -44,9 +43,7 @@ var types = { Hash256bit: typeforce.BufferN(32), Network: Network, Satoshi: Satoshi, - UInt2: UInt2, - UInt31: UInt31, - Bip32Path: Bip32Path + UInt31: UInt31 } for (var typeName in typeforce) {