lbry.go/binding/lbryschema-python-binding.go

42 lines
991 B
Go
Raw Normal View History

2017-11-09 04:01:32 +01:00
package main
2017-11-09 04:01:32 +01:00
import (
"../claim"
"C"
2017-11-09 04:01:32 +01:00
)
//export VerifySignature
func VerifySignature(claimHex string, certificateHex string, claimAddress string, certificateId string, blockchainName string) bool {
decodedClaim, err := claim.DecodeClaimHex(claimHex, blockchainName)
2017-11-09 04:01:32 +01:00
if err != nil {
return false
}
decodedCertificate, err := claim.DecodeClaimHex(certificateHex, blockchainName)
2017-11-13 16:11:19 +01:00
if err != nil {
return false
}
result, err := decodedClaim.ValidateClaimSignature(decodedCertificate, claimAddress, certificateId, blockchainName)
2017-11-09 04:01:32 +01:00
if err != nil {
return false
}
2017-11-13 16:11:19 +01:00
if result == false {
return false
}
return true
}
//export DecodeClaimHex
func DecodeClaimHex(claimHex string, blockchainName string) *C.char {
decodedClaim, err := claim.DecodeClaimHex(claimHex, blockchainName)
2017-11-13 16:11:19 +01:00
if err != nil {
return C.CString("decode error")
}
decoded, err := decodedClaim.RenderJSON()
if err != nil {
return C.CString("encode error")
}
return C.CString(decoded)
2017-11-09 04:01:32 +01:00
}
func main() {}