Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 6.1.0-rc.0 to 6.1.0

14

package.json
{
"name": "bitcoinjs-lib",
"version": "6.1.0-rc.0",
"version": "6.1.0",
"description": "Client-side Bitcoin JavaScript library",

@@ -31,4 +31,4 @@ "main": "./src/index.js",

"integration": "npm run build && npm run nobuild:integration",
"lint": "tslint -p tsconfig.json -c tslint.json",
"lint:tests": "tslint -p test/tsconfig.json -c tslint.json",
"lint": "eslint ts_src/** src/**/*.js",
"lint:tests": "eslint test/**/*.spec.ts",
"mocha:ts": "mocha --recursive --require test/ts-node-register",

@@ -72,2 +72,4 @@ "nobuild:coverage-report": "nyc report --reporter=lcov",

"@types/wif": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"better-npm-audit": "^3.7.3",

@@ -81,2 +83,5 @@ "bip32": "^3.0.1",

"ecpair": "^2.0.1",
"eslint": "^8.29.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"hoodwink": "^2.0.0",

@@ -86,3 +91,3 @@ "minimaldata": "^1.0.2",

"nyc": "^15.1.0",
"prettier": "1.16.4",
"prettier": "^2.8.0",
"proxyquire": "^2.0.1",

@@ -94,3 +99,2 @@ "randombytes": "^2.1.0",

"ts-node": "^8.3.0",
"tslint": "^6.1.3",
"typescript": "^4.4.4"

@@ -97,0 +101,0 @@ },

@@ -79,5 +79,17 @@ # BitcoinJS (bitcoinjs-lib)

