| 331 | } |
| 332 | |
| 333 | func removeAttribute(srvc *native.NativeService) ([]byte, error) { |
| 334 | args := common.NewZeroCopySource(srvc.Input) |
| 335 | // arg0: ID |
| 336 | arg0, err := utils.DecodeVarBytes(args) |
| 337 | if err != nil { |
| 338 | return utils.BYTE_FALSE, errors.New("remove attribute failed: argument 0 error") |
| 339 | } |
| 340 | // arg1: path |
| 341 | arg1, err := utils.DecodeVarBytes(args) |
| 342 | if err != nil { |
| 343 | return utils.BYTE_FALSE, errors.New("remove attribute failed: argument 1 error") |
| 344 | } |
| 345 | // arg2: operator's public key |
| 346 | arg2, err := utils.DecodeVarBytes(args) |
| 347 | if err != nil { |
| 348 | return utils.BYTE_FALSE, errors.New("remove attribute failed: argument 2 error") |
| 349 | } |
| 350 | |
| 351 | err = checkWitness(srvc, arg2) |
| 352 | if err != nil { |
| 353 | return utils.BYTE_FALSE, errors.New("remove attribute failed: " + err.Error()) |
| 354 | } |
| 355 | key, err := encodeID(arg0) |
| 356 | if err != nil { |
| 357 | return utils.BYTE_FALSE, errors.New("remove attribute failed: " + err.Error()) |
| 358 | } |
| 359 | if !isValid(srvc, key) { |
| 360 | return utils.BYTE_FALSE, errors.New("remove attribute failed: ID not registered") |
| 361 | } |
| 362 | if !isOwner(srvc, key, arg2) { |
| 363 | return utils.BYTE_FALSE, errors.New("remove attribute failed: no authorization") |
| 364 | } |
| 365 | |
| 366 | err = deleteAttr(srvc, key, arg1) |
| 367 | if err != nil { |
| 368 | return utils.BYTE_FALSE, errors.New("remove attribute failed: " + err.Error()) |
| 369 | } |
| 370 | |
| 371 | triggerAttributeEvent(srvc, "remove", arg0, [][]byte{arg1}) |
| 372 | return utils.BYTE_TRUE, nil |
| 373 | } |
| 374 | |
| 375 | func verifySignature(srvc *native.NativeService) ([]byte, error) { |
| 376 | source := common.NewZeroCopySource(srvc.Input) |