client

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Keys_       = make(map[string]string)
	Checksum_   = make([]byte, sha512.Size)
	Wallet_     Wallet
	Locked      = true
	WalletName_ = "wallet.json"
)
View Source
var (
	ErrInitializeTransport = errors.New("Failed to initialize transport.")
)
View Source
var (
	//OpTypeKey include a description of the operation and the key needed to sign it
	OpTypeKey = make(map[types.OpType][]string)
)
View Source
var RefBlockMap = make(map[time.Time]uint32)

Functions

func CreatePrivateKey

func CreatePrivateKey(user, role, password string) string

CreatePrivateKey generates a private key based on the specified parameters.

func CreatePublicKey

func CreatePublicKey(prefix, privatekey string) string

CreatePublicKey generates a public key based on the prefix and the private key.

func Decrypt

func Decrypt(key []byte, text string) (string, error)

func EncodeWallet added in v0.0.3

func EncodeWallet(password string, wallet_data *WalletData) (string, error)

func Encrypt

func Encrypt(key []byte, text string) (string, error)

func HasElem

func HasElem(s interface{}, elem interface{}) bool

func JSONOpString

func JSONOpString(v []types.Operation) (string, error)

JSONOpString generate Operations to String

func JSONTrxString

func JSONTrxString(v *transactions.SignedTransaction) (string, error)

JSONTrxString generate Trx to String

func Pad

func Pad(src []byte) []byte

func RandStringBytes

func RandStringBytes(n int) (string, error)

func SaveWalletFile

func SaveWalletFile(wallet_path string, wallet_filename string, password string, wallet_data *WalletData) error

func SetAsset

func SetAsset(amount float64, symbol string) *types.Asset

SetAsset returns data of type Asset

func Unpad

func Unpad(src []byte) ([]byte, error)

func ValidateAmount

func ValidateAmount(amount string) bool

func ValidateFee

func ValidateFee(fee string, minFee float64) bool

func ValidateNameAccount

func ValidateNameAccount(name string) error

Types

type BResp

type BResp struct {
	ID      string
	JSONTrx string
}

BResp of response when sending a transaction.

type Client

type Client struct {
	AsyncProtocol bool

	// Database represents database_api.
	API *api.API

	// Current private keys for operations
	CurrentKeys *Keys
	// contains filtered or unexported fields
}

Client can be used to access BEOWULF remote APIs. There is a public field for every BEOWULF API available,

func NewClient

func NewClient(s string, isTestNet bool) (*Client, error)

NewClient creates a new RPC client that use the given CallCloser internally. Initialize only server present API. Absent API initialized as nil value.

func (*Client) AccountCreate

func (client *Client) AccountCreate(creator, newAccountName, publicKey, fee string) (*OperResp, error)

func (*Client) AccountCreateWS

func (client *Client) AccountCreateWS(creator, newAccountName, password, fee string) (*OperResp, error)

func (*Client) AccountSupernodeUnvote

func (client *Client) AccountSupernodeUnvote(username, supernodeName, fee string) (*OperResp, error)

Unvote

func (*Client) AccountSupernodeVote

func (client *Client) AccountSupernodeVote(username, supernodeName, fee string, votes int64) (*OperResp, error)

AccountSupernodeVote of voting for the delegate.

func (*Client) AccountUpdate

func (client *Client) AccountUpdate(account, publicKey, fee string) (*OperResp, error)

AccountUpdate update public key for account

func (*Client) AddAuthorizedIssuingAccounts added in v1.0.2

func (client *Client) AddAuthorizedIssuingAccounts(fromName, scid, symbol, fee string, issuingAccounts []string) (*OperResp, error)

func (*Client) AddProperty added in v1.0.2

func (client *Client) AddProperty(fromName, scid, symbol, propertyName, propertyType, fee string, authorizedEditingAccounts []string) (*OperResp, error)

func (*Client) BurnNFT added in v1.0.2

func (client *Client) BurnNFT(fromName, scid, fee string, nfts []api.NFTTransferRequest) (*OperResp, error)

func (*Client) Close

func (client *Client) Close() error

Close should be used to close the client when no longer needed. It simply calls Close() on the underlying CallCloser.

func (*Client) CommitBlockSidechain added in v1.0.4

func (client *Client) CommitBlockSidechain(csid, fromName, content, fee string) (*OperResp, error)

func (*Client) CreateMultiSigAccount

func (client *Client) CreateMultiSigAccount(creator, newAccountName, fee string, accountOwners []string, keyOwners []string,
	threshold uint32) (*OperResp, error)

CreateMultiSigAccount creating an account shared among many users in systems

func (*Client) CreateNFT added in v1.0.2

func (client *Client) CreateNFT(fromName, scid, name, symbol, maxSupply, fee string, authorizedIssuingAccounts []string) (*OperResp, error)

Create NFT

func (*Client) CreateToken

func (client *Client) CreateToken(creator, controlAcc, tokenName string, decimals uint8, maxSupply uint64) (*OperResp, error)

func (*Client) CreateTrx

func (client *Client) CreateTrx(trxOps []types.Operation, extension string) (*transactions.SignedTransaction, error)

func (*Client) CreateTrxTransfer

func (client *Client) CreateTrxTransfer(fromName, toName, memo, amount, fee string, extension string) (*transactions.SignedTransaction, error)

func (*Client) GenKeys

func (client *Client) GenKeys(newAccountName string) (*WalletData, error)

AccountCreate creating a user in systems

func (*Client) GetAccount

func (client *Client) GetAccount(account string) (*api.AccountInfo, error)

func (*Client) GetActiveSupernodes

func (client *Client) GetActiveSupernodes() (*[]string, error)

func (*Client) GetBalance

func (client *Client) GetBalance(account, tokenName string, decimals uint8) (*string, error)

func (*Client) GetBlock

func (client *Client) GetBlock(blockNum uint32) (*api.Block, error)

func (*Client) GetHeadBlockNum

func (client *Client) GetHeadBlockNum() (uint32, error)

Get HeadBlockNumber from mem before getting from Blockchain

func (*Client) GetKeyReferences

func (client *Client) GetKeyReferences(publicKey string) (*[][]string, error)

func (*Client) GetLatestNFTBlock added in v1.0.2

func (client *Client) GetLatestNFTBlock() (*api.NFTBlock, error)

func (*Client) GetNFTBalance added in v1.0.2

func (client *Client) GetNFTBalance(account, symbol string, limit, offset uint32) (*api.NFTInstanceList, error)

func (*Client) GetNFTBalanceOfAccount added in v1.0.2

func (client *Client) GetNFTBalanceOfAccount(account string, limit, offset uint32) (map[string]api.NFTInstanceList, error)

func (*Client) GetNFTBlock added in v1.0.2

func (client *Client) GetNFTBlock(blockNum uint32) (*api.NFTBlock, error)

func (*Client) GetNFTInstances added in v1.0.2

func (client *Client) GetNFTInstances(symbol string, limit, offset uint32) (*api.NFTInstanceList, error)

func (*Client) GetNFTTransaction added in v1.0.2

func (client *Client) GetNFTTransaction(trxid string) (*api.NFTTransaction, error)

func (*Client) GetNFTs added in v1.0.2

func (client *Client) GetNFTs(symbol string, limit, offset uint32) (*api.NFTList, error)

func (*Client) GetPrivateKey

func (client *Client) GetPrivateKey() string

func (*Client) GetPublicKey

func (client *Client) GetPublicKey() string

func (*Client) GetSigningKeysOwner

func (client *Client) GetSigningKeysOwner() ([][]byte, error)

func (*Client) GetSupernodeByAccount

func (client *Client) GetSupernodeByAccount(account string) (*api.SupernodeInfo, error)

func (*Client) GetSupernodeVoted

func (client *Client) GetSupernodeVoted(account string) (*api.SupernodeVoteList, error)

func (*Client) GetToken

func (client *Client) GetToken(name string) (*api.TokenInfo, error)

func (*Client) GetTransaction

func (client *Client) GetTransaction(trx string) (*api.TransactionResponse, error)

func (*Client) GetTrx

func (client *Client) GetTrx(strx []types.Operation, extension string) (*types.Transaction, error)

func (*Client) ImportKey

func (client *Client) ImportKey(wif_key, name string) bool

func (*Client) IssueNFT added in v1.0.2

func (client *Client) IssueNFT(fromName, scid, symbol, to, fee string) (*OperResp, error)

func (*Client) IssueWithProperties added in v1.0.2

func (client *Client) IssueWithProperties(fromName, scid, symbol, to, fee string, properties interface{}) (*OperResp, error)

func (*Client) ListAccounts

func (client *Client) ListAccounts(lowerBound string, limit uint32) (*[]string, error)

func (*Client) ListSupernodes

func (client *Client) ListSupernodes(lowerBound string, limit uint32) (*[]string, error)

func (*Client) ListTokens

func (client *Client) ListTokens() (*api.TokenList, error)

func (*Client) LoadWallet

func (client *Client) LoadWallet(wallet_filename string) bool

func (*Client) MultiOp

func (client *Client) MultiOp(trx []types.Operation, extension string) (*OperResp, error)

