Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
7111f9c
[LIB] - rm lodash from dependencies
MichaelAJay Apr 16, 2026
583e5e2
[LIB] lint address.js
MichaelAJay Apr 16, 2026
fc3270c
[LIB] replaces lodash in address.js
MichaelAJay Apr 16, 2026
a86ad2c
[LIB] lint hdprivatekey.js
MichaelAJay Apr 16, 2026
508394a
[LIB] rm lodash usage in hdprivatekey
MichaelAJay Apr 16, 2026
43ea0fe
change isUndefined() replacement
MichaelAJay Apr 16, 2026
d6fdf4e
[LIB] lint hdpublickey
MichaelAJay Apr 16, 2026
af89af0
[LIB] remove lodash from hdpublickey
MichaelAJay Apr 16, 2026
ea561e2
[LIB] lint message.js
MichaelAJay Apr 16, 2026
8d56f53
[LIB] rm lodash from message.js
MichaelAJay Apr 16, 2026
97a9d91
[LIB] lint opcode.js
MichaelAJay Apr 16, 2026
d1b70af
[LIB] replace lodash in opcode.js
MichaelAJay Apr 16, 2026
d5d19f0
[LIB] lint privatekey.js
MichaelAJay Apr 16, 2026
f411112
[LIB] rm lodash from privatekey.js
MichaelAJay Apr 16, 2026
dbdc2d1
[LIB] lint publickey.js
MichaelAJay Apr 16, 2026
01e89fa
[LIB] rm lodash from publickey.js
MichaelAJay Apr 16, 2026
0661636
[LIB] lint unit.js
MichaelAJay Apr 16, 2026
d200d42
[LIB] rm lodash from unit.js
MichaelAJay Apr 16, 2026
01b1ae7
[LIB] rm lodas from unit.js 2/2
MichaelAJay Apr 16, 2026
e833fe9
[LIB] favor for of over forEach
MichaelAJay Apr 16, 2026
57b3426
[LIB] lint uri.js
MichaelAJay Apr 16, 2026
87233d4
[LIB] rm lodash from uri.js
MichaelAJay Apr 16, 2026
749b0a1
[LIB] lint block.js
MichaelAJay Apr 16, 2026
f043978
[LIB] rm lodash from block.js
MichaelAJay Apr 16, 2026
5c8edfb
[LIB] replace forEach with map in block.js
MichaelAJay Apr 16, 2026
6fbe443
[LIB] lint blockheader.js
MichaelAJay Apr 16, 2026
b72fef9
[LIB] rm lodash from blockheader.js
MichaelAJay Apr 16, 2026
b8ec4e4
[LIB\ lint merkleblock.js
MichaelAJay Apr 16, 2026
3371c00
[LIB] rm lodash from merkleblock.js
MichaelAJay Apr 16, 2026
457fa42
[LIB] lint bn.js
MichaelAJay Apr 16, 2026
0e9e0b4
[LIB] bn.js - rm lodash, fix useless if block
MichaelAJay Apr 16, 2026
b41c337
[LIB] lint signature.js
MichaelAJay Apr 16, 2026
7f7c353
[LIB] singature.js - replace common bitwise operation with declarativ…
MichaelAJay Apr 16, 2026
12a949f
[LIB] rm lodash use in signature.js
MichaelAJay Apr 16, 2026
10489c6
[LIB] base58.js - lint, refactor validCharacters to remove lodash imp…
MichaelAJay Apr 16, 2026
bb5665f
[LIB] lint base58check.js
MichaelAJay Apr 17, 2026
a77dfff
[LIB] rm lodash from base58check.js
MichaelAJay Apr 17, 2026
fb3213e
[LIB] lint bufferreader.js
MichaelAJay Apr 17, 2026
3423042
[LIB] rm lodash from bufferreader.js
MichaelAJay Apr 17, 2026
4f7cd9a
[LIB] lint errors/index.js
MichaelAJay Apr 17, 2026
7c49a96
[LIB] rm lodash from errors/index.js
MichaelAJay Apr 17, 2026
1f30fc3
[LIB] lint interpreter.js
MichaelAJay Apr 17, 2026
fdad938
[LIB] rm lodash from interpreter.js
MichaelAJay Apr 17, 2026
5ea0dfa
[LIB] lint script.js
MichaelAJay Apr 17, 2026
1048475
[LIB] rm lodash from scripts.js
MichaelAJay Apr 17, 2026
983ccf5
[LIB] lint output.js
MichaelAJay Apr 17, 2026
7bb7d71
[LIB] rm lodash from transaction/output.js
MichaelAJay Apr 17, 2026
982a9e6
[LIB] lint transaction/transaction.js
MichaelAJay Apr 17, 2026
82ce3a4
[LIB] lint transaction/transaction.js 2
MichaelAJay Apr 17, 2026
83376d3
[LIB] replace forEach in transaction/transaction.js
MichaelAJay Apr 17, 2026
f0a8468
[LIB] rm lodash from transaction/transaction.js
MichaelAJay Apr 17, 2026
0c76529
[LIB] lint transaction/unspentoutput.js
MichaelAJay Apr 17, 2026
6995719
[LIB] rm lodash from transaction/unspentoutput.js
MichaelAJay Apr 17, 2026
c6a6b02
[LIB] lint transaction/input/input.js
MichaelAJay Apr 17, 2026
bed0313
[LIB] rm lodash from transaction/input/input.js
MichaelAJay Apr 17, 2026
694b0f4
[LIB] lint transaction/input/multisig.js
MichaelAJay Apr 17, 2026
7527ff5
[LIB] rm lodash from transaction/input/multisig.js
MichaelAJay Apr 17, 2026
8444b20
[LIB] lint transaction/input/multisigscripthash.js
MichaelAJay Apr 17, 2026
1d4ce52
[LIB] rm lodash from transaction/input/multisigscripthash.js
MichaelAJay Apr 17, 2026
dd04ac5
[LIB] lint util/js.js
MichaelAJay Apr 17, 2026
db2f04b
[LIB] rm lodash from util/js.js
MichaelAJay Apr 17, 2026
094d3e2
[LIB] lint util/preconditions.js
MichaelAJay Apr 17, 2026
5b53c56
[LIB] rm lodash from util/preconditions.js
MichaelAJay Apr 17, 2026
64fc9ae
bug fix fixes failing tests
MichaelAJay Apr 20, 2026
387440c
fix failing test which was stubbing lodash behavior
MichaelAJay Apr 20, 2026
4eab4e1
[LIB] lint test/hdkeys.js
MichaelAJay Apr 20, 2026
155cbae
[LIB] rm lodash from test/hdkeys.js
MichaelAJay Apr 20, 2026
7e8ccac
[LIB] lint test/hdprivatekey.js
MichaelAJay Apr 20, 2026
c51c426
[LIB] forEach -> "for of" test/hdprivatekey.js
MichaelAJay Apr 20, 2026
85ca33c
[LIB] rm lodash from test/hdprivatekey.js
MichaelAJay Apr 20, 2026
35a7163
[LIB] lint test/hdpublickey.js
MichaelAJay Apr 20, 2026
690ce30
[LIB] rm lodash from test/hdpublickey.js
MichaelAJay Apr 20, 2026
6e5713b
[LIB] lint test/opcode.js
MichaelAJay Apr 20, 2026
8466370
[LIB] rm lodash from test/opcode.js
MichaelAJay Apr 20, 2026
a9f0ba8
[LIB] lint test/crypto/signature.js
MichaelAJay Apr 20, 2026
d0a7359
[LIB] forEach -> for in test/crypto/signature.js
MichaelAJay Apr 20, 2026
4772936
[LIB] disable no-bitwise in test/crypto/signature.js
MichaelAJay Apr 20, 2026
c6eb1a3
[LIB] rm lodash from test/crypto/signature.js
MichaelAJay Apr 20, 2026
f362e40
[LIB] lint test/script/interpreter.js (w/ .only)
MichaelAJay Apr 20, 2026
7a27c9a
[LIB] replace forEach w/ for of - test/script/interpreter.js
MichaelAJay Apr 20, 2026
c567465
[LIB] rm lodash from test/script/interpreter.js
MichaelAJay Apr 20, 2026
b1448bc
[LIB] lint test/transaction/output.js & rm lodash (unused)
MichaelAJay Apr 20, 2026
862ef04
[LIB] lint test/transaction/signature.js & remove lodash (unused)
MichaelAJay Apr 20, 2026
bfc3d7d
[LIB] lint test/transaction/transaction.js
MichaelAJay Apr 20, 2026
3753a7e
[LIB] rm unused imports in test/transaction/transaction.js (includes …
MichaelAJay Apr 20, 2026
b6a581e
[LIB] lint test/transaction/unspentoutput.js
MichaelAJay Apr 20, 2026
ef0dc55
[LIB] rm lodash from test/transaction/unspentoutput.js
MichaelAJay Apr 20, 2026
2587b58
[LIB] lint test/transcation/input/input.js
MichaelAJay Apr 20, 2026
a01f59f
[LIB] rm lodash from test/transaction/input/input.js
MichaelAJay Apr 20, 2026
8781ecc
[LIB] lint test/transaction/input/multisig.js
MichaelAJay Apr 20, 2026
449fd1a
[LIB] rm lodash from test/transaction/input/multisig.js & fix brittle…
MichaelAJay Apr 20, 2026
af2d76e
[LIB] lint test/transaction/input/multisigscripthash.js
MichaelAJay Apr 20, 2026
7969e1f
[LIB] rm lodash from test/transaction/input/multisigscripthash.js & f…
MichaelAJay Apr 20, 2026
eb5721e
[LIB] lint test/transaction/input/publickeyhash.js
MichaelAJay Apr 20, 2026
31b5690
[LIB] rm unused lodash import - transaction/input/publickeyhash.js
MichaelAJay Apr 20, 2026
83ed887
[LIB] rm .only from test.
MichaelAJay Apr 20, 2026
efa1a0d
Merge branch 'master' of https://github.com/bitpay/bitcore into rm-lo…
MichaelAJay Apr 27, 2026
6e5b46d
add back JSUtil import
MichaelAJay Apr 27, 2026
58e1ad4
fix bad import
MichaelAJay Apr 30, 2026
4453738
rm lodash bitcore export
MichaelAJay Apr 30, 2026
4f90558
uninstall lodash (rm from package-lock)
MichaelAJay Apr 30, 2026
563a19c
Merge branch 'master' of https://github.com/bitpay/bitcore into rm-lo…
MichaelAJay May 4, 2026
ebfe868
pin elliptic to 6.5.3
MichaelAJay May 4, 2026
07d6e08
Merge branch 'master' of https://github.com/bitpay/bitcore into rm-lo…
MichaelAJay May 5, 2026
304ab10
fix double imports
MichaelAJay May 6, 2026
cb3fbf3
fix direct buffer usage & optional chaining operator
MichaelAJay May 8, 2026
4b7e574
Merge branch 'master' of https://github.com/bitpay/bitcore into rm-lo…
MichaelAJay May 8, 2026
8b163d2
lint (kick tests)
MichaelAJay May 11, 2026
d88ba6e
bump rippled.Dockerfile base image (node 18 bullseye -> 22 trixie)
MichaelAJay May 11, 2026
4b2b111
update rippled.Dockerfile
MichaelAJay May 11, 2026
32c594e
update rippled Dockerfile to match XRPL documentation
MichaelAJay May 11, 2026
6167594
Merge commit '32c594eda28d56d58e15d2e1aa4b1cab76beedf6' into rm-lodash
MichaelAJay May 11, 2026
bc89dd9
update crpc rippled.Dockerfile
MichaelAJay May 11, 2026
50e4392
Merge branch 'master' of https://github.com/bitpay/bitcore into rm-lo…
MichaelAJay May 11, 2026
6eef478
fix bad merge resolution
MichaelAJay May 11, 2026
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
1 change: 0 additions & 1 deletion packages/bitcore-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ bitcore.deps.bs58 = require('bs58');

bitcore.deps.Buffer = Buffer;
bitcore.deps.elliptic = require('elliptic');
bitcore.deps._ = require('lodash');

// Internal usage, exposed for testing/advanced tweaking
bitcore.Transaction.sighash = require('./lib/transaction/sighash');
18 changes: 8 additions & 10 deletions packages/bitcore-lib/lib/address.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const _ = require('lodash');
const $ = require('./util/preconditions');
const Hash = require('./crypto/hash');
const Base58Check = require('./encoding/base58check');
Expand Down Expand Up @@ -29,16 +28,16 @@ const PublicKey = require('./publickey');
* @example
* ```javascript
* // validate that an input field is valid
* let error = Address.getValidationError(input, 'testnet');
* const error = Address.getValidationError(input, 'testnet');
* if (!error) {
* let address = Address(input, 'testnet');
* const address = Address(input, 'testnet');
* } else {
* // invalid network or checksum (typo?)
* let message = error.messsage;
* const message = error.messsage;
* }
*
* // get an address from a public key
* let address = Address(publicKey, 'testnet').toString();
* const address = Address(publicKey, 'testnet').toString();
* ```
*
* @param {*} data - The encoded data in various formats
Expand All @@ -56,7 +55,7 @@ function Address(data, network, type, multisigType) {
return new Address(data, network, type);
}

if (_.isArray(data) && _.isNumber(network)) {
if (Array.isArray(data) && typeof network === 'number') {
return Address.createMultisig(data, network, type, false, multisigType);
}

Expand Down Expand Up @@ -113,7 +112,7 @@ Address.prototype._classifyArguments = function(data, network, type) {
return Address._transformScript(data, network);
} else if (typeof(data) === 'string') {
return Address._transformString(data, network, type);
} else if (_.isObject(data)) {
} else if (typeof data === 'object' && data !== null) {
return Address._transformObject(data);
} else {
throw new TypeError('First argument is an unrecognized data format.');
Expand Down Expand Up @@ -247,7 +246,6 @@ Address._classifyFromVersion = function(buffer) {
} else {
throw new TypeError('Witness data must be 32 bytes for v1');
}
} else {
}
version.network = Networks.get(info.prefix, 'bech32prefix');
} else {
Expand Down Expand Up @@ -378,7 +376,7 @@ Address.createMultisig = function(publicKeys, threshold, network, nestedWitness,
throw new TypeError('Type must be either scripthash or witnessscripthash to create multisig.');
}
if (nestedWitness || Address.isPayToWitnessScriptHash(type)) {
publicKeys = _.map(publicKeys, PublicKey);
publicKeys = publicKeys.map(key => PublicKey(key));
for (let i = 0; i < publicKeys.length; i++) {
if (!publicKeys[i].compressed) {
throw new TypeError('Witness addresses must use compressed public keys.');
Expand Down Expand Up @@ -563,7 +561,7 @@ Address.fromObject = function fromObject(obj) {
* @example
* ```javascript
* // a network mismatch error
* let error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet');
* const error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet');
* ```
*
* @param {string} data - The encoded data
Expand Down
19 changes: 7 additions & 12 deletions packages/bitcore-lib/lib/block/block.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const _ = require('lodash');
const BN = require('../crypto/bn');
const Hash = require('../crypto/hash');
const BufferReader = require('../encoding/bufferreader');
Expand All @@ -22,7 +21,7 @@ function Block(arg) {
if (!(this instanceof Block)) {
return new Block(arg);
}
_.extend(this, Block._from(arg));
Object.assign(this, Block._from(arg));
return this;
}

Expand All @@ -39,7 +38,7 @@ Block._from = function _from(arg) {
let info = {};
if (BufferUtil.isBuffer(arg)) {
info = Block._fromBufferReader(BufferReader(arg));
} else if (_.isObject(arg)) {
} else if (typeof arg === 'object' && arg !== null) {
info = Block._fromObject(arg);
} else {
throw new TypeError('Unrecognized argument for Block');
Expand All @@ -53,12 +52,11 @@ Block._from = function _from(arg) {
* @private
*/
Block._fromObject = function _fromObject(data) {
const transactions = [];
data.transactions.forEach(function(tx) {
const transactions = data.transactions.map(tx => {
if (tx instanceof Transaction) {
transactions.push(tx);
return tx;
} else {
transactions.push(Transaction().fromObject(tx));
return Transaction().fromObject(tx);
}
});
const info = {
Expand Down Expand Up @@ -139,10 +137,7 @@ Block.fromRawBlock = function fromRawBlock(data) {
* @returns {Object} - A plain object with the block properties
*/
Block.prototype.toObject = Block.prototype.toJSON = function toObject() {
const transactions = [];
this.transactions.forEach(function(tx) {
transactions.push(tx.toObject());
});
const transactions = this.transactions.map(tx => tx.toObject());
return {
header: this.header.toObject(),
transactions: transactions
Expand Down Expand Up @@ -261,7 +256,7 @@ const idProperty = {
}
return this._id;
},
set: _.noop
set: function () {/** no op */}
};
Object.defineProperty(Block.prototype, 'id', idProperty);
Object.defineProperty(Block.prototype, 'hash', idProperty);
Expand Down
12 changes: 6 additions & 6 deletions packages/bitcore-lib/lib/block/blockheader.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';

const _ = require('lodash');
const BN = require('../crypto/bn');
const Hash = require('../crypto/hash');
const BufferReader = require('../encoding/bufferreader');
const BufferWriter = require('../encoding/bufferwriter');
const BufferUtil = require('../util/buffer');
const JSUtil = require('../util/js');
const $ = require('../util/preconditions');

const GENESIS_BITS = 0x1d00ffff;
Expand Down Expand Up @@ -52,7 +50,7 @@ BlockHeader._from = function _from(arg) {
let info = {};
if (BufferUtil.isBuffer(arg)) {
info = BlockHeader._fromBufferReader(BufferReader(arg));
} else if (_.isObject(arg)) {
} else if (typeof arg === 'object' && arg !== null) {
info = BlockHeader._fromObject(arg);
} else {
throw new TypeError('Unrecognized argument for BlockHeader');
Expand All @@ -69,10 +67,10 @@ BlockHeader._fromObject = function _fromObject(data) {
$.checkArgument(data, 'data is required');
let prevHash = data.prevHash;
let merkleRoot = data.merkleRoot;
if (_.isString(data.prevHash)) {
if (typeof data.prevHash === 'string') {
prevHash = BufferUtil.reverse(Buffer.from(data.prevHash, 'hex'));
}
if (_.isString(data.merkleRoot)) {
if (typeof data.merkleRoot === 'string') {
merkleRoot = BufferUtil.reverse(Buffer.from(data.merkleRoot, 'hex'));
}
const info = {
Expand Down Expand Up @@ -208,7 +206,9 @@ BlockHeader.prototype.toBufferWriter = function toBufferWriter(bw) {
BlockHeader.prototype.getTargetDifficulty = function getTargetDifficulty(bits) {
bits = bits || this.bits;

// eslint-disable-next-line no-bitwise
let target = new BN(bits & 0xffffff);
// eslint-disable-next-line no-bitwise
let mov = 8 * ((bits >>> 24) - 3);
while (mov-- > 0) {
target = target.mul(new BN(2));
Expand Down Expand Up @@ -251,7 +251,7 @@ const idProperty = {
}
return this._id;
},
set: _.noop
set: function () {/** no op */}
};
Object.defineProperty(BlockHeader.prototype, 'id', idProperty);
Object.defineProperty(BlockHeader.prototype, 'hash', idProperty);
Expand Down
18 changes: 9 additions & 9 deletions packages/bitcore-lib/lib/block/merkleblock.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
'use strict';

const _ = require('lodash');
const Hash = require('../crypto/hash');
const BufferReader = require('../encoding/bufferreader');
const BufferWriter = require('../encoding/bufferwriter');
const errors = require('../errors');
const Transaction = require('../transaction');
const BufferUtil = require('../util/buffer');
const JSUtil = require('../util/js');
const $ = require('../util/preconditions');
const BlockHeader = require('./blockheader');

Expand All @@ -29,7 +27,7 @@ function MerkleBlock(arg) {
let info = {};
if (BufferUtil.isBuffer(arg)) {
info = MerkleBlock._fromBufferReader(BufferReader(arg));
} else if (_.isObject(arg)) {
} else if (typeof arg === 'object' && arg !== null) {
let header;
if (arg.header instanceof BlockHeader) {
header = arg.header;
Expand Down Expand Up @@ -61,7 +59,7 @@ function MerkleBlock(arg) {
} else {
throw new TypeError('Unrecognized argument for MerkleBlock');
}
_.extend(this, info);
Object.assign(this, info);
this._flagBitsUsed = 0;
this._hashesUsed = 0;

Expand Down Expand Up @@ -129,8 +127,8 @@ MerkleBlock.prototype.toObject = MerkleBlock.prototype.toJSON = function toObjec
* @returns {Boolean} - True/False whether this MerkleBlock is Valid
*/
MerkleBlock.prototype.validMerkleTree = function validMerkleTree() {
$.checkState(_.isArray(this.flags), 'MerkleBlock flags is not an array');
$.checkState(_.isArray(this.hashes), 'MerkleBlock hashes is not an array');
$.checkState(Array.isArray(this.flags), 'MerkleBlock flags is not an array');
$.checkState(Array.isArray(this.hashes), 'MerkleBlock hashes is not an array');

// Can't have more hashes than numTransactions
if (this.hashes.length > this.numTransactions) {
Expand All @@ -156,8 +154,8 @@ MerkleBlock.prototype.validMerkleTree = function validMerkleTree() {
* @returns {Array} - txs hash that match the filter
*/
MerkleBlock.prototype.filterdTxsHash = function filterdTxsHash() {
$.checkState(_.isArray(this.flags), 'MerkleBlock flags is not an array');
$.checkState(_.isArray(this.hashes), 'MerkleBlock hashes is not an array');
$.checkState(Array.isArray(this.flags), 'MerkleBlock flags is not an array');
$.checkState(Array.isArray(this.hashes), 'MerkleBlock hashes is not an array');

// Can't have more hashes than numTransactions
if (this.hashes.length > this.numTransactions) {
Expand Down Expand Up @@ -210,6 +208,7 @@ MerkleBlock.prototype._traverseMerkleTree = function traverseMerkleTree(depth, p
if (opts.flagBitsUsed > this.flags.length * 8) {
return null;
}
// eslint-disable-next-line no-bitwise
const isParentOfMatch = (this.flags[opts.flagBitsUsed >> 3] >>> (opts.flagBitsUsed++ & 7)) & 1;
if (depth === 0 || !isParentOfMatch) {
if (opts.hashesUsed >= this.hashes.length) {
Expand Down Expand Up @@ -241,6 +240,7 @@ MerkleBlock.prototype._traverseMerkleTree = function traverseMerkleTree(depth, p
* @private
*/
MerkleBlock.prototype._calcTreeWidth = function calcTreeWidth(height) {
// eslint-disable-next-line no-bitwise
return (this.numTransactions + (1 << height) - 1) >> height;
};

Expand All @@ -263,7 +263,7 @@ MerkleBlock.prototype._calcTreeHeight = function calcTreeHeight() {
* @private
*/
MerkleBlock.prototype.hasTransaction = function hasTransaction(tx) {
$.checkArgument(!_.isUndefined(tx), 'tx cannot be undefined');
$.checkArgument(tx != null, 'tx cannot be undefined');
$.checkArgument(tx instanceof Transaction || typeof tx === 'string',
'Invalid tx given, tx must be a "string" or "Transaction"');

Expand Down
13 changes: 10 additions & 3 deletions packages/bitcore-lib/lib/crypto/bn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const BN = require('bn.js');
const _ = require('lodash');
const BufferUtil = require('../util/buffer');
const $ = require('../util/preconditions');

Expand All @@ -18,12 +17,12 @@ BN.One = new BN(1);
BN.Minus1 = new BN(-1);

BN.fromNumber = function(n) {
$.checkArgument(_.isNumber(n));
$.checkArgument(typeof n === 'number');
return new BN(n);
};

BN.fromString = function(str, base) {
$.checkArgument(_.isString(str));
$.checkArgument(typeof str === 'string');
return new BN(str, base);
};

Expand Down Expand Up @@ -56,7 +55,9 @@ BN.fromSM = function(buf, opts) {
buf = reversebuf(buf);
}

// eslint-disable-next-line no-bitwise
if (buf[0] & 0x80) {
// eslint-disable-next-line no-bitwise
buf[0] = buf[0] & 0x7f;
ret = BN.fromBuffer(buf);
ret.neg().copy(ret);
Expand Down Expand Up @@ -99,18 +100,22 @@ BN.prototype.toSMBigEndian = function() {
let buf;
if (this.cmp(BN.Zero) === -1) {
buf = this.neg().toBuffer();
// eslint-disable-next-line no-bitwise
if (buf[0] & 0x80) {
buf = Buffer.concat([Buffer.from([0x80]), buf]);
} else {
// eslint-disable-next-line no-bitwise
buf[0] = buf[0] | 0x80;
}
} else {
buf = this.toBuffer();
// eslint-disable-next-line no-bitwise
if (buf[0] & 0x80) {
buf = Buffer.concat([Buffer.from([0x00]), buf]);
}
}

// eslint-disable-next-line no-bitwise
if (buf.length === 1 & buf[0] === 0) {
buf = Buffer.from([]);
}
Expand Down Expand Up @@ -145,12 +150,14 @@ BN.fromScriptNumBuffer = function(buf, fRequireMinimal, size) {
// If the most-significant-byte - excluding the sign bit - is zero
// then we're not minimal. Note how this test also rejects the
// negative-zero encoding, 0x80.
// eslint-disable-next-line no-bitwise
if ((buf[buf.length - 1] & 0x7f) === 0) {
// One exception: if there's more than one byte and the most
// significant bit of the second-most-significant-byte is set
// it would conflict with the sign bit. An example of this case
// is +-255, which encode to 0xff00 and 0xff80 respectively.
// (big-endian).
// eslint-disable-next-line no-bitwise
if (buf.length <= 1 || (buf[buf.length - 2] & 0x80) === 0) {
throw new Error('non-minimally encoded script number');
}
Expand Down
8 changes: 4 additions & 4 deletions packages/bitcore-lib/lib/crypto/point.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const EC = require('elliptic').ec;
const BufferUtil = require('../util/buffer');
const BN = require('./bn');
const EC = require('elliptic').ec;

const ec = new EC('secp256k1');
const ecPoint = ec.curve.point.bind(ec.curve);
Expand All @@ -24,7 +24,7 @@ const Point = function Point(x, y, isRed) {
let point;
try {
point = ecPoint(x, y, isRed);
} catch (e) {
} catch {
throw new Error('Invalid Point');
}
point.validate();
Expand All @@ -46,7 +46,7 @@ Point.fromX = function fromX(odd, x) {
let point;
try {
point = ecPointFromX(x, odd);
} catch (e) {
} catch {
throw new Error('Invalid X');
}
point.validate();
Expand Down Expand Up @@ -127,7 +127,7 @@ Point.prototype.validate = function validate() {
let p2;
try {
p2 = ecPointFromX(this.getX(), this.getY().isOdd());
} catch (e) {
} catch {
throw new Error('Point does not lie on the curve');
}

Expand Down
Loading