// GetAnchorOrigin will retrieve anchor credential based on CID, parse Sidetree core index file referenced in anchor
// credential and return anchor origin.
GetAnchorOrigin will retrieve anchor credential based on CID, parse Sidetree core index file referenced in anchor
credential and return anchor origin.
// GetAnchorOrigin will retrieve anchor credential based on CID parse Sidetree core index file referenced in anchor // credential and return anchor origin .
func (c *OrbClient) GetAnchorOrigin(cid, suffix string) (interface{}, error) {
	anchorEventBytes, err := c.casReader.Read(cid)
	if err != nil {
		return nil, fmt.Errorf("unable to read CID[%s] from CAS: %w", cid, err)
	}
	logger.Debugf("read anchor[%s]: %s", cid, string(anchorEventBytes))
	anchorEvent := &vocab.AnchorEventType{}
	err = json.Unmarshal(anchorEventBytes, anchorEvent)
	if err != nil {
		return nil, fmt.Errorf("unmarshal anchor event from CID[%s] from CAS: %w", cid, err)
	}
	vc, err := util.VerifiableCredentialFromAnchorEvent(anchorEvent, c.getParseCredentialOpts()...)
	if err != nil {
		return nil, fmt.Errorf("get verifiable credential from anchor event for CID[%s]: %w", cid, err)
	}
	suffixOp, err := c.getAnchoredOperation(anchorinfo.AnchorInfo{Hashlink: cid}, anchorEvent, vc, suffix)
	if err != nil {
		return nil, fmt.Errorf("failed to get anchored operation for suffix[%s] in anchor[%s]: %w", suffix, cid, err)
	}
	if suffixOp.Type != operation.TypeCreate && suffixOp.Type != operation.TypeRecover {
		return nil, fmt.Errorf("anchor origin is only available for 'create' and 'recover' operations")
	}
	return suffixOp.AnchorOrigin, nil
}
func ( c * OrbClient ) GetAnchorOrigin ( cid , suffix string ) ( interface { } , error ) { anchorEventBytes , err := c . casReader . Read ( cid ) if err != nil { return nil , fmt . Errorf ( " " , cid , err ) } logger . Debugf ( " " , cid , string ( anchorEventBytes ) ) anchorEvent := & vocab . AnchorEventType { } err = json . Unmarshal ( anchorEventBytes , anchorEvent ) if err != nil { return nil , fmt . Errorf ( " " , cid , err ) } vc , err := util . VerifiableCredentialFromAnchorEvent ( anchorEvent , c . getParseCredentialOpts ( ) ... ) if err != nil { return nil , fmt . Errorf ( " " , cid , err ) } suffixOp , err := c . getAnchoredOperation ( anchorinfo . AnchorInfo { Hashlink : cid } , anchorEvent , vc , suffix ) if err != nil { return nil , fmt . Errorf ( " " , suffix , cid , err ) } if suffixOp . Type != operation . TypeCreate && suffixOp . Type != operation . TypeRecover { return nil , fmt . Errorf ( " " ) } return suffixOp . AnchorOrigin , nil }
GetAnchorOrigin will retrieve anchor credential based on CID, parse Sidetree core index file referenced in anchor
credential and return anchor origin.
GetAnchorOrigin will retrieve anchor credential based on CID parse Sidetree core index file referenced in anchor credential and return anchor origin .