package exchain

import "github.com/holiman/uint256"

type Wallet struct {
	Coin          string      `json:"coin"`
	Balance       uint256.Int `json:"balance"`
	FrozenBalance uint256.Int `json:"frozenBalance"`
}

func (w *Wallet) AddBalance(balance uint256.Int) {
	w.Balance = *new(uint256.Int).Add(&w.Balance, &balance)
}

type ProxyPublickey [64]byte

type AccountInfo struct {
	ProxySigner ProxyPublickey
	Wallets     []Wallet // a sorted wallet list.
}

func (acc *AccountInfo) GetWallet(coin string) *Wallet {
	for i := range acc.Wallets {
		if acc.Wallets[i].Coin == coin {
			return &acc.Wallets[i]
		}
	}
	return nil
}

func (acc *AccountInfo) GetWallets() []Wallet {
	return acc.Wallets
}