func (*Client) MultipleIssueNFT added in v1.0.2

func (client *Client) MultipleIssueNFT(fromName, scid, fee string, instances []api.Instance) (*OperResp, error)

func (*Client) RemoveAuthorizedIssuingAccounts added in v1.0.2

func (client *Client) RemoveAuthorizedIssuingAccounts(fromName, scid, symbol, fee string, issuingAccounts []string) (*OperResp, error)

func (*Client) SendTrx

func (client *Client) SendTrx(strx []types.Operation, extension string) (*BResp, error)

SendTrx generates and sends an array of transactions to BEOWULF.

func (*Client) SendTrxMultiSig

func (client *Client) SendTrxMultiSig(tx *transactions.SignedTransaction) (*BResp, error)

func (*Client) SetKeys

func (client *Client) SetKeys(keys *Keys)

SetKeys you can specify keys for signing transactions.

func (*Client) SetKeysFromEncodeWallet added in v0.0.3

func (client *Client) SetKeysFromEncodeWallet(wallet_json string, password string) error

func (*Client) SetKeysFromFileWallet

func (client *Client) SetKeysFromFileWallet(pathFileWallet string, password string) error

func (*Client) SetPassword

func (client *Client) SetPassword(password string) error

func (*Client) SetProperties added in v1.0.2

func (client *Client) SetProperties(fromName, scid, symbol, fee string, nfts []api.NFTProperty) (*OperResp, error)

func (*Client) SignTrx

func (*Client) SignTrxMulti

func (client *Client) SignTrxMulti(tx *transactions.SignedTransaction) ([]string, error)

func (*Client) SigningKeys

func (client *Client) SigningKeys(trx types.Operation) ([][]byte, error)

SigningKeys returns the key from the CurrentKeys

func (*Client) SupernodeUpdate

func (client *Client) SupernodeUpdate(owner, blocksigningkey, fee string) (*OperResp, error)

SupernodeUpdate updating delegate data

func (*Client) Transfer

func (client *Client) Transfer(fromName, toName, memo, amount, fee string) (*OperResp, error)

Transfer of funds to any user.

func (*Client) TransferEx

func (client *Client) TransferEx(fromName, toName, memo, amount, fee string, extension string) (*OperResp, error)

func (*Client) TransferNFT added in v1.0.2

func (client *Client) TransferNFT(fromName, scid, to, fee string, nfts []api.NFTTransferRequest) (*OperResp, error)

func (*Client) TransferToVesting

func (client *Client) TransferToVesting(from, to, amount, fee string) (*OperResp, error)

TransferToVesting transfer to POWER

func (*Client) Unlock

func (client *Client) Unlock(password string) error

func (*Client) UpdateMetadata added in v1.0.2

func (client *Client) UpdateMetadata(fromName, scid, symbol, url, image, fee string) (*OperResp, error)

func (*Client) UpdateMultiSigAccount

func (client *Client) UpdateMultiSigAccount(account, fee string, accountOwners []string, keyOwners []string, threshold uint32) (*OperResp, error)

AccountUpdate update owner keys for account TODO: every key has different weight on account

func (*Client) UpdateName added in v1.0.2

func (client *Client) UpdateName(fromName, scid, symbol, name, fee string) (*OperResp, error)

func (*Client) UpdateOrgName added in v1.0.2

func (client *Client) UpdateOrgName(fromName, scid, symbol, orgName, fee string) (*OperResp, error)

func (*Client) UpdatePropertyDefinition added in v1.0.2

func (client *Client) UpdatePropertyDefinition(fromName, scid, symbol, propertyName, newPropertyName, newPropertyType, fee string) (*OperResp, error)

func (*Client) WithdrawVesting

func (client *Client) WithdrawVesting(account, vshares, fee string) (*OperResp, error)

WithdrawVesting down POWER

type Keys

type Keys struct {
	OKey []string
}

Keys is used as a keystroke for a specific user. Only a few keys can be set.

type OperResp

type OperResp struct {
	NameOper string
	Bresp    *BResp
}

OperResp type is returned when the operation is performed.

type PlainKeys

type PlainKeys struct {
	Checksum [sha512.Size]byte `json:"checksum"`
	Keys     map[string]string `json:"keys"`
}

type Wallet

type Wallet struct {
	CipherKeys string `json:"cipher_keys"`
	CipherType string `json:"cipher_type"` // "aes-256-cbc"
	Salt       string `json:"salt"`
	Name       string `json:"name"`
}

type WalletData

type WalletData struct {
	Name       string `json:"name"`
	PrivateKey string `json:"private_key"`
	PublicKey  string `json:"public_key"`
}

Jump to

Keyboard shortcuts

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