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

@bitgo/bitcoinjs-lib

Package Overview
Dependencies
Maintainers
7
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitgo/bitcoinjs-lib - npm Package Compare versions

Comparing version 7.0.0-rc.0 to 7.0.0-rc.1

10

package.json
{
"name": "@bitgo/bitcoinjs-lib",
"version": "7.0.0-rc.0",
"version": "7.0.0-rc.1",
"description": "Client-side Bitcoin JavaScript library",

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

"nobuild:coverage-html": "nyc report --reporter=html",
"nobuild:coverage": "npm run build:tests && nyc --check-coverage --branches 90 --functions 90 --lines 90 mocha && npm run clean:jstests",
"nobuild:coverage": "npm run build:tests && nyc --check-coverage --branches 89 --functions 90 --lines 90 mocha && npm run clean:jstests",
"nobuild:integration": "npm run mocha:ts -- --timeout 50000 'test/integration/*.ts'",

@@ -54,3 +54,3 @@ "nobuild:unit": "npm run mocha:ts -- 'test/*.ts'",

"bech32": "^2.0.0",
"bip174": "^2.0.1",
"bip174": "npm:@bitgo/bip174@3.0.0",
"bs58check": "^2.1.2",

@@ -82,3 +82,3 @@ "create-hash": "^1.1.0",

"dhttp": "^3.0.0",
"ecpair": "^2.0.1",
"ecpair": "git+https://github.com/brandonblack/ecpair#2fd5696110aa8bba136c5a5240019cd1ced16431",
"hoodwink": "^2.0.0",

@@ -93,3 +93,3 @@ "minimaldata": "^1.0.2",

"rimraf": "^2.6.3",
"tiny-secp256k1": "^2.2.0",
"tiny-secp256k1": "^2.2.1",
"ts-node": "^8.3.0",

@@ -96,0 +96,0 @@ "tslint": "^6.1.3",

@@ -37,2 +37,5 @@ 'use strict';

console.warn(FUTURE_SEGWIT_VERSION_WARNING);
if (!network.bech32) {
throw new TypeError("Network doesn't support native segwit");
}
return toBech32(data, version, network.bech32);

@@ -39,0 +42,0 @@ }

@@ -11,3 +11,3 @@ import * as address from './address';

export { TaggedHashPrefix } from './crypto';
export { Psbt, PsbtTxInput, PsbtTxOutput, Signer, SignerAsync, HDSigner, HDSignerAsync, } from './psbt';
export { Psbt, PsbtTransaction, PsbtTxInput, PsbtTxOutput, Signer, SignerAsync, HDSigner, HDSignerAsync, } from './psbt';
export { OPS as opcodes } from './ops';

@@ -14,0 +14,0 @@ export { Transaction } from './transaction';

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

@@ -32,2 +32,8 @@ exports.address = address;

});
Object.defineProperty(exports, 'PsbtTransaction', {
enumerable: true,
get: function() {
return psbt_1.PsbtTransaction;
},
});
var ops_1 = require('./ops');

