address

package
v0.0.0-...-4fc266b Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEntropyBitLen = 128
)

Variables

View Source
var (
	ErrAddressUnknown            = errors.New("unknown address")
	ErrAddressExists             = errors.New("address already exists")
	ErrConfigStorageEmpty        = errors.New("config storage not set")
	ErrNoFreeAddresses           = errors.New("no free addresses")
	ErrInvalidAddressBytes       = errors.New("invalid address bytes")
	ErrInvalidAddress            = errors.New("invalid address string")
	ErrAddressBytesEmpty         = errors.New("address bytes empty")
	ErrAddressStringEmpty        = errors.New("address string empty")
	ErrPrivateKeyEmpty           = errors.New("private key empty")
	ErrAddressPrivateKeyMismatch = errors.New("address and private key mismatch")
	ErrInvalidMnemonicLen        = errors.New("invalid mnemonic length")
)

Functions

This section is empty.

Types

type Address

type Address struct {
	Address      string `json:"address" storm:"id"`
	AddressBytes []byte `json:"addressBytes" storm:"index"`
	PrivateKey   []byte `json:"privateKey"`
	Master       bool   `json:"master"`

	Subscribed bool  `json:"subscribed"`
	ServiceId  int   `json:"serviceId"`
	UserId     int64 `json:"userId"`
	InvoiceId  int64 `json:"invoiceId"`
	WatchOnly  bool  `json:"watchOnly"`

	Bip39Support  bool     `json:"bip39Support,omitempty"`
	Bip39Mnemonic []string `json:"bip39Mnemonic,omitempty"`
}

func (*Address) Decode

func (m *Address) Decode(b []byte) error

func (*Address) Encode

func (m *Address) Encode() []byte

func (*Address) GetKey

func (a *Address) GetKey() []byte

func (*Address) String

func (a *Address) String() string

type AddressCodec

type AddressCodec interface {
	EncodeBytesToAddress(addressBytes []byte) (string, error)
	DecodeAddressToBytes(address string) ([]byte, error)
	PrivateKeyToAddress(privateKey []byte) (string, []byte, error)
	IsValid(address string) bool
}

type Config

type Config struct {
	Debug bool `json:"debug"`

	EnableAddressGenerate bool   `json:"enableAddressGenerate"`
	MinFreePoolSize       int    `json:"minFreePoolSize"`
	GeneratePoolUpTo      int    `json:"generatePoolUpTo"`
	Bip39Support          bool   `json:"bip39Support"`
	Bip36MnemonicLen      int    `json:"bip36MnemonicLen"`
	Bip44CoinType         string `json:"bip44CoinType"`
	Bip32DerivationPath   string `json:"bip32DerivationPath"`
	// contains filtered or unexported fields
}

func (*Config) Load

func (c *Config) Load() (err error)

func (*Config) Save

func (c *Config) Save() (err error)

type Manager

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

func NewManager

func NewManager(options ...MemPoolOption) (pool *Manager, err error)

func (*Manager) AddAddressFill

func (p *Manager) AddAddressFill(addressString string, fill func(a *Address)) (addressRecord *Address, err error)

func (*Manager) AddAddressRecord

func (p *Manager) AddAddressRecord(address *Address) (err error)

func (*Manager) AddAddressRecordsBulk

func (p *Manager) AddAddressRecordsBulk(addresses []*Address) (err error)

func (*Manager) AddPrivateKey

func (p *Manager) AddPrivateKey(privateKeyBytes []byte) (address string, err error)

func (*Manager) AddPrivateKeyHex

func (p *Manager) AddPrivateKeyHex(privateKeyHex string) (address string, err error)

func (*Manager) AddPrivateKeyHexFill

func (p *Manager) AddPrivateKeyHexFill(privateKeyHex string, fillParams func(address *Address)) (addressString string, err error)

func (*Manager) DevCheckMemPool

func (p *Manager) DevCheckMemPool()

func (*Manager) DevDumpMemPool

func (p *Manager) DevDumpMemPool()

func (*Manager) GenerateBit44Address

func (p *Manager) GenerateBit44Address() (addressRecord *Address, err error)

func (*Manager) GenerateBit44AddressWithLen

func (p *Manager) GenerateBit44AddressWithLen(mnemonicLen int) (addressRecord *Address, err error)

func (*Manager) GetAddress

func (p *Manager) GetAddress(address string) (addressRecord *Address, err error)

func (*Manager) GetFreeAddressAndSubscribe

func (p *Manager) GetFreeAddressAndSubscribe(serviceId int, userId, invoiceId int64, watchOnly bool) (addressRecord *Address, err error)

func (*Manager) IsAddressKnown

func (p *Manager) IsAddressKnown(address string) bool

func (*Manager) NewAddressRecord

func (p *Manager) NewAddressRecord(addressString string, privateKey []byte) (addressRecord *Address, err error)

func (*Manager) NewAddressRecordFill

func (p *Manager) NewAddressRecordFill(addressString string, fill func(a *Address)) (addressRecord *Address, err error)

func (*Manager) RecoverBit44Address

func (p *Manager) RecoverBit44Address(mnemonic []string) (addressRecord *Address, err error)

func (*Manager) WalkAllAddresses

func (p *Manager) WalkAllAddresses(walker func(address *Address))

type MemPoolOption

type MemPoolOption func(pool *Manager) error

func WithAddressCodec

func WithAddressCodec(codec AddressCodec) MemPoolOption

func WithAddressStorage

func WithAddressStorage(store storage.SimpleStorage) MemPoolOption

func WithConfigStorage

func WithConfigStorage(store storage.BinStorage) MemPoolOption

type ObjectsSource

type ObjectsSource interface {
	// AppendKeys should append the keys of the maps to the supplied slice and return the resulting slice
	AppendKeys([]string) []string
	// Get should return the value for the supplied key
	Get(string) *Address
}

ObjectsSource is for supplying data to initialise fastStore

Jump to

Keyboard shortcuts

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