username

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Package username implements a register of names that point to any blockchain address.

Each username consist of a name and a domain. Username format is `<name>*<namespace>`, for example `alice*iov`. Each username is unique. Any number of usernames can point to the same location. A location is a blockchain ID and an address value that is specific to that network.

You can think of the functionality provided by this package similar to what domain name server does. This functionality is narrowed to blockchains only.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCodec = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCodec   = fmt.Errorf("proto: integer overflow")
)

Functions

func NewTokenBucket

func NewTokenBucket() orm.ModelBucket

NewTokenBucket returns a ModelBucket instance limited to interacting with a Token model only. Only a valid Username instance should be used as a key. Alternatively tokens can be queried by owner.

func RegisterQuery

func RegisterQuery(qr weave.QueryRouter)

RegisterQuery expose tokens bucket to queries.

func RegisterRoutes

func RegisterRoutes(r weave.Registry, auth x.Authenticator)

Types

type BlockchainAddress

type BlockchainAddress struct {
	// An arbitrary blockchain ID.
	BlockchainID string `protobuf:"bytes,1,opt,name=blockchain_id,json=blockchainId,proto3" json:"blockchain_id,omitempty"`
	// An address on the specified blockchain network. Address is not a
	// weave.Address as we cannot know what is the format of an address on the
	// chain that this token instance links to. Because we do not know the rules
	// to validate an address for any blockchain ID, this is an arbitrary bulk of
	// data.
	// It is more convinient to always use encoded representation of each address
	// and store it as a string. Using bytes while compact is not as comfortable
	// to use.
	Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
}

BlockchainAddress represents a blochain address. This structure clubs together blokchain ID together with an address on that network. It is used to point to an address on any blockchain network.

func (*BlockchainAddress) Clone

func (*BlockchainAddress) Descriptor

func (*BlockchainAddress) Descriptor() ([]byte, []int)

func (*BlockchainAddress) GetAddress

func (m *BlockchainAddress) GetAddress() string

func (*BlockchainAddress) GetBlockchainID

func (m *BlockchainAddress) GetBlockchainID() string

func (*BlockchainAddress) Marshal

func (m *BlockchainAddress) Marshal() (dAtA []byte, err error)

func (*BlockchainAddress) MarshalTo

func (m *BlockchainAddress) MarshalTo(dAtA []byte) (int, error)

func (*BlockchainAddress) ProtoMessage

func (*BlockchainAddress) ProtoMessage()

func (*BlockchainAddress) Reset

func (m *BlockchainAddress) Reset()

func (*BlockchainAddress) Size

func (m *BlockchainAddress) Size() (n int)

func (*BlockchainAddress) String

func (m *BlockchainAddress) String() string

func (*BlockchainAddress) Unmarshal

func (m *BlockchainAddress) Unmarshal(dAtA []byte) error

func (*BlockchainAddress) Validate

func (ba *BlockchainAddress) Validate() error

func (*BlockchainAddress) XXX_DiscardUnknown

func (m *BlockchainAddress) XXX_DiscardUnknown()

func (*BlockchainAddress) XXX_Marshal

func (m *BlockchainAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BlockchainAddress) XXX_Merge

func (m *BlockchainAddress) XXX_Merge(src proto.Message)

func (*BlockchainAddress) XXX_Size

func (m *BlockchainAddress) XXX_Size() int

func (*BlockchainAddress) XXX_Unmarshal

func (m *BlockchainAddress) XXX_Unmarshal(b []byte) error

type ChangeTokenTargetsMsg

type ChangeTokenTargetsMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Username is the unique name of the token, for example alice*iov
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// New targets is a list of blockchain addresses that this token should point
	// to after the change. Old list is overwritten with what is provided.
	NewTargets []BlockchainAddress `protobuf:"bytes,3,rep,name=new_targets,json=newTargets,proto3" json:"new_targets"`
}

ChangeTokenTargetsMsg is a request to change the address that this token points to. Only the owner of a token can request this operation.

func (*ChangeTokenTargetsMsg) Descriptor

func (*ChangeTokenTargetsMsg) Descriptor() ([]byte, []int)

func (*ChangeTokenTargetsMsg) GetMetadata

func (m *ChangeTokenTargetsMsg) GetMetadata() *weave.Metadata

func (*ChangeTokenTargetsMsg) GetNewTargets

func (m *ChangeTokenTargetsMsg) GetNewTargets() []BlockchainAddress

func (*ChangeTokenTargetsMsg) GetUsername

func (m *ChangeTokenTargetsMsg) GetUsername() string

func (*ChangeTokenTargetsMsg) Marshal

func (m *ChangeTokenTargetsMsg) Marshal() (dAtA []byte, err error)

func (*ChangeTokenTargetsMsg) MarshalTo

func (m *ChangeTokenTargetsMsg) MarshalTo(dAtA []byte) (int, error)

func (ChangeTokenTargetsMsg) Path

func (*ChangeTokenTargetsMsg) ProtoMessage

func (*ChangeTokenTargetsMsg) ProtoMessage()

func (*ChangeTokenTargetsMsg) Reset

func (m *ChangeTokenTargetsMsg) Reset()

func (*ChangeTokenTargetsMsg) Size

func (m *ChangeTokenTargetsMsg) Size() (n int)

func (*ChangeTokenTargetsMsg) String

func (m *ChangeTokenTargetsMsg) String() string

func (*ChangeTokenTargetsMsg) Unmarshal

func (m *ChangeTokenTargetsMsg) Unmarshal(dAtA []byte) error

func (*ChangeTokenTargetsMsg) Validate

func (m *ChangeTokenTargetsMsg) Validate() error

func (*ChangeTokenTargetsMsg) XXX_DiscardUnknown

func (m *ChangeTokenTargetsMsg) XXX_DiscardUnknown()

func (*ChangeTokenTargetsMsg) XXX_Marshal

func (m *ChangeTokenTargetsMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ChangeTokenTargetsMsg) XXX_Merge

func (m *ChangeTokenTargetsMsg) XXX_Merge(src proto.Message)

func (*ChangeTokenTargetsMsg) XXX_Size

func (m *ChangeTokenTargetsMsg) XXX_Size() int

func (*ChangeTokenTargetsMsg) XXX_Unmarshal

func (m *ChangeTokenTargetsMsg) XXX_Unmarshal(b []byte) error

type Configuration added in v0.21.0

type Configuration struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Owner is present to implement gconf.OwnedConfig interface
	// This defines the Address that is allowed to update the Configuration object and is
	// needed to make use of gconf.NewUpdateConfigurationHandler
	Owner github_com_iov_one_weave.Address `protobuf:"bytes,2,opt,name=owner,proto3,casttype=github.com/iov-one/weave.Address" json:"owner,omitempty"`
	// Valid username name defines a regular expression that every valid username
	// part name must match (a username is <name>*<label>)
	ValidUsernameName string `protobuf:"bytes,3,opt,name=valid_username_name,json=validUsernameName,proto3" json:"valid_username_name,omitempty"`
	// Valid username label defines a regular expression that every valid
	// namespace label must match (a username is <name>*<label>)
	ValidUsernameLabel string `protobuf:"bytes,4,opt,name=valid_username_label,json=validUsernameLabel,proto3" json:"valid_username_label,omitempty"`
}

Configuration is a dynamic configuration used by this extension, managed by the functionality provided by gconf package.

func (*Configuration) Descriptor added in v0.21.0

func (*Configuration) Descriptor() ([]byte, []int)

func (*Configuration) GetMetadata added in v0.21.0

func (m *Configuration) GetMetadata() *weave.Metadata

func (*Configuration) GetOwner added in v0.21.0

func (*Configuration) GetValidUsernameLabel added in v0.21.0

func (m *Configuration) GetValidUsernameLabel() string

func (*Configuration) GetValidUsernameName added in v0.21.0

func (m *Configuration) GetValidUsernameName() string

func (*Configuration) Marshal added in v0.21.0

func (m *Configuration) Marshal() (dAtA []byte, err error)

func (*Configuration) MarshalTo added in v0.21.0

func (m *Configuration) MarshalTo(dAtA []byte) (int, error)

func (*Configuration) ProtoMessage added in v0.21.0

func (*Configuration) ProtoMessage()

func (*Configuration) Reset added in v0.21.0

func (m *Configuration) Reset()

func (*Configuration) Size added in v0.21.0

func (m *Configuration) Size() (n int)

func (*Configuration) String added in v0.21.0

func (m *Configuration) String() string

func (*Configuration) Unmarshal added in v0.21.0

func (m *Configuration) Unmarshal(dAtA []byte) error

func (*Configuration) Validate added in v0.21.0

func (c *Configuration) Validate() error

func (*Configuration) XXX_DiscardUnknown added in v0.21.0

func (m *Configuration) XXX_DiscardUnknown()

func (*Configuration) XXX_Marshal added in v0.21.0

func (m *Configuration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Configuration) XXX_Merge added in v0.21.0

func (m *Configuration) XXX_Merge(src proto.Message)

func (*Configuration) XXX_Size added in v0.21.0

func (m *Configuration) XXX_Size() int

func (*Configuration) XXX_Unmarshal added in v0.21.0

func (m *Configuration) XXX_Unmarshal(b []byte) error

type Initializer added in v0.18.0

type Initializer struct{}

Initializer fulfils the Initializer interface to load data from the genesis file

func (*Initializer) FromGenesis added in v0.18.0

func (*Initializer) FromGenesis(opts weave.Options, params weave.GenesisParams, kv weave.KVStore) error

FromGenesis will parse initial account info from genesis and save it to the database

type RegisterTokenMsg

type RegisterTokenMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Username is the unique name of the token, for example alice*iov
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// Targets is a blockchain address list that this token should point to.
	Targets []BlockchainAddress `protobuf:"bytes,3,rep,name=targets,proto3" json:"targets"`
}

RegisterTokenMsg is creating a new username token. The owner is always set to the main signer.

func (*RegisterTokenMsg) Descriptor

func (*RegisterTokenMsg) Descriptor() ([]byte, []int)

func (*RegisterTokenMsg) GetMetadata

func (m *RegisterTokenMsg) GetMetadata() *weave.Metadata

func (*RegisterTokenMsg) GetTargets

func (m *RegisterTokenMsg) GetTargets() []BlockchainAddress

func (*RegisterTokenMsg) GetUsername

func (m *RegisterTokenMsg) GetUsername() string

func (*RegisterTokenMsg) Marshal

func (m *RegisterTokenMsg) Marshal() (dAtA []byte, err error)

func (*RegisterTokenMsg) MarshalTo

func (m *RegisterTokenMsg) MarshalTo(dAtA []byte) (int, error)

func (RegisterTokenMsg) Path

func (RegisterTokenMsg) Path() string

func (*RegisterTokenMsg) ProtoMessage

func (*RegisterTokenMsg) ProtoMessage()

func (*RegisterTokenMsg) Reset

func (m *RegisterTokenMsg) Reset()

func (*RegisterTokenMsg) Size

func (m *RegisterTokenMsg) Size() (n int)

func (*RegisterTokenMsg) String

func (m *RegisterTokenMsg) String() string

func (*RegisterTokenMsg) Unmarshal

func (m *RegisterTokenMsg) Unmarshal(dAtA []byte) error

func (*RegisterTokenMsg) Validate

func (m *RegisterTokenMsg) Validate() error

func (*RegisterTokenMsg) XXX_DiscardUnknown

func (m *RegisterTokenMsg) XXX_DiscardUnknown()

func (*RegisterTokenMsg) XXX_Marshal

func (m *RegisterTokenMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RegisterTokenMsg) XXX_Merge

func (m *RegisterTokenMsg) XXX_Merge(src proto.Message)

func (*RegisterTokenMsg) XXX_Size

func (m *RegisterTokenMsg) XXX_Size() int

func (*RegisterTokenMsg) XXX_Unmarshal

func (m *RegisterTokenMsg) XXX_Unmarshal(b []byte) error

type Token

type Token struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Targets specifies where this username token points to. This must be at
	// least one blockchain address elemenet.
	Targets []BlockchainAddress `protobuf:"bytes,2,rep,name=targets,proto3" json:"targets"`
	// Owner is a weave.Address that controls this token. Only the owner can
	// modify a username token.
	Owner github_com_iov_one_weave.Address `protobuf:"bytes,3,opt,name=owner,proto3,casttype=github.com/iov-one/weave.Address" json:"owner,omitempty"`
}

Token model represents a username mapping to an address together with all metadata.

Each Token model is stored using the username as the key. This guarantee that the name is unique. Username is a combination of a name and a domain. The format is <name>*<domain>

Each token points to a blockchain and an address on that blockchain. Both blockchain ID and address are an arbitrary string as we do not want to limit ourselves to certain patterns.

func (*Token) Copy

func (t *Token) Copy() orm.CloneableData

func (*Token) Descriptor

func (*Token) Descriptor() ([]byte, []int)

func (*Token) GetMetadata

func (m *Token) GetMetadata() *weave.Metadata

func (*Token) GetOwner

func (m *Token) GetOwner() github_com_iov_one_weave.Address

func (*Token) GetTargets

func (m *Token) GetTargets() []BlockchainAddress

func (*Token) Marshal

func (m *Token) Marshal() (dAtA []byte, err error)

func (*Token) MarshalTo

func (m *Token) MarshalTo(dAtA []byte) (int, error)

func (*Token) ProtoMessage

func (*Token) ProtoMessage()

func (*Token) Reset

func (m *Token) Reset()

func (*Token) Size

func (m *Token) Size() (n int)

func (*Token) String

func (m *Token) String() string

func (*Token) Unmarshal

func (m *Token) Unmarshal(dAtA []byte) error

func (*Token) Validate

func (t *Token) Validate() error

Validate ensures the payment channel is valid.

func (*Token) XXX_DiscardUnknown

func (m *Token) XXX_DiscardUnknown()

func (*Token) XXX_Marshal

func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Token) XXX_Merge

func (m *Token) XXX_Merge(src proto.Message)

func (*Token) XXX_Size

func (m *Token) XXX_Size() int

func (*Token) XXX_Unmarshal

func (m *Token) XXX_Unmarshal(b []byte) error

type TransferTokenMsg

type TransferTokenMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	// Username is the unique name of the token, for example alice*iov
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	// Owner is a weave address that will owns this token after the change.
	NewOwner github_com_iov_one_weave.Address `` /* 127-byte string literal not displayed */
}

TransferTokenMsg is a request to transfer an ownership of a token. The mesage must be signed by the current token owner. Acceptance of the new owner is not required in order to succeed.

func (*TransferTokenMsg) Descriptor

func (*TransferTokenMsg) Descriptor() ([]byte, []int)

func (*TransferTokenMsg) GetMetadata

func (m *TransferTokenMsg) GetMetadata() *weave.Metadata

func (*TransferTokenMsg) GetNewOwner

func (*TransferTokenMsg) GetUsername

func (m *TransferTokenMsg) GetUsername() string

func (*TransferTokenMsg) Marshal

func (m *TransferTokenMsg) Marshal() (dAtA []byte, err error)

func (*TransferTokenMsg) MarshalTo

func (m *TransferTokenMsg) MarshalTo(dAtA []byte) (int, error)

func (TransferTokenMsg) Path

func (TransferTokenMsg) Path() string

