account

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthToWei   = Quintillion
	CentsToWei = 100000000000
)
View Source
const RegistrationFileName = "registration.txt"
View Source
const RegistrationVersion = 2

Variables

This section is empty.

Functions

func ArchonSignatureFor

func ArchonSignatureFor(r io.Reader, acc ifc.IAccount) (string, []byte, int64, error)

func GasPerGByteFromProfile

func GasPerGByteFromProfile(gasPerMByte int64) string

func GasToInt64

func GasToInt64(gas float64) int64

func GenerateNewEthKey

func GenerateNewEthKey() []byte

func GenerateNewEthWallet

func GenerateNewEthWallet(path, password, pKey string) (err error)

GenerateNewEthWallet creates a new .json wallet file

func GenerateNewNeoWallet

func GenerateNewNeoWallet(path, password, wif string) (err error)

GenerateNewNeoWallet creates a new .json wallet file

func GenerateNewWalletFile

func GenerateNewWalletFile(accT ifc.AccountType, showPassword bool)

func GetEthereumUploadTxInfo

func GetEthereumUploadTxInfo(txId string) (*ifc.UploadTxInfo, error)

GetEthereumUploadTxInfo returns info needed to verify the transaction on the SP side

func GetNodeId added in v1.0.5

func GetNodeId(acc ifc.IAccount) (nodeId string, err error)

func GetRegistrationInfo

func GetRegistrationInfo(regPath string) (*interfaces.RegistrationInfo, error)

func IsEth

func IsEth(acc ifc.IAccount) bool

func NewIAccount

func NewIAccount(walletPath string, password string) (iaccount ifc.IAccount, err error)

func PrettyCurrencyForAccount

func PrettyCurrencyForAccount(acc ifc.IAccount, amount int64) string

func PrivateKeyFromString

func PrivateKeyFromString(hexkey string) (*ecdsa.PrivateKey, error)

func ProposeUpload

func ProposeUpload(acc ifc.IAccount, fc *shards.FileContainer, s *shards.ShardsContainer, a *ArchonUrl, sps StorageProviders, maxPayment int64) (txId string, price int64, err error)

if maxPayment is negative, then the user will be prompted

func PublicFromPrivate

func PublicFromPrivate(priv *ecdsa.PrivateKey) []byte

func Sign

func Sign(acc ifc.IAccount, hash []byte) (sig []byte, err error)

Sign and verify is done with ecdsa for both Eth and Neo

func Verify

func Verify(acc ifc.IAccount, hash, signature, publicKey []byte) bool

func WeiPerByteFromProfile

func WeiPerByteFromProfile(weiPerMByte int64) string

func WeiString

func WeiString(wei int64) string

Types

type EthAccount

type EthAccount struct {
	PrivateKey *ecdsa.PrivateKey // Public key is also available through this
	// contains filtered or unexported fields
}

Implements IAccount for Ethereum

func NewEthAccount

func NewEthAccount(walletPath string, password string) (ethAcc *EthAccount, err error)

walletPath may be relative (to exe folder, or absolute)

func (*EthAccount) AddressBytes

func (acc *EthAccount) AddressBytes() []byte

func (*EthAccount) AddressString

func (acc *EthAccount) AddressString() string

func (*EthAccount) BlockchainName

func (account *EthAccount) BlockchainName() string

func (*EthAccount) EcdsaPrivateKey

func (account *EthAccount) EcdsaPrivateKey() *ecdsa.PrivateKey

func (*EthAccount) EcdsaPublicKeyBytes

func (acc *EthAccount) EcdsaPublicKeyBytes() []byte

func (*EthAccount) GetAccountType

func (acc *EthAccount) GetAccountType() ifc.AccountType

--------------------- IAccount start -----------------------------------------------

func (*EthAccount) GetEarnings

func (acc *EthAccount) GetEarnings() (int64, error)

func (*EthAccount) GetEthAddress

func (acc *EthAccount) GetEthAddress() *EthAddress

func (*EthAccount) GetEthPrivate

func (account *EthAccount) GetEthPrivate() *[32]byte

func (*EthAccount) GetEthereumKeyset

func (account *EthAccount) GetEthereumKeyset() *wallet.EthereumKeyset

func (*EthAccount) GetUploadTxInfo

func (acc *EthAccount) GetUploadTxInfo(txId string) (info *ifc.UploadTxInfo, err error)

func (*EthAccount) GetUserName

func (account *EthAccount) GetUserName() (userName string, err error)

GetUserName returns the user name, if registered, otherwise empty string Note SPs have no user name

func (*EthAccount) HundredthOfCent

func (acc *EthAccount) HundredthOfCent() int64

func (*EthAccount) IsSpRegistered

func (acc *EthAccount) IsSpRegistered() (isRegistered bool)

func (*EthAccount) IsTxAccepted

func (acc *EthAccount) IsTxAccepted(txId string) bool

func (*EthAccount) Permission

func (acc *EthAccount) Permission() UrlPermission

func (*EthAccount) PrettyCurrency

func (acc *EthAccount) PrettyCurrency(amount int64) string

func (*EthAccount) PrivateKeyBytes

func (account *EthAccount) PrivateKeyBytes() []byte

func (*EthAccount) PrivateKeyString

func (account *EthAccount) PrivateKeyString() string

func (*EthAccount) ProposeUpload

func (acc *EthAccount) ProposeUpload(fc *shards.FileContainer, s *shards.ShardsContainer, a *ArchonUrl, sps StorageProviders, maxPayment int64) (txId string, price int64, err error)

func (*EthAccount) PublicKeyBytes

func (acc *EthAccount) PublicKeyBytes() []byte

func (*EthAccount) PublicKeyString

func (account *EthAccount) PublicKeyString() string

func (*EthAccount) RegisterSP

func (acc *EthAccount) RegisterSP(r *ifc.RegistrationInfo) (txId string, err error)

func (*EthAccount) RegisterUserName

func (account *EthAccount) RegisterUserName(userName string) error

func (*EthAccount) Sign

func (acc *EthAccount) Sign(hash []byte) (sig []byte, err error)

func (*EthAccount) UnregisterSP

func (acc *EthAccount) UnregisterSP() (err error)

func (*EthAccount) Verify

func (acc *EthAccount) Verify(hash, signature, publicKey []byte) bool

type EthereumKey

type EthereumKey struct {
	PrivateKey []byte // 32
	PublicKey  []byte // 64
}

Needed because file signing is done with Eth keys

func ToEcdsa

func ToEcdsa(privateKey []byte) (ethKey *EthereumKey, err error)

type NeoAccount

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

func NewNeoAccount

func NewNeoAccount(walletPath string, password string) (acc *NeoAccount, err error)

walletPath may be relative (to exe folder) or absolute

func NewNeoAccountFromWif

func NewNeoAccountFromWif(wif string) (acc *NeoAccount, err error)

func (*NeoAccount) AddressBytes

func (account *NeoAccount) AddressBytes() []byte

func (*NeoAccount) AddressString

func (account *NeoAccount) AddressString() string

func (*NeoAccount) BlockchainName

func (account *NeoAccount) BlockchainName() string

func (*NeoAccount) EcdsaPrivateKey

func (acc *NeoAccount) EcdsaPrivateKey() *ecdsa.PrivateKey

func (*NeoAccount) EcdsaPublicKeyBytes

func (acc *NeoAccount) EcdsaPublicKeyBytes() []byte

func (*NeoAccount) GetAccountType

func (acc *NeoAccount) GetAccountType() interfaces.AccountType

--------------------- IAccount start -----------------------------------------------

func (*NeoAccount) GetEarnings

func (acc *NeoAccount) GetEarnings() (int64, error)

func (*NeoAccount) GetUploadTxInfo

func (acc *NeoAccount) GetUploadTxInfo(txId string) (pInfo *interfaces.UploadTxInfo, err error)

func (*NeoAccount) GetUserName

func (acc *NeoAccount) GetUserName() (string, error)

GetUserName returns the user name, if registered, otherwise empty string Note SPs have no user name

func (*NeoAccount) GetWallet

func (acc *NeoAccount) GetWallet() *wallet.Account

func (*NeoAccount) HundredthOfCent

func (acc *NeoAccount) HundredthOfCent() int64

func (*NeoAccount) IsSpRegistered

func (acc *NeoAccount) IsSpRegistered() bool

func (*NeoAccount) IsTxAccepted

func (acc *NeoAccount) IsTxAccepted(txId string) bool

func (*NeoAccount) Permission

func (acc *NeoAccount) Permission() UrlPermission

func (*NeoAccount) PrettyCurrency

func (acc *NeoAccount) PrettyCurrency(amount int64) string

func (*NeoAccount) PrivateKeyBytes

func (account *NeoAccount) PrivateKeyBytes() []byte

func (*NeoAccount) PrivateKeyString

func (account *NeoAccount) PrivateKeyString() string

func (*NeoAccount) ProposeUpload

func (acc *NeoAccount) ProposeUpload(fc *shards.FileContainer, s *shards.ShardsContainer, a *ArchonUrl, sps StorageProviders, maxPayment int64) (txIds map[string]string, totalPrice int64, err error)

func (*NeoAccount) PublicKeyBytes

func (account *NeoAccount) PublicKeyBytes() []byte

func (*NeoAccount) PublicKeyString

func (account *NeoAccount) PublicKeyString() string

func (*NeoAccount) RegisterSP

func (acc *NeoAccount) RegisterSP(r *interfaces.RegistrationInfo) (txId string, err error)

func (*NeoAccount) RegisterUserName

func (acc *NeoAccount) RegisterUserName(userName string) error

func (*NeoAccount) Sign

func (acc *NeoAccount) Sign(hash []byte) (sig []byte, err error)

func (*NeoAccount) UnregisterSP

func (acc *NeoAccount) UnregisterSP() error

func (*NeoAccount) Verify

func (acc *NeoAccount) Verify(hash, signature, publicKey []byte) bool

Jump to

Keyboard shortcuts

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