bitcoinjs-lib
Advanced tools
Comparing version 1.3.1 to 1.4.1
{ | ||
"name": "bitcoinjs-lib", | ||
"version": "1.3.1", | ||
"version": "1.4.1", | ||
"description": "Client-side Bitcoin JavaScript library", | ||
@@ -34,31 +34,2 @@ "main": "./src/index.js", | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bitcoinjs/bitcoinjs-lib.git" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^5.12.0", | ||
"bs58": "^2.0.0", | ||
"coveralls": "^2.11.2", | ||
"helloblock-js": "^0.2.5", | ||
"istanbul": "^0.3.2", | ||
"jshint": "^2.5.6", | ||
"mocha": "^1.21.4", | ||
"mocha-lcov-reporter": "0.0.1", | ||
"sinon": "^1.10.3", | ||
"uglify-js": "^2.4.15" | ||
}, | ||
"testling": { | ||
"browsers": [ | ||
"android-browser/4.2..latest", | ||
"chrome/20..latest", | ||
"firefox/21..latest", | ||
"ipad/6..latest", | ||
"iphone/6..latest", | ||
"opera/15..latest", | ||
"safari/latest" | ||
], | ||
"harness": "mocha-bdd", | ||
"files": "test/*.js" | ||
}, | ||
"scripts": { | ||
@@ -73,2 +44,6 @@ "compile": "browserify ./src/index.js -s bitcoin | uglifyjs > bitcoinjs-min.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/bitcoinjs/bitcoinjs-lib.git" | ||
}, | ||
"browser": { | ||
@@ -82,3 +57,15 @@ "crypto": "crypto-browserify" | ||
"ecurve": "1.0.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^5.12.0", | ||
"bs58": "^2.0.0", | ||
"coveralls": "^2.11.2", | ||
"helloblock-js": "^0.2.5", | ||
"istanbul": "^0.3.2", | ||
"jshint": "^2.5.6", | ||
"mocha": "^1.21.4", | ||
"mocha-lcov-reporter": "0.0.1", | ||
"sinon": "^1.10.3", | ||
"uglify-js": "^2.4.15" | ||
} | ||
} |
@@ -9,4 +9,2 @@ # BitcoinJS (bitcoinjs-lib) | ||
[![Browser Support](https://ci.testling.com/bitcoinjs/bitcoinjs-lib.png)](https://ci.testling.com/bitcoinjs/bitcoinjs-lib) | ||
The pure JavaScript Bitcoin library for node.js and browsers. | ||
@@ -71,3 +69,3 @@ A continued implementation of the original `0.1.3` version used by over a million wallet users; the backbone for almost all Bitcoin web wallets in production today. | ||
The below examples are implemented as integration tests, but should be very easy to follow. Pull requests welcome. | ||
The below examples are implemented as integration tests, they should be very easy to understand. Otherwise, pull requests are appreciated. | ||
@@ -101,2 +99,3 @@ - [Generate a random address](https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L8) | ||
- [QuickCoin](https://wallet.quickcoin.co) | ||
- [Robocoin](https://wallet.robocoin.com) | ||
- [Skyhook ATM](http://projectskyhook.com) | ||
@@ -103,0 +102,0 @@ |
@@ -38,8 +38,6 @@ var assert = require('assert') | ||
var type = scripts.classifyOutput(script) | ||
if (scripts.isPubKeyHashOutput(script)) return new Address(script.chunks[2], network.pubKeyHash) | ||
if (scripts.isScriptHashOutput(script)) return new Address(script.chunks[1], network.scriptHash) | ||
if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash) | ||
if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash) | ||
assert(false, type + ' has no matching Address') | ||
assert(false, script.toASM() + ' has no matching Address') | ||
} | ||
@@ -46,0 +44,0 @@ |
@@ -162,2 +162,10 @@ var assert = require('assert') | ||
function varIntBuffer(i) { | ||
var size = varIntSize(i) | ||
var buffer = new Buffer(size) | ||
writeVarInt(buffer, i, 0) | ||
return buffer | ||
} | ||
function reverse(buffer) { | ||
@@ -175,2 +183,3 @@ var buffer2 = new Buffer(buffer) | ||
reverse: reverse, | ||
varIntBuffer: varIntBuffer, | ||
varIntSize: varIntSize, | ||
@@ -177,0 +186,0 @@ writePushDataInt: writePushDataInt, |
@@ -14,17 +14,14 @@ var assert = require('assert') | ||
function findBIP32ParamsByVersion(version) { | ||
function findBIP32NetworkByVersion(version) { | ||
for (var name in networks) { | ||
var network = networks[name] | ||
for (var type in network.bip32) { | ||
if (version != network.bip32[type]) continue | ||
if (version === network.bip32.private || | ||
version === network.bip32.public) { | ||
return { | ||
isPrivate: (type === 'private'), | ||
network: network | ||
} | ||
return network | ||
} | ||
} | ||
assert(false, 'Could not find version ' + version.toString(16)) | ||
assert(false, 'Could not find network for ' + version.toString(16)) | ||
} | ||
@@ -78,8 +75,8 @@ | ||
HDNode.fromBase58 = function(string) { | ||
return HDNode.fromBuffer(base58check.decode(string), true) | ||
HDNode.fromBase58 = function(string, network) { | ||
return HDNode.fromBuffer(base58check.decode(string), network, true) | ||
} | ||
// FIXME: remove in 2.x.y | ||
HDNode.fromBuffer = function(buffer, __ignoreDeprecation) { | ||
HDNode.fromBuffer = function(buffer, network, __ignoreDeprecation) { | ||
if (!__ignoreDeprecation) { | ||
@@ -93,4 +90,11 @@ console.warn('HDNode.fromBuffer() is deprecated for removal in 2.x.y, use fromBase58 instead') | ||
var version = buffer.readUInt32BE(0) | ||
var params = findBIP32ParamsByVersion(version) | ||
if (network) { | ||
assert(version === network.bip32.private || version === network.bip32.public, 'Network doesn\'t match') | ||
// auto-detect | ||
} else { | ||
network = findBIP32NetworkByVersion(version) | ||
} | ||
// 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ... | ||
@@ -115,7 +119,7 @@ var depth = buffer.readUInt8(4) | ||
// 33 bytes: private key data (0x00 + k) | ||
if (params.isPrivate) { | ||
if (version === network.bip32.private) { | ||
assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key') | ||
data = buffer.slice(46, 78) | ||
var d = BigInteger.fromBuffer(data) | ||
hd = new HDNode(d, chainCode, params.network) | ||
hd = new HDNode(d, chainCode, network) | ||
@@ -132,3 +136,3 @@ // 33 bytes: public key data (0x02 + X or 0x03 + X) | ||
hd = new HDNode(Q, chainCode, params.network) | ||
hd = new HDNode(Q, chainCode, network) | ||
} | ||
@@ -144,4 +148,4 @@ | ||
// FIXME: remove in 2.x.y | ||
HDNode.fromHex = function(hex) { | ||
return HDNode.fromBuffer(new Buffer(hex, 'hex')) | ||
HDNode.fromHex = function(hex, network) { | ||
return HDNode.fromBuffer(new Buffer(hex, 'hex'), network) | ||
} | ||
@@ -148,0 +152,0 @@ |
module.exports = { | ||
Address: require('./address'), | ||
base58check: require('./base58check'), | ||
Block: require('./block'), | ||
bufferutils: require('./bufferutils'), | ||
@@ -5,0 +6,0 @@ crypto: require('./crypto'), |
@@ -16,4 +16,3 @@ var bufferutils = require('./bufferutils') | ||
var messageBuffer = new Buffer(message) | ||
var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length)) | ||
bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0) | ||
var lengthBuffer = bufferutils.varIntBuffer(messageBuffer.length) | ||
@@ -20,0 +19,0 @@ var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer]) |
@@ -115,3 +115,3 @@ var assert = require('assert') | ||
function isNulldataOutput(script) { | ||
function isNullDataOutput(script) { | ||
return script.chunks[0] === ops.OP_RETURN | ||
@@ -131,3 +131,3 @@ } | ||
return 'pubkey' | ||
} else if (isNulldataOutput(script)) { | ||
} else if (isNullDataOutput(script)) { | ||
return 'nulldata' | ||
@@ -246,3 +246,3 @@ } | ||
function dataOutput(data) { | ||
function nullDataOutput(data) { | ||
return Script.fromChunks([ops.OP_RETURN, data]) | ||
@@ -252,13 +252,28 @@ } | ||
module.exports = { | ||
isCanonicalPubKey: isCanonicalPubKey, | ||
isCanonicalSignature: isCanonicalSignature, | ||
isPubKeyHashInput: isPubKeyHashInput, | ||
isPubKeyHashOutput: isPubKeyHashOutput, | ||
isPubKeyInput: isPubKeyInput, | ||
isPubKeyOutput: isPubKeyOutput, | ||
isScriptHashInput: isScriptHashInput, | ||
isScriptHashOutput: isScriptHashOutput, | ||
isMultisigInput: isMultisigInput, | ||
isMultisigOutput: isMultisigOutput, | ||
isNullDataOutput: isNullDataOutput, | ||
classifyOutput: classifyOutput, | ||
classifyInput: classifyInput, | ||
classifyOutput: classifyOutput, | ||
dataOutput: dataOutput, | ||
multisigInput: multisigInput, | ||
pubKeyOutput: pubKeyOutput, | ||
pubKeyHashOutput: pubKeyHashOutput, | ||
scriptHashOutput: scriptHashOutput, | ||
multisigOutput: multisigOutput, | ||
pubKeyInput: pubKeyInput, | ||
pubKeyHashInput: pubKeyHashInput, | ||
pubKeyHashOutput: pubKeyHashOutput, | ||
pubKeyInput: pubKeyInput, | ||
pubKeyOutput: pubKeyOutput, | ||
scriptHashInput: scriptHashInput, | ||
scriptHashOutput: scriptHashOutput | ||
multisigInput: multisigInput, | ||
dataOutput: function(data) { | ||
console.warn('dataOutput is deprecated, use nullDataOutput by 2.0.0') | ||
return nullDataOutput(data) | ||
}, | ||
nullDataOutput: nullDataOutput | ||
} |
@@ -23,17 +23,17 @@ var assert = require('assert') | ||
// Extract/add inputs | ||
transaction.ins.forEach(function(txin) { | ||
txb.addInput(txin.hash, txin.index, txin.sequence) | ||
transaction.ins.forEach(function(txIn) { | ||
txb.addInput(txIn.hash, txIn.index, txIn.sequence) | ||
}) | ||
// Extract/add outputs | ||
transaction.outs.forEach(function(txout) { | ||
txb.addOutput(txout.script, txout.value) | ||
transaction.outs.forEach(function(txOut) { | ||
txb.addOutput(txOut.script, txOut.value) | ||
}) | ||
// Extract/add signatures | ||
transaction.ins.forEach(function(txin, i) { | ||
transaction.ins.forEach(function(txIn, i) { | ||
// Ignore empty scripts | ||
if (txin.script.buffer.length === 0) return | ||
if (txIn.script.buffer.length === 0) return | ||
assert(!Array.prototype.every.call(txin.hash, function(x) { | ||
assert(!Array.prototype.every.call(txIn.hash, function(x) { | ||
return x === 0 | ||
@@ -43,3 +43,3 @@ }), 'coinbase inputs not supported') | ||
var redeemScript | ||
var scriptSig = txin.script | ||
var scriptSig = txIn.script | ||
var scriptType = scripts.classifyInput(scriptSig) | ||
@@ -46,0 +46,0 @@ |
@@ -86,3 +86,3 @@ var assert = require('assert') | ||
/** | ||
* Create a new txin. | ||
* Create a new txIn. | ||
* | ||
@@ -126,3 +126,3 @@ * Can be called with any of: | ||
/** | ||
* Create a new txout. | ||
* Create a new txOut. | ||
* | ||
@@ -161,15 +161,15 @@ * Can be called with: | ||
newTx.ins = this.ins.map(function(txin) { | ||
newTx.ins = this.ins.map(function(txIn) { | ||
return { | ||
hash: txin.hash, | ||
index: txin.index, | ||
script: txin.script, | ||
sequence: txin.sequence | ||
hash: txIn.hash, | ||
index: txIn.index, | ||
script: txIn.script, | ||
sequence: txIn.sequence | ||
} | ||
}) | ||
newTx.outs = this.outs.map(function(txout) { | ||
newTx.outs = this.outs.map(function(txOut) { | ||
return { | ||
script: txout.script, | ||
value: txout.value | ||
script: txOut.script, | ||
value: txOut.value | ||
} | ||
@@ -211,4 +211,4 @@ }) | ||
// Blank out other inputs' signatures | ||
txTmp.ins.forEach(function(txin) { | ||
txin.script = Script.EMPTY | ||
txTmp.ins.forEach(function(txIn) { | ||
txIn.script = Script.EMPTY | ||
}) | ||
@@ -287,15 +287,15 @@ txTmp.ins[inIndex].script = hashScript | ||
this.ins.forEach(function(txin) { | ||
writeSlice(txin.hash) | ||
writeUInt32(txin.index) | ||
writeVarInt(txin.script.buffer.length) | ||
writeSlice(txin.script.buffer) | ||
writeUInt32(txin.sequence) | ||
this.ins.forEach(function(txIn) { | ||
writeSlice(txIn.hash) | ||
writeUInt32(txIn.index) | ||
writeVarInt(txIn.script.buffer.length) | ||
writeSlice(txIn.script.buffer) | ||
writeUInt32(txIn.sequence) | ||
}) | ||
writeVarInt(this.outs.length) | ||
this.outs.forEach(function(txout) { | ||
writeUInt64(txout.value) | ||
writeVarInt(txout.script.buffer.length) | ||
writeSlice(txout.script.buffer) | ||
this.outs.forEach(function(txOut) { | ||
writeUInt64(txOut.value) | ||
writeVarInt(txOut.script.buffer.length) | ||
writeSlice(txOut.script.buffer) | ||
}) | ||
@@ -302,0 +302,0 @@ |
@@ -13,7 +13,7 @@ var assert = require('assert') | ||
fixtures.valid.forEach(function(f) { | ||
var hash = new Buffer(f.hex, 'hex') | ||
var hash = new Buffer(f.hash, 'hex') | ||
var addr = new Address(hash, f.version) | ||
assert.equal(addr.version, f.version) | ||
assert.equal(addr.hash.toString('hex'), f.hex) | ||
assert.equal(addr.hash.toString('hex'), f.hash) | ||
}) | ||
@@ -25,7 +25,7 @@ }) | ||
fixtures.valid.forEach(function(f) { | ||
it('imports ' + f.description + '(' + f.network + ') correctly', function() { | ||
it('imports ' + f.script + ' (' + f.network + ') correctly', function() { | ||
var addr = Address.fromBase58Check(f.base58check) | ||
assert.equal(addr.version, f.version) | ||
assert.equal(addr.hash.toString('hex'), f.hex) | ||
assert.equal(addr.hash.toString('hex'), f.hash) | ||
}) | ||
@@ -45,8 +45,8 @@ }) | ||
fixtures.valid.forEach(function(f) { | ||
it('imports ' + f.description + '(' + f.network + ') correctly', function() { | ||
var script = Script.fromHex(f.script) | ||
it('imports ' + f.script + ' (' + f.network + ') correctly', function() { | ||
var script = Script.fromASM(f.script) | ||
var addr = Address.fromOutputScript(script, networks[f.network]) | ||
assert.equal(addr.version, f.version) | ||
assert.equal(addr.hash.toString('hex'), f.hex) | ||
assert.equal(addr.hash.toString('hex'), f.hash) | ||
}) | ||
@@ -57,3 +57,3 @@ }) | ||
it('throws when ' + f.description, function() { | ||
var script = Script.fromHex(f.hex) | ||
var script = Script.fromASM(f.script) | ||
@@ -69,3 +69,3 @@ assert.throws(function() { | ||
fixtures.valid.forEach(function(f) { | ||
it('exports ' + f.description + '(' + f.network + ') correctly', function() { | ||
it('exports ' + f.script + ' (' + f.network + ') correctly', function() { | ||
var addr = Address.fromBase58Check(f.base58check) | ||
@@ -81,7 +81,7 @@ var result = addr.toBase58Check() | ||
fixtures.valid.forEach(function(f) { | ||
it('imports ' + f.description + '(' + f.network + ') correctly', function() { | ||
it('imports ' + f.script + ' (' + f.network + ') correctly', function() { | ||
var addr = Address.fromBase58Check(f.base58check) | ||
var script = addr.toOutputScript() | ||
assert.equal(script.toHex(), f.script) | ||
assert.equal(script.toASM(), f.script) | ||
}) | ||
@@ -92,3 +92,3 @@ }) | ||
it('throws when ' + f.description, function() { | ||
var addr = new Address(new Buffer(f.hex, 'hex'), f.version) | ||
var addr = new Address(new Buffer(f.hash, 'hex'), f.version) | ||
@@ -95,0 +95,0 @@ assert.throws(function() { |
@@ -91,2 +91,12 @@ var assert = require('assert') | ||
describe('varIntBuffer', function() { | ||
fixtures.valid.forEach(function(f) { | ||
it('encodes ' + f.dec + ' correctly', function() { | ||
var buffer = bufferutils.varIntBuffer(f.dec) | ||
assert.equal(buffer.toString('hex'), f.hexVI) | ||
}) | ||
}) | ||
}) | ||
describe('varIntSize', function() { | ||
@@ -103,3 +113,3 @@ fixtures.valid.forEach(function(f) { | ||
describe('writePushDataInt', function() { | ||
fixtures.valid.forEach(function(f, i) { | ||
fixtures.valid.forEach(function(f) { | ||
if (!f.hexPD) return | ||
@@ -106,0 +116,0 @@ |
{ | ||
"valid": [ | ||
{ | ||
"description": "pubKeyHash", | ||
"network": "bitcoin", | ||
"version": 0, | ||
"hex": "751e76e8199196d454941c45d1b3a323f1433bd6", | ||
"hash": "751e76e8199196d454941c45d1b3a323f1433bd6", | ||
"base58check": "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH", | ||
"script": "76a914751e76e8199196d454941c45d1b3a323f1433bd688ac" | ||
"script": "OP_DUP OP_HASH160 751e76e8199196d454941c45d1b3a323f1433bd6 OP_EQUALVERIFY OP_CHECKSIG" | ||
}, | ||
{ | ||
"description": "scriptHash", | ||
"network": "bitcoin", | ||
"version": 5, | ||
"hex": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", | ||
"hash": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", | ||
"base58check": "3LRW7jeCvQCRdPF8S3yUCfRAx4eqXFmdcr", | ||
"script": "a914cd7b44d0b03f2d026d1e586d7ae18903b0d385f687" | ||
"script": "OP_HASH160 cd7b44d0b03f2d026d1e586d7ae18903b0d385f6 OP_EQUAL" | ||
}, | ||
{ | ||
"description": "pubKeyHash", | ||
"network": "testnet", | ||
"version": 111, | ||
"hex": "751e76e8199196d454941c45d1b3a323f1433bd6", | ||
"hash": "751e76e8199196d454941c45d1b3a323f1433bd6", | ||
"base58check": "mrCDrCybB6J1vRfbwM5hemdJz73FwDBC8r", | ||
"script": "76a914751e76e8199196d454941c45d1b3a323f1433bd688ac" | ||
"script": "OP_DUP OP_HASH160 751e76e8199196d454941c45d1b3a323f1433bd6 OP_EQUALVERIFY OP_CHECKSIG" | ||
}, | ||
{ | ||
"description": "scriptHash", | ||
"network": "testnet", | ||
"version": 196, | ||
"hex": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", | ||
"hash": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", | ||
"base58check": "2NByiBUaEXrhmqAsg7BbLpcQSAQs1EDwt5w", | ||
"script": "a914cd7b44d0b03f2d026d1e586d7ae18903b0d385f687" | ||
"script": "OP_HASH160 cd7b44d0b03f2d026d1e586d7ae18903b0d385f6 OP_EQUAL" | ||
} | ||
@@ -51,12 +47,12 @@ ], | ||
{ | ||
"description": "pubkey has no matching Address", | ||
"hex": "21031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95ac" | ||
"description": "has no matching Address", | ||
"script": "031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95 OP_CHECKSIG" | ||
}, | ||
{ | ||
"description": "multisig has no matching Address", | ||
"hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae" | ||
"description": "has no matching Address", | ||
"script": "OP_TRUE 032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca33016 02308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a OP_2 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "nulldata has no matching Address", | ||
"hex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" | ||
"description": "has no matching Address", | ||
"script": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" | ||
} | ||
@@ -67,3 +63,3 @@ ], | ||
"description": "24kPZCmVgzfkpGdXExy56234MRHrsqQxNWE has no matching Script", | ||
"hex": "751e76e8199196d454941c45d1b3a323f1433bd6", | ||
"hash": "751e76e8199196d454941c45d1b3a323f1433bd6", | ||
"version": 153 | ||
@@ -70,0 +66,0 @@ } |
{ | ||
"valid": [ | ||
{ | ||
"network": "bitcoin", | ||
"master": { | ||
@@ -11,3 +12,2 @@ "seed": "000102030405060708090a0b0c0d0e0f", | ||
"hexPriv": "0488ade4000000000000000000873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d50800e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35", | ||
"network": "bitcoin", | ||
"base58": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", | ||
@@ -27,5 +27,2 @@ "base58Priv": "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", | ||
"chainCode": "47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141", | ||
"hex": "0488b21e013442193e8000000047fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56", | ||
"hexPriv": "0488ade4013442193e8000000047fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae623614100edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea", | ||
"network": "bitcoin", | ||
"base58": "xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw", | ||
@@ -43,5 +40,2 @@ "base58Priv": "xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4cV1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7", | ||
"chainCode": "2a7857631386ba23dacac34180dd1983734e444fdbf774041578e9b6adb37c19", | ||
"hex": "0488b21e025c1bd648000000012a7857631386ba23dacac34180dd1983734e444fdbf774041578e9b6adb37c1903501e454bf00751f24b1b489aa925215d66af2234e3891c3b21a52bedb3cd711c", | ||
"hexPriv": "0488ade4025c1bd648000000012a7857631386ba23dacac34180dd1983734e444fdbf774041578e9b6adb37c19003c6cb8d0f6a264c91ea8b5030fadaa8e538b020f0a387421a12de9319dc93368", | ||
"network": "bitcoin", | ||
"base58": "xpub6ASuArnXKPbfEwhqN6e3mwBcDTgzisQN1wXN9BJcM47sSikHjJf3UFHKkNAWbWMiGj7Wf5uMash7SyYq527Hqck2AxYysAA7xmALppuCkwQ", | ||
@@ -60,5 +54,2 @@ "base58Priv": "xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs", | ||
"chainCode": "04466b9cc8e161e966409ca52986c584f07e9dc81f735db683c3ff6ec7b1503f", | ||
"hex": "0488b21e03bef5a2f98000000204466b9cc8e161e966409ca52986c584f07e9dc81f735db683c3ff6ec7b1503f0357bfe1e341d01c69fe5654309956cbea516822fba8a601743a012a7896ee8dc2", | ||
"hexPriv": "0488ade403bef5a2f98000000204466b9cc8e161e966409ca52986c584f07e9dc81f735db683c3ff6ec7b1503f00cbce0d719ecf7431d88e6a89fa1483e02e35092af60c042b1df2ff59fa424dca", | ||
"network": "bitcoin", | ||
"base58": "xpub6D4BDPcP2GT577Vvch3R8wDkScZWzQzMMUm3PWbmWvVJrZwQY4VUNgqFJPMM3No2dFDFGTsxxpG5uJh7n7epu4trkrX7x7DogT5Uv6fcLW5", | ||
@@ -76,5 +67,2 @@ "base58Priv": "xprv9z4pot5VBttmtdRTWfWQmoH1taj2axGVzFqSb8C9xaxKymcFzXBDptWmT7FwuEzG3ryjH4ktypQSAewRiNMjANTtpgP4mLTj34bhnZX7UiM", | ||
"chainCode": "cfb71883f01676f587d023cc53a35bc7f88f724b1f8c2892ac1275ac822a3edd", | ||
"hex": "0488b21e04ee7ab90c00000002cfb71883f01676f587d023cc53a35bc7f88f724b1f8c2892ac1275ac822a3edd02e8445082a72f29b75ca48748a914df60622a609cacfce8ed0e35804560741d29", | ||
"hexPriv": "0488ade404ee7ab90c00000002cfb71883f01676f587d023cc53a35bc7f88f724b1f8c2892ac1275ac822a3edd000f479245fb19a38a1954c5c7c0ebab2f9bdfd96a17563ef28a6a4b1a2a764ef4", | ||
"network": "bitcoin", | ||
"base58": "xpub6FHa3pjLCk84BayeJxFW2SP4XRrFd1JYnxeLeU8EqN3vDfZmbqBqaGJAyiLjTAwm6ZLRQUMv1ZACTj37sR62cfN7fe5JnJ7dh8zL4fiyLHV", | ||
@@ -92,5 +80,2 @@ "base58Priv": "xprvA2JDeKCSNNZky6uBCviVfJSKyQ1mDYahRjijr5idH2WwLsEd4Hsb2Tyh8RfQMuPh7f7RtyzTtdrbdqqsunu5Mm3wDvUAKRHSC34sJ7in334", | ||
"chainCode": "c783e67b921d2beb8f6b389cc646d7263b4145701dadd2161548a8b078e65e9e", | ||
"hex": "0488b21e05d880d7d83b9aca00c783e67b921d2beb8f6b389cc646d7263b4145701dadd2161548a8b078e65e9e022a471424da5e657499d1ff51cb43c47481a03b1e77f951fe64cec9f5a48f7011", | ||
"hexPriv": "0488ade405d880d7d83b9aca00c783e67b921d2beb8f6b389cc646d7263b4145701dadd2161548a8b078e65e9e00471b76e389e528d6de6d816857e012c5455051cad6660850e58372a6c3e6e7c8", | ||
"network": "bitcoin", | ||
"base58": "xpub6H1LXWLaKsWFhvm6RVpEL9P4KfRZSW7abD2ttkWP3SSQvnyA8FSVqNTEcYFgJS2UaFcxupHiYkro49S8yGasTvXEYBVPamhGW6cFJodrTHy", | ||
@@ -105,2 +90,3 @@ "base58Priv": "xprvA41z7zogVVwxVSgdKUHDy1SKmdb533PjDz7J6N6mV6uS3ze1ai8FHa8kmHScGpWmj4WggLyQjgPie1rFSruoUihUZREPSL39UNdE3BBDu76", | ||
{ | ||
"network": "bitcoin", | ||
"master": { | ||
@@ -111,3 +97,2 @@ "seed": "fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542", | ||
"chainCode": "60499f801b896d83179a4374aeb7822aaeaceaa0db1f85ee3e904c4defbd9689", | ||
"network": "bitcoin", | ||
"base58": "xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB", | ||
@@ -128,5 +113,2 @@ "base58Priv": "xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U", | ||
"chainCode": "f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c", | ||
"hex": "0488b21e01bd16bee500000000f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c02fc9e5af0ac8d9b3cecfe2a888e2117ba3d089d8585886c9c826b6b22a98d12ea", | ||
"hexPriv": "0488ade401bd16bee500000000f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c00abe74a98f6c7eabee0428f53798f0ab8aa1bd37873999041703c742f15ac7e1e", | ||
"network": "bitcoin", | ||
"base58": "xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH", | ||
@@ -145,5 +127,2 @@ "base58Priv": "xprv9vHkqa6EV4sPZHYqZznhT2NPtPCjKuDKGY38FBWLvgaDx45zo9WQRUT3dKYnjwih2yJD9mkrocEZXo1ex8G81dwSM1fwqWpWkeS3v86pgKt", | ||
"chainCode": "be17a268474a6bb9c61e1d720cf6215e2a88c5406c4aee7b38547f585c9a37d9", | ||
"hex": "0488b21e025a61ff8effffffffbe17a268474a6bb9c61e1d720cf6215e2a88c5406c4aee7b38547f585c9a37d903c01e7425647bdefa82b12d9bad5e3e6865bee0502694b94ca58b666abc0a5c3b", | ||
"hexPriv": "0488ade4025a61ff8effffffffbe17a268474a6bb9c61e1d720cf6215e2a88c5406c4aee7b38547f585c9a37d900877c779ad9687164e9c2f4f0f4ff0340814392330693ce95a58fe18fd52e6e93", | ||
"network": "bitcoin", | ||
"base58": "xpub6ASAVgeehLbnwdqV6UKMHVzgqAG8Gr6riv3Fxxpj8ksbH9ebxaEyBLZ85ySDhKiLDBrQSARLq1uNRts8RuJiHjaDMBU4Zn9h8LZNnBC5y4a", | ||
@@ -161,5 +140,2 @@ "base58Priv": "xprv9wSp6B7kry3Vj9m1zSnLvN3xH8RdsPP1Mh7fAaR7aRLcQMKTR2vidYEeEg2mUCTAwCd6vnxVrcjfy2kRgVsFawNzmjuHc2YmYRmagcEPdU9", | ||
"chainCode": "f366f48f1ea9f2d1d3fe958c95ca84ea18e4c4ddb9366c336c927eb246fb38cb", | ||
"hex": "0488b21e03d8ab493700000001f366f48f1ea9f2d1d3fe958c95ca84ea18e4c4ddb9366c336c927eb246fb38cb03a7d1d856deb74c508e05031f9895dab54626251b3806e16b4bd12e781a7df5b9", | ||
"hexPriv": "0488ade403d8ab493700000001f366f48f1ea9f2d1d3fe958c95ca84ea18e4c4ddb9366c336c927eb246fb38cb00704addf544a06e5ee4bea37098463c23613da32020d604506da8c0518e1da4b7", | ||
"network": "bitcoin", | ||
"base58": "xpub6DF8uhdarytz3FWdA8TvFSvvAh8dP3283MY7p2V4SeE2wyWmG5mg5EwVvmdMVCQcoNJxGoWaU9DCWh89LojfZ537wTfunKau47EL2dhHKon", | ||
@@ -178,5 +154,2 @@ "base58Priv": "xprv9zFnWC6h2cLgpmSA46vutJzBcfJ8yaJGg8cX1e5StJh45BBciYTRXSd25UEPVuesF9yog62tGAQtHjXajPPdbRCHuWS6T8XA2ECKADdw4Ef", | ||
"chainCode": "637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e29", | ||
"hex": "0488b21e0478412e3afffffffe637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e2902d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0", | ||
"hexPriv": "0488ade40478412e3afffffffe637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e2900f1c7c871a54a804afe328b4c83a1c33b8e5ff48f5087273f04efa83b247d6a2d", | ||
"network": "bitcoin", | ||
"base58": "xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL", | ||
@@ -194,5 +167,2 @@ "base58Priv": "xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc", | ||
"chainCode": "9452b549be8cea3ecb7a84bec10dcfd94afe4d129ebfd3b3cb58eedf394ed271", | ||
"hex": "0488b21e0531a507b8000000029452b549be8cea3ecb7a84bec10dcfd94afe4d129ebfd3b3cb58eedf394ed271024d902e1a2fc7a8755ab5b694c575fce742c48d9ff192e63df5193e4c7afe1f9c", | ||
"hexPriv": "0488ade40531a507b8000000029452b549be8cea3ecb7a84bec10dcfd94afe4d129ebfd3b3cb58eedf394ed27100bb7d39bdb83ecf58f2fd82b6d918341cbef428661ef01ab97c28a4842125ac23", | ||
"network": "bitcoin", | ||
"base58": "xpub6FnCn6nSzZAw5Tw7cgR9bi15UV96gLZhjDstkXXxvCLsUXBGXPdSnLFbdpq8p9HmGsApME5hQTZ3emM2rnY5agb9rXpVGyy3bdW6EEgAtqt", | ||
@@ -205,2 +175,33 @@ "base58Priv": "xprvA2nrNbFZABcdryreWet9Ea4LvTJcGsqrMzxHx98MMrotbir7yrKCEXw7nadnHM8Dq38EGfSh6dqA9QWTyefMLEcBYJUuekgW4BYPJcr9E7j", | ||
] | ||
}, | ||
{ | ||
"network": "litecoin", | ||
"master": { | ||
"seed": "000102030405060708090a0b0c0d0e0f", | ||
"wif": "TAroS5Knm8GZcnpPycBgzjwwDLWMyQjDrcuGPPoArgrbW7Ln22qp", | ||
"pubKey": "0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2", | ||
"chainCode": "873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508", | ||
"hex": "0488b21e000000000000000000873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d5080339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2", | ||
"hexPriv": "019d9cfe000000000000000000873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d50800e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35", | ||
"base58": "Ltub2SSUS19CirucWFod2ZsYA2J4v4U76YiCXHdcQttnoiy5aGanFHCPDBX7utfG6f95u1cUbZJNafmvzNCzZZJTw1EmyFoL8u1gJbGM8ipu491", | ||
"base58Priv": "Ltpv71G8qDifUiNetP6nmxPA5STrUVmv2J9YSmXajv8VsYBUyuPhvN9xCaQrfX2wo5xxJNtEazYCFRUu5FmokYMM79pcqz8pcdo4rNXAFPgyB4k", | ||
"identifier": "3442193e1bb70916e914552172cd4e2dbc9df811", | ||
"fingerprint": "3442193e", | ||
"address": "LPzGaoLUtXFkmNo3u1chDxGxDnSaBQTTxm" | ||
}, | ||
"children": [ | ||
{ | ||
"description": "m/0'", | ||
"m": 0, | ||
"hardened": true, | ||
"wif": "TB22qU2V9EJCVKJ8cdYaTfvDhnYcCzthcWgFm1k6hbvbKM1NLxoL", | ||
"pubKey": "035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56", | ||
"chainCode": "47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141", | ||
"base58": "Ltub2UhtRiSfp82berwLEKkB34QBEt2TUdCDCu4WNzGumvAMwYsxfWjULKsXhADxqy3cuDu3TnqoKJr1xmB8Wb2qzthWAtbb4CutpXPuSU1YMgG", | ||
"base58Priv": "Ltpv73XYpw28ZyVe2zEVyiFnxUZxoKLGQNdZ8NxUi1WcqjNmMBgtLbh3KimGSnPHCoLv1RmvxHs4dnKmo1oXQ8dXuDu8uroxrbVxZPA1gXboYvx", | ||
"identifier": "5c1bd648ed23aa5fd50ba52b2457c11e9e80a6a7", | ||
"fingerprint": "5c1bd648", | ||
"address": "LTcyn1jun6g9hvxtsT7cqMRSyix7AULC76" | ||
} | ||
] | ||
} | ||
@@ -215,4 +216,9 @@ ], | ||
{ | ||
"exception": "Could not find version 0", | ||
"exception": "Could not find network for 0", | ||
"string": "1111111111111adADjFaSNPxwXqLjHLj4mBfYxuewDPbw9hEj1uaXCzMxRPXDFF3cUoezTFYom4sEmEVSQmENPPR315cFk9YUFVek73wE9" | ||
}, | ||
{ | ||
"exception": "Network doesn\\'t match", | ||
"string": "Ltpv73XYpw28ZyVe2zEVyiFnxUZxoKLGQNdZ8NxUi1WcqjNmMBgtLbh3KimGSnPHCoLv1RmvxHs4dnKmo1oXQ8dXuDu8uroxrbVxZPA1gXboYvx", | ||
"network": "bitcoin" | ||
} | ||
@@ -238,3 +244,3 @@ ], | ||
{ | ||
"exception": "Could not find version 22222222", | ||
"exception": "Could not find network for 22222222", | ||
"hex": "222222220000000000000000007ffc03d4a1f2fb41ef93374c69e4d19e42e27c9a87ec8b799a205eecd3b43b5f02948d03e260a571e21bcf5bfd8e3b6602800df154906e06b2bc88eee410aee355" | ||
@@ -241,0 +247,0 @@ }, |
{ | ||
"valid": [ | ||
{ | ||
"description": "when txSize < 1kb", | ||
"network": "bitcoin", | ||
"txSize": 1, | ||
"fee": 10000 | ||
}, | ||
{ | ||
"description": "when txSize >= 1kb", | ||
"network": "bitcoin", | ||
"txSize": 1000, | ||
"fee": 10000 | ||
}, | ||
{ | ||
"description": "rounding", | ||
"network": "bitcoin", | ||
"txSize": 2800, | ||
"fee": 30000 | ||
}, | ||
{ | ||
"description": "when outputs.value > DUST_SOFT_LIMIT, feePerKb is used", | ||
"network": "dogecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 100000000 | ||
"valid": { | ||
"constants": [ | ||
{ | ||
"network": "bitcoin", | ||
"bip32": { | ||
"private": "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", | ||
"public": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8" | ||
} | ||
], | ||
"fee": 100000000 | ||
}, | ||
{ | ||
"description": "when not every outputs.value > DUST_SOFT_LIMIT", | ||
"network": "dogecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 99999999 | ||
}, | ||
{ | ||
"value": 99999999 | ||
}, | ||
{ | ||
"network": "testnet", | ||
"bip32": { | ||
"private": "tprv8ZgxMBicQKsPeDgjzdC36fs6bMjGApWDNLR9erAXMs5skhMv36j9MV5ecvfavji5khqjWaWSFhN3YcCUUdiKH6isR4Pwy3U5y5egddBr16m", | ||
"public": "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp" | ||
} | ||
], | ||
"fee": 300000000 | ||
}, | ||
{ | ||
"description": "rounding", | ||
"network": "dogecoin", | ||
"txSize": 2800, | ||
"fee": 300000000 | ||
}, | ||
{ | ||
"description": "when outputs.value > DUST_SOFT_LIMIT, feePerKb is used", | ||
"network": "litecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 100000 | ||
}, | ||
{ | ||
"network": "litecoin", | ||
"bip32": { | ||
"private": "Ltpv71G8qDifUiNetP6nmxPA5STrUVmv2J9YSmXajv8VsYBUyuPhvN9xCaQrfX2wo5xxJNtEazYCFRUu5FmokYMM79pcqz8pcdo4rNXAFPgyB4k", | ||
"public": "Ltub2SSUS19CirucWFod2ZsYA2J4v4U76YiCXHdcQttnoiy5aGanFHCPDBX7utfG6f95u1cUbZJNafmvzNCzZZJTw1EmyFoL8u1gJbGM8ipu491" | ||
} | ||
], | ||
"fee": 100000 | ||
}, | ||
{ | ||
"description": "when not every outputs.value > DUST_SOFT_LIMIT", | ||
"network": "litecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 99999 | ||
}, | ||
{ | ||
"value": 99999 | ||
}, | ||
{ | ||
"network": "dogecoin", | ||
"bip32": { | ||
"private": "dgpv51eADS3spNJh9Gjth94XcPwAczvQaDJs9rqx11kvxKs6r3Ek8AgERHhjLs6mzXQFHRzQqGwqdeoDkZmr8jQMBfi43b7sT3sx3cCSk5fGeUR", | ||
"public": "dgub8kXBZ7ymNWy2S8Q3jNgVjFUm5ZJ3QLLaSTdAA89ukSv7Q6MSXwE14b7Nv6eDpE9JJXinTKc8LeLVu19uDPrm5uJuhpKNzV2kAgncwo6bNpP" | ||
} | ||
], | ||
"fee": 300000 | ||
}, | ||
{ | ||
"description": "rounding", | ||
"network": "litecoin", | ||
"txSize": 2800, | ||
"fee": 300000 | ||
} | ||
] | ||
}, | ||
{ | ||
"network": "viacoin", | ||
"bip32": { | ||
"private": "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", | ||
"public": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8" | ||
} | ||
}, | ||
{ | ||
"network": "viacointestnet", | ||
"bip32": { | ||
"private": "tprv8ZgxMBicQKsPeDgjzdC36fs6bMjGApWDNLR9erAXMs5skhMv36j9MV5ecvfavji5khqjWaWSFhN3YcCUUdiKH6isR4Pwy3U5y5egddBr16m", | ||
"public": "tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp" | ||
} | ||
}, | ||
{ | ||
"network": "gamerscoin", | ||
"bip32": { | ||
"private": "Ltpv71G8qDifUiNetP6nmxPA5STrUVmv2J9YSmXajv8VsYBUyuPhvN9xCaQrfX2wo5xxJNtEazYCFRUu5FmokYMM79pcqz8pcdo4rNXAFPgyB4k", | ||
"public": "Ltub2SSUS19CirucWFod2ZsYA2J4v4U76YiCXHdcQttnoiy5aGanFHCPDBX7utfG6f95u1cUbZJNafmvzNCzZZJTw1EmyFoL8u1gJbGM8ipu491" | ||
} | ||
}, | ||
{ | ||
"network": "jumbucks", | ||
"bip32": { | ||
"private": "jprv5eCacBgN4Bz4zYxgVQ7RDt1a3eREhEaj8KjAcJ7YwogxGo2rmBF5kvAQS53JwZpo5wnUmJ9Q7kB6b2gQ1MzC6yaTc188hr6hXZ5t8Ruria1", | ||
"public": "jpub1sBw1hDFtZYND339bReRb1xJbgFj6hJaVYemQgXAW9Dw9bN1JiZLJiUtHLgcTTEs1UgRGFAYm3XQPYsYJbpqj1aYPhrMsNcJHfgdAhvFZBB" | ||
} | ||
}, | ||
{ | ||
"network": "zetacoin", | ||
"bip32": { | ||
"private": "xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi", | ||
"public": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8" | ||
} | ||
} | ||
], | ||
"estimateFee": [ | ||
{ | ||
"description": "when txSize < 1kb", | ||
"network": "bitcoin", | ||
"txSize": 1, | ||
"fee": 10000 | ||
}, | ||
{ | ||
"description": "when txSize >= 1kb", | ||
"network": "bitcoin", | ||
"txSize": 1000, | ||
"fee": 10000 | ||
}, | ||
{ | ||
"description": "rounding", | ||
"network": "bitcoin", | ||
"txSize": 2800, | ||
"fee": 30000 | ||
}, | ||
{ | ||
"description": "when outputs.value > DUST_SOFT_LIMIT, feePerKb is used", | ||
"network": "dogecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 100000000 | ||
} | ||
], | ||
"fee": 100000000 | ||
}, | ||
{ | ||
"description": "when not every outputs.value > DUST_SOFT_LIMIT", | ||
"network": "dogecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 99999999 | ||
}, | ||
{ | ||
"value": 99999999 | ||
} | ||
], | ||
"fee": 300000000 | ||
}, | ||
{ | ||
"description": "rounding", | ||
"network": "dogecoin", | ||
"txSize": 2800, | ||
"fee": 300000000 | ||
}, | ||
{ | ||
"description": "when outputs.value > DUST_SOFT_LIMIT, feePerKb is used", | ||
"network": "litecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 100000 | ||
} | ||
], | ||
"fee": 100000 | ||
}, | ||
{ | ||
"description": "when not every outputs.value > DUST_SOFT_LIMIT", | ||
"network": "litecoin", | ||
"txSize": 1000, | ||
"outputs": [ | ||
{ | ||
"value": 99999 | ||
}, | ||
{ | ||
"value": 99999 | ||
} | ||
], | ||
"fee": 300000 | ||
}, | ||
{ | ||
"description": "rounding", | ||
"network": "litecoin", | ||
"txSize": 2800, | ||
"fee": 300000 | ||
} | ||
] | ||
} | ||
} |
@@ -59,75 +59,68 @@ { | ||
"invalid": { | ||
"classify": [ | ||
"isPubKeyHashInput": [ | ||
{ | ||
"description": "multisig output : OP_CHECKMULTISIG not found", | ||
"description": "pubKeyHash input : extraneous data", | ||
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 ffffffff" | ||
} | ||
], | ||
"isScriptHashInput": [ | ||
{ | ||
"description": "redeemScript not data", | ||
"scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 OP_RESERVED" | ||
} | ||
], | ||
"isPubKeyInput": [ | ||
{ | ||
"description": "non-canonical signature", | ||
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf7593ffffffffffffffff" | ||
} | ||
], | ||
"isMultisigOutput": [ | ||
{ | ||
"description": "OP_CHECKMULTISIG not found", | ||
"scriptPubKey": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_HASH160" | ||
}, | ||
{ | ||
"description": "multisig output : less than 4 chunks", | ||
"description": "less than 4 chunks", | ||
"scriptPubKey": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 OP_HASH160" | ||
}, | ||
{ | ||
"description": "multisig output : m === 0", | ||
"description": "m === 0", | ||
"scriptPubKey": "OP_0 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : m < OP_1", | ||
"description": "m < OP_1", | ||
"scriptPubKey": "OP_1NEGATE 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : m > OP_16", | ||
"description": "m > OP_16", | ||
"scriptPubKey": "OP_NOP 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_2 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : n === 0", | ||
"description": "n === 0", | ||
"scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_0 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : n < OP_1", | ||
"description": "n < OP_1", | ||
"scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_1NEGATE OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : n > OP_16", | ||
"description": "n > OP_16", | ||
"scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_NOP OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : n < m", | ||
"description": "n < m", | ||
"scriptPubKey": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 OP_1 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : n < len(pubKeys)", | ||
"description": "n < len(pubKeys)", | ||
"scriptPubKey": "OP_2 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02b80011a883a0fd621ad46dfc405df1e74bf075cbaf700fd4aebef6e96f848340 024289801366bcee6172b771cf5a7f13aaecd237a0b9a1ff9d769cabc2e6b70a34 OP_2 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "multisig output : non-canonical pubKey (bad length)", | ||
"description": "non-canonical pubKey (bad length)", | ||
"scriptPubKey": "OP_1 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ffff OP_1 OP_CHECKMULTISIG" | ||
}, | ||
{ | ||
"description": "pubKeyHash input : extraneous data", | ||
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 ffffffff" | ||
}, | ||
{ | ||
"description": "scriptHash input : redeemScript not data", | ||
"scriptSig": "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 OP_RESERVED" | ||
}, | ||
{ | ||
"description": "pubKey input : non-canonical signature", | ||
"scriptSig": "304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf7593ffffffffffffffff" | ||
} | ||
], | ||
"multisig": [ | ||
"multisigInput": [ | ||
{ | ||
"exception": "Not enough pubKeys provided", | ||
"m": 4, | ||
"pubKeys": [ | ||
"02ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f", | ||
"02fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f", | ||
"036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e19" | ||
], | ||
"signatures": [ | ||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" | ||
], | ||
"scriptPubKey": true | ||
}, | ||
{ | ||
"exception": "Not enough signatures provided", | ||
@@ -140,4 +133,3 @@ "pubKeys": [ | ||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" | ||
], | ||
"scriptPubKey": false | ||
] | ||
}, | ||
@@ -154,4 +146,17 @@ { | ||
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501" | ||
] | ||
} | ||
], | ||
"multisigOutput": [ | ||
{ | ||
"exception": "Not enough pubKeys provided", | ||
"m": 4, | ||
"pubKeys": [ | ||
"02ea1297665dd733d444f31ec2581020004892cdaaf3dd6c0107c615afb839785f", | ||
"02fab2dea1458990793f56f42e4a47dbf35a12a351f26fa5d7e0cc7447eaafa21f", | ||
"036c6802ce7e8113723dd92cdb852e492ebb157a871ca532c3cb9ed08248ff0e19" | ||
], | ||
"scriptPubKey": false | ||
"signatures": [ | ||
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801" | ||
] | ||
} | ||
@@ -158,0 +163,0 @@ ] |
@@ -68,5 +68,6 @@ var assert = require('assert') | ||
it('calculates privKey and chainCode for ' + f.master.fingerprint, function() { | ||
var hd = HDNode.fromSeedHex(f.master.seed) | ||
var network = networks[f.network] | ||
var hd = HDNode.fromSeedHex(f.master.seed, network) | ||
assert.equal(hd.privKey.toWIF(), f.master.wif) | ||
assert.equal(hd.privKey.toWIF(network), f.master.wif) | ||
assert.equal(hd.chainCode.toString('hex'), f.master.chainCode) | ||
@@ -92,3 +93,4 @@ }) | ||
it('exports ' + f.master.base58 + ' (public) correctly', function() { | ||
var hd = HDNode.fromSeedHex(f.master.seed).neutered() | ||
var network = networks[f.network] | ||
var hd = HDNode.fromSeedHex(f.master.seed, network).neutered() | ||
@@ -101,3 +103,4 @@ assert.equal(hd.toBase58(), f.master.base58) | ||
it('exports ' + f.master.base58Priv + ' (private) correctly', function() { | ||
var hd = HDNode.fromSeedHex(f.master.seed) | ||
var network = networks[f.network] | ||
var hd = HDNode.fromSeedHex(f.master.seed, network) | ||
@@ -138,3 +141,5 @@ assert.equal(hd.toBase58(), f.master.base58Priv) | ||
assert.throws(function() { | ||
HDNode.fromBase58(f.string) | ||
var network = networks[f.network] | ||
HDNode.fromBase58(f.string, network) | ||
}, new RegExp(f.exception)) | ||
@@ -182,3 +187,4 @@ }) | ||
it('exports ' + f.master.hexPriv + ' (private) correctly', function() { | ||
var hd = HDNode.fromSeedHex(f.master.seed) | ||
var network = networks[f.network] | ||
var hd = HDNode.fromSeedHex(f.master.seed, network) | ||
@@ -220,16 +226,9 @@ assert.equal(hd.toHex(), f.master.hexPriv) | ||
describe('getAddress', function() { | ||
var f = fixtures.valid[0] | ||
fixtures.valid.forEach(function(f) { | ||
it('returns ' + f.master.address + ' for ' + f.master.fingerprint, function() { | ||
var hd = HDNode.fromBase58(f.master.base58) | ||
it('returns the Address (pubHash) for ' + f.master.fingerprint, function() { | ||
var hd = HDNode.fromBase58(f.master.base58) | ||
assert.equal(hd.getAddress().toString(), f.master.address) | ||
assert.equal(hd.getAddress().toString(), f.master.address) | ||
}) | ||
}) | ||
it('supports alternative networks', function() { | ||
var hd = HDNode.fromBase58(f.master.base58) | ||
hd.network = networks.testnet | ||
assert.equal(hd.getAddress().version, networks.testnet.pubKeyHash) | ||
}) | ||
}) | ||
@@ -253,4 +252,4 @@ | ||
describe('derive', function() { | ||
function verifyVector(hd, v, depth) { | ||
assert.equal(hd.privKey.toWIF(), v.wif) | ||
function verifyVector(hd, network, v, depth) { | ||
assert.equal(hd.privKey.toWIF(network), v.wif) | ||
assert.equal(hd.pubKey.toHex(), v.pubKey) | ||
@@ -267,4 +266,5 @@ assert.equal(hd.chainCode.toString('hex'), v.chainCode) | ||
fixtures.valid.forEach(function(f, j) { | ||
var hd = HDNode.fromSeedHex(f.master.seed) | ||
fixtures.valid.forEach(function(f) { | ||
var network = networks[f.network] | ||
var hd = HDNode.fromSeedHex(f.master.seed, network) | ||
@@ -281,3 +281,3 @@ // FIXME: test data is only testing Private -> private for now | ||
verifyVector(hd, c, i + 1) | ||
verifyVector(hd, network, c, i + 1) | ||
}) | ||
@@ -284,0 +284,0 @@ }) |
@@ -81,3 +81,3 @@ var assert = require('assert') | ||
var data = new Buffer('cafedeadbeef', 'hex') | ||
var dataScript = bitcoin.scripts.dataOutput(data) | ||
var dataScript = bitcoin.scripts.nullDataOutput(data) | ||
@@ -84,0 +84,0 @@ tx.addInput(unspent.txHash, unspent.index) |
var assert = require('assert') | ||
var networks = require('../src/networks') | ||
var sinon = require('sinon') | ||
var HDNode = require('../src/hdnode') | ||
var Transaction = require('../src/transaction') | ||
@@ -18,15 +20,31 @@ | ||
fixtures.valid.forEach(function(f) { | ||
describe(f.network + ' estimateFee', function() { | ||
describe('constants', function() { | ||
fixtures.valid.constants.forEach(function(f) { | ||
var network = networks[f.network] | ||
it('calculates the fee correctly for ' + f.description, function() { | ||
var buffer = new Buffer(f.txSize) | ||
txToBuffer.returns(buffer) | ||
Object.keys(f.bip32).forEach(function(name) { | ||
var extb58 = f.bip32[name] | ||
var estimateFee = network.estimateFee | ||
var tx = new Transaction() | ||
tx.outs = f.outputs || [] | ||
it('resolves ' + extb58 + ' to ' + f.network, function() { | ||
assert.equal(HDNode.fromBase58(extb58, network).network, network) | ||
}) | ||
}) | ||
}) | ||
}) | ||
assert.equal(estimateFee(tx), f.fee) | ||
describe('estimateFee', function() { | ||
fixtures.valid.estimateFee.forEach(function(f) { | ||
describe('(' + f.network + ')', function() { | ||
var network = networks[f.network] | ||
it('calculates the fee correctly for ' + f.description, function() { | ||
var buffer = new Buffer(f.txSize) | ||
txToBuffer.returns(buffer) | ||
var estimateFee = network.estimateFee | ||
var tx = new Transaction() | ||
tx.outs = f.outputs || [] | ||
assert.equal(estimateFee(tx), f.fee) | ||
}) | ||
}) | ||
@@ -33,0 +51,0 @@ }) |
var assert = require('assert') | ||
var scripts = require('../src/scripts') | ||
var Address = require('../src/address') | ||
var ECPubKey = require('../src/ecpubkey') | ||
@@ -11,2 +10,6 @@ var Script = require('../src/script') | ||
describe('Scripts', function() { | ||
// TODO | ||
describe.skip('isCanonicalPubKey', function() {}) | ||
describe.skip('isCanonicalSignature', function() {}) | ||
describe('classifyInput', function() { | ||
@@ -23,13 +26,2 @@ fixtures.valid.forEach(function(f) { | ||
}) | ||
fixtures.invalid.classify.forEach(function(f) { | ||
if (!f.scriptSig) return | ||
it('returns nonstandard for ' + f.description, function() { | ||
var script = Script.fromASM(f.scriptSig) | ||
var type = scripts.classifyInput(script) | ||
assert.equal(type, 'nonstandard') | ||
}) | ||
}) | ||
}) | ||
@@ -48,35 +40,59 @@ | ||
}) | ||
}) | ||
fixtures.invalid.classify.forEach(function(f) { | ||
if (!f.scriptPubKey) return | ||
;['PubKey', 'PubKeyHash', 'ScriptHash', 'Multisig', 'NullData'].forEach(function(type) { | ||
var inputFn = scripts['is' + type + 'Input'] | ||
var outputFn= scripts['is' + type + 'Output'] | ||
it('returns nonstandard for ' + f.description, function() { | ||
var script = Script.fromASM(f.scriptPubKey) | ||
var type = scripts.classifyOutput(script) | ||
describe('is' + type + 'Input', function() { | ||
fixtures.valid.forEach(function(f) { | ||
var expected = type.toLowerCase() === f.type | ||
assert.equal(type, 'nonstandard') | ||
if (inputFn && f.scriptSig) { | ||
it('returns ' + expected + ' for ' + f.scriptSig, function() { | ||
var script = Script.fromASM(f.scriptSig) | ||
assert.equal(inputFn(script), expected) | ||
}) | ||
} | ||
}) | ||
}) | ||
describe('is' + type + 'Output', function() { | ||
fixtures.valid.forEach(function(f) { | ||
var expected = type.toLowerCase() === f.type | ||
if (outputFn && f.scriptPubKey) { | ||
it('returns ' + expected + ' for ' + f.scriptPubKey, function() { | ||
var script = Script.fromASM(f.scriptPubKey) | ||
assert.equal(outputFn(script), expected) | ||
}) | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('pubKey', function() { | ||
describe('pubKeyInput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
if (f.type !== 'pubkey') return | ||
describe('input script', function() { | ||
it('is generated correctly for ' + f.pubKey, function() { | ||
var signature = new Buffer(f.signature, 'hex') | ||
it('returns ' + f.scriptSig, function() { | ||
var signature = new Buffer(f.signature, 'hex') | ||
var scriptSig = scripts.pubKeyInput(signature) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
var scriptSig = scripts.pubKeyInput(signature) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
}) | ||
}) | ||
describe('output script', function() { | ||
it('is generated correctly for ' + f.pubKey, function() { | ||
var pubKey = ECPubKey.fromHex(f.pubKey) | ||
describe('pubKeyOutput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
if (f.type !== 'pubkey') return | ||
var scriptPubKey = scripts.pubKeyOutput(pubKey) | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
it('returns ' + f.scriptPubKey, function() { | ||
var pubKey = ECPubKey.fromHex(f.pubKey) | ||
var scriptPubKey = scripts.pubKeyOutput(pubKey) | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
@@ -86,3 +102,3 @@ }) | ||
describe('pubKeyHash', function() { | ||
describe('pubKeyHashInput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
@@ -92,18 +108,22 @@ if (f.type !== 'pubkeyhash') return | ||
var pubKey = ECPubKey.fromHex(f.pubKey) | ||
var address = pubKey.getAddress() | ||
describe('input script', function() { | ||
it('is generated correctly for ' + address, function() { | ||
var signature = new Buffer(f.signature, 'hex') | ||
it('returns ' + f.scriptSig, function() { | ||
var signature = new Buffer(f.signature, 'hex') | ||
var scriptSig = scripts.pubKeyHashInput(signature, pubKey) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
var scriptSig = scripts.pubKeyHashInput(signature, pubKey) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
}) | ||
}) | ||
describe('output script', function() { | ||
it('is generated correctly for ' + address, function() { | ||
var scriptPubKey = scripts.pubKeyHashOutput(address.hash) | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
describe('pubKeyHashOutput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
if (f.type !== 'pubkeyhash') return | ||
var pubKey = ECPubKey.fromHex(f.pubKey) | ||
var address = pubKey.getAddress() | ||
it('returns ' + f.scriptPubKey, function() { | ||
var scriptPubKey = scripts.pubKeyHashOutput(address.hash) | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
@@ -113,56 +133,56 @@ }) | ||
describe('multisig', function() { | ||
describe('multisigInput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
if (f.type !== 'multisig') return | ||
it('returns ' + f.scriptSig, function() { | ||
var signatures = f.signatures.map(function(signature) { | ||
return new Buffer(signature, 'hex') | ||
}) | ||
var scriptSig = scripts.multisigInput(signatures) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
}) | ||
fixtures.invalid.multisigInput.forEach(function(f) { | ||
var pubKeys = f.pubKeys.map(ECPubKey.fromHex) | ||
var scriptPubKey = scripts.multisigOutput(pubKeys.length, pubKeys) | ||
describe('input script', function() { | ||
it('is generated correctly for ' + f.scriptPubKey, function() { | ||
var signatures = f.signatures.map(function(signature) { | ||
return new Buffer(signature, 'hex') | ||
}) | ||
var scriptSig = scripts.multisigInput(signatures) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
it('throws on ' + f.exception, function() { | ||
var signatures = f.signatures.map(function(signature) { | ||
return new Buffer(signature, 'hex') | ||
}) | ||
}) | ||
describe('output script', function() { | ||
it('is generated correctly for ' + f.scriptPubKey, function() { | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
assert.throws(function() { | ||
scripts.multisigInput(signatures, scriptPubKey) | ||
}, new RegExp(f.exception)) | ||
}) | ||
}) | ||
}) | ||
fixtures.invalid.multisig.forEach(function(f) { | ||
describe('multisigOutput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
if (f.type !== 'multisig') return | ||
var pubKeys = f.pubKeys.map(ECPubKey.fromHex) | ||
var scriptPubKey = scripts.multisigOutput(pubKeys.length, pubKeys) | ||
if (f.scriptPubKey) { | ||
describe('output script', function() { | ||
it('throws on ' + f.exception, function() { | ||
assert.throws(function() { | ||
scripts.multisigOutput(f.m, pubKeys) | ||
}, new RegExp(f.exception)) | ||
}) | ||
}) | ||
} else { | ||
describe('input script', function() { | ||
it('throws on ' + f.exception, function() { | ||
var signatures = f.signatures.map(function(signature) { | ||
return new Buffer(signature, 'hex') | ||
}) | ||
it('returns ' + f.scriptPubKey, function() { | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
}) | ||
assert.throws(function() { | ||
scripts.multisigInput(signatures, scriptPubKey) | ||
}, new RegExp(f.exception)) | ||
}) | ||
}) | ||
} | ||
fixtures.invalid.multisigOutput.forEach(function(f) { | ||
var pubKeys = f.pubKeys.map(function(p) { return new Buffer(p, 'hex') }) | ||
it('throws on ' + f.exception, function() { | ||
assert.throws(function() { | ||
scripts.multisigOutput(f.m, pubKeys) | ||
}, new RegExp(f.exception)) | ||
}) | ||
}) | ||
}) | ||
describe('scripthash', function() { | ||
describe('scriptHashInput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
@@ -174,18 +194,20 @@ if (f.type !== 'scripthash') return | ||
var address = Address.fromOutputScript(Script.fromASM(f.scriptPubKey)) | ||
it('returns ' + f.scriptSig, function() { | ||
var scriptSig = scripts.scriptHashInput(redeemScriptSig, redeemScript) | ||
describe('input script', function() { | ||
it('is generated correctly for ' + address, function() { | ||
var scriptSig = scripts.scriptHashInput(redeemScriptSig, redeemScript) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
assert.equal(scriptSig.toASM(), f.scriptSig) | ||
}) | ||
}) | ||
}) | ||
describe('output script', function() { | ||
it('is generated correctly for ' + address, function() { | ||
var scriptPubKey = scripts.scriptHashOutput(redeemScript.getHash()) | ||
describe('scriptHashOutput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
if (f.type !== 'scripthash') return | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
var redeemScript = Script.fromASM(f.redeemScript) | ||
it('returns ' + f.scriptPubKey, function() { | ||
var scriptPubKey = scripts.scriptHashOutput(redeemScript.getHash()) | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
@@ -195,3 +217,3 @@ }) | ||
describe('data', function() { | ||
describe('nullDataOutput', function() { | ||
fixtures.valid.forEach(function(f) { | ||
@@ -201,8 +223,6 @@ if (f.type !== 'nulldata') return | ||
var data = new Buffer(f.data, 'hex') | ||
var scriptPubKey = scripts.dataOutput(data) | ||
var scriptPubKey = scripts.nullDataOutput(data) | ||
describe('output script', function() { | ||
it('is generated correctly for ' + f.scriptPubKey, function() { | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
it('returns ' + f.scriptPubKey, function() { | ||
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) | ||
}) | ||
@@ -209,0 +229,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
628493
72
9363
147