Tighten the check for pay-to-pubkey scripts.
This commit tightens the check for a pay-to-pubkey script by ensuring the length of the pubkey is one of the two valid values of 33 or 65. This mirrors the checks in the multisig script type check as well. ok @owainga
This commit is contained in:
parent
982f282e10
commit
da1fcc6dbd
1 changed files with 2 additions and 2 deletions
|
@ -204,9 +204,9 @@ func isSmallInt(op *opcode) bool {
|
||||||
// isPubkey returns true if the script passed is a pubkey transaction, false
|
// isPubkey returns true if the script passed is a pubkey transaction, false
|
||||||
// otherwise.
|
// otherwise.
|
||||||
func isPubkey(pops []parsedOpcode) bool {
|
func isPubkey(pops []parsedOpcode) bool {
|
||||||
|
// valid pubkeys are either 33 or 65 bytes
|
||||||
return len(pops) == 2 &&
|
return len(pops) == 2 &&
|
||||||
pops[0].opcode.value > OP_FALSE &&
|
(len(pops[0].data) == 33 || len(pops[0].data) == 65) &&
|
||||||
pops[0].opcode.value <= OP_DATA_75 &&
|
|
||||||
pops[1].opcode.value == OP_CHECKSIG
|
pops[1].opcode.value == OP_CHECKSIG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue