fix noSorting, add testcase against bitcoind output
This commit is contained in:
parent
8ff1464b2c
commit
56bed9b3f2
|
@ -441,7 +441,7 @@ Script._sortKeys = function(keys) {
|
|||
|
||||
Script.createMultisig = function(n_required, inKeys, opts) {
|
||||
opts = opts || {};
|
||||
var keys = opts.noSorting ? i || inKeys : this._sortKeys(inKeys);
|
||||
var keys = opts.noSorting ? inKeys : this._sortKeys(inKeys);
|
||||
var script = new Script();
|
||||
script.writeN(n_required);
|
||||
keys.forEach(function(key) {
|
||||
|
|
|
@ -130,4 +130,24 @@ describe('Script', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#createMultisig', function() {
|
||||
it('should create ', function() {
|
||||
var pubs = testPubKeysHex.map( function(hex) {
|
||||
return new Buffer(hex,'hex');
|
||||
});
|
||||
var s1 = Script.createMultisig(3,pubs, {noSorting: true});
|
||||
|
||||
// test case generated with: bitcoind createmultisig 3 '["02c525d65d18be8fb36ab50a21bee02ac9fdc2c176fa18791ac664ea4b95572ae0", "02b937d54b550a3afdc2819772822d25869495f9e588b56a0205617d80514f0758", "0266dd7664e65958f3cc67bf92ad6243bc495df5ab56691719263977104b635bea","02ee91377073b04d1d9d19597b81a7be3db6554bd7d16151cb5599a6107a589e70", "02c8f63ad4822ef360b5c300f08488fa0fa24af2b2bebb6d6b602ca938ee5af793"]'
|
||||
|
||||
s1.getBuffer().toString('hex').should.equal('532102c525d65d18be8fb36ab50a21bee02ac9fdc2c176fa18791ac664ea4b95572ae02102b937d54b550a3afdc2819772822d25869495f9e588b56a0205617d80514f0758210266dd7664e65958f3cc67bf92ad6243bc495df5ab56691719263977104b635bea2102ee91377073b04d1d9d19597b81a7be3db6554bd7d16151cb5599a6107a589e702102c8f63ad4822ef360b5c300f08488fa0fa24af2b2bebb6d6b602ca938ee5af79355ae');
|
||||
var s2 = Script.createMultisig(3,pubs);
|
||||
|
||||
// test case generated with: bitcoind createmultisig 3 '["0266dd7664e65958f3cc67bf92ad6243bc495df5ab56691719263977104b635bea", "02b937d54b550a3afdc2819772822d25869495f9e588b56a0205617d80514f0758", "02c525d65d18be8fb36ab50a21bee02ac9fdc2c176fa18791ac664ea4b95572ae0", "02c8f63ad4822ef360b5c300f08488fa0fa24af2b2bebb6d6b602ca938ee5af793", "02ee91377073b04d1d9d19597b81a7be3db6554bd7d16151cb5599a6107a589e70"]'
|
||||
s2.getBuffer().toString('hex').should.equal('53210266dd7664e65958f3cc67bf92ad6243bc495df5ab56691719263977104b635bea2102b937d54b550a3afdc2819772822d25869495f9e588b56a0205617d80514f07582102c525d65d18be8fb36ab50a21bee02ac9fdc2c176fa18791ac664ea4b95572ae02102c8f63ad4822ef360b5c300f08488fa0fa24af2b2bebb6d6b602ca938ee5af7932102ee91377073b04d1d9d19597b81a7be3db6554bd7d16151cb5599a6107a589e7055ae');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue