fix isMultisig: compare to n value.
This commit is contained in:
parent
2299ee757e
commit
d32a951f37
@ -1017,7 +1017,7 @@ script.isMultisig = function isMultisig(s, pubs) {
|
|||||||
});
|
});
|
||||||
}).length;
|
}).length;
|
||||||
|
|
||||||
return total >= m;
|
return total === n;
|
||||||
};
|
};
|
||||||
|
|
||||||
script.isScripthash = function isScripthash(s, hash) {
|
script.isScripthash = function isScripthash(s, hash) {
|
||||||
|
|||||||
@ -153,7 +153,7 @@ Wallet.prototype.multisig = function multisig(options) {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// Use p2sh multisig by default
|
// Use p2sh multisig by default
|
||||||
if (!options.type && this.keys.length > 1)
|
if (!options.type && (this.keys.length > 1 || this.n > 1))
|
||||||
this.type = 'scripthash';
|
this.type = 'scripthash';
|
||||||
|
|
||||||
if (this.m < 1 || this.m > this.n)
|
if (this.m < 1 || this.m > this.n)
|
||||||
|
|||||||
@ -72,16 +72,23 @@ describe('Wallet', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should multisign/verify TX', function() {
|
it('should multisign/verify TX', function() {
|
||||||
var w = bcoin.wallet();
|
var w = bcoin.wallet({
|
||||||
var k2 = bcoin.wallet().getPublicKey();
|
multisig: {
|
||||||
|
type: 'multisig',
|
||||||
|
m: 1,
|
||||||
|
n: 2
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var k2 = w.getPublicKey().concat(1);
|
||||||
|
w.addKey(k2);
|
||||||
|
assert.equal(w.getOwnAddress(), w.getFullAddress());
|
||||||
|
|
||||||
// Input transcation
|
// Input transcation
|
||||||
var src = bcoin.tx({
|
var src = bcoin.tx({
|
||||||
outputs: [{
|
outputs: [{
|
||||||
value: 5460 * 2,
|
value: 5460 * 2,
|
||||||
minSignatures: 1,
|
minSignatures: 1,
|
||||||
keys: [ w.getPublicKey(), w.getPublicKey().concat(1) ]
|
keys: [ w.getPublicKey(), k2 ]
|
||||||
// keys: [ w.getPublicKey(), k2 ]
|
|
||||||
}, {
|
}, {
|
||||||
value: 5460 * 2,
|
value: 5460 * 2,
|
||||||
address: w.getAddress() + 'x'
|
address: w.getAddress() + 'x'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user