Documentation ¶
Overview ¶
Package wallet is used inside KMS to provide features related to wallet generation & CRUD access.
Index ¶
- Variables
- func ValidateAddress(blockchain Blockchain, address string) error
- type AssetType
- type BitcoinProvider
- type Blockchain
- type CreateTransactionParams
- type EthProvider
- type EthTransactionParams
- type Generator
- type Provider
- type Repository
- type Service
- func (s *Service) CreateEthereumTransaction(_ context.Context, wallet *Wallet, params EthTransactionParams) (string, error)
- func (s *Service) CreateMaticTransaction(_ context.Context, wallet *Wallet, params EthTransactionParams) (string, error)
- func (s *Service) CreateTronTransaction(ctx context.Context, wallet *Wallet, params TronTransactionParams) (TronTransaction, error)
- func (s *Service) CreateWallet(_ context.Context, blockchain Blockchain) (*Wallet, error)
- func (s *Service) DeleteWallet(ctx context.Context, id uuid.UUID) error
- func (s *Service) GetWallet(_ context.Context, id uuid.UUID, withTrashed bool) (*Wallet, error)
- type TronProvider
- func (p *TronProvider) Base58ToHexAddress(address string) (string, error)
- func (p *TronProvider) Generate() *Wallet
- func (p *TronProvider) GetBlockchain() Blockchain
- func (p *TronProvider) NewTransaction(ctx context.Context, wallet *Wallet, params TronTransactionParams) (TronTransaction, error)
- func (p *TronProvider) ValidateAddress(address string) bool
- type TronTransaction
- type TronTransactionParams
- type Wallet
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidAddress = errors.New("invalid address") ErrInvalidContractAddress = errors.New("invalid contract address") ErrInvalidAmount = errors.New("invalid amount") ErrInvalidNetwork = errors.New("invalid network") ErrInvalidGasSettings = errors.New("invalid network gas settings") ErrInvalidNonce = errors.New("invalid nonce") ErrTronResponse = errors.New("invalid response from TRON node") ErrInsufficientBalance = errors.New("sender balance is insufficient") ErrUnknownBlockchain = errors.New("unknown blockchain") )
View Source
var ErrNotFound = errors.New("wallet not found")
Functions ¶
func ValidateAddress ¶
func ValidateAddress(blockchain Blockchain, address string) error
Types ¶
type BitcoinProvider ¶
type BitcoinProvider struct { Blockchain Blockchain CryptoReader io.Reader }
func (*BitcoinProvider) Generate ¶
func (p *BitcoinProvider) Generate() *Wallet
func (*BitcoinProvider) GetBlockchain ¶
func (p *BitcoinProvider) GetBlockchain() Blockchain
func (*BitcoinProvider) ValidateAddress ¶
func (p *BitcoinProvider) ValidateAddress(address string) bool
type Blockchain ¶
type Blockchain string
const ( BTC Blockchain = "BTC" ETH Blockchain = "ETH" TRON Blockchain = "TRON" MATIC Blockchain = "MATIC" )
func ListBlockchains ¶
func ListBlockchains() []Blockchain
func (Blockchain) IsSpecified ¶
func (b Blockchain) IsSpecified() bool
func (Blockchain) IsValid ¶
func (b Blockchain) IsValid() bool
func (Blockchain) NotSpecified ¶
func (b Blockchain) NotSpecified() bool
func (Blockchain) String ¶
func (b Blockchain) String() string
func (Blockchain) ToMoneyBlockchain ¶
func (b Blockchain) ToMoneyBlockchain() money.Blockchain
type CreateTransactionParams ¶
type EthProvider ¶
type EthProvider struct { Blockchain Blockchain CryptoReader io.Reader }
EthProvider generates wallets for eth-like chains (eth, tron, bsc, matic, ...)
func (*EthProvider) Generate ¶
func (p *EthProvider) Generate() *Wallet
func (*EthProvider) GetBlockchain ¶
func (p *EthProvider) GetBlockchain() Blockchain
func (*EthProvider) NewTransaction ¶
func (p *EthProvider) NewTransaction(w *Wallet, params EthTransactionParams) (string, error)
func (*EthProvider) ValidateAddress ¶
func (p *EthProvider) ValidateAddress(address string) bool
type EthTransactionParams ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
func NewGenerator() *Generator
func (*Generator) AddProvider ¶
func (*Generator) CreateWallet ¶
func (g *Generator) CreateWallet(blockchain Blockchain) (*Wallet, error)
type Provider ¶
type Provider interface { Generate() *Wallet GetBlockchain() Blockchain ValidateAddress(address string) bool }
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func NewRepository ¶
func NewRepository(db *bbolt.DB) *Repository
func (*Repository) Set ¶
func (r *Repository) Set(w *Wallet) error
func (*Repository) SoftDelete ¶
func (r *Repository) SoftDelete(w *Wallet) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) CreateEthereumTransaction ¶
func (s *Service) CreateEthereumTransaction( _ context.Context, wallet *Wallet, params EthTransactionParams, ) (string, error)
CreateEthereumTransaction creates and sings new raw Ethereum transaction based on provided input.
func (*Service) CreateMaticTransaction ¶
func (*Service) CreateTronTransaction ¶
func (s *Service) CreateTronTransaction( ctx context.Context, wallet *Wallet, params TronTransactionParams, ) (TronTransaction, error)
func (*Service) CreateWallet ¶
func (*Service) DeleteWallet ¶
type TronProvider ¶
type TronProvider struct { Blockchain Blockchain Trongrid *trongrid.Provider CryptoReader io.Reader }
func (*TronProvider) Base58ToHexAddress ¶
func (p *TronProvider) Base58ToHexAddress(address string) (string, error)
Base58ToHexAddress converts from base58 to hex. Example: input: TBREsCfBdPyD612xZnwvGPux7osbXvtzLh output: 410fe47f49fd91f0edb7fa2b94a3c45d9c2231709c
func (*TronProvider) Generate ¶
func (p *TronProvider) Generate() *Wallet
func (*TronProvider) GetBlockchain ¶
func (p *TronProvider) GetBlockchain() Blockchain
func (*TronProvider) NewTransaction ¶
func (p *TronProvider) NewTransaction( ctx context.Context, wallet *Wallet, params TronTransactionParams, ) (TronTransaction, error)
NewTransaction create new trx / trc20 transaction. see https://developers.tron.network/docs/tron-protocol-transaction.
func (*TronProvider) ValidateAddress ¶
func (p *TronProvider) ValidateAddress(address string) bool
type TronTransaction ¶
type TronTransaction = trongrid.Transaction
type TronTransactionParams ¶
Click to show internal directories.
Click to hide internal directories.