diff --git a/neofs/config.yml b/neofs/config.yml index 9fc400a..b22aa29 100644 --- a/neofs/config.yml +++ b/neofs/config.yml @@ -1,5 +1,5 @@ name: "NeoFS" -safemethods: ["alphabetList", "innerRingCandidates", "config", "listConfig", "version"] +safemethods: ["alphabetList", "alphabetAddress", "innerRingCandidates", "config", "listConfig", "version"] events: - name: Deposit parameters: diff --git a/neofs/neofs_contract.go b/neofs/neofs_contract.go index c617002..b036993 100644 --- a/neofs/neofs_contract.go +++ b/neofs/neofs_contract.go @@ -15,6 +15,7 @@ package smart_contract Inner ring list related methods: - AlphabetList + - AlphabetAddress - InnerRingCandidates - InnerRingCandidateAdd - InnerRingCandidateRemove @@ -26,6 +27,7 @@ package smart_contract - SetConfig Other utility methods: + - Migrate - Version - Cheque */ @@ -127,6 +129,12 @@ func AlphabetList() []common.IRNode { return getNodes(ctx, alphabetKey) } +// AlphabetAddress returns 2\3n+1 multi signature address of alphabet nodes. +func AlphabetAddress() interop.Hash160 { + ctx := storage.GetReadOnlyContext() + return multiaddress(getNodes(ctx, alphabetKey)) +} + // InnerRingCandidates returns array of inner ring candidate node keys. func InnerRingCandidates() []common.IRNode { ctx := storage.GetReadOnlyContext() @@ -534,3 +542,17 @@ func rmNodeByKey(lst, add []common.IRNode, k []byte) ([]common.IRNode, []common. return newLst, add, flag } + +// multiaddress returns multi signature address from list of IRNode structures +// with m = 2/3n+1. +func multiaddress(n []common.IRNode) []byte { + threshold := len(n)*2/3 + 1 + + keys := []interop.PublicKey{} + for _, node := range n { + key := node.PublicKey + keys = append(keys, key) + } + + return contract.CreateMultisigAccount(threshold, keys) +}