func (*TransferTokenMsg) ProtoMessage

func (*TransferTokenMsg) ProtoMessage()

func (*TransferTokenMsg) Reset

func (m *TransferTokenMsg) Reset()

func (*TransferTokenMsg) Size

func (m *TransferTokenMsg) Size() (n int)

func (*TransferTokenMsg) String

func (m *TransferTokenMsg) String() string

func (*TransferTokenMsg) Unmarshal

func (m *TransferTokenMsg) Unmarshal(dAtA []byte) error

func (*TransferTokenMsg) Validate

func (m *TransferTokenMsg) Validate() error

func (*TransferTokenMsg) XXX_DiscardUnknown

func (m *TransferTokenMsg) XXX_DiscardUnknown()

func (*TransferTokenMsg) XXX_Marshal

func (m *TransferTokenMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TransferTokenMsg) XXX_Merge

func (m *TransferTokenMsg) XXX_Merge(src proto.Message)

func (*TransferTokenMsg) XXX_Size

func (m *TransferTokenMsg) XXX_Size() int

func (*TransferTokenMsg) XXX_Unmarshal

func (m *TransferTokenMsg) XXX_Unmarshal(b []byte) error

type UpdateConfigurationMsg added in v0.21.0

type UpdateConfigurationMsg struct {
	Metadata *weave.Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
	Patch    *Configuration  `protobuf:"bytes,2,opt,name=patch,proto3" json:"patch,omitempty"`
}

UpdateConfigurationMsg is used by the gconf extension to update the configuration.

func (*UpdateConfigurationMsg) Descriptor added in v0.21.0

func (*UpdateConfigurationMsg) Descriptor() ([]byte, []int)

func (*UpdateConfigurationMsg) GetMetadata added in v0.21.0

func (m *UpdateConfigurationMsg) GetMetadata() *weave.Metadata

func (*UpdateConfigurationMsg) GetPatch added in v0.21.0

func (m *UpdateConfigurationMsg) GetPatch() *Configuration

func (*UpdateConfigurationMsg) Marshal added in v0.21.0

func (m *UpdateConfigurationMsg) Marshal() (dAtA []byte, err error)

func (*UpdateConfigurationMsg) MarshalTo added in v0.21.0

func (m *UpdateConfigurationMsg) MarshalTo(dAtA []byte) (int, error)

func (UpdateConfigurationMsg) Path added in v0.22.0

func (*UpdateConfigurationMsg) ProtoMessage added in v0.21.0

func (*UpdateConfigurationMsg) ProtoMessage()

func (*UpdateConfigurationMsg) Reset added in v0.21.0

func (m *UpdateConfigurationMsg) Reset()

func (*UpdateConfigurationMsg) Size added in v0.21.0

func (m *UpdateConfigurationMsg) Size() (n int)

func (*UpdateConfigurationMsg) String added in v0.21.0

func (m *UpdateConfigurationMsg) String() string

func (*UpdateConfigurationMsg) Unmarshal added in v0.21.0

func (m *UpdateConfigurationMsg) Unmarshal(dAtA []byte) error

func (*UpdateConfigurationMsg) Validate added in v0.22.0

func (msg *UpdateConfigurationMsg) Validate() error

func (*UpdateConfigurationMsg) XXX_DiscardUnknown added in v0.21.0

func (m *UpdateConfigurationMsg) XXX_DiscardUnknown()

func (*UpdateConfigurationMsg) XXX_Marshal added in v0.21.0

func (m *UpdateConfigurationMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateConfigurationMsg) XXX_Merge added in v0.21.0

func (m *UpdateConfigurationMsg) XXX_Merge(src proto.Message)

func (*UpdateConfigurationMsg) XXX_Size added in v0.21.0

func (m *UpdateConfigurationMsg) XXX_Size() int

func (*UpdateConfigurationMsg) XXX_Unmarshal added in v0.21.0

func (m *UpdateConfigurationMsg) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL