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

@bitgo/utxo-lib

Package Overview
Dependencies
Maintainers
4
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitgo/utxo-lib - npm Package Compare versions

Comparing version 1.10.0-rc.12 to 1.10.0-rc.13

22

dist/src/bitgo/nonStandardHalfSigned.js

@@ -17,13 +17,8 @@ "use strict";

}
// We only use `txb.build()` on certain legacy v1 SDKs.
// Since native segwit was never enabled in v1 we do not have to worry about p2wsh inputs
// and can focus on p2sh and p2shP2wsh.
if (!input.script) {
throw new Error(`native segwit not supported`);
let decompiledSigScript;
if (input.witness && input.witness.length > 0) {
decompiledSigScript = input.witness;
}
const inputClassification = bscript.classifyInput(input.script, true);
const decompiledSigScript = input.witness.length ? input.witness : bscript.decompile(input.script);
const expectedScriptType = inputClassification === bscript.types.P2SH || inputClassification === bscript.types.P2WSH;
if (!expectedScriptType) {
return;
else {
decompiledSigScript = bscript.decompile(input.script);
}

@@ -37,4 +32,7 @@ // The shape of a non-standard half-signed input is

if (op0 !== opcodes.OP_0 && !(Buffer.isBuffer(op0) && op0.length === 0)) {
throw new Error(`unexpected instruction`);
return;
}
if (bscript.classifyOutput(sigScript) !== bscript.types.MULTISIG) {
return;
}
const paddedSigScript = [

@@ -54,2 +52,2 @@ op0,

exports.padInputScript = padInputScript;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9uU3RhbmRhcmRIYWxmU2lnbmVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JpdGdvL25vblN0YW5kYXJkSGFsZlNpZ25lZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQTs7R0FFRztBQUNILHVDQUF1QztBQUN2QyxxQ0FBcUM7QUFJckM7OztHQUdHO0FBQ0gsU0FBZ0IsY0FBY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10.0-rc.12",
"version": "1.10.0-rc.13",
"description": "Client-side Bitcoin JavaScript library",

@@ -21,11 +21,17 @@ "main": "./dist/src/index.js",

"scripts": {
"prepare": "npm run build",
"build": "tsc --project tsconfig.build.json",
"coverage-report": "nyc report --reporter=lcov",
"coverage-html": "nyc report --reporter=html",
"coverage": "npm run build && BITGO_UTXO_LIB_TEST_EXPECTED_COUNT=3594 nyc --check-coverage --branches 88 --functions 90 mocha",
"integration-test": "mocha test/integration/",
"standard": "standard",
"test": "npm run standard && npm run coverage",
"coverage": "npm run build && nyc --check-coverage mocha",
"test": "npm run coverage",
"unit-test": "mocha"
},
"nyc": {
"include": [
"src/**"
],
"branches": 78,
"functions": 90
},
"repository": {

@@ -41,18 +47,7 @@ "type": "git",

"@bitgo/blake2b": "^3.0.1",
"bech32": "0.0.3",
"bigi": "^1.4.0",
"bip66": "^1.1.0",
"bitcoin-ops": "^1.3.0",
"bitcoinjs-lib": "git+https://github.com/BitGo/bitcoinjs-lib.git#19fd098772",
"bs58check": "^2.0.0",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.3",
"debug": "~3.1.0",
"ecurve": "^1.0.0",
"merkle-lib": "^2.0.10",
"pushdata-bitcoin": "^1.0.1",
"randombytes": "^2.0.1",
"safe-buffer": "^5.0.1",
"typeforce": "^1.11.3",
"varuint-bitcoin": "^1.0.4",
"wif": "^2.0.1"
"varuint-bitcoin": "^1.0.4"
},

@@ -62,20 +57,11 @@ "devDependencies": {

"axios": "^0.21.1",
"bip39": "^2.3.0",
"bip65": "^1.0.1",
"bs58": "^4.0.0",
"dhttp": "^2.4.2",
"debug": "^3.1.0",
"fs-extra": "^9.1.0",
"minimaldata": "^1.0.2",
"mocha": "^8.4.0",
"nyc": "^15.1.0",
"proxyquire": "^1.4.0",
"sinon": "^1.12.2",
"standard": "^9.0.2",
"ts-node": "^9.1.1"
"ts-node": "^9.1.1",
"typescript": "^4.4.3"
},
"license": "MIT",
"optionalDependencies": {
"secp256k1": "^3.5.2"
},
"gitHead": "fce052925597b7ca2e83e233499c8ea2eec06b4b"
"gitHead": "0d3db112db1495986f23e0e12b56c617f5c0bfd7"
}

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

# BitGo UTXO library (bitgo-utxo-lib)
[![Build Status](https://travis-ci.org/BitGo/bitgo-utxo-lib.png?branch=master)](https://travis-ci.org/BitGo/bitgo-utxo-lib)
[![NPM](https://img.shields.io/npm/v/bitgo-utxo-lib.svg)](https://www.npmjs.org/package/bitgo-utxo-lib)
[![Known Vulnerabilities](https://snyk.io/test/github/BitGo/bitgo-utxo-lib/badge.svg?targetFile=package.json)](https://snyk.io/test/github/BitGo/bitgo-utxo-lib?targetFile=package.json)
# BitGo UTXO library
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
This library is a wrapper around [bitcoinjs-lib](https://github.com/bitcoinjs/bitcoinjs-lib) adding altcoin support.
Originally a fork of [bitcoinjs-lib](https://github.com/BitGo/bitcoinjs-lib); we evolved this library to support the transaction building process of different UTXO based coins.
## Supported coins
- Bitcoin
- Bitcoin Cash
- Bitcoin Gold
- Bitcoin SV (Satoshi Vision)
- Dash
- Litecoin
- Zcash (Sapling compatible)
## Features
- Clean: Pure JavaScript, concise code, easy to read.
- Tested: Coverage > 90%, third-party integration tests.
- Compatible: Works on Node.js and all modern browsers.
- Powerful: Support for advanced features, such as multi-sig, HD Wallets.
- Secure: Strong random number generation, PGP signed releases, trusted developers.
- Principled: No support for browsers with RNG (IE < 11)
- Standardized: Node community coding style, Browserify, Node's stdlib and Buffers.
- Experiment-friendly: Mainnet and Testnet support.
- Multicoin support: Configurable behaviour based on [network](https://github.com/BitGo/bitgo-utxo-lib/blob/master/src/networks.js) objects.

@@ -38,112 +16,28 @@ - Backed by [BitGo](https://www.bitgo.com/info/)

### Node.js
``` javascript
var bitGoUTXO = require('@bitgo/utxo-lib')
```typescript
import * as utxolib from '@bitgo/utxo-lib'
```
### Browser
If you're familiar with how to use browserify, ignore this and proceed normally.
These steps are advisory only, and may not be suitable for your application.
[Browserify](https://github.com/substack/node-browserify) is assumed to be installed for these steps.
## Usage
For your project, create an `index.js` file
``` javascript
let bitGoUTXO = require('@bitgo/utxo-lib')
Support for parsing and building altcoin transactions is provided by the following methods
// your code here
function myFunction () {
return bitGoUTXO.ECPair.makeRandom().toWIF()
}
* `utxolib.bitgo.createTransactionFromBuffer(buffer, network): UtxoTransaction` (similarly `createTransactionFromHex(string, network)`)
* `utxolib.bitgo.createTransactionBuilderForNetwork(network): UtxoTransactionBuilder`
* `utxolib.bitgo.createTransactionBuilderFromTransaction(tx): UtxoTransactionBuilder`
module.exports = {
myFunction
}
```
The `UtxoTransaction(Builder)` classes have the same interface as the `Transaction` type in `bitcoinjs-lib` .
Now, to compile for the browser:
``` bash
browserify index.js --standalone foo > app.js
```
## Supported coins
You can now put `<script src="app.js" />` in your web page, using `foo.myFunction` to create a new Bitcoin private key.
|Network|Mainnet|Testnet|
|---|---|---|
|Bitcoin|`utxolib.networks.bitcoin`|`utxolib.networks.testnet`|
|Bitcoin Cash|`utxolib.networks.bitcoincash`|`utxolib.networks.bitcoincashTestnet`|
|Bitcoin Gold|`utxolib.networks.bitcoingold`|`utxolib.networks.bitcoingoldTestnet`|
|Bitcoin SV (Satoshi Vision)|`utxolib.networks.bitcoinsv`|`utxolib.networks.bitcoinsvTestnet`|
|Dash|`utxolib.networks.dash`|`utxolib.networks.dash`|
|Litecoin|`utxolib.networks.litecoin`|`utxolib.networks.litecoinTest`|
|Zcash|`utxolib.networks.zcash`|`utxolib.networks.zcashTest`|
**NOTE**: If you uglify the javascript, you must exclude the following variable names from being mangled: `BigInteger`, `ECPair`, `Point`.
This is because of the function-name-duck-typing used in [typeforce](https://github.com/dcousens/typeforce).
Example:
``` bash
uglifyjs ... --mangle --reserved 'BigInteger,ECPair,Point'
```
**NOTE**: This library tracks Node LTS features, if you need strict ES5, use [`--transform babelify`](https://github.com/babel/babelify) in conjunction with your `browserify` step (using an [`es2015`](http://babeljs.io/docs/plugins/preset-es2015/) preset).
**NOTE**: If you expect this library to run on an iOS 10 device, ensure that you are using [buffer@5.0.5](https://github.com/feross/buffer/pull/155) or greater.
## Examples
The below examples are implemented as integration tests, they should be very easy to understand.
Otherwise, pull requests are appreciated.
Some examples interact (via HTTPS) with a 3rd Party Blockchain Provider (3PBP).
### Bitcoin
- [Generate a random address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L12)
- [Generate an address from a SHA256 hash](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L19)
- [Import an address via WIF](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L29)
- [Generate a 2-of-3 P2SH multisig address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L36)
- [Generate a SegWit address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L50)
- [Generate a SegWit P2SH address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L60)
- [Generate a SegWit 3-of-4 multisig address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L71)
- [Generate a SegWit 2-of-2 P2SH multisig address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L86)
- [Support the retrieval of transactions for an address (3rd party blockchain)](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L100)
- [Generate a Testnet address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L121)
- [Generate a Litecoin address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/addresses.js#L131)
- [Create a 1-to-1 Transaction](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L14)
- [Create a 2-to-2 Transaction](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L28)
- [Create (and broadcast via 3PBP) a typical Transaction](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L46)
- [Create (and broadcast via 3PBP) a Transaction with an OP\_RETURN output](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L88)
- [Create (and broadcast via 3PBP) a Transaction with a 2-of-4 P2SH(multisig) input](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L115)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit P2SH(P2WPKH) input](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L151)
- [Create (and broadcast via 3PBP) a Transaction with a SegWit 3-of-4 P2SH(P2WSH(multisig)) input](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/transactions.js#L183)
- [Import a BIP32 testnet xpriv and export to WIF](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L8)
- [Export a BIP32 xpriv, then import it](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L15)
- [Export a BIP32 xpub](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L26)
- [Create a BIP32, bitcoin, account 0, external address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L35)
- [Create a BIP44, bitcoin, account 0, external address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L50)
- [Create a BIP49, bitcoin testnet, account 0, external address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L66)
- [Use BIP39 to generate BIP32 addresses](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/bip32.js#L83)
- [Create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/cltv.js#L37)
- [Create (and broadcast via 3PBP) a Transaction where Alice and Bob can redeem the output at any time](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/cltv.js#L71)
- [Create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/cltv.js#L104)
- [Recover a private key from duplicate R values](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/crypto.js#L14)
- [Recover a BIP32 parent private key from the parent public key, and a derived, non-hardened child private key](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/crypto.js#L115)
- [Generate a single-key stealth address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/stealth.js#L70:)
- [Generate a single-key stealth address (randomly)](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/stealth.js#L89:)
- [Recover parent recipient.d, if a derived private key is leaked (and nonce was revealed)](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/stealth.js#L105)
- [Generate a dual-key stealth address](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/stealth.js#L122)
- [Generate a dual-key stealth address (randomly)](https://github.com/BitGo/BitGoJS/tree/master/modules/utxo-lib/test/integration/stealth.js#L145)
If you have a use case that you feel could be listed here, please [ask for it](https://github.com/BitGo/bitgo-utxo-lib/issues/new)!
### Running the test suite
``` bash
npm test
npm run-script coverage
```
## Complementing Libraries
- [BIP21](https://github.com/bitcoinjs/bip21) - A BIP21 compatible URL encoding utility library
- [BIP38](https://github.com/bitcoinjs/bip38) - Passphrase-protected private keys
- [BIP39](https://github.com/bitcoinjs/bip39) - Mnemonic generation for deterministic keys
- [BIP32-Utils](https://github.com/bitcoinjs/bip32-utils) - A set of utilities for working with BIP32
- [BIP66](https://github.com/bitcoinjs/bip66) - Strict DER signature decoding
- [BIP69](https://github.com/bitcoinjs/bip69) - Lexicographical Indexing of Transaction Inputs and Outputs
- [Base58](https://github.com/cryptocoinjs/bs58) - Base58 encoding/decoding
- [Base58 Check](https://github.com/bitcoinjs/bs58check) - Base58 check encoding/decoding
- [Bech32](https://github.com/bitcoinjs/bech32) - A BIP173 compliant Bech32 encoding library
- [coinselect](https://github.com/bitcoinjs/coinselect) - A fee-optimizing, transaction input selection module for bitcoinjs-lib.
- [merkle-lib](https://github.com/bitcoinjs/merkle-lib) - A performance conscious library for merkle root and tree calculations.
- [minimaldata](https://github.com/bitcoinjs/minimaldata) - A module to check bitcoin policy: SCRIPT_VERIFY_MINIMALDATA
## LICENSE [MIT](LICENSE)
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