TxBuilder: replace switch lookup with object lookup
This commit is contained in:
parent
d3af28e37e
commit
085b813958
1 changed files with 4 additions and 9 deletions
|
@ -275,6 +275,8 @@ TransactionBuilder.prototype.__build = function(allowIncomplete) {
|
||||||
return tx
|
return tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var canSignTypes = { 'pubkeyhash': true, 'multisig': true, 'pubkey': true }
|
||||||
|
|
||||||
TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashType) {
|
TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashType) {
|
||||||
assert(index in this.inputs, 'No input at index: ' + index)
|
assert(index in this.inputs, 'No input at index: ' + index)
|
||||||
hashType = hashType || Transaction.SIGHASH_ALL
|
hashType = hashType || Transaction.SIGHASH_ALL
|
||||||
|
@ -360,15 +362,8 @@ TransactionBuilder.prototype.sign = function(index, privKey, redeemScript, hashT
|
||||||
input.signatures = input.signatures || []
|
input.signatures = input.signatures || []
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input.scriptType) {
|
// do we know how to sign this?
|
||||||
case 'pubkeyhash':
|
assert(input.scriptType in canSignTypes, input.scriptType + ' not supported')
|
||||||
case 'multisig':
|
|
||||||
case 'pubkey':
|
|
||||||
break
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert(false, input.scriptType + ' not supported')
|
|
||||||
}
|
|
||||||
|
|
||||||
var signatureHash
|
var signatureHash
|
||||||
if (input.redeemScript) {
|
if (input.redeemScript) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue