ontsdk

package
v0.0.0-...-9c98f16 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: BSD-2-Clause Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// SCHEME - did scheme
	SCHEME = "did"
	// METHOD - did method
	METHOD = "ont"
	// VER - did version
	VER = 0x41
)
View Source
const (
	// KeyStatusRevoke -
	KeyStatusRevoke = "revoked"
	// KyeStatusInUse -
	KyeStatusInUse = "in use"
)

Variables

View Source
var (
	// OntContractAddress -
	OntContractAddress, _ = utils.AddressFromHexString("0100000000000000000000000000000000000000")
	// OngContractAddress -
	OngContractAddress, _ = utils.AddressFromHexString("0200000000000000000000000000000000000000")
	// OntIDContractAddress -
	OntIDContractAddress, _ = utils.AddressFromHexString("0300000000000000000000000000000000000000")
	// GlobalParamsContractAddress -
	GlobalParamsContractAddress, _ = utils.AddressFromHexString("0400000000000000000000000000000000000000")
	// AuthContractAddress -
	AuthContractAddress, _ = utils.AddressFromHexString("0600000000000000000000000000000000000000")
	// GovernanceContractAddress -
	GovernanceContractAddress, _ = utils.AddressFromHexString("0700000000000000000000000000000000000000")
)
View Source
var (
	// OntContractVersion -
	OntContractVersion = byte(0)
	// OngContractVersion -
	OngContractVersion = byte(0)
	// OntIDContractVersion -
	OntIDContractVersion = byte(0)
	// GlobalParamsContractVersion -
	GlobalParamsContractVersion = byte(0)
	// AuthContractVersion -
	AuthContractVersion = byte(0)
	// GovernanceContractVersion -
	GovernanceContractVersion = byte(0)
)
View Source
var DefaultWalletName = "MyWallet"

DefaultWalletName -

View Source
var DefaultWalletVersion = "1.1"

DefaultWalletVersion -

View Source
var ErrAccountNotFound = errors.New("account not found")

ErrAccountNotFound -

View Source
var ErrControllerNotFound = errors.New("controller not found")

ErrControllerNotFound -

View Source
var ErrIdentityNotFound = errors.New("identity not found")

ErrIdentityNotFound -

Functions

func CheckKeyTypeCurve

func CheckKeyTypeCurve(keyType keypair.KeyType, curveCode byte) bool

CheckKeyTypeCurve -

func CheckSigScheme

func CheckSigScheme(keyType keypair.KeyType, sigScheme s.SignatureScheme) bool

CheckSigScheme -

func CreateID

func CreateID(nonce []byte) (string, error)

CreateID -

func GenerateID

func GenerateID() (string, error)

GenerateID -

func GetCurveName

func GetCurveName(pubKey []byte) string

GetCurveName -

func GetKeyTypeString

func GetKeyTypeString(keyType keypair.KeyType) string

GetKeyTypeString -

func ScryptEqual

func ScryptEqual(s1, s2 *keypair.ScryptParam) bool

ScryptEqual -

func VerifyID

func VerifyID(id string) bool

VerifyID -

Types

type Account

type Account struct {
	PrivateKey keypair.PrivateKey
	PublicKey  keypair.PublicKey
	Address    common.Address
	SigScheme  s.SignatureScheme
}

Account - crypto object

func NewAccount

func NewAccount(sigscheme ...s.SignatureScheme) *Account

NewAccount -

func (*Account) GetPrivateKey

func (a *Account) GetPrivateKey() keypair.PrivateKey

GetPrivateKey -

func (*Account) GetPublicKey

func (a *Account) GetPublicKey() keypair.PublicKey

GetPublicKey -

func (*Account) GetSigScheme

func (a *Account) GetSigScheme() s.SignatureScheme

GetSigScheme -

func (*Account) Sign

func (a *Account) Sign(data []byte) ([]byte, error)

Sign -

type AccountData

type AccountData struct {
	keypair.ProtectedKey

	Label     string `json:"label"`
	PubKey    string `json:"publicKey"`
	SigSch    string `json:"signatureScheme"`
	IsDefault bool   `json:"isDefault"`
	Lock      bool   `json:"lock"`
	// contains filtered or unexported fields
}

AccountData - for wallet read and save, no crypto object included

func NewAccountData

func NewAccountData(keyType keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte, scrypts ...*keypair.ScryptParam) (*AccountData, error)

NewAccountData -

func (*AccountData) Clone

func (a *AccountData) Clone() *AccountData

Clone -

func (*AccountData) GetAccount

func (a *AccountData) GetAccount(passwd []byte) (*Account, error)

GetAccount -

func (*AccountData) GetKeyPair

func (a *AccountData) GetKeyPair() *keypair.ProtectedKey

GetKeyPair -

func (*AccountData) GetScrypt

func (a *AccountData) GetScrypt() *keypair.ScryptParam

GetScrypt -

func (*AccountData) SetKeyPair

func (a *AccountData) SetKeyPair(keyinfo *keypair.ProtectedKey)

SetKeyPair -

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth -

func (*Auth) AssignFuncsToRole

func (nc *Auth) AssignFuncsToRole(gasPrice, gasLimit uint64, contractAddress common.Address, signer *Account, adminID, role []byte, funcNames []string, keyIndex int) (common.Uint256, error)

AssignFuncsToRole -

func (*Auth) AssignOntIDsToRole

func (nc *Auth) AssignOntIDsToRole(gasPrice, gasLimit uint64, signer *Account, contractAddress common.Address, admOntID, role []byte, persons [][]byte, keyIndex int) (common.Uint256, error)

AssignOntIDsToRole -

func (*Auth) Delegate

func (nc *Auth) Delegate(gasPrice, gasLimit uint64, signer *Account, contractAddress common.Address, from, to, role []byte, period, level, keyIndex int) (common.Uint256, error)

Delegate -

func (*Auth) NewAssignFuncsToRoleTransaction

func (nc *Auth) NewAssignFuncsToRoleTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, adminID, role []byte, funcNames []string, keyIndex int) (*types.MutableTransaction, error)

NewAssignFuncsToRoleTransaction -

func (*Auth) NewAssignOntIDsToRoleTransaction

func (nc *Auth) NewAssignOntIDsToRoleTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, admOntID, role []byte, persons [][]byte, keyIndex int) (*types.MutableTransaction, error)

NewAssignOntIDsToRoleTransaction -

func (*Auth) NewDelegateTransaction

func (nc *Auth) NewDelegateTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, from, to, role []byte, period, level, keyIndex int) (*types.MutableTransaction, error)

NewDelegateTransaction -

func (*Auth) NewTransferTransaction

func (nc *Auth) NewTransferTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, newAdminID []byte, keyIndex int) (*types.MutableTransaction, error)

NewTransferTransaction -

func (*Auth) NewVerifyTokenTransaction

func (nc *Auth) NewVerifyTokenTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, caller []byte, funcName string, keyIndex int) (*types.MutableTransaction, error)

NewVerifyTokenTransaction -

func (*Auth) NewWithdrawTransaction

func (nc *Auth) NewWithdrawTransaction(gasPrice, gasLimit uint64, contractAddress common.Address, initiator, delegate, role []byte, keyIndex int) (*types.MutableTransaction, error)

NewWithdrawTransaction -

func (*Auth) Transfer

func (nc *Auth) Transfer(gasPrice, gasLimit uint64, signer *Account, contractAddress common.Address, newAdminID []byte, keyIndex int) (common.Uint256, error)

Transfer -

func (*Auth) VerifyToken

func (nc *Auth) VerifyToken(gasPrice, gasLimit uint64, signer *Account, contractAddress common.Address, caller []byte, funcName string, keyIndex int) (common.Uint256, error)

VerifyToken -

func (*Auth) Withdraw

func (nc *Auth) Withdraw(gasPrice, gasLimit uint64, signer *Account, contractAddress common.Address, initiator, delegate, role []byte, keyIndex int) (common.Uint256, error)

Withdraw -

type Controller

type Controller struct {
	ID         string
	PrivateKey keypair.PrivateKey
	PublicKey  keypair.PublicKey
	SigScheme  s.SignatureScheme
}

Controller -

func (*Controller) GetPrivateKey

func (c *Controller) GetPrivateKey() keypair.PrivateKey

GetPrivateKey -

func (*Controller) GetPublicKey

func (c *Controller) GetPublicKey() keypair.PublicKey

GetPublicKey -

func (*Controller) GetSigScheme

func (c *Controller) GetSigScheme() s.SignatureScheme

GetSigScheme -

func (*Controller) Sign

func (c *Controller) Sign(data []byte) ([]byte, error)

Sign -

type ControllerData

type ControllerData struct {
	ID     string `json:"id"`
	Public string `json:"publicKey,omitemtpy"`
	SigSch string `json:"signatureScheme"`
	keypair.ProtectedKey
	// contains filtered or unexported fields
}

ControllerData -

func NewControllerData

func NewControllerData(id string, keyType keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte, scrypts ...*keypair.ScryptParam) (*ControllerData, error)

NewControllerData -

func NewControllerDataFromProtectedKey

func NewControllerDataFromProtectedKey(id, pubKey string, protectedKey *keypair.ProtectedKey, SigSch string, scrypts ...*keypair.ScryptParam) *ControllerData

NewControllerDataFromProtectedKey -

func (*ControllerData) Clone

func (c *ControllerData) Clone() *ControllerData

Clone -

func (*ControllerData) GetController

func (c *ControllerData) GetController(passwd []byte) (*Controller, error)

GetController -

func (*ControllerData) GetKeyPair

func (c *ControllerData) GetKeyPair() *keypair.ProtectedKey

GetKeyPair -

func (*ControllerData) GetScrypt

func (c *ControllerData) GetScrypt() *keypair.ScryptParam

GetScrypt -

func (*ControllerData) SetKeyPair

func (c *ControllerData) SetKeyPair(keyinfo *keypair.ProtectedKey)

SetKeyPair -

type DDO

type DDO struct {
	OntID      string
	Owners     []*DDOOwner
	Attributes []*DDOAttribute
	Recovery   string
}

DDO -

type DDOAttribute

type DDOAttribute struct {
	Key       []byte
	ValueType []byte
	Value     []byte
}

DDOAttribute -

type DDOOwner

type DDOOwner struct {
	PubKeyID string
	Type     string
	Curve    string
	Value    string
	// contains filtered or unexported fields
}

DDOOwner -

func (*DDOOwner) GetIndex

func (d *DDOOwner) GetIndex() uint32

GetIndex -

type GlobalParam

type GlobalParam struct {
	// contains filtered or unexported fields
}

GlobalParam -

func (*GlobalParam) AcceptAdmin

func (nc *GlobalParam) AcceptAdmin(gasPrice, gasLimit uint64, signer *Account) (common.Uint256, error)

AcceptAdmin -

func (*GlobalParam) CreateSnapshot

func (nc *GlobalParam) CreateSnapshot(gasPrice, gasLimit uint64, signer *Account) (common.Uint256, error)

CreateSnapshot -

func (*GlobalParam) GetGlobalParams

func (nc *GlobalParam) GetGlobalParams(params []string) (map[string]string, error)

GetGlobalParams -

func (*GlobalParam) NewAcceptAdminTransaction

func (nc *GlobalParam) NewAcceptAdminTransaction(gasPrice, gasLimit uint64, admin common.Address) (*types.MutableTransaction, error)

NewAcceptAdminTransaction -

func (*GlobalParam) NewCreateSnapshotTransaction

func (nc *GlobalParam) NewCreateSnapshotTransaction(gasPrice, gasLimit uint64) (*types.MutableTransaction, error)

NewCreateSnapshotTransaction -

func (*GlobalParam) NewSetGlobalParamsTransaction

func (nc *GlobalParam) NewSetGlobalParamsTransaction(gasPrice, gasLimit uint64, params map[string]string) (*types.MutableTransaction, error)

NewSetGlobalParamsTransaction -

func (*GlobalParam) NewSetOperatorTransaction

func (nc *GlobalParam) NewSetOperatorTransaction(gasPrice, gasLimit uint64, operator common.Address) (*types.MutableTransaction, error)

NewSetOperatorTransaction -

func (*GlobalParam) NewTransferAdminTransaction

func (nc *GlobalParam) NewTransferAdminTransaction(gasPrice, gasLimit uint64, newAdmin common.Address) (*types.MutableTransaction, error)

NewTransferAdminTransaction -

func (*GlobalParam) SetGlobalParams

func (nc *GlobalParam) SetGlobalParams(gasPrice, gasLimit uint64, signer *Account, params map[string]string) (common.Uint256, error)

SetGlobalParams -

func (*GlobalParam) SetOperator

func (nc *GlobalParam) SetOperator(gasPrice, gasLimit uint64, signer *Account, operator common.Address) (common.Uint256, error)

SetOperator -

func (*GlobalParam) TransferAdmin

func (nc *GlobalParam) TransferAdmin(gasPrice, gasLimit uint64, signer *Account, newAdmin common.Address) (common.Uint256, error)

TransferAdmin -

type Identity

type Identity struct {
	ID        string
	Label     string
	Lock      bool
	IsDefault bool

	Extra interface{}
	// contains filtered or unexported fields
}

Identity -

func GetDefaultIdentityFromID

func GetDefaultIdentityFromID(id string, passwd []byte) (*Identity, error)

GetDefaultIdentityFromID - generate identity from id string

func NewIdentity

func NewIdentity(scrypt *keypair.ScryptParam) (*Identity, error)

NewIdentity - new identity with scrypt

func NewIdentityFromIdentityData

func NewIdentityFromIdentityData(identityData *IdentityData) (*Identity, error)

NewIdentityFromIdentityData -

func (*Identity) AddControllerData

func (i *Identity) AddControllerData(controllerData *ControllerData) error

AddControllerData -

func (*Identity) ControllerCount

func (i *Identity) ControllerCount() int

ControllerCount -

func (*Identity) DeleteControllerData

func (i *Identity) DeleteControllerData(id string) error

DeleteControllerData -

func (*Identity) GetControllerByID

func (i *Identity) GetControllerByID(id string, passwd []byte) (*Controller, error)

GetControllerByID -

func (*Identity) GetControllerByIndex

func (i *Identity) GetControllerByIndex(index int, passwd []byte) (*Controller, error)

GetControllerByIndex -

func (*Identity) GetControllerByPubKey

func (i *Identity) GetControllerByPubKey(pubKey string, passwd []byte) (*Controller, error)

GetControllerByPubKey -

func (*Identity) GetControllerDataByID

func (i *Identity) GetControllerDataByID(id string) (*ControllerData, error)

GetControllerDataByID -

func (*Identity) GetControllerDataByIndex

func (i *Identity) GetControllerDataByIndex(index int) (*ControllerData, error)

GetControllerDataByIndex -

func (*Identity) GetControllerDataByPubKey

func (i *Identity) GetControllerDataByPubKey(pubKey string) (*ControllerData, error)

GetControllerDataByPubKey -

func (*Identity) NewController

func (i *Identity) NewController(id string, keyType keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte) (*Controller, error)

NewController -

func (*Identity) NewDefaultSettingController

func (i *Identity) NewDefaultSettingController(id string, passwd []byte) (*Controller, error)

NewDefaultSettingController -

func (*Identity) ToIdentityData

func (i *Identity) ToIdentityData() *IdentityData

ToIdentityData -

type IdentityData

type IdentityData struct {
	ID        string            `json:"ontid"`
	Label     string            `json:"label,omitempty"`
	Lock      bool              `json:"lock"`
	IsDefault bool              `json:"isDefault"`
	Control   []*ControllerData `json:"controls,omitempty"`
	Extra     interface{}       `json:"extra,omitempty"`
	// contains filtered or unexported fields
}

IdentityData -

type NativeContract

type NativeContract struct {
	Ont          *Ont
	Ong          *Ong
	OntID        *OntID
	GlobalParams *GlobalParam
	Auth         *Auth
	// contains filtered or unexported fields
}

NativeContract -

func (*NativeContract) InvokeNativeContract

func (nc *NativeContract) InvokeNativeContract(
	gasPrice,
	gasLimit uint64,
	singer *Account,
	version byte,
	contractAddress common.Address,
	method string,
	params []interface{},
) (common.Uint256, error)

InvokeNativeContract -

func (*NativeContract) NewNativeInvokeTransaction

func (nc *NativeContract) NewNativeInvokeTransaction(
	gasPrice,
	gasLimit uint64,
	version byte,
	contractAddress common.Address,
	method string,
	params []interface{},
) (*types.MutableTransaction, error)

NewNativeInvokeTransaction -

func (*NativeContract) PreExecInvokeNativeContract

func (nc *NativeContract) PreExecInvokeNativeContract(
	contractAddress common.Address,
	version byte,
	method string,
	params []interface{},
) (*sdkcom.PreExecResult, error)

PreExecInvokeNativeContract -

type NeoVMContract

type NeoVMContract struct {
	// contains filtered or unexported fields
}

NeoVMContract -

func (*NeoVMContract) DeployNeoVMSmartContract

func (nc *NeoVMContract) DeployNeoVMSmartContract(
	gasPrice,
	gasLimit uint64,
	singer *Account,
	needStorage bool,
	code,
	name,
	version,
	author,
	email,
	desc string) (common.Uint256, error)

DeployNeoVMSmartContract - Deploy smart contract to ontology

func (*NeoVMContract) InvokeNeoVMContract

func (nc *NeoVMContract) InvokeNeoVMContract(
	gasPrice,
	gasLimit uint64,
	signer *Account,
	contractAddress common.Address,
	params []interface{}) (common.Uint256, error)

InvokeNeoVMContract -

func (*NeoVMContract) NewDeployNeoVMCodeTransaction

func (nc *NeoVMContract) NewDeployNeoVMCodeTransaction(gasPrice, gasLimit uint64, contract *sdkcom.SmartContract) *types.MutableTransaction

NewDeployNeoVMCodeTransaction -

func (*NeoVMContract) NewNeoVMInvokeTransaction

func (nc *NeoVMContract) NewNeoVMInvokeTransaction(
	gasPrice,
	gasLimit uint64,
	contractAddress common.Address,
	params []interface{},
) (*types.MutableTransaction, error)

NewNeoVMInvokeTransaction -

