address

package
v0.31.2-beta Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 21 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

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) (*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 Parameters

type Parameters struct {
	// ClientPubkey is the client's pubkey for the static address. It is
	// used for the 2-of-2 funding output as well as for the client's
	// timeout path.
	ClientPubkey *btcec.PublicKey

	// ClientPubkey is the client's pubkey for the static address. It is
	// used for the 2-of-2 funding output.
	ServerPubkey *btcec.PublicKey

	// Expiry is the CSV timout value at which the client can claim the
	// static address's timout path.
	Expiry uint32

	// PkScript is the unique static address's output script.
	PkScript []byte

	// KeyLocator is the locator of the client's key.
	KeyLocator keychain.KeyLocator

	// ProtocolVersion is the protocol version of the static address.
	ProtocolVersion version.AddressProtocolVersion

	// InitiationHeight is the height at which the address was initiated.
	InitiationHeight int32
}

Parameters holds all the necessary information for the 2-of-2 multisig address.

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) Close

func (s *SqlStore) Close()

Close closes the database connection.

func (*SqlStore) CreateStaticAddress

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

CreateStaticAddress creates a static address record in the database.

func (*SqlStore) GetAllStaticAddresses

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

GetAllStaticAddresses returns all address known to the server.

func (*SqlStore) GetStaticAddress

func (s *SqlStore) GetStaticAddress(ctx context.Context,
	pkScript []byte) (*Parameters, error)

GetStaticAddress retrieves static address parameters for a given pkScript.

type Store

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

	// GetStaticAddress fetches static address parameters for a given
	// address ID.
	GetStaticAddress(ctx context.Context, pkScript []byte) (*Parameters,
		error)

	// GetAllStaticAddresses retrieves all static addresses from the store.
	GetAllStaticAddresses(ctx context.Context) ([]*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