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 5.1.6 to 5.1.7

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# 5.1.7
__fixed__
- Fixed Transaction class Output interface typing for TypeScript (#1506)
- Add `weight()` to Block class, add optional includeWitness arg to Transaction byteLength method (#1515)
- Match the old TransactionBuilder behavior of allowing for multiple instances of the same pubkey to be in a p2ms script for PSBT (#1519)
__added__
- Allow the API consumer to pass in the finalizer functions to allow for any type of transaction to be finalized. It places the most crucial part of transaction construction on the consumer, and should be used with caution. (#1491)
# 5.1.6

@@ -2,0 +11,0 @@ __fixed__

26

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

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

"build": "npm run clean && tsc -p ./tsconfig.json && npm run formatjs",
"build:tests": "npm run clean:jstests && tsc -p ./test/tsconfig.json",
"clean": "rimraf src types",
"clean:jstests": "rimraf 'test/**/!(ts-node-register)*.js'",
"coverage-report": "npm run build && npm run nobuild:coverage-report",

@@ -30,8 +32,10 @@ "coverage-html": "npm run build && npm run nobuild:coverage-html",

"lint": "tslint -p tsconfig.json -c tslint.json",
"lint:tests": "tslint -p test/tsconfig.json -c tslint.json",
"mocha:ts": "mocha --recursive --require test/ts-node-register",
"nobuild:coverage-report": "nyc report --reporter=lcov",
"nobuild:coverage-html": "nyc report --reporter=html",
"nobuild:coverage": "nyc --check-coverage --branches 90 --functions 90 --lines 90 mocha",
"nobuild:integration": "mocha --timeout 50000 test/integration/",
"nobuild:unit": "mocha",
"prettier": "prettier 'ts_src/**/*.ts' --ignore-path ./.prettierignore",
"nobuild:coverage": "npm run build:tests && nyc --check-coverage --branches 90 --functions 90 --lines 90 mocha && npm run clean:jstests",
"nobuild:integration": "npm run mocha:ts -- --timeout 50000 'test/integration/*.ts'",
"nobuild:unit": "npm run mocha:ts -- 'test/*.ts'",
"prettier": "prettier 'ts_src/**/*.ts' 'test/**/*.ts' --ignore-path ./.prettierignore",
"prettierjs": "prettier 'src/**/*.js' --ignore-path ./.prettierignore",

@@ -50,3 +54,2 @@ "test": "npm run build && npm run format:ci && npm run lint && npm run nobuild:coverage",

"dependencies": {
"@types/node": "10.12.18",
"bech32": "^1.1.2",

@@ -69,3 +72,7 @@ "bip174": "^1.0.1",

"devDependencies": {
"bip39": "^2.3.0",
"@types/bs58": "^4.0.0",
"@types/mocha": "^5.2.7",
"@types/node": "12.7.5",
"@types/proxyquire": "^1.3.28",
"bip39": "^3.0.2",
"bip65": "^1.0.1",

@@ -78,4 +85,4 @@ "bip68": "^1.0.3",

"minimaldata": "^1.0.2",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"mocha": "^6.2.0",
"nyc": "^15.0.0",
"prettier": "1.16.4",

@@ -85,2 +92,3 @@ "proxyquire": "^2.0.1",

"rimraf": "^2.6.3",
"ts-node": "^8.3.0",
"tslint": "^5.16.0",

@@ -87,0 +95,0 @@ "typescript": "3.2.2"

@@ -88,47 +88,38 @@ # BitcoinJS (bitcoinjs-lib)

### Warning: Currently the tests use TransactionBuilder, which will be removed in the future (v6.x.x or higher)
We will move towards replacing all instances of TransactionBuilder in the tests with the new Psbt.
- [Generate a random address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Import an address via WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a 2-of-3 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a SegWit address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a SegWit P2SH address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a SegWit 3-of-4 multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a SegWit 2-of-2 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Support the retrieval of transactions for an address (3rd party blockchain)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a Testnet address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Generate a Litecoin address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.spec.ts)
- [Create a 1-to-1 Transaction](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a typical Transaction](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction with an OP\_RETURN output](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction with a 2-of-4 P2SH(multisig) input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2SH(P2WPKH) input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2WPKH input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2PK input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit 3-of-4 P2SH(P2WSH(multisig)) input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction and sign with an HDSigner interface (bip32)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.spec.ts)
- [Import a BIP32 testnet xpriv and export to WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Export a BIP32 xpriv, then import it](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Export a BIP32 xpub](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Create a BIP32, bitcoin, account 0, external address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Create a BIP44, bitcoin, account 0, external address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Create a BIP49, bitcoin testnet, account 0, external address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Use BIP39 to generate BIP32 addresses](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the past)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the future)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Alice and Bob can redeem the output at any time](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.spec.ts)
- [Create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the future) (simple CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.spec.ts)
- [Create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry (simple CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Bob and Charles can send (complex CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Alice (mediator) and Bob can send after 2 blocks (complex CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.spec.ts)
- [Create (and broadcast via 3PBP) a Transaction where Alice (mediator) can send after 5 blocks (complex CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.spec.ts)
Currently we have a few examples on how to use the newer Psbt class at the following link:
- [Psbt examples](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions-psbt.js)
The rest of the examples are below (using TransactionBuilder for Transaction creation)
- [Generate a random address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Import an address via WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a 2-of-3 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a SegWit address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a SegWit P2SH address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a SegWit 3-of-4 multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a SegWit 2-of-2 P2SH multisig address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Support the retrieval of transactions for an address (3rd party blockchain)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a Testnet address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Generate a Litecoin address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js)
- [Create a 1-to-1 Transaction](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create a 2-to-2 Transaction](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a typical Transaction](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a Transaction with an OP\_RETURN output](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a Transaction with a 2-of-4 P2SH(multisig) input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2SH(P2WPKH) input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2WPKH input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2PK input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit 3-of-4 P2SH(P2WSH(multisig)) input](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Verify a Transaction signature](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/transactions.js)
- [Import a BIP32 testnet xpriv and export to WIF](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Export a BIP32 xpriv, then import it](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Export a BIP32 xpub](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Create a BIP32, bitcoin, account 0, external address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Create a BIP44, bitcoin, account 0, external address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Create a BIP49, bitcoin testnet, account 0, external address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Use BIP39 to generate BIP32 addresses](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the past)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.js)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the future)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.js)
- [Create (and broadcast via 3PBP) a Transaction where Alice and Bob can redeem the output at any time](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.js)
- [Create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/cltv.js)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the future) (simple CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.js)
- [Create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry (simple CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.js)
- [Create (and broadcast via 3PBP) a Transaction where Bob and Charles can send (complex CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.js)
- [Create (and broadcast via 3PBP) a Transaction where Alice (mediator) and Bob can send after 2 blocks (complex CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.js)
- [Create (and broadcast via 3PBP) a Transaction where Alice (mediator) can send after 5 blocks (complex CHECKSEQUENCEVERIFY)](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/csv.js)
If you have a use case that you feel could be listed here, please [ask for it](https://github.com/bitcoinjs/bitcoinjs-lib/issues/new)!

@@ -135,0 +126,0 @@

@@ -130,3 +130,8 @@ 'use strict';

}
byteLength(headersOnly) {
weight() {
const base = this.byteLength(false, false);
const total = this.byteLength(false, true);
return base * 3 + total;
}
byteLength(headersOnly, allowWitness = true) {
if (headersOnly || !this.transactions) return 80;

@@ -136,3 +141,3 @@ return (

varuint.encodingLength(this.transactions.length) +
this.transactions.reduce((a, x) => a + x.byteLength(), 0)
this.transactions.reduce((a, x) => a + x.byteLength(allowWitness), 0)
);

@@ -139,0 +144,0 @@ }

@@ -146,2 +146,13 @@ 'use strict';

addInput(inputData) {
if (
arguments.length > 1 ||
!inputData ||
inputData.hash === undefined ||
inputData.index === undefined
) {
throw new Error(
`Invalid arguments for Psbt.addInput. ` +
`Requires single object with at least [hash] and [index]`,
);
}
checkInputsForPartialSig(this.data.inputs, 'addInput');

@@ -167,2 +178,13 @@ const c = this.__CACHE;

addOutput(outputData) {
if (
arguments.length > 1 ||
!outputData ||
outputData.value === undefined ||
(outputData.address === undefined && outputData.script === undefined)
) {
throw new Error(
`Invalid arguments for Psbt.addOutput. ` +
`Requires single object with at least [script or address] and [value]`,
);
}
checkInputsForPartialSig(this.data.inputs, 'addOutput');

@@ -209,3 +231,3 @@ const { address } = outputData;

}
finalizeInput(inputIndex) {
finalizeInput(inputIndex, finalScriptsFunc = getFinalScripts) {
const input = utils_1.checkForInput(this.data.inputs, inputIndex);

@@ -218,10 +240,7 @@ const { script, isP2SH, isP2WSH, isSegwit } = getScriptFromInput(

if (!script) throw new Error(`No script found for input #${inputIndex}`);
const scriptType = classifyScript(script);
if (!canFinalize(input, script, scriptType))
throw new Error(`Can not finalize input #${inputIndex}`);
checkPartialSigSighashes(input);
const { finalScriptSig, finalScriptWitness } = getFinalScripts(
const { finalScriptSig, finalScriptWitness } = finalScriptsFunc(
inputIndex,
input,
script,
scriptType,
input.partialSig,
isSegwit,

@@ -575,3 +594,3 @@ isP2SH,

const p2ms = payments.p2ms({ output: script });
return hasSigs(p2ms.m, input.partialSig);
return hasSigs(p2ms.m, input.partialSig, p2ms.pubkeys);
default:

@@ -581,6 +600,18 @@ return false;

}
function hasSigs(neededSigs, partialSig) {
function hasSigs(neededSigs, partialSig, pubkeys) {
if (!partialSig) return false;
if (partialSig.length > neededSigs) throw new Error('Too many signatures');
return partialSig.length === neededSigs;
let sigs;
if (pubkeys) {
sigs = pubkeys
.map(pkey => {
const pubkey = ecpair_1.fromPublicKey(pkey, { compressed: true })
.publicKey;
return partialSig.find(pSig => pSig.pubkey.equals(pubkey));
})
.filter(v => !!v);
} else {
sigs = partialSig;
}
if (sigs.length > neededSigs) throw new Error('Too many signatures');
return sigs.length === neededSigs;
}

@@ -747,3 +778,16 @@ function isFinalized(input) {

}
function getFinalScripts(
function getFinalScripts(inputIndex, input, script, isSegwit, isP2SH, isP2WSH) {
const scriptType = classifyScript(script);
if (!canFinalize(input, script, scriptType))
throw new Error(`Can not finalize input #${inputIndex}`);
return prepareFinalScripts(
script,
scriptType,
input.partialSig,
isSegwit,
isP2SH,
isP2WSH,
);
}
function prepareFinalScripts(
script,

@@ -750,0 +794,0 @@ scriptType,

@@ -182,4 +182,4 @@ 'use strict';

weight() {
const base = this.__byteLength(false);
const total = this.__byteLength(true);
const base = this.byteLength(false);
const total = this.byteLength(true);
return base * 3 + total;

@@ -190,4 +190,20 @@ }

}
byteLength() {
return this.__byteLength(true);
byteLength(_ALLOW_WITNESS = true) {
const hasWitnesses = _ALLOW_WITNESS && this.hasWitnesses();
return (
(hasWitnesses ? 10 : 8) +
varuint.encodingLength(this.ins.length) +
varuint.encodingLength(this.outs.length) +
this.ins.reduce((sum, input) => {
return sum + 40 + varSliceSize(input.script);
}, 0) +
this.outs.reduce((sum, output) => {
return sum + 8 + varSliceSize(output.script);
}, 0) +
(hasWitnesses
? this.ins.reduce((sum, input) => {
return sum + vectorSize(input.witness);
}, 0)
: 0)
);
}

@@ -274,3 +290,3 @@ clone() {

// serialize and hash
const buffer = Buffer.allocUnsafe(txTmp.__byteLength(false) + 4);
const buffer = Buffer.allocUnsafe(txTmp.byteLength(false) + 4);
buffer.writeInt32LE(hashType, buffer.length - 4);

@@ -392,23 +408,4 @@ txTmp.__toBuffer(buffer, 0, false);

}
__byteLength(_ALLOW_WITNESS) {
const hasWitnesses = _ALLOW_WITNESS && this.hasWitnesses();
return (
(hasWitnesses ? 10 : 8) +
varuint.encodingLength(this.ins.length) +
varuint.encodingLength(this.outs.length) +
this.ins.reduce((sum, input) => {
return sum + 40 + varSliceSize(input.script);
}, 0) +
this.outs.reduce((sum, output) => {
return sum + 8 + varSliceSize(output.script);
}, 0) +
(hasWitnesses
? this.ins.reduce((sum, input) => {
return sum + vectorSize(input.witness);
}, 0)
: 0)
);
}
__toBuffer(buffer, initialOffset, _ALLOW_WITNESS) {
if (!buffer) buffer = Buffer.allocUnsafe(this.__byteLength(_ALLOW_WITNESS));
__toBuffer(buffer, initialOffset, _ALLOW_WITNESS = false) {
if (!buffer) buffer = Buffer.allocUnsafe(this.byteLength(_ALLOW_WITNESS));
let offset = initialOffset || 0;

@@ -415,0 +412,0 @@ function writeSlice(slice) {

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Network } from './networks';

@@ -3,0 +2,0 @@ export interface Base58CheckResult {

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Transaction } from './transaction';

@@ -19,8 +18,9 @@ export declare class Block {

hasWitness(): boolean;
byteLength(headersOnly: boolean): number;
weight(): number;
byteLength(headersOnly?: boolean, allowWitness?: boolean): number;
getHash(): Buffer;
getId(): string;
getUTCDate(): Date;
toBuffer(headersOnly: boolean): Buffer;
toHex(headersOnly: boolean): string;
toBuffer(headersOnly?: boolean): Buffer;
toHex(headersOnly?: boolean): string;
checkTxRoots(): boolean;

@@ -27,0 +27,0 @@ checkProofOfWork(): boolean;

@@ -1,4 +0,3 @@

/// <reference types="node" />
export declare function readUInt64LE(buffer: Buffer, offset: number): number;
export declare function writeUInt64LE(buffer: Buffer, value: number, offset: number): number;
export declare function reverseBuffer(buffer: Buffer): Buffer;

@@ -1,2 +0,1 @@

/// <reference types="node" />
declare const types: {

@@ -14,4 +13,4 @@ P2MS: string;

declare function classifyOutput(script: Buffer): string;
declare function classifyInput(script: Buffer, allowIncomplete: boolean): string;
declare function classifyWitness(script: Buffer[], allowIncomplete: boolean): string;
declare function classifyInput(script: Buffer, allowIncomplete?: boolean): string;
declare function classifyWitness(script: Buffer[], allowIncomplete?: boolean): string;
export { classifyInput as input, classifyOutput as output, classifyWitness as witness, types, };

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function ripemd160(buffer: Buffer): Buffer;

@@ -3,0 +2,0 @@ export declare function sha1(buffer: Buffer): Buffer;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Network } from './networks';

@@ -3,0 +2,0 @@ interface ECPairOptions {

@@ -17,4 +17,4 @@ import * as bip32 from 'bip32';

export { Network } from './networks';
export { Payment, PaymentOpts, Stack, StackElement } from './payments';
export { Payment, PaymentCreator, PaymentOpts, Stack, StackElement, } from './payments';
export { OpCode } from './script';
export { Input as TxInput, Output as TxOutput } from './transaction';

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Network } from '../networks';

@@ -27,2 +26,3 @@ import { p2data as embed } from './embed';

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

@@ -29,0 +29,0 @@ export interface PaymentOpts {

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Psbt as PsbtBase } from 'bip174';

@@ -62,3 +61,3 @@ import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces';

finalizeAllInputs(): this;
finalizeInput(inputIndex: number): this;
finalizeInput(inputIndex: number, finalScriptsFunc?: FinalScriptsFunc): this;
validateSignaturesOfAllInputs(): boolean;

@@ -129,2 +128,17 @@ validateSignaturesOfInput(inputIndex: number, pubkey?: Buffer): boolean;

}
/**
* This function must do two things:
* 1. Check if the `input` can be finalized. If it can not be finalized, throw.
* ie. `Can not finalize input #${inputIndex}`
* 2. Create the finalScriptSig and finalScriptWitness Buffers.
*/
declare type FinalScriptsFunc = (inputIndex: number, // Which input is it?
input: PsbtInput, // The PSBT input contents
script: Buffer, // The "meaningful" locking script Buffer (redeemScript for P2SH etc.)
isSegwit: boolean, // Is it segwit?
isP2SH: boolean, // Is it P2SH?
isP2WSH: boolean) => {
finalScriptSig: Buffer | undefined;
finalScriptWitness: Buffer | undefined;
};
export {};

@@ -1,3 +0,2 @@

/// <reference types="node" />
export declare function decode(buffer: Buffer, maxLength?: number, minimal?: boolean): number;
export declare function encode(_number: number): Buffer;

@@ -1,2 +0,1 @@

/// <reference types="node" />
interface ScriptSignature {

@@ -3,0 +2,0 @@ signature: Buffer;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from './payments';

@@ -3,0 +2,0 @@ import * as scriptNumber from './script_number';

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from '../../payments';

@@ -3,0 +2,0 @@ export declare function check(script: Buffer | Stack, allowIncomplete?: boolean): boolean;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from '../../payments';

@@ -3,0 +2,0 @@ export declare function check(script: Buffer | Stack, allowIncomplete?: boolean): boolean;

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from '../../payments';

@@ -3,0 +2,0 @@ export declare function check(script: Buffer | Stack): boolean;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from '../../payments';

@@ -3,0 +2,0 @@ export declare function check(script: Buffer | Stack): boolean;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from '../../payments';

@@ -3,0 +2,0 @@ export declare function check(script: Buffer | Stack): boolean;

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>, allowIncomplete?: boolean): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Stack } from '../../payments';

@@ -3,0 +2,0 @@ export declare function check(script: Buffer | Stack): boolean;

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(chunks: Buffer[], allowIncomplete?: boolean): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
export declare function check(script: Buffer | Array<number | Buffer>): boolean;

@@ -3,0 +2,0 @@ export declare namespace check {

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Signer } from './ecpair';

@@ -3,0 +2,0 @@ import { Network } from './networks';

@@ -1,6 +0,1 @@

/// <reference types="node" />
export interface BlankOutput {
script: Buffer;
valueBuffer: Buffer;
}
export interface Output {

@@ -10,3 +5,2 @@ script: Buffer;

}
declare type OpenOutput = Output | BlankOutput;
export interface Input {

@@ -33,3 +27,3 @@ hash: Buffer;

ins: Input[];
outs: OpenOutput[];
outs: Output[];
isCoinbase(): boolean;

@@ -41,3 +35,3 @@ addInput(hash: Buffer, index: number, sequence?: number, scriptSig?: Buffer): number;

virtualSize(): number;
byteLength(): number;
byteLength(_ALLOW_WITNESS?: boolean): number;
clone(): Transaction;

@@ -60,5 +54,3 @@ /**

setWitness(index: number, witness: Buffer[]): void;
private __byteLength;
private __toBuffer;
}
export {};
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