func (*NeoVMContract) PreExecInvokeNeoVMContract

func (nc *NeoVMContract) PreExecInvokeNeoVMContract(
	contractAddress common.Address,
	params []interface{}) (*sdkcom.PreExecResult, error)

PreExecInvokeNeoVMContract -

type Ong

type Ong struct {
	// contains filtered or unexported fields
}

Ong -

func (*Ong) Allowance

func (o *Ong) Allowance(from, to common.Address) (uint64, error)

Allowance -

func (*Ong) Approve

func (o *Ong) Approve(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)

Approve -

func (*Ong) BalanceOf

func (o *Ong) BalanceOf(address common.Address) (uint64, error)

BalanceOf -

func (*Ong) Decimals

func (o *Ong) Decimals() (byte, error)

Decimals -

func (*Ong) MultiTransfer

func (o *Ong) MultiTransfer(gasPrice, gasLimit uint64, states []*ont.State, signer *Account) (common.Uint256, error)

MultiTransfer -

func (*Ong) Name

func (o *Ong) Name() (string, error)

Name -

func (*Ong) NewApproveTransaction

func (o *Ong) NewApproveTransaction(gasPrice, gasLimit uint64, from, to common.Address, amount uint64) (*types.MutableTransaction, error)

NewApproveTransaction -

func (*Ong) NewMultiTransferTransaction

func (o *Ong) NewMultiTransferTransaction(gasPrice, gasLimit uint64, states []*ont.State) (*types.MutableTransaction, error)

NewMultiTransferTransaction -

func (*Ong) NewTransferFromTransaction

func (o *Ong) NewTransferFromTransaction(gasPrice, gasLimit uint64, sender, from, to common.Address, amount uint64) (*types.MutableTransaction, error)

NewTransferFromTransaction -

func (*Ong) NewTransferTransaction

func (o *Ong) NewTransferTransaction(gasPrice, gasLimit uint64, from, to common.Address, amount uint64) (*types.MutableTransaction, error)

NewTransferTransaction -

func (*Ong) NewWithdrawONGTransaction

func (o *Ong) NewWithdrawONGTransaction(gasPrice, gasLimit uint64, address common.Address, amount uint64) (*types.MutableTransaction, error)

NewWithdrawONGTransaction -

func (*Ong) Symbol

func (o *Ong) Symbol() (string, error)

Symbol -

func (*Ong) TotalSupply

func (o *Ong) TotalSupply() (uint64, error)

TotalSupply -

func (*Ong) Transfer

func (o *Ong) Transfer(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)

Transfer -

func (*Ong) TransferFrom

func (o *Ong) TransferFrom(gasPrice, gasLimit uint64, sender *Account, from, to common.Address, amount uint64) (common.Uint256, error)

TransferFrom -

func (*Ong) UnboundONG

func (o *Ong) UnboundONG(address common.Address) (uint64, error)

UnboundONG -

func (*Ong) WithdrawONG

func (o *Ong) WithdrawONG(gasPrice, gasLimit uint64, address *Account, amount uint64) (common.Uint256, error)

WithdrawONG -

type Ont

type Ont struct {
	// contains filtered or unexported fields
}

Ont -

func (*Ont) Allowance

func (o *Ont) Allowance(from, to common.Address) (uint64, error)

Allowance -

func (*Ont) Approve

func (o *Ont) Approve(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)

Approve -

func (*Ont) BalanceOf

func (o *Ont) BalanceOf(address common.Address) (uint64, error)

BalanceOf -

func (*Ont) Decimals

func (o *Ont) Decimals() (byte, error)

Decimals -

func (*Ont) MultiTransfer

func (o *Ont) MultiTransfer(gasPrice, gasLimit uint64, states []*ont.State, signer *Account) (common.Uint256, error)

MultiTransfer -

func (*Ont) Name

func (o *Ont) Name() (string, error)

Name -

func (*Ont) NewApproveTransaction

func (o *Ont) NewApproveTransaction(gasPrice, gasLimit uint64, from, to common.Address, amount uint64) (*types.MutableTransaction, error)

NewApproveTransaction -

func (*Ont) NewMultiTransferTransaction

func (o *Ont) NewMultiTransferTransaction(gasPrice, gasLimit uint64, states []*ont.State) (*types.MutableTransaction, error)

NewMultiTransferTransaction -

func (*Ont) NewTransferFromTransaction

func (o *Ont) NewTransferFromTransaction(gasPrice, gasLimit uint64, sender, from, to common.Address, amount uint64) (*types.MutableTransaction, error)

NewTransferFromTransaction -

func (*Ont) NewTransferTransaction

func (o *Ont) NewTransferTransaction(gasPrice, gasLimit uint64, from, to common.Address, amount uint64) (*types.MutableTransaction, error)

NewTransferTransaction -

func (*Ont) Symbol

func (o *Ont) Symbol() (string, error)

Symbol -

func (*Ont) TotalSupply

func (o *Ont) TotalSupply() (uint64, error)

TotalSupply -

func (*Ont) Transfer

func (o *Ont) Transfer(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)

Transfer -

func (*Ont) TransferFrom

func (o *Ont) TransferFrom(gasPrice, gasLimit uint64, sender *Account, from, to common.Address, amount uint64) (common.Uint256, error)

TransferFrom -

type OntID

type OntID struct {
	// contains filtered or unexported fields
}

OntID -

func (*OntID) AddAttributes

func (nc *OntID) AddAttributes(gasPrice, gasLimit uint64, signer *Account, OntID string, attributes []*DDOAttribute, controller *Controller) (common.Uint256, error)

AddAttributes -

func (*OntID) AddKey

func (nc *OntID) AddKey(gasPrice, gasLimit uint64, OntID string, signer *Account, newPubKey keypair.PublicKey, controller *Controller) (common.Uint256, error)

AddKey -

func (*OntID) ChangeRecovery

func (nc *OntID) ChangeRecovery(gasPrice, gasLimit uint64, signer *Account, OntID string, newRecovery, oldRecovery common.Address, controller *Controller) (common.Uint256, error)

ChangeRecovery -

func (*OntID) GetAttributes

func (nc *OntID) GetAttributes(OntID string) ([]*DDOAttribute, error)

GetAttributes -

func (*OntID) GetDDO

func (nc *OntID) GetDDO(OntID string) (*DDO, error)

GetDDO -

func (*OntID) GetKeyState

func (nc *OntID) GetKeyState(OntID string, keyIndex int) (string, error)

GetKeyState -

func (*OntID) GetPublicKeys

func (nc *OntID) GetPublicKeys(OntID string) ([]*DDOOwner, error)

GetPublicKeys -

func (*OntID) NewAddAttributesTransaction

func (nc *OntID) NewAddAttributesTransaction(gasPrice, gasLimit uint64, OntID string, attributes []*DDOAttribute, pubKey keypair.PublicKey) (*types.MutableTransaction, error)

NewAddAttributesTransaction -

func (*OntID) NewAddKeyTransaction

func (nc *OntID) NewAddKeyTransaction(gasPrice, gasLimit uint64, OntID string, newPubKey, pubKey keypair.PublicKey) (*types.MutableTransaction, error)

NewAddKeyTransaction -

func (*OntID) NewChangeRecoveryTransaction

func (nc *OntID) NewChangeRecoveryTransaction(gasPrice, gasLimit uint64, OntID string, newRecovery, oldRecovery common.Address) (*types.MutableTransaction, error)

NewChangeRecoveryTransaction -

func (*OntID) NewRegIDWithAttributesTransaction

func (nc *OntID) NewRegIDWithAttributesTransaction(gasPrice, gasLimit uint64, OntID string, pubKey keypair.PublicKey, attributes []*DDOAttribute) (*types.MutableTransaction, error)

NewRegIDWithAttributesTransaction -

func (*OntID) NewRegIDWithPublicKeyTransaction

func (nc *OntID) NewRegIDWithPublicKeyTransaction(gasPrice, gasLimit uint64, OntID string, pubKey keypair.PublicKey) (*types.MutableTransaction, error)

NewRegIDWithPublicKeyTransaction -

func (*OntID) NewRemoveAttributeTransaction

func (nc *OntID) NewRemoveAttributeTransaction(gasPrice, gasLimit uint64, OntID string, key []byte, pubKey keypair.PublicKey) (*types.MutableTransaction, error)

NewRemoveAttributeTransaction -

func (*OntID) NewRevokeKeyTransaction

func (nc *OntID) NewRevokeKeyTransaction(gasPrice, gasLimit uint64, OntID string, removedPubKey, pubKey keypair.PublicKey) (*types.MutableTransaction, error)

NewRevokeKeyTransaction -

func (*OntID) NewSetRecoveryTransaction

func (nc *OntID) NewSetRecoveryTransaction(gasPrice, gasLimit uint64, OntID string, recovery common.Address, pubKey keypair.PublicKey) (*types.MutableTransaction, error)

NewSetRecoveryTransaction -

func (*OntID) RegIDWithAttributes

func (nc *OntID) RegIDWithAttributes(gasPrice, gasLimit uint64, signer *Account, OntID string, controller *Controller, attributes []*DDOAttribute) (common.Uint256, error)

RegIDWithAttributes -

func (*OntID) RegIDWithPublicKey

func (nc *OntID) RegIDWithPublicKey(gasPrice, gasLimit uint64, signer *Account, OntID string, controller *Controller) (common.Uint256, error)

RegIDWithPublicKey -

func (*OntID) RemoveAttribute

func (nc *OntID) RemoveAttribute(gasPrice, gasLimit uint64, signer *Account, OntID string, removeKey []byte, controller *Controller) (common.Uint256, error)

RemoveAttribute -

func (*OntID) RevokeKey

func (nc *OntID) RevokeKey(gasPrice, gasLimit uint64, OntID string, signer *Account, removedPubKey keypair.PublicKey, controller *Controller) (common.Uint256, error)

RevokeKey -

func (*OntID) SetRecovery

func (nc *OntID) SetRecovery(gasPrice, gasLimit uint64, signer *Account, OntID string, recovery common.Address, controller *Controller) (common.Uint256, error)

SetRecovery -

func (*OntID) VerifySignature

func (nc *OntID) VerifySignature(OntID string, keyIndex int, controller *Controller) (bool, error)

VerifySignature -

type OntologySdk

type OntologySdk struct {
	client.ClientMgr
	Native *NativeContract
	NeoVM  *NeoVMContract
}

OntologySdk is the main struct for user

func NewOntologySdk

func NewOntologySdk() *OntologySdk

NewOntologySdk return OntologySdk.

func (*OntologySdk) CreateWallet

func (sdk *OntologySdk) CreateWallet(walletFile string) (*Wallet, error)

CreateWallet return a new wallet

func (*OntologySdk) GetAdddrByPubKey

func (sdk *OntologySdk) GetAdddrByPubKey(pubKey keypair.PublicKey) string

GetAdddrByPubKey -

func (*OntologySdk) GetMultiAddr

func (sdk *OntologySdk) GetMultiAddr(pubkeys []keypair.PublicKey, m int) (string, error)

GetMultiAddr -

func (*OntologySdk) MultiSignToTransaction

func (sdk *OntologySdk) MultiSignToTransaction(tx *types.MutableTransaction, m uint16, pubKeys []keypair.PublicKey, signer Signer) error

MultiSignToTransaction -

func (*OntologySdk) NewInvokeTransaction

func (sdk *OntologySdk) NewInvokeTransaction(gasPrice, gasLimit uint64, invokeCode []byte) *types.MutableTransaction

NewInvokeTransaction return smart contract invoke transaction

func (*OntologySdk) OpenWallet

func (sdk *OntologySdk) OpenWallet(walletFile string) (*Wallet, error)

OpenWallet return a wallet instance

func (*OntologySdk) SignToTransaction

func (sdk *OntologySdk) SignToTransaction(tx *types.MutableTransaction, signer Signer) error

SignToTransaction -

type Signer

type Signer interface {
	Sign(data []byte) ([]byte, error)
	GetPublicKey() keypair.PublicKey
	GetPrivateKey() keypair.PrivateKey
	GetSigScheme() s.SignatureScheme
}

Signer -

type Wallet

type Wallet struct {
	Name    string
	Version string
	Scrypt  *keypair.ScryptParam
	Extra   string
	// contains filtered or unexported fields
}

Wallet -

func LoadWalletFromData

func LoadWalletFromData(wd WalletData, path string) (*Wallet, error)

LoadWalletFromData - Load walletData to wallet

func NewWallet

func NewWallet(path string) *Wallet

NewWallet -

func OpenWallet

func OpenWallet(path string) (*Wallet, error)

OpenWallet - open wallet from file on path. Create it if not existed.

func (*Wallet) AddAccountData

func (w *Wallet) AddAccountData(accountData *AccountData) error

AddAccountData -

func (*Wallet) AddIdentity

func (w *Wallet) AddIdentity(identity *Identity) error

AddIdentity -

func (*Wallet) ChangeAccountPassword

func (w *Wallet) ChangeAccountPassword(address string, oldPassword, newPassword []byte) error

ChangeAccountPassword -

func (*Wallet) DeleteAccount

func (w *Wallet) DeleteAccount(address string) error

DeleteAccount -

func (*Wallet) DeleteIdentity

func (w *Wallet) DeleteIdentity(id string) error

DeleteIdentity -

func (*Wallet) ExportAccounts

func (w *Wallet) ExportAccounts(path string, accountDatas []*AccountData, passwds [][]byte, newScrypts ...*keypair.ScryptParam) (*Wallet, error)

ExportAccounts -

func (*Wallet) GetAccountByAddress

func (w *Wallet) GetAccountByAddress(address string, passwd []byte) (*Account, error)

GetAccountByAddress -

func (*Wallet) GetAccountByIndex

