diff --git a/pkg/owner/id.go b/pkg/owner/id.go index d3339638..4862b67b 100644 --- a/pkg/owner/id.go +++ b/pkg/owner/id.go @@ -43,3 +43,11 @@ func ScriptHashBE(id *ID) ([]byte, error) { return addr.BytesBE(), nil } + +// NewIDFromNeo3Wallet creates new owner identity from 25-byte neo wallet. +func NewIDFromNeo3Wallet(v *NEO3Wallet) *ID { + id := NewID() + id.SetNeo3Wallet(v) + + return id +} diff --git a/pkg/owner/id_test.go b/pkg/owner/id_test.go index e0b0f8a2..581d9f2c 100644 --- a/pkg/owner/id_test.go +++ b/pkg/owner/id_test.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "testing" + "github.com/nspcc-dev/neofs-crypto/test" "github.com/stretchr/testify/require" ) @@ -21,3 +22,11 @@ func TestIDV2(t *testing.T) { require.Equal(t, wallet.Bytes(), idV2.GetValue()) } + +func TestNewIDFromNeo3Wallet(t *testing.T) { + wallet, err := NEO3WalletFromPublicKey(&test.DecodeKey(1).PublicKey) + require.NoError(t, err) + + id := NewIDFromNeo3Wallet(wallet) + require.Equal(t, id.ToV2().GetValue(), wallet.Bytes()) +}