icon

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: GPL-3.0 Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const (
	//币种
	Symbol    = "ICX"
	MasterKey = "Icon seed"
	CurveType = owcrypt.ECC_CURVE_SECP256K1
)

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, password string) string

See 2 (end of page 4) http://www.ietf.org/rfc/rfc2617.txt "To receive authorization, the client sends the userid and password, separated by a single colon (":") character, within a base64 encoded string in the credentials." It is not meant to be urlencoded.

Types

type Client

type Client struct {
	BaseURL string
	Debug   bool
	Client  *req.Req
	Header  req.Header
}

func NewClient

func NewClient(url string, debug bool) *Client

func (*Client) Call

func (c *Client) Call(path string, request map[string]interface{}) (*gjson.Result, error)

Call calls a remote procedure on another node, specified by the path.

func (*Client) Call_icx_getBalance

func (c *Client) Call_icx_getBalance(address string) (string, error)

func (*Client) Call_icx_getTransactionByHash

func (c *Client) Call_icx_getTransactionByHash(txhash string) (string, error)

func (*Client) Call_icx_sendTransaction

func (c *Client) Call_icx_sendTransaction(request map[string]interface{}) (string, error)

type Key

type Key struct {
	Address    string `storm:"id"`
	PublicKey  []byte
	PrivateKey []byte
}

type Transaction

type Transaction struct {
	From      string
	To        string
	Value     string //0x + Hex string
	Timestamp string
	Nonce     string
	StepLimit string
	Tx_hash   string
}

type WalletConfig

type WalletConfig struct {
	//币种
	Symbol    string
	MasterKey string

	//钱包服务API
	ServerAPI string

	//汇总阀值
	Threshold decimal.Decimal
	//汇总地址
	SumAddress string
	//汇总执行间隔时间
	CycleSeconds time.Duration
	//默认配置内容
	DefaultConfig string
	//曲线类型
	CurveType uint32
	//stepLimit 矿工费上限
	StepLimit int64
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(symbol string, masterKey string) *WalletConfig

func (*WalletConfig) InitConfig

func (wc *WalletConfig) InitConfig()

initConfig 初始化配置文件

func (*WalletConfig) PrintConfig

func (wc *WalletConfig) PrintConfig() error

printConfig Print config information

type WalletManager

type WalletManager struct {
	Storage      *hdkeystore.HDKeystore        //秘钥存取
	WalletClient *Client                       // 节点客户端
	Config       *WalletConfig                 //钱包管理配置
	WalletsInSum map[string]*openwallet.Wallet //参与汇总的钱包

}

func NewWalletManager

func NewWalletManager() *WalletManager

func (*WalletManager) AddWalletInSummary

func (wm *WalletManager) AddWalletInSummary(wid string, wallet *openwallet.Wallet)

func (*WalletManager) BackupWalletFlow

func (wm *WalletManager) BackupWalletFlow() error

备份钱包流程

func (*WalletManager) CalculateTxHash

func (wm *WalletManager) CalculateTxHash(from, to, value string, stepLimit, nonce int64) (map[string]interface{}, [32]byte)

计算交易体hash

{
	 	"version": "0x3",
	 	"from": "hx2006f91de4cd0b9ce74cb00a06e66eaeb44c70b1",
	 	"stepLimit": "0xf4240",
	 	"timestamp": "0x5796c0695145c",
	 	"nid": "0x1",
	 	"to": "hxb12addba58c934ff924aa87ee65d06ee20f89eb8",
	 	"value": "0x8f0d180",
	 	"nonce": "0x64",
	 	"signature": "9G7dKZx1KcdTAwbwtSlnlNklB3EQRpGBUK5kb5nqW1MyM9RxmiVvODbD9HaCuERKbf/KN5tlL1T5V95kN6x+RAE=",
	 }

func (*WalletManager) CreateAddressFlow

func (wm *WalletManager) CreateAddressFlow() error

创建地址流程

func (*WalletManager) CreateBatchAddress

func (wm *WalletManager) CreateBatchAddress(walletId, password string, count uint64) (string, []*openwallet.Address, error)

func (*WalletManager) CreateNewPrivateKey

func (wm *WalletManager) CreateNewPrivateKey(key *hdkeystore.HDKey, start, index uint64) (*openwallet.Address, error)

CreateNewPrivateKey 创建私钥,返回私钥wif格式字符串

func (*WalletManager) CreateNewWallet

func (wm *WalletManager) CreateNewWallet(name, password string) (*openwallet.Wallet, string, error)

CreateNewWallet 创建钱包

func (*WalletManager) CreateWalletFlow

func (wm *WalletManager) CreateWalletFlow() error

创建钱包流程

func (*WalletManager) GetLastBlock

func (wm *WalletManager) GetLastBlock() (*gjson.Result, error)

func (*WalletManager) GetWalletByID

func (wm *WalletManager) GetWalletByID(walletID string) (*openwallet.Wallet, error)

GetWalletByID 获取钱包

func (*WalletManager) GetWalletList

func (wm *WalletManager) GetWalletList() error

GetWalletList 获取钱包列表

func (*WalletManager) GetWallets

func (wm *WalletManager) GetWallets() ([]*openwallet.Wallet, error)

GetWalletKeys 通过给定的文件路径加载keystore文件得到钱包列表

func (*WalletManager) InitConfigFlow

func (wm *WalletManager) InitConfigFlow() error

初始化配置流程

func (*WalletManager) LoadConfig

func (wm *WalletManager) LoadConfig() error

loadConfig 读取配置

func (*WalletManager) RestoreWallet

func (wm *WalletManager) RestoreWallet(keyFile, dbFile, password string) error

RestoreWallet 恢复钱包

func (*WalletManager) RestoreWalletFlow

func (w *WalletManager) RestoreWalletFlow() error

RestoreWalletFlow 恢复钱包

func (*WalletManager) ShowConfig

func (wm *WalletManager) ShowConfig() error

查看配置信息

func (*WalletManager) SummaryFollow

func (wm *WalletManager) SummaryFollow() error

SummaryFollow 汇总流程

func (*WalletManager) SummaryWallets

func (wm *WalletManager) SummaryWallets()

汇总钱包

func (*WalletManager) Transfer

func (wm *WalletManager) Transfer(sk []byte, from, to, value string, stepLimit, nonce int64) (string, error)

转账

func (*WalletManager) TransferFlow

func (wm *WalletManager) TransferFlow() error

SendTXFlow 发送交易

Jump to

Keyboard shortcuts

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