func (w *Wallet) GetAccountByIndex(index int, passwd []byte) (*Account, error)

GetAccountByIndex - Index start from 1

func (*Wallet) GetAccountByLabel

func (w *Wallet) GetAccountByLabel(label string, passwd []byte) (*Account, error)

GetAccountByLabel -

func (*Wallet) GetAccountCount

func (w *Wallet) GetAccountCount() int

GetAccountCount -

func (*Wallet) GetAccountDataByAddress

func (w *Wallet) GetAccountDataByAddress(address string) (*AccountData, error)

GetAccountDataByAddress -

func (*Wallet) GetAccountDataByIndex

func (w *Wallet) GetAccountDataByIndex(index int) (*AccountData, error)

GetAccountDataByIndex - Index start from 1

func (*Wallet) GetAccountDataByLabel

func (w *Wallet) GetAccountDataByLabel(label string) (*AccountData, error)

GetAccountDataByLabel -

func (*Wallet) GetDefaultAccount

func (w *Wallet) GetDefaultAccount(passwd []byte) (*Account, error)

GetDefaultAccount -

func (*Wallet) GetDefaultAccountData

func (w *Wallet) GetDefaultAccountData() (*AccountData, error)

GetDefaultAccountData -

func (*Wallet) GetDefaultIdentity

func (w *Wallet) GetDefaultIdentity() (*Identity, error)

GetDefaultIdentity -

func (*Wallet) GetIdentityByID

func (w *Wallet) GetIdentityByID(id string) (*Identity, error)

GetIdentityByID -

func (*Wallet) GetIdentityByIndex

func (w *Wallet) GetIdentityByIndex(index int) (*Identity, error)

GetIdentityByIndex - Index start from 1

func (*Wallet) GetIdentityByLabel

func (w *Wallet) GetIdentityByLabel(label string) (*Identity, error)

GetIdentityByLabel -

func (*Wallet) GetIdentityCount

func (w *Wallet) GetIdentityCount() int

GetIdentityCount -

func (*Wallet) GetWalletData

func (w *Wallet) GetWalletData() WalletData

GetWalletData - get walletdata from wallets

func (*Wallet) ImportAccounts

func (w *Wallet) ImportAccounts(accountDatas []*AccountData, passwds [][]byte) error

ImportAccounts -

func (*Wallet) NewAccount

func (w *Wallet) NewAccount(keyType keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte) (*Account, error)

NewAccount -

func (*Wallet) NewAccountFromWIF

func (w *Wallet) NewAccountFromWIF(wif, passwd []byte) (*Account, error)

NewAccountFromWIF -

func (*Wallet) NewDefaultSettingAccount

func (w *Wallet) NewDefaultSettingAccount(passwd []byte) (*Account, error)

NewDefaultSettingAccount -

func (*Wallet) NewDefaultSettingIdentity

func (w *Wallet) NewDefaultSettingIdentity(passwd []byte) (*Identity, error)

NewDefaultSettingIdentity -

func (*Wallet) NewIdentity

func (w *Wallet) NewIdentity(keyType keypair.KeyType, curveCode byte, sigScheme s.SignatureScheme, passwd []byte) (*Identity, error)

NewIdentity -

func (*Wallet) Save

func (w *Wallet) Save() error

Save -

func (*Wallet) SetDefaultAccount

func (w *Wallet) SetDefaultAccount(address string) error

SetDefaultAccount -

func (*Wallet) SetDefaultIdentity

func (w *Wallet) SetDefaultIdentity(id string) error

SetDefaultIdentity -

func (*Wallet) SetIdentityLabel

func (w *Wallet) SetIdentityLabel(id, newLabel string) error

SetIdentityLabel -

func (*Wallet) SetLabel

func (w *Wallet) SetLabel(address, newLabel string) error

SetLabel -

func (*Wallet) SetSigScheme

func (w *Wallet) SetSigScheme(address string, sigScheme s.SignatureScheme) error

SetSigScheme -

type WalletData

type WalletData struct {
	Name       string               `json:"name"`
	Version    string               `json:"version"`
	Scrypt     *keypair.ScryptParam `json:"scrypt"`
	Identities []*IdentityData      `json:"identities,omitempty"`
	Accounts   []*AccountData       `json:"accounts,omitempty"`
	Extra      string               `json:"extra,omitempty"`
}

WalletData -

func NewWalletData

func NewWalletData() *WalletData

NewWalletData -

func (*WalletData) Clone

func (wd *WalletData) Clone() *WalletData

Clone -

func (*WalletData) Load

func (wd *WalletData) Load(path string) error

Load -

func (*WalletData) Save

func (wd *WalletData) Save(path string) error

Save -

Jump to

Keyboard shortcuts

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