@@ -34,0 +40,0 @@ Object.defineProperty(exports, 'opcodes', {

export interface Network {
messagePrefix: string;
bech32: string;
bech32?: string;
bip32: Bip32;

@@ -5,0 +5,0 @@ pubKeyHash: number;

@@ -46,2 +46,5 @@ 'use strict';

const o = { name: 'p2wpkh', network };
if (!network.bech32) {
throw new TypeError("Network doesn't support native segwit");
}
lazy.prop(o, 'address', () => {

@@ -48,0 +51,0 @@ if (!o.hash) return;

@@ -75,2 +75,5 @@ 'use strict';

}
if (!network.bech32) {
throw new TypeError("Network doesn't support native segwit");
}
const o = { network };

@@ -77,0 +80,0 @@ lazy.prop(o, 'address', () => {

/// <reference types="node" />
import { Psbt as PsbtBase } from 'bip174';
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate } from 'bip174/src/lib/interfaces';
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, Transaction as ITransaction } from 'bip174/src/lib/interfaces';
import { Network } from './networks';

@@ -16,3 +16,3 @@ import { Transaction } from './transaction';

script: Buffer;
value: number;
value: bigint;
}

@@ -80,5 +80,5 @@ export interface PsbtTxOutput extends TransactionOutput {

addOutput(outputData: PsbtOutputExtended): this;
extractTransaction(disableFeeCheck?: boolean): Transaction;
extractTransaction(disableFeeCheck?: boolean): Transaction<bigint>;
getFeeRate(): number;
getFee(): number;
getFee(): bigint;
finalizeAllInputs(): this;

@@ -121,7 +121,7 @@ finalizeInput(inputIndex: number, finalScriptsFunc?: FinalScriptsFunc): this;

address: string;
value: number;
value: bigint;
}
interface PsbtOutputExtendedScript extends PsbtOutput {
script: Buffer;
value: number;
value: bigint;
}

@@ -170,2 +170,20 @@ interface HDSignerBase {

/**
* This class implements the Transaction interface from bip174 library.
* It contains a bitcoinjs-lib Transaction object.
*/
export declare class PsbtTransaction implements ITransaction {
tx: Transaction<bigint>;
constructor({ tx, buffer, }?: {
tx?: Transaction<bigint>;
buffer?: Buffer;
});
getInputOutputCounts(): {
inputCount: number;
outputCount: number;
};
addInput(input: any): void;
addOutput(output: any): void;
toBuffer(): Buffer;
}
/**
* This function must do two things:

@@ -172,0 +190,0 @@ * 1. Check if the `input` can be finalized. If it can not be finalized, throw.

'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.Psbt = void 0;
exports.PsbtTransaction = exports.Psbt = void 0;
const bip174_1 = require('bip174');

@@ -259,7 +259,4 @@ const varuint = require('bip174/src/lib/converter/varint');

getFeeRate() {
return getTxCacheValue(
'__FEE_RATE',
'fee rate',
this.data.inputs,
this.__CACHE,
return Number(
getTxCacheValue('__FEE_RATE', 'fee rate', this.data.inputs, this.__CACHE),
);

@@ -620,3 +617,3 @@ }

*/
const transactionFromBuffer = buffer => new PsbtTransaction(buffer);
const transactionFromBuffer = buffer => new PsbtTransaction({ buffer });
/**

@@ -627,4 +624,13 @@ * This class implements the Transaction interface from bip174 library.

class PsbtTransaction {
constructor(buffer = Buffer.from([2, 0, 0, 0, 0, 0, 0, 0, 0, 0])) {
this.tx = transaction_1.Transaction.fromBuffer(buffer);
constructor({ tx, buffer } = {}) {
if (tx !== undefined) {
this.tx = tx;
} else {
buffer = buffer || Buffer.from([2, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
this.tx = transaction_1.Transaction.fromBuffer(
buffer,
undefined,
'bigint',
);
}
checkTxEmpty(this.tx);

@@ -662,3 +668,3 @@ Object.defineProperty(this, 'tx', {

!Buffer.isBuffer(output.script) ||
typeof output.value !== 'number'
typeof output.value !== 'bigint'
) {

@@ -673,2 +679,3 @@ throw new Error('Error adding output.');

}
exports.PsbtTransaction = PsbtTransaction;
function canFinalize(input, script, scriptType) {

@@ -745,8 +752,11 @@ switch (scriptType) {

function checkFees(psbt, cache, opts) {
const feeRate = cache.__FEE_RATE || psbt.getFeeRate();
const feeRate = Number(cache.__FEE_RATE) || psbt.getFeeRate();
const vsize = cache.__EXTRACTED_TX.virtualSize();
const satoshis = feeRate * vsize;
if (feeRate >= opts.maximumFeeRate) {
const satoshis = BigInt(feeRate) * BigInt(vsize);
if (Number(feeRate) >= opts.maximumFeeRate) {
const satoshisPerCoin = BigInt(1e8);
const coinString = (satoshis / satoshisPerCoin).toString();
const satsString = (satoshis % satoshisPerCoin).toString().padStart(8, '0');
throw new Error(
`Warning: You are paying around ${(satoshis / 1e8).toFixed(8)} in ` +
`Warning: You are paying around ${coinString}.${satsString} in ` +
`fees, which is ${feeRate} satoshi per byte for a transaction ` +

@@ -1021,2 +1031,3 @@ `with a VSize of ${vsize} bytes (segwit counted as 0.25 byte per ` +

sighashType,
prevout.value,
);

@@ -1218,3 +1229,7 @@ }

cache.__NON_WITNESS_UTXO_BUF_CACHE[inputIndex] = input.nonWitnessUtxo;
const tx = transaction_1.Transaction.fromBuffer(input.nonWitnessUtxo);
const tx = transaction_1.Transaction.fromBuffer(
input.nonWitnessUtxo,
undefined,
'bigint',
);
cache.__NON_WITNESS_UTXO_TX_CACHE[inputIndex] = tx;

@@ -1243,3 +1258,3 @@ const self = cache;

function inputFinalizeGetAmts(inputs, tx, cache, mustFinalize) {
let inputAmount = 0;
let inputAmount = BigInt(0);
inputs.forEach((input, idx) => {

@@ -1262,3 +1277,3 @@ if (mustFinalize && input.finalScriptSig)

});
const outputAmount = tx.outs.reduce((total, o) => total + o.value, 0);
const outputAmount = tx.outs.reduce((total, o) => total + o.value, BigInt(0));
const fee = inputAmount - outputAmount;

@@ -1271,3 +1286,3 @@ if (fee < 0) {

cache.__EXTRACTED_TX = tx;
cache.__FEE_RATE = Math.floor(fee / bytes);
cache.__FEE_RATE = fee / BigInt(bytes);
}

@@ -1274,0 +1289,0 @@ function nonWitnessUtxoTxFromCache(cache, input, inputIndex) {

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

*/
hashForSignature(inIndex: number, prevOutScript: Buffer, hashType: number): Buffer;
hashForSignature(inIndex: number, prevOutScript: Buffer, hashType: number, prevOutValue?: TNumber): Buffer;
hashForWitnessV1(inIndex: number, prevOutScripts: Buffer[], values: TNumber[], hashType: number, leafHash?: Buffer, annex?: Buffer): Buffer;

@@ -50,0 +50,0 @@ hashForWitnessV0(inIndex: number, prevOutScript: Buffer, value: TNumber, hashType: number): Buffer;

@@ -207,3 +207,9 @@ 'use strict';

*/
hashForSignature(inIndex, prevOutScript, hashType) {
hashForSignature(
inIndex,
prevOutScript,
hashType,
// @ts-expect-error Optional for override in forks
prevOutValue,
) {
typeforce(

@@ -210,0 +216,0 @@ types.tuple(types.UInt32, types.Buffer, /* types.UInt8 */ types.Number),

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