Skip to content

Commit a57c6d3

Browse files
Updated bitcoinjs-lib to version 4.0.3.
Updated README.md, LICENSE & CHANGELOG.md to reflect version 4.0.3 changes.
1 parent 63d6048 commit a57c6d3

File tree

12 files changed

+182
-75
lines changed

12 files changed

+182
-75
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 4.0.3
2+
__fixed__
3+
- Fixed `TransactionBuilder` to require that the Transaction has outputs before signing (#1151)
4+
- Fixed `payments.p2sh`, which now takes the network from the redeem attribute if one is not given in the object argument (#1232)
5+
- Fixed `Block.calculateTarget` to allow for exponents up to 29 (#1285)
6+
- Fixed some low priority rarely occurring bugs with multisig payments and `TransactionBuilder` multisig processing (#1307)
7+
8+
__added__
9+
- Regtest network object to `networks` (#1261)
10+
111
# 4.0.2
212
__fixed__
313
- Fixed `TransactionBuilder` not throwing when payment type validation should fail (#1195)
@@ -19,7 +29,7 @@ __added__
1929

2030
__changed__
2131
- `ECPair.prototype.sign` now returns a 64-byte signature `Buffer`, not an `ECSignature` object (#1084)
22-
- `ECPair` (and all ECDSA code) now uses [`tiny-secp256k1`](http://github.com/bitcoinjs/tiny-secp256k1), which uses the [`libsecp256k1` library](https://github.com/bitcoin-core/secp256k1) (#1070)
32+
- `ECPair` (and all ECDSA code) now uses [`tiny-secp256k1`](https://github.com/bitcoinjs/tiny-secp256k1), which uses the [`libsecp256k1` library](https://github.com/bitcoin-core/secp256k1) (#1070)
2333
- `TransactionBuilder` internal variables are now `__` prefixed to discourage public usage (#1038)
2434
- `TransactionBuilder` now defaults to version 2 transaction versions (#1036)
2535
- `script.decompile` now returns `[Buffer]` or `null`, if decompilation failed (#1039)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2011-2018 bitcoinjs-lib contributors
3+
Copyright (c) 2011-2019 bitcoinjs-lib contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 88 additions & 43 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rn-bitcoinjs-lib",
3-
"version": "4.0.2-3",
3+
"version": "4.0.3",
44
"description": "Client-side Bitcoin JavaScript library",
55
"main": "./src/index.js",
66
"engines": {
@@ -52,7 +52,7 @@
5252
"bip68": "^1.0.3",
5353
"bn.js": "^4.11.8",
5454
"bs58": "^4.0.0",
55-
"dhttp": "^2.5.0",
55+
"dhttp": "^3.0.0",
5656
"hoodwink": "^2.0.0",
5757
"minimaldata": "^1.0.2",
5858
"mocha": "^5.2.0",
@@ -62,19 +62,23 @@
6262
},
6363
"license": "MIT",
6464
"react-native": {
65+
"crypto": "react-native-crypto",
6566
"_stream_transform": "readable-stream/transform",
6667
"_stream_readable": "readable-stream/readable",
6768
"_stream_writable": "readable-stream/writable",
6869
"_stream_duplex": "readable-stream/duplex",
6970
"_stream_passthrough": "readable-stream/passthrough",
70-
"stream": "stream-browserify"
71+
"stream": "stream-browserify",
72+
"vm": "vm-browserify"
7173
},
7274
"browser": {
75+
"crypto": "react-native-crypto",
7376
"_stream_transform": "readable-stream/transform",
7477
"_stream_readable": "readable-stream/readable",
7578
"_stream_writable": "readable-stream/writable",
7679
"_stream_duplex": "readable-stream/duplex",
7780
"_stream_passthrough": "readable-stream/passthrough",
78-
"stream": "stream-browserify"
81+
"stream": "stream-browserify",
82+
"vm": "vm-browserify"
7983
}
8084
}

src/block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Block.calculateTarget = function (bits) {
145145
const exponent = ((bits & 0xff000000) >> 24) - 3
146146
const mantissa = bits & 0x007fffff
147147
const target = Buffer.alloc(32, 0)
148-
target.writeUInt32BE(mantissa, 28 - exponent)
148+
target.writeUIntBE(mantissa, 29 - exponent, 3)
149149
return target
150150
}
151151

src/classify.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const witnessScriptHash = require('./templates/witnessscripthash')
99
const witnessCommitment = require('./templates/witnesscommitment')
1010

1111
const types = {
12-
MULTISIG: 'multisig',
12+
P2MS: 'multisig',
1313
NONSTANDARD: 'nonstandard',
1414
NULLDATA: 'nulldata',
1515
P2PK: 'pubkey',
@@ -30,7 +30,7 @@ function classifyOutput (script) {
3030
const chunks = decompile(script)
3131
if (!chunks) throw new TypeError('Invalid script')
3232

33-
if (multisig.output.check(chunks)) return types.MULTISIG
33+
if (multisig.output.check(chunks)) return types.P2MS
3434
if (pubKey.output.check(chunks)) return types.P2PK
3535
if (witnessCommitment.output.check(chunks)) return types.WITNESS_COMMITMENT
3636
if (nullData.output.check(chunks)) return types.NULLDATA
@@ -45,7 +45,7 @@ function classifyInput (script, allowIncomplete) {
4545

4646
if (pubKeyHash.input.check(chunks)) return types.P2PKH
4747
if (scriptHash.input.check(chunks, allowIncomplete)) return types.P2SH
48-
if (multisig.input.check(chunks, allowIncomplete)) return types.MULTISIG
48+
if (multisig.input.check(chunks, allowIncomplete)) return types.P2MS
4949
if (pubKey.input.check(chunks)) return types.P2PK
5050

5151
return types.NONSTANDARD

src/ecpair.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { randomBytes } from 'react-native-randombytes'
2-
31
const ecc = require('tiny-secp256k1')
2+
import { randomBytes } from 'react-native-randombytes'
43
const typeforce = require('typeforce')
54
const types = require('./types')
65
const wif = require('wif')

src/networks.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ module.exports = {
1313
scriptHash: 0x05,
1414
wif: 0x80
1515
},
16+
regtest: {
17+
messagePrefix: '\x18Bitcoin Signed Message:\n',
18+
bech32: 'bcrt',
19+
bip32: {
20+
public: 0x043587cf,
21+
private: 0x04358394
22+
},
23+
pubKeyHash: 0x6f,
24+
scriptHash: 0xc4,
25+
wif: 0xef
26+
},
1627
testnet: {
1728
messagePrefix: '\x18Bitcoin Signed Message:\n',
1829
bech32: 'tb',

src/payments/p2ms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function p2ms (a, opts) {
129129
if (a.input[0] !== OPS.OP_0) throw new TypeError('Input is invalid')
130130
if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature)) throw new TypeError('Input has invalid signature(s)')
131131

132-
if (a.signatures && !stacksEqual(a.signatures.equals(o.signatures))) throw new TypeError('Signature mismatch')
132+
if (a.signatures && !stacksEqual(a.signatures, o.signatures)) throw new TypeError('Signature mismatch')
133133
if (a.m !== undefined && a.m !== a.signatures.length) throw new TypeError('Signature count mismatch')
134134
}
135135
}

src/payments/p2sh.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ function p2sh (a, opts) {
4545
witness: typef.maybe(typef.arrayOf(typef.Buffer))
4646
}, a)
4747

48-
const network = a.network || BITCOIN_NETWORK
48+
let network = a.network
49+
if (!network) {
50+
network = (a.redeem && a.redeem.network) || BITCOIN_NETWORK
51+
}
52+
4953
const o = { network }
5054

5155
const _address = lazy.value(function () {

0 commit comments

Comments
 (0)