address

package
v0.33.3-beta Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "SADDR"

Subsystem defines the sub system name of this package.

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Manager

type Manager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Manager manages the address state machines.

func NewManager

func NewManager(cfg *ManagerConfig, currentHeight int32) (*Manager, error)

NewManager creates a new address manager.

func (*Manager) GetStaticAddress

func (m *Manager) GetStaticAddress(ctx context.Context) (*script.StaticAddress,
	error)

GetStaticAddress returns a taproot address for the given client and server public keys and expiry.

func (*Manager) GetStaticAddressParameters

func (m *Manager) GetStaticAddressParameters(ctx context.Context) (
	*script.Parameters, error)

GetStaticAddressParameters returns the parameters of the static address.

func (*Manager) GetTaprootAddress

func (m *Manager) GetTaprootAddress(clientPubkey, serverPubkey *btcec.PublicKey,
	expiry int64) (*btcutil.AddressTaproot, error)

GetTaprootAddress returns a taproot address for the given client and server public keys and expiry.

func (*Manager) ListUnspent

func (m *Manager) ListUnspent(ctx context.Context, minConfs,
	maxConfs int32) ([]*lnwallet.Utxo, error)

ListUnspent returns a list of utxos at the static address.

func (*Manager) ListUnspentRaw

func (m *Manager) ListUnspentRaw(ctx context.Context, minConfs,
	maxConfs int32) (*btcutil.AddressTaproot, []*lnwallet.Utxo, error)

ListUnspentRaw returns a list of utxos at the static address.

func (*Manager) NewAddress

func (m *Manager) NewAddress(ctx context.Context) (*btcutil.AddressTaproot,
	int64, error)

NewAddress creates a new static address with the server or returns an existing one.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, initChan chan struct{}) error

Run runs the address manager.

type ManagerConfig

type ManagerConfig struct {
	// AddressClient is the client that communicates with the loop server
	// to manage static addresses.
	AddressClient staticaddressrpc.StaticAddressServerClient

	// FetchL402 is the function used to fetch the l402 token.
	FetchL402 func(context.Context) error

	// Store is the database store that is used to store static address
	// related records.
	Store Store

	// WalletKit is the wallet client that is used to derive new keys from
	// lnd's wallet.
	WalletKit lndclient.WalletKitClient

	// ChainParams is the chain configuration(mainnet, testnet...) this
	// manager uses.
	ChainParams *chaincfg.Params

	// ChainNotifier is the chain notifier that is used to listen for new
	// blocks.
	ChainNotifier lndclient.ChainNotifierClient
}

ManagerConfig holds the configuration for the address manager.

type SqlStore

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

SqlStore is the backing store for static addresses.

func NewSqlStore

func NewSqlStore(db *loopdb.BaseDB) *SqlStore

NewSqlStore constructs a new SQLStore from a BaseDB. The BaseDB is agnostic to the underlying driver which can be postgres or sqlite.

func (*SqlStore) CreateStaticAddress

func (s *SqlStore) CreateStaticAddress(ctx context.Context,
	addrParams *script.Parameters) error

CreateStaticAddress creates a static address record in the database.

func (*SqlStore) GetAllStaticAddresses

func (s *SqlStore) GetAllStaticAddresses(ctx context.Context) (
	[]*script.Parameters, error)

GetAllStaticAddresses returns all address known to the server.

type Store

type Store interface {
	// CreateStaticAddress inserts a new static address with its parameters
	// into the store.
	CreateStaticAddress(ctx context.Context,
		addrParams *script.Parameters) error

	// GetAllStaticAddresses retrieves all static addresses from the store.
	GetAllStaticAddresses(ctx context.Context) ([]*script.Parameters,
		error)
}

Store is the database interface that is used to store and retrieve static addresses.

Jump to

Keyboard shortcuts

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