### Browser
The recommended method of using `bitcoinjs-lib` in your browser is through [Browserify](https://github.com/substack/node-browserify).
If you're familiar with how to use browserify, ignore this and carry on, otherwise, it is recommended to read the tutorial at https://browserify.org/.
The recommended method of using `bitcoinjs-lib` in your browser is through [browserify](http://browserify.org/).
If you'd like to use a different (more modern) build tool than `browserify`, you can compile just this library and its dependencies into a single JavaScript file:
```sh
$ npm install bitcoinjs-lib browserify
$ npx browserify --standalone bitcoin - -o bitcoinjs-lib.js <<<"module.exports = require('bitcoinjs-lib');"
```
Which you can then import as an ESM module:
```javascript
<script type="module">import "/scripts/bitcoinjs-lib.js"</script>
````
**NOTE**: We use Node Maintenance LTS features, if you need strict ES5, use [`--transform babelify`](https://github.com/babel/babelify) in conjunction with your `browserify` step (using an [`es2015`](https://babeljs.io/docs/plugins/preset-es2015/) preset).

@@ -84,0 +96,0 @@

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.toOutputScript = exports.fromOutputScript = exports.toBech32 = exports.toBase58Check = exports.fromBech32 = exports.fromBase58Check = void 0;
exports.toOutputScript =
exports.fromOutputScript =
exports.toBech32 =
exports.toBase58Check =
exports.fromBech32 =
exports.fromBase58Check =
void 0;
const networks = require('./networks');

@@ -5,0 +11,0 @@ const payments = require('./payments');

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.BufferReader = exports.BufferWriter = exports.cloneBuffer = exports.reverseBuffer = exports.writeUInt64LE = exports.readUInt64LE = exports.varuint = void 0;
exports.BufferReader =
exports.BufferWriter =
exports.cloneBuffer =
exports.reverseBuffer =
exports.writeUInt64LE =
exports.readUInt64LE =
exports.varuint =
void 0;
const types = require('./types');

@@ -56,2 +63,5 @@ const { typeforce } = types;

class BufferWriter {
static withCapacity(size) {
return new BufferWriter(Buffer.alloc(size));
}
constructor(buffer, offset = 0) {

@@ -62,5 +72,2 @@ this.buffer = buffer;

}
static withCapacity(size) {
return new BufferWriter(Buffer.alloc(size));
}
writeUInt8(i) {

@@ -67,0 +74,0 @@ this.offset = this.buffer.writeUInt8(i, this.offset);

@@ -8,4 +8,4 @@ /// <reference types="node" />

declare const TAGS: readonly ["BIP0340/challenge", "BIP0340/aux", "BIP0340/nonce", "TapLeaf", "TapBranch", "TapSighash", "TapTweak", "KeyAgg list", "KeyAgg coefficient"];
export declare type TaggedHashPrefix = typeof TAGS[number];
export type TaggedHashPrefix = typeof TAGS[number];
export declare function taggedHash(prefix: TaggedHashPrefix, data: Buffer): Buffer;
export {};
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.taggedHash = exports.hash256 = exports.hash160 = exports.sha256 = exports.sha1 = exports.ripemd160 = void 0;
exports.taggedHash =
exports.hash256 =
exports.hash160 =
exports.sha256 =
exports.sha1 =
exports.ripemd160 =
void 0;
const createHash = require('create-hash');

@@ -8,10 +14,6 @@ const RipeMd160 = require('ripemd160');

try {
return createHash('rmd160')
.update(buffer)
.digest();
return createHash('rmd160').update(buffer).digest();
} catch (err) {
try {
return createHash('ripemd160')
.update(buffer)
.digest();
return createHash('ripemd160').update(buffer).digest();
} catch (err2) {

@@ -24,11 +26,7 @@ return new RipeMd160().update(buffer).digest();

function sha1(buffer) {
return createHash('sha1')
.update(buffer)
.digest();
return createHash('sha1').update(buffer).digest();
}
exports.sha1 = sha1;
function sha256(buffer) {
return createHash('sha256')
.update(buffer)
.digest();
return createHash('sha256').update(buffer).digest();
}

@@ -35,0 +33,0 @@ exports.sha256 = sha256;

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.initEccLib = exports.Transaction = exports.opcodes = exports.Psbt = exports.Block = exports.script = exports.payments = exports.networks = exports.crypto = exports.address = void 0;
exports.initEccLib =
exports.Transaction =
exports.opcodes =
exports.Psbt =
exports.Block =
exports.script =
exports.payments =
exports.networks =
exports.crypto =
exports.address =
void 0;
const address = require('./address');

@@ -17,3 +27,3 @@ exports.address = address;

enumerable: true,
get: function() {
get: function () {
return block_1.Block;

@@ -25,3 +35,3 @@ },

enumerable: true,
get: function() {
get: function () {
return psbt_1.Psbt;

@@ -33,3 +43,3 @@ },

enumerable: true,
get: function() {
get: function () {
return ops_1.OPS;

@@ -41,3 +51,3 @@ },

enumerable: true,
get: function() {
get: function () {
return transaction_1.Transaction;

@@ -49,5 +59,5 @@ },

enumerable: true,
get: function() {
get: function () {
return ecc_lib_1.initEccLib;
},
});

@@ -23,3 +23,3 @@ /// <reference types="node" />

*/
export declare type HashTree = HashLeaf | HashBranch;
export type HashTree = HashLeaf | HashBranch;
export declare function rootHashFromPath(controlBlock: Buffer, leafHash: Buffer): Buffer;

@@ -26,0 +26,0 @@ /**

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.tweakKey = exports.tapTweakHash = exports.tapleafHash = exports.findScriptPath = exports.toHashTree = exports.rootHashFromPath = exports.MAX_TAPTREE_DEPTH = exports.LEAF_VERSION_TAPSCRIPT = void 0;
exports.tweakKey =
exports.tapTweakHash =
exports.tapleafHash =
exports.findScriptPath =
exports.toHashTree =
exports.rootHashFromPath =
exports.MAX_TAPTREE_DEPTH =
exports.LEAF_VERSION_TAPSCRIPT =
void 0;
const buffer_1 = require('buffer');

@@ -15,5 +23,3 @@ const ecc_lib_1 = require('../ecc_lib');

throw new TypeError(
`The control-block length is too small. Got ${
controlBlock.length
}, expected min 33.`,
`The control-block length is too small. Got ${controlBlock.length}, expected min 33.`,
);

@@ -20,0 +26,0 @@ const m = (controlBlock.length - 33) / 32;

@@ -32,4 +32,4 @@ /// <reference types="node" />

}
export declare type PaymentCreator = (a: Payment, opts?: PaymentOpts) => Payment;
export declare type PaymentFunction = () => Payment;
export type PaymentCreator = (a: Payment, opts?: PaymentOpts) => Payment;
export type PaymentFunction = () => Payment;
export interface PaymentOpts {

@@ -39,5 +39,5 @@ validate?: boolean;

}
export declare type StackElement = Buffer | number;
export declare type Stack = StackElement[];
export declare type StackFunction = () => Stack;
export type StackElement = Buffer | number;
export type Stack = StackElement[];
export type StackFunction = () => Stack;
export { embed, p2ms, p2pk, p2pkh, p2sh, p2wpkh, p2wsh, p2tr };
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.p2tr = exports.p2wsh = exports.p2wpkh = exports.p2sh = exports.p2pkh = exports.p2pk = exports.p2ms = exports.embed = void 0;
exports.p2tr =
exports.p2wsh =
exports.p2wpkh =
exports.p2sh =
exports.p2pkh =
exports.p2pk =
exports.p2ms =
exports.embed =
void 0;
const embed_1 = require('./embed');
Object.defineProperty(exports, 'embed', {
enumerable: true,
get: function() {
get: function () {
return embed_1.p2data;

@@ -14,3 +22,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2ms_1.p2ms;

@@ -22,3 +30,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2pk_1.p2pk;

@@ -30,3 +38,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2pkh_1.p2pkh;

@@ -38,3 +46,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2sh_1.p2sh;

@@ -46,3 +54,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2wpkh_1.p2wpkh;

@@ -54,3 +62,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2wsh_1.p2wsh;

@@ -62,3 +70,3 @@ },

enumerable: true,
get: function() {
get: function () {
return p2tr_1.p2tr;

@@ -65,0 +73,0 @@ },

@@ -250,5 +250,3 @@ 'use strict';

throw new TypeError(
`The control-block length is too small. Got ${
controlBlock.length
}, expected min 33.`,
`The control-block length is too small. Got ${controlBlock.length}, expected min 33.`,
);

@@ -255,0 +253,0 @@ if ((controlBlock.length - 33) % 32 !== 0)

@@ -21,3 +21,3 @@ /// <reference types="node" />

}
export declare type ValidateSigFunction = (pubkey: Buffer, msghash: Buffer, signature: Buffer) => boolean;
export type ValidateSigFunction = (pubkey: Buffer, msghash: Buffer, signature: Buffer) => boolean;
/**

@@ -129,3 +129,3 @@ * Psbt class can parse and generate a PSBT binary based off of the BIP174.

}
declare type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
interface PsbtOutputExtendedAddress extends PsbtOutput {

@@ -188,3 +188,3 @@ address: string;

*/
declare type FinalScriptsFunc = (inputIndex: number, // Which input is it?
type FinalScriptsFunc = (inputIndex: number, // Which input is it?
input: PsbtInput, // The PSBT input contents

@@ -198,3 +198,3 @@ script: Buffer, // The "meaningful" locking script Buffer (redeemScript for P2SH etc.)

};
declare type FinalTaprootScriptsFunc = (inputIndex: number, // Which input is it?
type FinalTaprootScriptsFunc = (inputIndex: number, // Which input is it?
input: PsbtInput, // The PSBT input contents

@@ -204,3 +204,3 @@ tapLeafHashToFinalize?: Buffer) => {

};
declare type AllScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard' | 'p2sh-witnesspubkeyhash' | 'p2sh-pubkeyhash' | 'p2sh-multisig' | 'p2sh-pubkey' | 'p2sh-nonstandard' | 'p2wsh-pubkeyhash' | 'p2wsh-multisig' | 'p2wsh-pubkey' | 'p2wsh-nonstandard' | 'p2sh-p2wsh-pubkeyhash' | 'p2sh-p2wsh-multisig' | 'p2sh-p2wsh-pubkey' | 'p2sh-p2wsh-nonstandard';
type AllScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard' | 'p2sh-witnesspubkeyhash' | 'p2sh-pubkeyhash' | 'p2sh-multisig' | 'p2sh-pubkey' | 'p2sh-nonstandard' | 'p2wsh-pubkeyhash' | 'p2wsh-multisig' | 'p2wsh-pubkey' | 'p2wsh-nonstandard' | 'p2sh-p2wsh-pubkeyhash' | 'p2sh-p2wsh-multisig' | 'p2sh-p2wsh-pubkey' | 'p2sh-p2wsh-nonstandard';
export {};

@@ -65,2 +65,16 @@ 'use strict';

class Psbt {
static fromBase64(data, opts = {}) {
const buffer = Buffer.from(data, 'base64');
return this.fromBuffer(buffer, opts);
}
static fromHex(data, opts = {}) {
const buffer = Buffer.from(data, 'hex');
return this.fromBuffer(buffer, opts);
}
static fromBuffer(buffer, opts = {}) {
const psbtBase = bip174_1.Psbt.fromBuffer(buffer, transactionFromBuffer);
const psbt = new Psbt(opts, psbtBase);
checkTxForDupeIns(psbt.__CACHE.__TX, psbt.__CACHE);
return psbt;
}
constructor(opts = {}, data = new bip174_1.Psbt(new PsbtTransaction())) {

@@ -95,16 +109,2 @@ this.data = data;

}
static fromBase64(data, opts = {}) {
const buffer = Buffer.from(data, 'base64');
return this.fromBuffer(buffer, opts);
}
static fromHex(data, opts = {}) {
const buffer = Buffer.from(data, 'hex');
return this.fromBuffer(buffer, opts);
}
static fromBuffer(buffer, opts = {}) {
const psbtBase = bip174_1.Psbt.fromBuffer(buffer, transactionFromBuffer);
const psbt = new Psbt(opts, psbtBase);
checkTxForDupeIns(psbt.__CACHE.__TX, psbt.__CACHE);
return psbt;
}
get inputCount() {

@@ -1241,4 +1241,5 @@ return this.data.inputs.length;

// P2WPKH uses the P2PKH template for prevoutScript when signing
const signingScript = payments.p2pkh({ hash: meaningfulScript.slice(2) })
.output;
const signingScript = payments.p2pkh({
hash: meaningfulScript.slice(2),
}).output;
hash = unsignedTx.hashForWitnessV0(

@@ -1245,0 +1246,0 @@ inputIndex,

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.checkTaprootInputForSigs = exports.tapTreeFromList = exports.tapTreeToList = exports.tweakInternalPubKey = exports.checkTaprootOutputFields = exports.checkTaprootInputFields = exports.isTaprootOutput = exports.isTaprootInput = exports.serializeTaprootSignature = exports.tapScriptFinalizer = exports.toXOnly = void 0;
exports.checkTaprootInputForSigs =
exports.tapTreeFromList =
exports.tapTreeToList =
exports.tweakInternalPubKey =
exports.checkTaprootOutputFields =
exports.checkTaprootInputFields =
exports.isTaprootOutput =
exports.isTaprootInput =
exports.serializeTaprootSignature =
exports.tapScriptFinalizer =
exports.toXOnly =
void 0;
const types_1 = require('../types');

@@ -107,4 +118,5 @@ const transaction_1 = require('../transaction');

throw new Error(
`Cannot tweak tap internal key for input #${inputIndex}. Public key: ${tapInternalKey &&
tapInternalKey.toString('hex')}`,
`Cannot tweak tap internal key for input #${inputIndex}. Public key: ${
tapInternalKey && tapInternalKey.toString('hex')
}`,
);

@@ -230,3 +242,4 @@ return outputKey.x;

inputData === newInputData &&
(isTaprootInput(newInputData) && hasNonTaprootFields(newInputData)); // todo: bad? use !===
isTaprootInput(newInputData) &&
hasNonTaprootFields(newInputData); // todo: bad? use !===
if (isBadTaprootUpdate || isBadNonTaprootUpdate || hasMixedFields)

@@ -249,3 +262,4 @@ throw new Error(

inputData === newInputData &&
(isTaprootOutput(newInputData) && hasNonTaprootFields(newInputData));
isTaprootOutput(newInputData) &&
hasNonTaprootFields(newInputData);
if (isBadTaprootUpdate || isBadNonTaprootUpdate || hasMixedFields)

@@ -252,0 +266,0 @@ throw new Error(

@@ -14,3 +14,3 @@ /// <reference types="node" />

export declare function checkInputForSig(input: PsbtInput, action: string): boolean;
declare type SignatureDecodeFunc = (buffer: Buffer) => {
type SignatureDecodeFunc = (buffer: Buffer) => {
signature: Buffer;

@@ -17,0 +17,0 @@ hashType: number;

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.signatureBlocksAction = exports.checkInputForSig = exports.pubkeyInScript = exports.pubkeyPositionInScript = exports.witnessStackToScriptWitness = exports.isP2TR = exports.isP2SHScript = exports.isP2WSHScript = exports.isP2WPKH = exports.isP2PKH = exports.isP2PK = exports.isP2MS = void 0;
exports.signatureBlocksAction =
exports.checkInputForSig =
exports.pubkeyInScript =
exports.pubkeyPositionInScript =
exports.witnessStackToScriptWitness =
exports.isP2TR =
exports.isP2SHScript =
exports.isP2WSHScript =
exports.isP2WPKH =
exports.isP2PKH =
exports.isP2PK =
exports.isP2MS =
void 0;
const varuint = require('bip174/src/lib/converter/varint');

@@ -5,0 +17,0 @@ const bscript = require('../script');

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.signature = exports.number = exports.isCanonicalScriptSignature = exports.isDefinedHashType = exports.isCanonicalPubKey = exports.toStack = exports.fromASM = exports.toASM = exports.decompile = exports.compile = exports.isPushOnly = exports.OPS = void 0;
exports.signature =
exports.number =
exports.isCanonicalScriptSignature =
exports.isDefinedHashType =
exports.isCanonicalPubKey =
exports.toStack =
exports.fromASM =
exports.toASM =
exports.decompile =
exports.compile =
exports.isPushOnly =
exports.OPS =
void 0;
const bip66 = require('./bip66');

@@ -8,3 +20,3 @@ const ops_1 = require('./ops');

enumerable: true,
get: function() {
get: function () {
return ops_1.OPS;

@@ -181,4 +193,3 @@ },

exports.isCanonicalScriptSignature = isCanonicalScriptSignature;
// tslint:disable-next-line variable-name
exports.number = scriptNumber;
exports.signature = scriptSignature;

@@ -28,3 +28,3 @@ /// <reference types="node" />

*/
export declare type Taptree = [Taptree | Tapleaf, Taptree | Tapleaf] | Tapleaf;
export type Taptree = [Taptree | Tapleaf, Taptree | Tapleaf] | Tapleaf;
export declare function isTaptree(scriptTree: any): scriptTree is Taptree;

@@ -31,0 +31,0 @@ export interface TinySecp256k1Interface {

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.oneOf = exports.Null = exports.BufferN = exports.Function = exports.UInt32 = exports.UInt8 = exports.tuple = exports.maybe = exports.Hex = exports.Buffer = exports.String = exports.Boolean = exports.Array = exports.Number = exports.Hash256bit = exports.Hash160bit = exports.Buffer256bit = exports.isTaptree = exports.isTapleaf = exports.TAPLEAF_VERSION_MASK = exports.Network = exports.ECPoint = exports.Satoshi = exports.Signer = exports.BIP32Path = exports.UInt31 = exports.isPoint = exports.typeforce = void 0;
exports.oneOf =
exports.Null =
exports.BufferN =
exports.Function =
exports.UInt32 =
exports.UInt8 =
exports.tuple =
exports.maybe =
exports.Hex =
exports.Buffer =
exports.String =
exports.Boolean =
exports.Array =
exports.Number =
exports.Hash256bit =
exports.Hash160bit =
exports.Buffer256bit =
exports.isTaptree =
exports.isTapleaf =
exports.TAPLEAF_VERSION_MASK =
exports.Network =
exports.ECPoint =
exports.Satoshi =
exports.Signer =
exports.BIP32Path =
exports.UInt31 =
exports.isPoint =
exports.typeforce =
void 0;
const buffer_1 = require('buffer');

@@ -89,6 +117,6 @@ exports.typeforce = require('typeforce');

exports.Hash256bit = exports.typeforce.BufferN(32);
exports.Number = exports.typeforce.Number; // tslint:disable-line variable-name
exports.Number = exports.typeforce.Number;
exports.Array = exports.typeforce.Array;
exports.Boolean = exports.typeforce.Boolean; // tslint:disable-line variable-name
exports.String = exports.typeforce.String; // tslint:disable-line variable-name
exports.Boolean = exports.typeforce.Boolean;
exports.String = exports.typeforce.String;
exports.Buffer = exports.typeforce.Buffer;

@@ -95,0 +123,0 @@ exports.Hex = exports.typeforce.Hex;

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