Comparing version 0.10.3 to 0.10.4
{ | ||
"name": "bitcore", | ||
"main": "./bitcore.min.js", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"homepage": "http://bitcore.io", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var $ = require('./util/preconditions'); | ||
var base58check = require('./encoding/base58check'); | ||
var Base58Check = require('./encoding/base58check'); | ||
var Networks = require('./networks'); | ||
@@ -298,3 +298,3 @@ var Hash = require('./crypto/hash'); | ||
} | ||
var addressBuffer = base58check.decode(data); | ||
var addressBuffer = Base58Check.decode(data); | ||
var info = Address._transformBuffer(addressBuffer, network, type); | ||
@@ -490,3 +490,3 @@ return info; | ||
Address.prototype.toString = function() { | ||
return base58check.encode(this.toBuffer()); | ||
return Base58Check.encode(this.toBuffer()); | ||
}; | ||
@@ -493,0 +493,0 @@ |
'use strict'; | ||
var BN = require('./bn'); | ||
var bufferUtil = require('../util/buffer'); | ||
var BufferUtil = require('../util/buffer'); | ||
var ec = require('elliptic').curves.secp256k1; | ||
@@ -142,5 +142,5 @@ var ecPoint = ec.curve.point.bind(ec.curve); | ||
} | ||
return bufferUtil.concat([prefix, xbuf]); | ||
return BufferUtil.concat([prefix, xbuf]); | ||
}; | ||
module.exports = Point; |
'use strict'; | ||
var _ = require('lodash'); | ||
var base58 = require('./base58'); | ||
var Base58 = require('./base58'); | ||
var buffer = require('buffer'); | ||
@@ -29,6 +29,6 @@ var sha256sha256 = require('../crypto/hash').sha256sha256; | ||
if (_.isString(data)) { | ||
data = new buffer.Buffer(base58.decode(data)); | ||
data = new buffer.Buffer(Base58.decode(data)); | ||
} | ||
if (_.isString(checksum)) { | ||
checksum = new buffer.Buffer(base58.decode(checksum)); | ||
checksum = new buffer.Buffer(Base58.decode(checksum)); | ||
} | ||
@@ -46,3 +46,3 @@ if (!checksum) { | ||
var buf = new Buffer(base58.decode(s)); | ||
var buf = new Buffer(Base58.decode(s)); | ||
@@ -75,3 +75,3 @@ if (buf.length < 4) | ||
hash.copy(checkedBuf, buf.length); | ||
return base58.encode(checkedBuf); | ||
return Base58.encode(checkedBuf); | ||
}; | ||
@@ -78,0 +78,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var $ = require('../util/preconditions'); | ||
var bufferUtil = require('../util/buffer'); | ||
var BufferUtil = require('../util/buffer'); | ||
var BN = require('../crypto/bn'); | ||
@@ -170,5 +170,5 @@ | ||
this.pos = this.pos + len; | ||
return bufferUtil.reverse(buf); | ||
return BufferUtil.reverse(buf); | ||
}; | ||
module.exports = BufferReader; |
@@ -7,2 +7,3 @@ 'use strict'; | ||
var _ = require('lodash'); | ||
var $ = require('./util/preconditions'); | ||
@@ -281,6 +282,17 @@ var BN = require('./crypto/bn'); | ||
HDPrivateKey.fromJSON = HDPrivateKey.fromObject = HDPrivateKey.fromString = function(arg) { | ||
HDPrivateKey.fromJSON = function(arg) { | ||
$.checkArgument(JSUtil.isValidJSON(arg), 'No valid JSON string was provided'); | ||
return new HDPrivateKey(arg); | ||
}; | ||
HDPrivateKey.fromString = function(arg) { | ||
$.checkArgument(_.isString(arg), 'No valid string was provided'); | ||
return new HDPrivateKey(arg); | ||
}; | ||
HDPrivateKey.fromObject = function(arg) { | ||
$.checkArgument(_.isObject(arg), 'No valid argument was provided'); | ||
return new HDPrivateKey(arg); | ||
}; | ||
HDPrivateKey.prototype._buildFromJSON = function(arg) { | ||
@@ -287,0 +299,0 @@ return this._buildFromObject(JSON.parse(arg)); |
'use strict'; | ||
var _ = require('lodash'); | ||
var $ = require('./util/preconditions'); | ||
var BN = require('./crypto/bn'); | ||
@@ -359,6 +361,17 @@ var Base58 = require('./encoding/base58'); | ||
HDPublicKey.fromString = HDPublicKey.fromObject = HDPublicKey.fromJSON = function(arg) { | ||
HDPublicKey.fromJSON = function(arg) { | ||
$.checkArgument(JSUtil.isValidJSON(arg), 'No valid JSON string was provided'); | ||
return new HDPublicKey(arg); | ||
}; | ||
HDPublicKey.fromObject = function(arg) { | ||
$.checkArgument(_.isObject(arg), 'No valid argument was provided'); | ||
return new HDPublicKey(arg); | ||
}; | ||
HDPublicKey.fromString = function(arg) { | ||
$.checkArgument(_.isString(arg), 'No valid string was provided'); | ||
return new HDPublicKey(arg); | ||
}; | ||
/** | ||
@@ -365,0 +378,0 @@ * Returns the base58 checked representation of the public key |
@@ -121,3 +121,5 @@ 'use strict'; | ||
'testnet-seed.bitcoin.petertodd.org', | ||
'testnet-seed.bluematt.me' | ||
'testnet-seed.bluematt.me', | ||
'testnet-seed.alexykot.me', | ||
'testnet-seed.bitcoin.schildbach.de' | ||
], | ||
@@ -124,0 +126,0 @@ }); |
@@ -236,2 +236,11 @@ 'use strict'; | ||
/** | ||
* Will return a string formatted for the console | ||
* | ||
* @returns {String} Script opcode | ||
*/ | ||
Opcode.prototype.inspect = function() { | ||
return '<Opcode: ' + this.toString() + ', hex: '+this.toHex()+', decimal: '+this.num+'>'; | ||
}; | ||
module.exports = Opcode; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var Address = require('./address'); | ||
var base58check = require('./encoding/base58check'); | ||
var Base58Check = require('./encoding/base58check'); | ||
var BN = require('./crypto/bn'); | ||
@@ -210,3 +210,3 @@ var JSUtil = require('./util/js'); | ||
PrivateKey._transformWIF = function(str, network) { | ||
return PrivateKey._transformBuffer(base58check.decode(str), network); | ||
return PrivateKey._transformBuffer(Base58Check.decode(str), network); | ||
}; | ||
@@ -338,3 +338,3 @@ | ||
return base58check.encode(buf); | ||
return Base58Check.encode(buf); | ||
}; | ||
@@ -341,0 +341,0 @@ |
@@ -327,3 +327,3 @@ 'use strict'; | ||
/** | ||
* @returns {boolean} if this is an OP_RETURN data script | ||
* @returns {boolean} true if this is a valid standard OP_RETURN output | ||
*/ | ||
@@ -336,3 +336,3 @@ Script.prototype.isDataOut = function() { | ||
this.chunks[1].buf && | ||
this.chunks[1].buf.length <= 40 && | ||
this.chunks[1].buf.length <= Script.OP_RETURN_STANDARD_SIZE && | ||
this.chunks[1].length === this.chunks.len)); | ||
@@ -380,2 +380,4 @@ }; | ||
Script.OP_RETURN_STANDARD_SIZE = 80; | ||
Script.identifiers = {}; | ||
@@ -549,2 +551,4 @@ Script.identifiers.PUBKEY_OUT = Script.prototype.isPublicKeyOut; | ||
Script.buildMultisigOut = function(publicKeys, threshold, opts) { | ||
$.checkArgument(threshold <= publicKeys.length, | ||
'Number of required signatures must be less than or equal to the number of public keys'); | ||
opts = opts || {}; | ||
@@ -551,0 +555,0 @@ var script = new Script(); |
@@ -8,4 +8,3 @@ 'use strict'; | ||
var errors = require('../errors'); | ||
var util = require('../util/js'); | ||
var bufferUtil = require('../util/buffer'); | ||
var BufferUtil = require('../util/buffer'); | ||
var JSUtil = require('../util/js'); | ||
@@ -51,7 +50,7 @@ var BufferReader = require('../encoding/bufferreader'); | ||
return Transaction.shallowCopy(serialized); | ||
} else if (util.isHexa(serialized)) { | ||
} else if (JSUtil.isHexa(serialized)) { | ||
this.fromString(serialized); | ||
} else if (util.isValidJSON(serialized)) { | ||
} else if (JSUtil.isValidJSON(serialized)) { | ||
this.fromJSON(serialized); | ||
} else if (bufferUtil.isBuffer(serialized)) { | ||
} else if (BufferUtil.isBuffer(serialized)) { | ||
this.fromBuffer(serialized); | ||
@@ -125,7 +124,7 @@ } else if (_.isObject(serialized)) { | ||
Transaction.prototype.uncheckedSerialize = function() { | ||
Transaction.prototype.uncheckedSerialize = Transaction.prototype.toString = function() { | ||
return this.toBuffer().toString('hex'); | ||
}; | ||
Transaction.prototype.checkedSerialize = Transaction.prototype.toString = function() { | ||
Transaction.prototype.checkedSerialize = function() { | ||
var feeError = this._validateFees(); | ||
@@ -151,2 +150,5 @@ var missingChange = this._missingChange(); | ||
} | ||
if (this._getUnspentValue() < this._estimateFee() / Transaction.FEE_SECURITY_MARGIN) { | ||
return 'Fee is less than ' + Transaction.FEE_SECURITY_MARGIN + ' times the suggested amount'; | ||
} | ||
}; | ||
@@ -454,2 +456,4 @@ | ||
Transaction.prototype._fromMultisigUtxo = function(utxo, pubkeys, threshold) { | ||
$.checkArgument(threshold <= pubkeys.length, | ||
'Number of required signatures must be greater than the number of public keys'); | ||
utxo = new UnspentOutput(utxo); | ||
@@ -456,0 +460,0 @@ this.addInput(new MultiSigScriptHashInput({ |
@@ -32,2 +32,5 @@ 'use strict'; | ||
var parsed; | ||
if (!_.isString(arg)) { | ||
return false; | ||
} | ||
try { | ||
@@ -34,0 +37,0 @@ parsed = JSON.parse(arg); |
{ | ||
"name": "bitcore", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "A pure and powerful JavaScript Bitcoin library.", | ||
@@ -5,0 +5,0 @@ "author": "BitPay <dev@bitpay.com>", |
@@ -43,2 +43,15 @@ Bitcore | ||
## Examples | ||
* [Generate a random address](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#generate-a-random-address) | ||
* [Generate a address from a SHA256 hash](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#generate-a-address-from-a-sha256-hash) | ||
* [Import an address via WIF](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#import-an-address-via-wif) | ||
* [Create a Transaction](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#create-a-transaction) | ||
* [Sign a Bitcoin message](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#sign-a-bitcoin-message) | ||
* [Verify a Bitcoin message](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#verify-a-bitcoin-message) | ||
* [Create an OP RETURN transaction](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#create-an-op-return-transaction) | ||
* [Create a 2-of-3 multisig P2SH address](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#create-a-2-of-3-multisig-p2sh-address) | ||
* [Spend from a 2-of-2 multisig P2SH address](https://github.com/bitpay/bitcore/blob/master/docs/examples.md#spend-from-a-2-of-2-multisig-p2sh-address) | ||
## Modules | ||
@@ -45,0 +58,0 @@ This module provides bitcoin's core features. Other features and protocol extensions are built into separate modules. Here is a list of official bitcore modules: |
@@ -502,4 +502,10 @@ 'use strict'; | ||
}); | ||
it('fails if invalid array is provided', function() { | ||
expect(function() { | ||
return Address.createMultisig([],3,'testnet'); | ||
}).to.throw('Number of required signatures must be less than or equal to the number of public keys'); | ||
}); | ||
}); | ||
}); |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var Base58Check = bitcore.encoding.Base58Check; | ||
var base58 = bitcore.encoding.Base58; | ||
var Base58 = bitcore.encoding.Base58; | ||
@@ -76,5 +76,5 @@ describe('Base58Check', function() { | ||
it('should throw an error when there is a checksum mismatch', function() { | ||
var buf2 = base58.decode(enc); | ||
var buf2 = Base58.decode(enc); | ||
buf2[0] = buf2[0] + 1; | ||
var enc2 = base58.encode(buf2); | ||
var enc2 = Base58.encode(buf2); | ||
(function() { | ||
@@ -81,0 +81,0 @@ Base58Check.decode(enc2); |
@@ -13,3 +13,5 @@ 'use strict'; | ||
var _ = require('lodash'); | ||
var should = require('chai').should(); | ||
var expect = require('chai').expect; | ||
var bitcore = require('..'); | ||
@@ -20,2 +22,36 @@ var Networks = bitcore.Networks; | ||
describe('HDKeys building with static methods', function() { | ||
var classes = [HDPublicKey, HDPrivateKey]; | ||
var clazz, index; | ||
_.each(classes, function(clazz) { | ||
var expectStaticMethodFail = function(staticMethod, argument, message) { | ||
expect(clazz[staticMethod].bind(null, argument)).to.throw(message); | ||
}; | ||
it(clazz.name + ' fromJSON checks that a valid JSON is provided', function() { | ||
var errorMessage = 'No valid JSON string was provided'; | ||
var method = 'fromJSON'; | ||
expectStaticMethodFail(method, undefined, errorMessage); | ||
expectStaticMethodFail(method, null, errorMessage); | ||
expectStaticMethodFail(method, 'invalid JSON', errorMessage); | ||
expectStaticMethodFail(method, '{\'singlequotes\': true}', errorMessage); | ||
expectStaticMethodFail(method, {}, errorMessage); | ||
}); | ||
it(clazz.name + ' fromString checks that a string is provided', function() { | ||
var errorMessage = 'No valid string was provided'; | ||
var method = 'fromString'; | ||
expectStaticMethodFail(method, undefined, errorMessage); | ||
expectStaticMethodFail(method, null, errorMessage); | ||
expectStaticMethodFail(method, {}, errorMessage); | ||
}); | ||
it(clazz.name + ' fromObject checks that an object is provided', function() { | ||
var errorMessage = 'No valid argument was provided'; | ||
var method = 'fromObject'; | ||
expectStaticMethodFail(method, undefined, errorMessage); | ||
expectStaticMethodFail(method, null, errorMessage); | ||
expectStaticMethodFail(method, '', errorMessage); | ||
}); | ||
}); | ||
}); | ||
describe('BIP32 compliance', function() { | ||
@@ -22,0 +58,0 @@ |
@@ -81,12 +81,11 @@ 'use strict'; | ||
describe('should error with a nonsensical argument', function() { | ||
it('like a number', function() { | ||
describe('instantiation', function() { | ||
it('invalid argument: can not instantiate from a number', function() { | ||
expectFailBuilding(1, hdErrors.UnrecognizedArgument); | ||
}); | ||
it('allows no-new calling', function() { | ||
HDPrivateKey(xprivkey).toString().should.equal(xprivkey); | ||
}); | ||
}); | ||
it('allows no-new calling', function() { | ||
HDPrivateKey(xprivkey).toString().should.equal(xprivkey); | ||
}); | ||
it('inspect() displays correctly', function() { | ||
@@ -93,0 +92,0 @@ HDPrivateKey(xprivkey).inspect().should.equal('<HDPrivateKey: ' + xprivkey + '>'); |
@@ -12,3 +12,3 @@ 'use strict'; | ||
var hdErrors = bitcore.errors.HDPublicKey; | ||
var bufferUtil = bitcore.util.buffer; | ||
var BufferUtil = bitcore.util.buffer; | ||
var HDPrivateKey = bitcore.HDPrivateKey; | ||
@@ -121,3 +121,3 @@ var HDPublicKey = bitcore.HDPublicKey; | ||
var buffers = new HDPublicKey(xpubkey)._buffers; | ||
buffers.checksum = bufferUtil.integerAsBuffer(1); | ||
buffers.checksum = BufferUtil.integerAsBuffer(1); | ||
expectFail(function() { | ||
@@ -127,3 +127,2 @@ return new HDPublicKey(buffers); | ||
}); | ||
}); | ||
@@ -252,3 +251,3 @@ | ||
var valid; | ||
valid = HDPublicKey.isValidPath('m/-1/12'); | ||
@@ -255,0 +254,0 @@ valid.should.equal(false); |
@@ -146,3 +146,8 @@ 'use strict'; | ||
describe('#inspect', function() { | ||
it('should output opcode by name, hex, and decimal', function() { | ||
Opcode.fromString('OP_NOP').inspect().should.equal('<Opcode: OP_NOP, hex: 61, decimal: 97>'); | ||
}); | ||
}); | ||
}); |
@@ -12,3 +12,3 @@ 'use strict'; | ||
var Networks = bitcore.Networks; | ||
var base58check = bitcore.encoding.Base58Check; | ||
var Base58Check = bitcore.encoding.Base58Check; | ||
@@ -61,3 +61,3 @@ var validbase58 = require('./data/bitcoind/base58_keys_valid.json'); | ||
it('should create a private key from WIF buffer', function() { | ||
var a = new PrivateKey(base58check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m')); | ||
var a = new PrivateKey(Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m')); | ||
should.exist(a); | ||
@@ -105,3 +105,3 @@ should.exist(a.bn); | ||
expect(function() { | ||
var buf = base58check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); | ||
var buf = Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); | ||
var buf2 = Buffer.concat([buf, new Buffer(0x01)]); | ||
@@ -114,3 +114,3 @@ return new PrivateKey(buf2); | ||
expect(function() { | ||
var buf = base58check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); | ||
var buf = Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m'); | ||
var buf2 = Buffer.concat([new Buffer('ff', 'hex'), buf.slice(1, 33)]); | ||
@@ -117,0 +117,0 @@ return new PrivateKey(buf2); |
@@ -210,3 +210,3 @@ 'use strict'; | ||
it('should know this is an OP_RETURN script', function() { | ||
it('validates that this 40-byte OP_RETURN is standard', function() { | ||
var buf = new Buffer(40); | ||
@@ -216,4 +216,9 @@ buf.fill(0); | ||
}); | ||
it('validates that this 80-byte OP_RETURN is standard', function() { | ||
var buf = new Buffer(80); | ||
buf.fill(0); | ||
Script('OP_RETURN OP_PUSHDATA1 80 0x' + buf.toString('hex')).isDataOut().should.equal(true); | ||
}); | ||
it('should know this is not an OP_RETURN script', function() { | ||
it('validates that this 40-byte long OP_CHECKMULTISIG is not standard op_return', function() { | ||
var buf = new Buffer(40); | ||
@@ -224,2 +229,7 @@ buf.fill(0); | ||
it('validates that this 81-byte OP_RETURN is not a valid standard OP_RETURN', function() { | ||
var buf = new Buffer(81); | ||
buf.fill(0); | ||
Script('OP_RETURN OP_PUSHDATA1 81 0x' + buf.toString('hex')).isDataOut().should.equal(false); | ||
}); | ||
}); | ||
@@ -436,2 +446,8 @@ | ||
}); | ||
it('should fail when number of required signatures is greater than number of pubkeys', function() { | ||
expect(sortkeys.length).to.equal(3); | ||
expect(function() { | ||
return Script.buildMultisigOut(sortkeys, 4); | ||
}).to.throw('Number of required signatures must be less than or equal to the number of public keys'); | ||
}); | ||
it('should create unsorted script if specified', function() { | ||
@@ -438,0 +454,0 @@ var s = Script.buildMultisigOut(sortkeys, 2); |
@@ -31,3 +31,3 @@ 'use strict'; | ||
//make sure transacion to/from buffer is isomorphic | ||
tx.serialize().should.equal(txbuf.toString('hex')); | ||
tx.uncheckedSerialize().should.equal(txbuf.toString('hex')); | ||
@@ -34,0 +34,0 @@ //sighash ought to be correct |
@@ -23,3 +23,3 @@ 'use strict'; | ||
var transaction = new Transaction(tx_1_hex); | ||
transaction.serialize().should.equal(tx_1_hex); | ||
transaction.uncheckedSerialize().should.equal(tx_1_hex); | ||
}); | ||
@@ -63,3 +63,3 @@ | ||
it('serialize to Object roundtrip', function() { | ||
new Transaction(testTransaction.toObject()).serialize().should.equal(testTransaction.serialize()); | ||
new Transaction(testTransaction.toObject()).uncheckedSerialize().should.equal(testTransaction.serialize()); | ||
}); | ||
@@ -70,3 +70,3 @@ | ||
var copy = new Transaction(transaction); | ||
copy.serialize().should.equal(transaction.serialize()); | ||
copy.uncheckedSerialize().should.equal(transaction.uncheckedSerialize()); | ||
}); | ||
@@ -86,3 +86,3 @@ | ||
var transaction = new Transaction(); | ||
transaction.serialize().should.equal(tx_empty_hex); | ||
transaction.uncheckedSerialize().should.equal(tx_empty_hex); | ||
}); | ||
@@ -92,3 +92,3 @@ | ||
var transaction = new Transaction(tx_1_hex); | ||
transaction.serialize().should.equal(tx_1_hex); | ||
transaction.uncheckedSerialize().should.equal(tx_1_hex); | ||
}); | ||
@@ -134,2 +134,6 @@ | ||
var privateKey = 'cSBnVM4xvxarwGQuAfQFwqDg9k5tErHUHzgWsEfD4zdwUasvqRVY'; | ||
var private1 = '6ce7e97e317d2af16c33db0b9270ec047a91bff3eff8558afb5014afb2bb5976'; | ||
var private2 = 'c9b26b0f771a0d2dad88a44de90f05f416b3b385ff1d989343005546a0032890'; | ||
var public1 = new PrivateKey(private1).publicKey; | ||
var public2 = new PrivateKey(private2).publicKey; | ||
@@ -247,5 +251,15 @@ var simpleUtxoWith1BTC = { | ||
}); | ||
it('coverage: on second call to sign, change is not recalculated', function() { | ||
it('if fee is too small, fail serialization', function() { | ||
var transaction = new Transaction() | ||
.from(simpleUtxoWith100000Satoshis) | ||
.to(toAddress, 99999) | ||
.change(changeAddress) | ||
.sign(privateKey); | ||
expect(function() { | ||
return transaction.serialize(); | ||
}).to.throw(errors.Transaction.FeeError); | ||
}); | ||
it('on second call to sign, change is not recalculated', function() { | ||
var transaction = new Transaction() | ||
.from(simpleUtxoWith100000Satoshis) | ||
.to(toAddress, 100000) | ||
@@ -339,3 +353,3 @@ .change(changeAddress) | ||
var simple = new Transaction(); | ||
expect(new Transaction(simple.toJSON()).serialize()).to.equal(simple.serialize()); | ||
expect(new Transaction(simple.toJSON()).uncheckedSerialize()).to.equal(simple.uncheckedSerialize()); | ||
var complex = new Transaction() | ||
@@ -348,3 +362,3 @@ .from(simpleUtxoWith100000Satoshis) | ||
var ctx = new Transaction(cj); | ||
expect(ctx.serialize()).to.equal(complex.serialize()); | ||
expect(ctx.uncheckedSerialize()).to.equal(complex.uncheckedSerialize()); | ||
@@ -356,3 +370,3 @@ }); | ||
expect(JSON.parse(transaction.toJSON()).changeScript).to.equal(Script.fromAddress(changeAddress).toString()); | ||
expect(new Transaction(transaction.toJSON()).serialize()).to.equal(transaction.serialize()); | ||
expect(new Transaction(transaction.toJSON()).uncheckedSerialize()).to.equal(transaction.uncheckedSerialize()); | ||
}); | ||
@@ -377,6 +391,2 @@ it('serializes correctly p2sh multisig signed tx', function() { | ||
it('can serialize and deserialize a P2SH input', function() { | ||
var private1 = '6ce7e97e317d2af16c33db0b9270ec047a91bff3eff8558afb5014afb2bb5976'; | ||
var private2 = 'c9b26b0f771a0d2dad88a44de90f05f416b3b385ff1d989343005546a0032890'; | ||
var public1 = new PrivateKey(private1).publicKey; | ||
var public2 = new PrivateKey(private2).publicKey; | ||
var transaction = new Transaction() | ||
@@ -415,2 +425,13 @@ .from({ | ||
}); | ||
it('does not allow a threshold number greater than the amount of public keys', function() { | ||
expect(function() { | ||
transaction = new Transaction(); | ||
return transaction.from({ | ||
txId: '0000000000000000000000000000000000000000000000000000000000000000', | ||
outputIndex: 0, | ||
script: Script(), | ||
satoshis: 10000 | ||
}, [], 1); | ||
}).to.throw('Number of required signatures must be greater than the number of public keys'); | ||
}); | ||
}); | ||
@@ -417,0 +438,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1209834
130
20267
120
3