sigVerify in one line


#1

For example we have data set connected to the account

[{"1":publicKey}, {"2":publicKey}, {"3":publicKey}]

and code in RIDE for dApps

    func sig(tx:Transaction, key:String) = {
        sigVerify(tx.bodyBytes, tx.proofs[0], getBinary(this, key).value()) 
    }

    func sigVerifyAll(tx:Transaction, mod:String) = {        
        sig(tx, mod+"1") || sig(tx, mod+"2") || sig(tx, mod+"3") 
    }

sometimes I get an error which described situation when getBinary(this, key) doesn’t return ByteVector

Is it possible to take value() or return false in any unexpected situation without match?


#2

No. You should use match in this case

func sig(tx:Transaction, key:String) = {
        match(getBinary(this, key)) {
          case _: Unit => false
          case k: ByteVector => sigVerify(tx.bodyBytes, tx.proofs[0], k) 
    }