func ImportProofError(e keybase1.ProofResult) ProofError { ps := keybase1.ProofStatus(e.Status) if ps == keybase1.ProofStatus_OK { return nil } return NewProofError(ps, e.Desc) }
// Run starts the engine. func (e *ProveCheck) Run(ctx *Context) error { found, status, err := libkb.CheckPostedViaSigID(e.sigID) if err != nil { return err } e.found = found e.status = keybase1.ProofStatus(status) e.G().Log.Debug("looking for ChainLink for %s", e.sigID) me, err := libkb.LoadMe(libkb.NewLoadUserPubOptionalArg(e.G())) if err != nil { return err } link := me.LinkFromSigID(e.sigID) if link == nil { return fmt.Errorf("no chain link found for %s", e.sigID) } e.G().Log.Debug("chain link found: (%T)", link.Typed()) if rlink, ok := link.Typed().(libkb.RemoteProofChainLink); ok { e.proofText = rlink.ProofText() e.G().Log.Debug("chain link proof text: %q", e.proofText) } else { e.G().Log.Warning("chain link had invalid type: %T", link.Typed()) } return nil }
func CheckPosted(proofID string) (found bool, status keybase1.ProofStatus, err error) { res, e2 := G.API.Post(APIArg{ Endpoint: "sig/posted", NeedSession: true, Args: HTTPArgs{ "proof_id": S{proofID}, }, }) if e2 != nil { err = e2 return } var ( rfound bool rstatus int rerr error ) res.Body.AtKey("proof_ok").GetBoolVoid(&rfound, &rerr) res.Body.AtPath("proof_res.status").GetIntVoid(&rstatus, &rerr) return rfound, keybase1.ProofStatus(rstatus), rerr }
func NewCheckResult(jw *jsonw.Wrapper) (res *CheckResult, err error) { var t int64 var code int var desc string jw.AtKey("time").GetInt64Void(&t, &err) status := jw.AtKey("status") var pe ProofError if !status.IsNil() { status.AtKey("desc").GetStringVoid(&desc, &err) status.AtKey("code").GetIntVoid(&code, &err) pe = NewProofError(keybase1.ProofStatus(code), desc) } if err == nil { res = &CheckResult{ Status: pe, Time: time.Unix(t, 0), } } return }