txbuilder: re-add verification optimizations
This commit is contained in:
parent
4660b84c2d
commit
6c02e1692a
1 changed files with 7 additions and 1 deletions
|
@ -373,14 +373,20 @@ TransactionBuilder.prototype.sign = function (index, privKey, redeemScript, hash
|
||||||
|
|
||||||
// enforce signature order matches public keys
|
// enforce signature order matches public keys
|
||||||
if (input.scriptType === 'multisig' && input.redeemScript && input.signatures.length !== input.pubKeys.length) {
|
if (input.scriptType === 'multisig' && input.redeemScript && input.signatures.length !== input.pubKeys.length) {
|
||||||
|
// maintain a local copy of unmatched signatures
|
||||||
|
var unmatched = input.signatures.slice()
|
||||||
|
|
||||||
input.signatures = input.pubKeys.map(function (pubKey) {
|
input.signatures = input.pubKeys.map(function (pubKey) {
|
||||||
var match
|
var match
|
||||||
|
|
||||||
// check for any matching signatures
|
// check for any matching signatures
|
||||||
input.signatures.some(function (signature) {
|
unmatched.some(function (signature, i) {
|
||||||
if (!pubKey.verify(signatureHash, signature)) return false
|
if (!pubKey.verify(signatureHash, signature)) return false
|
||||||
match = signature
|
match = signature
|
||||||
|
|
||||||
|
// remove matched signature from unmatched
|
||||||
|
unmatched.splice(i, 1)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue