Fix compiler errors, tests, and scripts
This commit is contained in:
parent
e855bde3b3
commit
d684a6b2ef
60 changed files with 145 additions and 57 deletions
11
package.json
11
package.json
|
@ -2,7 +2,7 @@
|
||||||
"name": "bitcoinjs-lib",
|
"name": "bitcoinjs-lib",
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"description": "Client-side Bitcoin JavaScript library",
|
"description": "Client-side Bitcoin JavaScript library",
|
||||||
"main": "./src/index.js",
|
"main": "./dist/src/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.0.0"
|
"node": ">=8.0.0"
|
||||||
},
|
},
|
||||||
|
@ -17,17 +17,18 @@
|
||||||
"coverage-report": "nyc report --reporter=lcov",
|
"coverage-report": "nyc report --reporter=lcov",
|
||||||
"coverage-html": "nyc report --reporter=html",
|
"coverage-html": "nyc report --reporter=html",
|
||||||
"coverage": "nyc --check-coverage --branches 90 --functions 90 mocha",
|
"coverage": "nyc --check-coverage --branches 90 --functions 90 mocha",
|
||||||
"integration": "mocha --timeout 50000 test/integration/",
|
"integration": "npm run build && mocha --timeout 50000 test/integration/",
|
||||||
"standard": "standard",
|
"standard": "standard",
|
||||||
"test": "npm run standard && npm run coverage",
|
"test": "npm run build && npm run standard && npm run coverage",
|
||||||
"unit": "mocha"
|
"unit": "npm run build && mocha",
|
||||||
|
"build": "tsc -p tsconfig.json"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/bitcoinjs/bitcoinjs-lib.git"
|
"url": "https://github.com/bitcoinjs/bitcoinjs-lib.git"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"src"
|
"dist/src"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bech32": "^1.1.2",
|
"bech32": "^1.1.2",
|
||||||
|
|
|
@ -95,3 +95,4 @@ module.exports = {
|
||||||
toBech32: toBech32,
|
toBech32: toBech32,
|
||||||
toOutputScript: toOutputScript
|
toOutputScript: toOutputScript
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -175,3 +175,4 @@ Block.prototype.checkProofOfWork = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Block
|
module.exports = Block
|
||||||
|
export {}
|
||||||
|
|
|
@ -27,3 +27,4 @@ module.exports = {
|
||||||
readUInt64LE: readUInt64LE,
|
readUInt64LE: readUInt64LE,
|
||||||
writeUInt64LE: writeUInt64LE
|
writeUInt64LE: writeUInt64LE
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -68,3 +68,4 @@ module.exports = {
|
||||||
witness: classifyWitness,
|
witness: classifyWitness,
|
||||||
types: types
|
types: types
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -27,3 +27,4 @@ module.exports = {
|
||||||
sha1: sha1,
|
sha1: sha1,
|
||||||
sha256: sha256
|
sha256: sha256
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -104,3 +104,4 @@ module.exports = {
|
||||||
fromPublicKey,
|
fromPublicKey,
|
||||||
fromWIF
|
fromWIF
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -14,3 +14,4 @@ module.exports = {
|
||||||
payments: require('./payments'),
|
payments: require('./payments'),
|
||||||
script: script
|
script: script
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -36,3 +36,4 @@ module.exports = {
|
||||||
wif: 0xef
|
wif: 0xef
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -28,7 +28,10 @@ function p2data (a, opts) {
|
||||||
}, a)
|
}, a)
|
||||||
|
|
||||||
const network = a.network || BITCOIN_NETWORK
|
const network = a.network || BITCOIN_NETWORK
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
data: undefined
|
||||||
|
}
|
||||||
|
|
||||||
lazy.prop(o, 'output', function () {
|
lazy.prop(o, 'output', function () {
|
||||||
if (!a.data) return
|
if (!a.data) return
|
||||||
|
@ -54,3 +57,4 @@ function p2data (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2data
|
module.exports = p2data
|
||||||
|
export {}
|
||||||
|
|
|
@ -10,3 +10,4 @@ module.exports = { embed, p2ms, p2pk, p2pkh, p2sh, p2wpkh, p2wsh }
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// witness commitment
|
// witness commitment
|
||||||
|
export {}
|
||||||
|
|
|
@ -28,3 +28,4 @@ function value (f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { prop, value }
|
module.exports = { prop, value }
|
||||||
|
export {}
|
||||||
|
|
|
@ -42,7 +42,15 @@ function p2ms (a, opts) {
|
||||||
}, a)
|
}, a)
|
||||||
|
|
||||||
const network = a.network || BITCOIN_NETWORK
|
const network = a.network || BITCOIN_NETWORK
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
m: undefined,
|
||||||
|
n: undefined,
|
||||||
|
pubkeys: undefined,
|
||||||
|
output: undefined,
|
||||||
|
input: undefined,
|
||||||
|
signatures: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
let chunks
|
let chunks
|
||||||
let decoded = false
|
let decoded = false
|
||||||
|
@ -129,7 +137,7 @@ function p2ms (a, opts) {
|
||||||
if (a.input[0] !== OPS.OP_0) throw new TypeError('Input is invalid')
|
if (a.input[0] !== OPS.OP_0) throw new TypeError('Input is invalid')
|
||||||
if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature)) throw new TypeError('Input has invalid signature(s)')
|
if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature)) throw new TypeError('Input has invalid signature(s)')
|
||||||
|
|
||||||
if (a.signatures && !stacksEqual(a.signatures.equals(o.signatures))) throw new TypeError('Signature mismatch')
|
if (a.signatures && !stacksEqual(a.signatures.equals(o.signatures), undefined)) throw new TypeError('Signature mismatch')
|
||||||
if (a.m !== undefined && a.m !== a.signatures.length) throw new TypeError('Signature count mismatch')
|
if (a.m !== undefined && a.m !== a.signatures.length) throw new TypeError('Signature count mismatch')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,3 +146,4 @@ function p2ms (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2ms
|
module.exports = p2ms
|
||||||
|
export {}
|
||||||
|
|
|
@ -30,7 +30,12 @@ function p2pk (a, opts) {
|
||||||
const _chunks = lazy.value(function () { return bscript.decompile(a.input) })
|
const _chunks = lazy.value(function () { return bscript.decompile(a.input) })
|
||||||
|
|
||||||
const network = a.network || BITCOIN_NETWORK
|
const network = a.network || BITCOIN_NETWORK
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
input: undefined,
|
||||||
|
pubkey: undefined,
|
||||||
|
signature: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
lazy.prop(o, 'output', function () {
|
lazy.prop(o, 'output', function () {
|
||||||
if (!a.pubkey) return
|
if (!a.pubkey) return
|
||||||
|
@ -78,3 +83,4 @@ function p2pk (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2pk
|
module.exports = p2pk
|
||||||
|
export {}
|
||||||
|
|
|
@ -40,7 +40,12 @@ function p2pkh (a, opts) {
|
||||||
const _chunks = lazy.value(function () { return bscript.decompile(a.input) })
|
const _chunks = lazy.value(function () { return bscript.decompile(a.input) })
|
||||||
|
|
||||||
const network = a.network || BITCOIN_NETWORK
|
const network = a.network || BITCOIN_NETWORK
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
hash: undefined,
|
||||||
|
pubkey: undefined,
|
||||||
|
input: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
lazy.prop(o, 'address', function () {
|
lazy.prop(o, 'address', function () {
|
||||||
if (!o.hash) return
|
if (!o.hash) return
|
||||||
|
@ -135,3 +140,4 @@ function p2pkh (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2pkh
|
module.exports = p2pkh
|
||||||
|
export {}
|
||||||
|
|
|
@ -50,7 +50,12 @@ function p2sh (a, opts) {
|
||||||
network = (a.redeem && a.redeem.network) || BITCOIN_NETWORK
|
network = (a.redeem && a.redeem.network) || BITCOIN_NETWORK
|
||||||
}
|
}
|
||||||
|
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
hash: undefined,
|
||||||
|
redeem: undefined,
|
||||||
|
input: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
const _address = lazy.value(function () {
|
const _address = lazy.value(function () {
|
||||||
const payload = bs58check.decode(a.address)
|
const payload = bs58check.decode(a.address)
|
||||||
|
@ -191,3 +196,4 @@ function p2sh (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2sh
|
module.exports = p2sh
|
||||||
|
export {}
|
||||||
|
|
|
@ -46,7 +46,12 @@ function p2wpkh (a, opts) {
|
||||||
})
|
})
|
||||||
|
|
||||||
const network = a.network || BITCOIN_NETWORK
|
const network = a.network || BITCOIN_NETWORK
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
hash: undefined,
|
||||||
|
pubkey: undefined,
|
||||||
|
witness: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
lazy.prop(o, 'address', function () {
|
lazy.prop(o, 'address', function () {
|
||||||
if (!o.hash) return
|
if (!o.hash) return
|
||||||
|
@ -133,3 +138,4 @@ function p2wpkh (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2wpkh
|
module.exports = p2wpkh
|
||||||
|
export {}
|
||||||
|
|
|
@ -64,7 +64,12 @@ function p2wsh (a, opts) {
|
||||||
network = (a.redeem && a.redeem.network) || BITCOIN_NETWORK
|
network = (a.redeem && a.redeem.network) || BITCOIN_NETWORK
|
||||||
}
|
}
|
||||||
|
|
||||||
const o = { network }
|
const o = {
|
||||||
|
network,
|
||||||
|
hash: undefined,
|
||||||
|
redeem: undefined,
|
||||||
|
witness: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
lazy.prop(o, 'address', function () {
|
lazy.prop(o, 'address', function () {
|
||||||
if (!o.hash) return
|
if (!o.hash) return
|
||||||
|
@ -178,3 +183,4 @@ function p2wsh (a, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = p2wsh
|
module.exports = p2wsh
|
||||||
|
export {}
|
||||||
|
|
|
@ -203,3 +203,4 @@ module.exports = {
|
||||||
isPushOnly: isPushOnly,
|
isPushOnly: isPushOnly,
|
||||||
isDefinedHashType: isDefinedHashType
|
isDefinedHashType: isDefinedHashType
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -65,3 +65,4 @@ module.exports = {
|
||||||
decode: decode,
|
decode: decode,
|
||||||
encode: encode
|
encode: encode
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -62,3 +62,4 @@ module.exports = {
|
||||||
decode: decode,
|
decode: decode,
|
||||||
encode: encode
|
encode: encode
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -2,3 +2,4 @@ module.exports = {
|
||||||
input: require('./input'),
|
input: require('./input'),
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -21,3 +21,4 @@ function check (script, allowIncomplete) {
|
||||||
check.toJSON = function () { return 'multisig input' }
|
check.toJSON = function () { return 'multisig input' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -27,3 +27,4 @@ function check (script, allowIncomplete) {
|
||||||
check.toJSON = function () { return 'multi-sig output' }
|
check.toJSON = function () { return 'multi-sig output' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -12,3 +12,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'null data output' }
|
check.toJSON = function () { return 'null data output' }
|
||||||
|
|
||||||
module.exports = { output: { check: check } }
|
module.exports = { output: { check: check } }
|
||||||
|
export {}
|
||||||
|
|
|
@ -2,3 +2,4 @@ module.exports = {
|
||||||
input: require('./input'),
|
input: require('./input'),
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -13,3 +13,4 @@ check.toJSON = function () { return 'pubKey input' }
|
||||||
module.exports = {
|
module.exports = {
|
||||||
check: check
|
check: check
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -13,3 +13,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'pubKey output' }
|
check.toJSON = function () { return 'pubKey output' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -2,3 +2,4 @@ module.exports = {
|
||||||
input: require('./input'),
|
input: require('./input'),
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -12,3 +12,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'pubKeyHash input' }
|
check.toJSON = function () { return 'pubKeyHash input' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -16,3 +16,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'pubKeyHash output' }
|
check.toJSON = function () { return 'pubKeyHash output' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -2,3 +2,4 @@ module.exports = {
|
||||||
input: require('./input'),
|
input: require('./input'),
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -46,3 +46,4 @@ function check (script, allowIncomplete) {
|
||||||
check.toJSON = function () { return 'scriptHash input' }
|
check.toJSON = function () { return 'scriptHash input' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -14,3 +14,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'scriptHash output' }
|
check.toJSON = function () { return 'scriptHash output' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -40,3 +40,4 @@ module.exports = {
|
||||||
decode: decode,
|
decode: decode,
|
||||||
encode: encode
|
encode: encode
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -2,3 +2,4 @@ module.exports = {
|
||||||
input: require('./input'),
|
input: require('./input'),
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -16,3 +16,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'witnessPubKeyHash input' }
|
check.toJSON = function () { return 'witnessPubKeyHash input' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -15,3 +15,4 @@ check.toJSON = function () { return 'Witness pubKeyHash output' }
|
||||||
module.exports = {
|
module.exports = {
|
||||||
check
|
check
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -2,3 +2,4 @@ module.exports = {
|
||||||
input: require('./input'),
|
input: require('./input'),
|
||||||
output: require('./output')
|
output: require('./output')
|
||||||
}
|
}
|
||||||
|
export {}
|
||||||
|
|
|
@ -37,3 +37,4 @@ function check (chunks, allowIncomplete) {
|
||||||
check.toJSON = function () { return 'witnessScriptHash input' }
|
check.toJSON = function () { return 'witnessScriptHash input' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -13,3 +13,4 @@ function check (script) {
|
||||||
check.toJSON = function () { return 'Witness scriptHash output' }
|
check.toJSON = function () { return 'Witness scriptHash output' }
|
||||||
|
|
||||||
module.exports = { check }
|
module.exports = { check }
|
||||||
|
export {}
|
||||||
|
|
|
@ -138,7 +138,7 @@ Transaction.fromBuffer = function (buffer, __noStrict) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction.fromHex = function (hex) {
|
Transaction.fromHex = function (hex) {
|
||||||
return Transaction.fromBuffer(Buffer.from(hex, 'hex'))
|
return Transaction.fromBuffer(Buffer.from(hex, 'hex'), undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction.isCoinbaseHash = function (buffer) {
|
Transaction.isCoinbaseHash = function (buffer) {
|
||||||
|
@ -490,3 +490,4 @@ Transaction.prototype.setWitness = function (index, witness) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Transaction
|
module.exports = Transaction
|
||||||
|
export {}
|
||||||
|
|
|
@ -102,7 +102,7 @@ function expandInput (scriptSig, witnessStack, type, scriptPubKey) {
|
||||||
const outputType = classify.output(redeem.output)
|
const outputType = classify.output(redeem.output)
|
||||||
let expanded
|
let expanded
|
||||||
if (outputType === SCRIPT_TYPES.P2WPKH) {
|
if (outputType === SCRIPT_TYPES.P2WPKH) {
|
||||||
expanded = expandInput(redeem.input, redeem.witness, outputType)
|
expanded = expandInput(redeem.input, redeem.witness, outputType, undefined)
|
||||||
} else {
|
} else {
|
||||||
expanded = expandInput(bscript.compile(redeem.witness), [], outputType, redeem.output)
|
expanded = expandInput(bscript.compile(redeem.witness), [], outputType, redeem.output)
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ TransactionBuilder.prototype.setVersion = function (version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionBuilder.fromTransaction = function (transaction, network) {
|
TransactionBuilder.fromTransaction = function (transaction, network) {
|
||||||
const txb = new TransactionBuilder(network)
|
const txb = new TransactionBuilder(network, undefined)
|
||||||
|
|
||||||
// Copy transaction fields
|
// Copy transaction fields
|
||||||
txb.setVersion(transaction.version)
|
txb.setVersion(transaction.version)
|
||||||
|
@ -537,11 +537,17 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
|
||||||
const prevTxOut = txHash.toString('hex') + ':' + vout
|
const prevTxOut = txHash.toString('hex') + ':' + vout
|
||||||
if (this.__prevTxSet[prevTxOut] !== undefined) throw new Error('Duplicate TxOut: ' + prevTxOut)
|
if (this.__prevTxSet[prevTxOut] !== undefined) throw new Error('Duplicate TxOut: ' + prevTxOut)
|
||||||
|
|
||||||
let input = {}
|
let input = {
|
||||||
|
value: undefined,
|
||||||
|
prevOutScript: undefined,
|
||||||
|
pubkeys: undefined,
|
||||||
|
signatures: undefined,
|
||||||
|
prevOutType: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
// derive what we can from the scriptSig
|
// derive what we can from the scriptSig
|
||||||
if (options.script !== undefined) {
|
if (options.script !== undefined) {
|
||||||
input = expandInput(options.script, options.witness || [])
|
input = expandInput(options.script, options.witness || [], undefined, undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if an input value was given, retain it
|
// if an input value was given, retain it
|
||||||
|
@ -554,7 +560,7 @@ TransactionBuilder.prototype.__addInputUnsafe = function (txHash, vout, options)
|
||||||
let prevOutType
|
let prevOutType
|
||||||
|
|
||||||
if (!input.pubkeys && !input.signatures) {
|
if (!input.pubkeys && !input.signatures) {
|
||||||
const expanded = expandOutput(options.prevOutScript)
|
const expanded = expandOutput(options.prevOutScript, undefined)
|
||||||
if (expanded.pubkeys) {
|
if (expanded.pubkeys) {
|
||||||
input.pubkeys = expanded.pubkeys
|
input.pubkeys = expanded.pubkeys
|
||||||
input.signatures = expanded.signatures
|
input.signatures = expanded.signatures
|
||||||
|
@ -705,10 +711,10 @@ function signatureHashType (buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionBuilder.prototype.__canModifyInputs = function () {
|
TransactionBuilder.prototype.__canModifyInputs = function () {
|
||||||
return this.__inputs.every(function (input) {
|
return (this.__inputs || []).every(function (input) {
|
||||||
if (!input.signatures) return true
|
if (!input.signatures) return true
|
||||||
|
|
||||||
return input.signatures.every(function (signature) {
|
return (input.signatures || []).every(function (signature) {
|
||||||
if (!signature) return true
|
if (!signature) return true
|
||||||
const hashType = signatureHashType(signature)
|
const hashType = signatureHashType(signature)
|
||||||
|
|
||||||
|
@ -775,3 +781,4 @@ TransactionBuilder.prototype.__overMaximumFees = function (bytes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = TransactionBuilder
|
module.exports = TransactionBuilder
|
||||||
|
export {}
|
||||||
|
|
|
@ -47,3 +47,4 @@ for (var typeName in typeforce) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = types
|
module.exports = types
|
||||||
|
export {}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const baddress = require('../src/address')
|
const baddress = require('../dist/src/address')
|
||||||
const bscript = require('../src/script')
|
const bscript = require('../dist/src/script')
|
||||||
const fixtures = require('./fixtures/address.json')
|
const fixtures = require('./fixtures/address.json')
|
||||||
const NETWORKS = Object.assign({
|
const NETWORKS = Object.assign({
|
||||||
litecoin: {
|
litecoin: {
|
||||||
|
@ -14,7 +14,7 @@ const NETWORKS = Object.assign({
|
||||||
scriptHash: 0x32,
|
scriptHash: 0x32,
|
||||||
wif: 0xb0
|
wif: 0xb0
|
||||||
}
|
}
|
||||||
}, require('../src/networks'))
|
}, require('../dist/src/networks'))
|
||||||
|
|
||||||
describe('address', function () {
|
describe('address', function () {
|
||||||
describe('fromBase58Check', function () {
|
describe('fromBase58Check', function () {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it, beforeEach } = require('mocha')
|
const { describe, it, beforeEach } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const Block = require('../src/block')
|
const Block = require('../dist/src/block')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/block')
|
const fixtures = require('./fixtures/block')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const bufferutils = require('../src/bufferutils')
|
const bufferutils = require('../dist/src/bufferutils')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/bufferutils.json')
|
const fixtures = require('./fixtures/bufferutils.json')
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const bscript = require('../src/script')
|
const bscript = require('../dist/src/script')
|
||||||
const classify = require('../src/classify')
|
const classify = require('../dist/src/classify')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/templates.json')
|
const fixtures = require('./fixtures/templates.json')
|
||||||
|
|
||||||
const multisig = require('../src/templates/multisig')
|
const multisig = require('../dist/src/templates/multisig')
|
||||||
const nullData = require('../src/templates/nulldata')
|
const nullData = require('../dist/src/templates/nulldata')
|
||||||
const pubKey = require('../src/templates/pubkey')
|
const pubKey = require('../dist/src/templates/pubkey')
|
||||||
const pubKeyHash = require('../src/templates/pubkeyhash')
|
const pubKeyHash = require('../dist/src/templates/pubkeyhash')
|
||||||
const scriptHash = require('../src/templates/scripthash')
|
const scriptHash = require('../dist/src/templates/scripthash')
|
||||||
const witnessPubKeyHash = require('../src/templates/witnesspubkeyhash')
|
const witnessPubKeyHash = require('../dist/src/templates/witnesspubkeyhash')
|
||||||
const witnessScriptHash = require('../src/templates/witnessscripthash')
|
const witnessScriptHash = require('../dist/src/templates/witnessscripthash')
|
||||||
const witnessCommitment = require('../src/templates/witnesscommitment')
|
const witnessCommitment = require('../dist/src/templates/witnesscommitment')
|
||||||
|
|
||||||
const tmap = {
|
const tmap = {
|
||||||
pubKey,
|
pubKey,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const bcrypto = require('../src/crypto')
|
const bcrypto = require('../dist/src/crypto')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/crypto')
|
const fixtures = require('./fixtures/crypto')
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@ const assert = require('assert')
|
||||||
const proxyquire = require('proxyquire')
|
const proxyquire = require('proxyquire')
|
||||||
const hoodwink = require('hoodwink')
|
const hoodwink = require('hoodwink')
|
||||||
|
|
||||||
const ECPair = require('../src/ecpair')
|
const ECPair = require('../dist/src/ecpair')
|
||||||
const tinysecp = require('tiny-secp256k1')
|
const tinysecp = require('tiny-secp256k1')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/ecpair.json')
|
const fixtures = require('./fixtures/ecpair.json')
|
||||||
|
|
||||||
const NETWORKS = require('../src/networks')
|
const NETWORKS = require('../dist/src/networks')
|
||||||
const NETWORKS_LIST = [] // Object.values(NETWORKS)
|
const NETWORKS_LIST = [] // Object.values(NETWORKS)
|
||||||
for (let networkName in NETWORKS) {
|
for (let networkName in NETWORKS) {
|
||||||
NETWORKS_LIST.push(NETWORKS[networkName])
|
NETWORKS_LIST.push(NETWORKS[networkName])
|
||||||
|
@ -144,7 +144,7 @@ describe('ECPair', function () {
|
||||||
describe('uses randombytes RNG', function () {
|
describe('uses randombytes RNG', function () {
|
||||||
it('generates a ECPair', function () {
|
it('generates a ECPair', function () {
|
||||||
const stub = { randombytes: function () { return d } }
|
const stub = { randombytes: function () { return d } }
|
||||||
const ProxiedECPair = proxyquire('../src/ecpair', stub)
|
const ProxiedECPair = proxyquire('../dist/src/ecpair', stub)
|
||||||
|
|
||||||
const keyPair = ProxiedECPair.makeRandom()
|
const keyPair = ProxiedECPair.makeRandom()
|
||||||
assert.strictEqual(keyPair.toWIF(), exWIF)
|
assert.strictEqual(keyPair.toWIF(), exWIF)
|
||||||
|
|
|
@ -4,7 +4,7 @@ const u = require('./payments.utils')
|
||||||
|
|
||||||
;['embed', 'p2ms', 'p2pk', 'p2pkh', 'p2sh', 'p2wpkh', 'p2wsh'].forEach(function (p) {
|
;['embed', 'p2ms', 'p2pk', 'p2pkh', 'p2sh', 'p2wpkh', 'p2wsh'].forEach(function (p) {
|
||||||
describe(p, function () {
|
describe(p, function () {
|
||||||
const fn = require('../src/payments/' + p)
|
const fn = require('../dist/src/payments/' + p)
|
||||||
const fixtures = require('./fixtures/' + p)
|
const fixtures = require('./fixtures/' + p)
|
||||||
|
|
||||||
fixtures.valid.forEach(function (f, i) {
|
fixtures.valid.forEach(function (f, i) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const t = require('assert')
|
const t = require('assert')
|
||||||
const bscript = require('../src/script')
|
const bscript = require('../dist/src/script')
|
||||||
const BNETWORKS = require('../src/networks')
|
const BNETWORKS = require('../dist/src/networks')
|
||||||
|
|
||||||
function tryHex (x) {
|
function tryHex (x) {
|
||||||
if (Buffer.isBuffer(x)) return x.toString('hex')
|
if (Buffer.isBuffer(x)) return x.toString('hex')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const bscript = require('../src/script')
|
const bscript = require('../dist/src/script')
|
||||||
const minimalData = require('minimaldata')
|
const minimalData = require('minimaldata')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/script.json')
|
const fixtures = require('./fixtures/script.json')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const scriptNumber = require('../src/script_number')
|
const scriptNumber = require('../dist/src/script_number')
|
||||||
const fixtures = require('./fixtures/script_number.json')
|
const fixtures = require('./fixtures/script_number.json')
|
||||||
|
|
||||||
describe('script-number', function () {
|
describe('script-number', function () {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const bscriptSig = require('../src/script').signature
|
const bscriptSig = require('../dist/src/script').signature
|
||||||
const Buffer = require('safe-buffer').Buffer
|
const Buffer = require('safe-buffer').Buffer
|
||||||
const fixtures = require('./fixtures/signature.json')
|
const fixtures = require('./fixtures/signature.json')
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const { describe, it, beforeEach } = require('mocha')
|
const { describe, it, beforeEach } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const bscript = require('../src/script')
|
const bscript = require('../dist/src/script')
|
||||||
const fixtures = require('./fixtures/transaction')
|
const fixtures = require('./fixtures/transaction')
|
||||||
const Transaction = require('../src/transaction')
|
const Transaction = require('../dist/src/transaction')
|
||||||
|
|
||||||
describe('Transaction', function () {
|
describe('Transaction', function () {
|
||||||
function fromRaw (raw, noWitness) {
|
function fromRaw (raw, noWitness) {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const { describe, it, beforeEach } = require('mocha')
|
const { describe, it, beforeEach } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const baddress = require('../src/address')
|
const baddress = require('../dist/src/address')
|
||||||
const bscript = require('../src/script')
|
const bscript = require('../dist/src/script')
|
||||||
const payments = require('../src/payments')
|
const payments = require('../dist/src/payments')
|
||||||
|
|
||||||
const ECPair = require('../src/ecpair')
|
const ECPair = require('../dist/src/ecpair')
|
||||||
const Transaction = require('../src/transaction')
|
const Transaction = require('../dist/src/transaction')
|
||||||
const TransactionBuilder = require('../src/transaction_builder')
|
const TransactionBuilder = require('../dist/src/transaction_builder')
|
||||||
const NETWORKS = require('../src/networks')
|
const NETWORKS = require('../dist/src/networks')
|
||||||
|
|
||||||
const fixtures = require('./fixtures/transaction_builder')
|
const fixtures = require('./fixtures/transaction_builder')
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const { describe, it } = require('mocha')
|
const { describe, it } = require('mocha')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const types = require('../src/types')
|
const types = require('../dist/src/types')
|
||||||
const typeforce = require('typeforce')
|
const typeforce = require('typeforce')
|
||||||
|
|
||||||
describe('types', function () {
|
describe('types', function () {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
"src/**/*"
|
"src/**/*"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"**/*.spec.ts"
|
"**/*.spec.ts",
|
||||||
|
"node_modules/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue