Socket
Socket
Sign inDemoInstall

bitcoinjs-lib

Package Overview
Dependencies
Maintainers
3
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcoinjs-lib - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

11

CHANGELOG.md

@@ -0,1 +1,8 @@

# 4.0.2
__fixed__
- Fixed `TransactionBuilder` not throwing when payment type validation should fail (#1195)
__removed__
- Removed rogue `package.json` from `src/payments` (#1216)
# 4.0.1

@@ -18,3 +25,3 @@ __fixed__

- `TransactionBuilder` now defaults to version 2 transaction versions (#1036)
- `script.decompile` now returns `Buffer` or `null`, if decompilation failed (#1039)
- `script.decompile` now returns `[Buffer]` or `null`, if decompilation failed (#1039)

@@ -36,3 +43,3 @@ __fixed__

- Removed `script.isCanonicalSignature`, use `script.isCanonicalScriptSignature` instead (#1094)
- Removed `script.*.input/output/check` functions (`templates`) (previously added in #681, #682) (#1119)
- Removed `script.*.input/output/check` functions (`templates`), use `payments.*` instead (`templates` previously added in #681, #682) (#1119)
- Removed dependency `bigi`, uses `bn.js` internally now (via `tiny-secp256k1`) (#1070, #1112)

@@ -39,0 +46,0 @@ - Removed public access to `ECPair` constructor, use exported functions `ECPair.fromPrivateKey`, `ECPair.fromWIF`, `ECPair.makeRandom`, or `ECPair.fromPublicKey` (#1070)

6

package.json
{
"name": "bitcoinjs-lib",
"version": "4.0.1",
"version": "4.0.2",
"description": "Client-side Bitcoin JavaScript library",

@@ -20,3 +20,3 @@ "main": "./src/index.js",

"coverage": "nyc --check-coverage --branches 90 --functions 90 mocha",
"integration": "mocha test/integration/",
"integration": "mocha --timeout 50000 test/integration/",
"standard": "standard",

@@ -57,3 +57,3 @@ "test": "npm run standard && npm run coverage",

"dhttp": "^2.5.0",
"hoodwink": "^1.0.0",
"hoodwink": "^2.0.0",
"minimaldata": "^1.0.2",

@@ -60,0 +60,0 @@ "mocha": "^5.2.0",

@@ -30,3 +30,3 @@ # BitcoinJS (bitcoinjs-lib)

## Documentation
Presently, we do not have any formal documentation other than our [examples](#Examples), please [ask for help](https://github.com/bitcoinjs/bitcoinjs-lib/issues/new) if our examples aren't enough to guide you.
Presently, we do not have any formal documentation other than our [examples](#examples), please [ask for help](https://github.com/bitcoinjs/bitcoinjs-lib/issues/new) if our examples aren't enough to guide you.

@@ -33,0 +33,0 @@

@@ -8,5 +8,2 @@ const ecc = require('tiny-secp256k1')

const NETWORKS = require('./networks')
// TODO: why is the function name toJSON weird?
function isPoint (x) { return ecc.isPoint(x) }
const isOptions = typeforce.maybe(typeforce.compile({

@@ -61,3 +58,3 @@ compressed: types.maybe(types.Boolean),

function fromPublicKey (buffer, options) {
typeforce(isPoint, buffer)
typeforce(ecc.isPoint, buffer)
typeforce(isOptions, options)

@@ -64,0 +61,0 @@ return new ECPair(null, buffer, options)

@@ -22,3 +22,3 @@ const lazy = require('./lazy')

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -25,0 +25,0 @@ typef({

@@ -27,3 +27,3 @@ const lazy = require('./lazy')

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -30,0 +30,0 @@ function isAcceptableSignature (x) {

@@ -1,8 +0,8 @@

let lazy = require('./lazy')
let typef = require('typeforce')
let OPS = require('bitcoin-ops')
let ecc = require('tiny-secp256k1')
const lazy = require('./lazy')
const typef = require('typeforce')
const OPS = require('bitcoin-ops')
const ecc = require('tiny-secp256k1')
let bscript = require('../script')
let BITCOIN_NETWORK = require('../networks').bitcoin
const bscript = require('../script')
const BITCOIN_NETWORK = require('../networks').bitcoin

@@ -19,3 +19,3 @@ // input: {signature}

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -31,6 +31,6 @@ typef({

let _chunks = lazy.value(function () { return bscript.decompile(a.input) })
const _chunks = lazy.value(function () { return bscript.decompile(a.input) })
let network = a.network || BITCOIN_NETWORK
let o = { network }
const network = a.network || BITCOIN_NETWORK
const o = { network }

@@ -63,13 +63,10 @@ lazy.prop(o, 'output', function () {

if (opts.validate) {
if (a.pubkey && a.output) {
if (!a.pubkey.equals(o.pubkey)) throw new TypeError('Pubkey mismatch')
}
if (a.output) {
if (a.output[a.output.length - 1] !== OPS.OP_CHECKSIG) throw new TypeError('Output is invalid')
if (!ecc.isPoint(o.pubkey)) throw new TypeError('Output pubkey is invalid')
if (a.pubkey && !a.pubkey.equals(o.pubkey)) throw new TypeError('Pubkey mismatch')
}
if (a.signature) {
if (a.input && !a.input.equals(o.input)) throw new TypeError('Input mismatch')
if (a.input && !a.input.equals(o.input)) throw new TypeError('Signature mismatch')
}

@@ -79,3 +76,3 @@

if (_chunks().length !== 1) throw new TypeError('Input is invalid')
if (!bscript.isCanonicalScriptSignature(_chunks()[0])) throw new TypeError('Input has invalid signature')
if (!bscript.isCanonicalScriptSignature(o.signature)) throw new TypeError('Input has invalid signature')
}

@@ -82,0 +79,0 @@ }

@@ -21,3 +21,3 @@ const lazy = require('./lazy')

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -110,8 +110,9 @@ typef({

if (hash && !hash.equals(a.output.slice(3, 23))) throw new TypeError('Hash mismatch')
else hash = a.output.slice(3, 23)
const hash2 = a.output.slice(3, 23)
if (hash && !hash.equals(hash2)) throw new TypeError('Hash mismatch')
else hash = hash2
}
if (a.pubkey) {
let pkh = bcrypto.hash160(a.pubkey)
const pkh = bcrypto.hash160(a.pubkey)
if (hash && !hash.equals(pkh)) throw new TypeError('Hash mismatch')

@@ -122,3 +123,3 @@ else hash = pkh

if (a.input) {
let chunks = _chunks()
const chunks = _chunks()
if (chunks.length !== 2) throw new TypeError('Input is invalid')

@@ -131,3 +132,3 @@ if (!bscript.isCanonicalScriptSignature(chunks[0])) throw new TypeError('Input has invalid signature')

let pkh = bcrypto.hash160(chunks[1])
const pkh = bcrypto.hash160(chunks[1])
if (hash && !hash.equals(pkh)) throw new TypeError('Hash mismatch')

@@ -134,0 +135,0 @@ }

@@ -29,3 +29,3 @@ const lazy = require('./lazy')

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -62,3 +62,3 @@ typef({

return {
network: network,
network,
output: chunks[chunks.length - 1],

@@ -116,3 +116,3 @@ input: bscript.compile(chunks.slice(0, -1)),

if (_address().hash.length !== 20) throw new TypeError('Invalid address')
else hash = _address().hash
hash = _address().hash
}

@@ -131,2 +131,3 @@

a.output[22] !== OPS.OP_EQUAL) throw new TypeError('Output is invalid')
const hash2 = a.output.slice(2, 22)

@@ -172,5 +173,6 @@ if (hash && !hash.equals(hash2)) throw new TypeError('Hash mismatch')

if (a.redeem.network && a.redeem.network !== network) throw new TypeError('Network mismatch')
if (o.redeem) {
if (a.redeem.output && !a.redeem.output.equals(o.redeem.output)) throw new TypeError('Redeem.output mismatch')
if (a.redeem.input && !a.redeem.input.equals(o.redeem.input)) throw new TypeError('Redeem.input mismatch')
if (a.input) {
const redeem = _redeem()
if (a.redeem.output && !a.redeem.output.equals(redeem.output)) throw new TypeError('Redeem.output mismatch')
if (a.redeem.input && !a.redeem.input.equals(redeem.input)) throw new TypeError('Redeem.input mismatch')
}

@@ -177,0 +179,0 @@

@@ -24,3 +24,3 @@ const lazy = require('./lazy')

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -97,3 +97,2 @@ typef({

if (_address().data.length !== 20) throw new TypeError('Invalid address data')
// if (hash && !hash.equals(_address().data)) throw new TypeError('Hash mismatch')
hash = _address().data

@@ -100,0 +99,0 @@ }

@@ -31,3 +31,3 @@ const lazy = require('./lazy')

) throw new TypeError('Not enough data')
opts = opts || { validate: true }
opts = Object.assign({ validate: true }, opts || {})

@@ -126,3 +126,3 @@ typef({

if (_address().data.length !== 32) throw new TypeError('Invalid address data')
else hash = _address().data
hash = _address().data
}

@@ -129,0 +129,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc