Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
This repository was archived by the owner on May 28, 2019. It is now read-only.

BitcoinScirpt may be not able to match Multiple signature script #74

@zhaojiewen

Description

@zhaojiewen

In BitcoinScirpt Class,“matchMultisig” method below:

public func matchMultisig() -> ([PublicKey], required: Int)? {
if bytes.count < 1 || bytes.last != OpCode.OP_CHECKMULTISIG {
return nil
}

    var keys = [PublicKey]()

    var it = bytes.startIndex
    guard let (opcode, _) = getScriptOp(index: &it), OpCode.isSmallInteger(opcode) else {
        return nil
    }
    let required = BitcoinScript.decodeNumber(opcode: opcode)
    while case .some(_, let data?) = getScriptOp(index: &it), let key = PublicKey(data: data) {
        keys.append(key)
    }
    if !OpCode.isSmallInteger(opcode) {
        return nil
    }

    let expectedCount = BitcoinScript.decodeNumber(opcode: opcode)
    if keys.count != expectedCount || expectedCount < required {
        return nil
    }
    if it + 1 != bytes.endIndex {
        return nil
    }

    return (keys, required)
}

'expectedCount' is equal to 'required', so below code must be entered, and return nil:
if keys.count != expectedCount || expectedCount < required {
return nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions