From 8ef70e70d752e7fffd9f95574c2cc656e4f93f41 Mon Sep 17 00:00:00 2001 From: alexvanin Date: Thu, 16 Jul 2020 11:02:19 +0300 Subject: [PATCH] Add "Bind" and "Unbind" methods New methods allow to bind and unbind public keys with the owner, therefore the user can store and access data with the key, that does not related to the wallet. --- neofs_contract.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/neofs_contract.go b/neofs_contract.go index 3cabb60..58f6c10 100644 --- a/neofs_contract.go +++ b/neofs_contract.go @@ -35,6 +35,7 @@ const ( candidatesKey = "candidates" cashedChequesKey = "cheques" blockDiff = 20 // change base on performance evaluation + publicKeySize = 33 ) func Main(op string, args []interface{}) interface{} { @@ -228,6 +229,29 @@ func Main(op string, args []interface{}) interface{} { runtime.Notify("Cheque", id, user, amount, lockAcc) } + return true + case "Bind", "Unbind": + if len(args) < 2 { + panic("binding: bad arguments") + } + + user := args[0].([]byte) + if !runtime.CheckWitness(user) { + panic("binding: you should be the owner of the wallet") + } + + var keys [][]byte + for i := 1; i < len(args); i++ { + pub := args[i].([]byte) + if len(pub) != publicKeySize { + panic("binding: incorrect public key size") + } + + keys = append(keys, pub) + } + + runtime.Notify(op, user, keys) + return true case "InnerRingUpdate": data := args[0].([]byte)