LockLib

package
v0.0.0-...-fb77912 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTimeInSeconds = 30
	HardenedOffset = 0x80000000 // 用于生成硬化路径

	DefaultClockTimeInMinutes = 1
	AuthCodeTimer             = 800 * time.Millisecond
)

Variables

This section is empty.

Functions

func AccountVerCheck

func AccountVerCheck()

func AddOrUpdateAccount

func AddOrUpdateAccount(accJsonStr string) error

AddOrUpdateAccount 添加或者账号并保存

func AsyncAccSyncing

func AsyncAccSyncing()

func AsyncAuthSyncing

func AsyncAuthSyncing()

func AuthCodeTimerPause

func AuthCodeTimerPause()

func AuthCodeTimerResume

func AuthCodeTimerResume()

func AuthCodeTimerStop

func AuthCodeTimerStop()

func AuthVerCheck

func AuthVerCheck()

func ChangePassword

func ChangePassword(old, new string) error

func CloseWallet

func CloseWallet()

func CompleteRemoveWallet

func CompleteRemoveWallet()

func Decode

func Decode(ciphertext []byte, privateKey *ecdsa.PrivateKey) ([]byte, error)

func Encode

func Encode(data []byte, publicKey *ecdsa.PublicKey) ([]byte, error)

func GenerateMnemonic

func GenerateMnemonic() ([]byte, error)

func GenerateWallet

func GenerateWallet(mnemonic, password string) error

GenerateWallet 根据助记词生成以太坊HD钱包

func InitLocalData

func InitLocalData()

func InitSDK

func InitSDK(exi AppI, url, token string, logLevel int8) error

func InitWalletPath

func InitWalletPath(dbPath string) bool

func KeyExpireTime

func KeyExpireTime() int

KeyExpireTime 读取存储的 clock time 值

func LocalCachedAuth

func LocalCachedAuth() []byte

func LocalCachedData

func LocalCachedData() []byte

LocalCachedData sync data from local or server

func NewManualAuth

func NewManualAuth(issuer, account, secret string) error

func NewScanAuth

func NewScanAuth(url string) error

func OpenWallet

func OpenWallet(password string) error

OpenWallet 从 LevelDB 中读取钱包并解密

func RemoveAccount

func RemoveAccount(uuid string) error

RemoveAccount 从内存和 LevelDB 中移除指定的账号

func RemoveAuth

func RemoveAuth(key string) error

func SaveExpireTime

func SaveExpireTime(clockTime int) error

func ShowMnemonic

func ShowMnemonic(password string) (string, error)

func WalletAddress

func WalletAddress() string

func WalletClock

func WalletClock()

WalletClock 启动定时器,基于 KeyExpireTime 设置的时间间隔执行任务

func WalletIsOpen

func WalletIsOpen() bool

Types

type API

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

type Account

type Account struct {
	ID          uuid.UUID `json:"id"`
	Platform    string    `json:"platform"`
	Username    string    `json:"username"`
	Password    string    `json:"password"`
	LastUpdated int64     `json:"lastUpdated"` // 修改为 Unix 时间戳
}

Account 结构体,与 Swift 的 Account 对应

type AccountManager

type AccountManager struct {
	Accounts     map[string]*Account `json:"accounts"`
	LocalVersion int64               `json:"local_version"`
	SrvVersion   int64               `json:"srv_version"`
	// contains filtered or unexported fields
}

func (*AccountManager) UpdateLatestVersion

func (am *AccountManager) UpdateLatestVersion(srvVer int64)

type AppI

type AppI interface {
	Log(s string)
	DataUpdated(data []byte, err error)
	AuthDataUpdated(data []byte, err error)
	CloseWallet()
	AuthCodeUpdate(key, code string, timeleft int)
}

type AuthManager

type AuthManager struct {
	Auth         map[string]*TOTPConfig `json:"auth"`
	LocalVersion int64                  `json:"local_version"`
	SrvVersion   int64                  `json:"srv_version"`
	// contains filtered or unexported fields
}

func (*AuthManager) UpdateLatestVersion

func (am *AuthManager) UpdateLatestVersion(srvVer int64)

type AuthScheduler

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

type TOTPConfig

type TOTPConfig struct {
	Type      string `json:"type"`
	Issuer    string `json:"issuer"`
	Account   string `json:"account"`
	Secret    string `json:"secret"`
	Algorithm string `json:"algorithm"`
	Digits    int    `json:"digits"`
	Period    int    `json:"period"`
}

TOTPConfig 存储TOTP配置信息

type WalletManager

type WalletManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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