lndservices

package
v0.7.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CustomChannelRemoteReserve is the custom channel minimum remote
	// reserve that we'll use for our channels.
	CustomChannelRemoteReserve = 1062
)
View Source
const DefaultPsbtMaxFeeRatio = 0.75

DefaultPsbtMaxFeeRatio is the maximum ratio between fees paid and total output amount produced. Since taproot assets can be anchored to outpoints that may carry relatively small bitcoin amounts, we want to bump the allowed ratio between fees paid and total produced output amount. This can prove useful in high fee environments where we'd otherwise fail to fund the psbt.

View Source
const (
	// DefaultTimeout is the default timeout we use for RPC and database
	// operations.
	DefaultTimeout = 30 * time.Second
)
View Source
const Subsystem = "LNDS"

Subsystem defines the logging code for this subsystem.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

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 LndFeatureBitVerifier

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

LndFeatureBitVerifier is a struct that verifies that the feature bits of a target connected peer, using our registered lnd node.

func NewLndFeatureBitVerifier

func NewLndFeatureBitVerifier(
	lnd *lndclient.LndServices) *LndFeatureBitVerifier

NewLndFeatureBitVerifier creates a new LndFeatureBitVerifier instance.

func (*LndFeatureBitVerifier) HasFeature

func (l *LndFeatureBitVerifier) HasFeature(ctx context.Context,
	peerPub btcec.PublicKey, bit lnwire.FeatureBit) (bool, error)

HasFeature returns true if the peer has the given feature bit set. If the peer can't be found, then ErrNoPeer is returned.

type LndFsmDaemonAdapters

type LndFsmDaemonAdapters struct {

	// ContextGuard manages the context and quit channel for this service.
	fn.ContextGuard
	// contains filtered or unexported fields
}

LndFsmDaemonAdapters is a struct that implements the protofsm.DaemonAdapters interface.

func NewLndFsmDaemonAdapters

func NewLndFsmDaemonAdapters(lnd *lndclient.LndServices) *LndFsmDaemonAdapters

NewLndFsmDaemonAdapters creates a new instance of LndFsmDaemonAdapters.

func (*LndFsmDaemonAdapters) BroadcastTransaction

func (l *LndFsmDaemonAdapters) BroadcastTransaction(tx *wire.MsgTx,
	label string) error

BroadcastTransaction attempts to broadcast a transaction to the network. It uses the chain bridge to publish the transaction.

func (*LndFsmDaemonAdapters) RegisterConfirmationsNtfn

func (l *LndFsmDaemonAdapters) RegisterConfirmationsNtfn(
	txid *chainhash.Hash, pkScript []byte, numConfs uint32,
	heightHint uint32,
	optFuncs ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent,
	error)

RegisterConfirmationsNtfn registers an intent to be notified once the transaction with the given txid reaches the specified number of confirmations.

func (*LndFsmDaemonAdapters) RegisterSpendNtfn

func (l *LndFsmDaemonAdapters) RegisterSpendNtfn(outpoint *wire.OutPoint,
	pkScript []byte, heightHint uint32) (*chainntnfs.SpendEvent, error)

RegisterSpendNtfn registers an intent to be notified once the outpoint is spent on-chain.

func (*LndFsmDaemonAdapters) SendMessages

func (l *LndFsmDaemonAdapters) SendMessages(peer btcec.PublicKey,
	messages []lnwire.Message) error

SendMessages sends a slice of lnwire.Message to the peer with the given public key.

func (*LndFsmDaemonAdapters) Start

func (l *LndFsmDaemonAdapters) Start() error

Start attempts to start the service.

func (*LndFsmDaemonAdapters) Stop

func (l *LndFsmDaemonAdapters) Stop() error

Stop signals for the service to gracefully exit.

type LndInvoicesClient

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

LndInvoicesClient is an LND invoices RPC client.

func NewLndInvoicesClient

func NewLndInvoicesClient(lnd *lndclient.LndServices) *LndInvoicesClient

NewLndInvoicesClient creates a new LND invoices client for a given LND service.

func (*LndInvoicesClient) HtlcModifier

HtlcModifier is a bidirectional streaming RPC that allows a client to intercept and modify the HTLCs that attempt to settle the given invoice. The server will send HTLCs of invoices to the client and the client can modify some aspects of the HTLC in order to pass the invoice acceptance tests.

type LndMsgTransportClient

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

LndMsgTransportClient is an LND RPC message transport client.

func NewLndMsgTransportClient

func NewLndMsgTransportClient(
	lnd *lndclient.LndServices) *LndMsgTransportClient

NewLndMsgTransportClient creates a new message transport RPC client for a given LND service.

func (*LndMsgTransportClient) ReportError

func (l *LndMsgTransportClient) ReportError(ctx context.Context,
	peer btcec.PublicKey, pid funding.PendingChanID, err error)

ReportError sends a custom message with the error type to a peer.

NOTE: In order for this custom message to be sent over the lnd RPC interface, lnd needs to be configured with the `--custom-message=17` flag, which allows sending the non-custom error message type.

func (*LndMsgTransportClient) SendCustomMessage

func (l *LndMsgTransportClient) SendCustomMessage(ctx context.Context,
	msg lndclient.CustomMessage) error

SendCustomMessage sends a custom message to a peer.

func (*LndMsgTransportClient) SendMessage

func (l *LndMsgTransportClient) SendMessage(ctx context.Context,
	peer btcec.PublicKey, msg lnwire.Message) error

SendMessage sends a message to a remote peer.

func (*LndMsgTransportClient) SubscribeCustomMessages

func (l *LndMsgTransportClient) SubscribeCustomMessages(
	ctx context.Context) (<-chan lndclient.CustomMessage,
	<-chan error, error)

SubscribeCustomMessages creates a subscription to custom messages received from our peers.

type LndPbstChannelFunder

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

LndPbstChannelFunder is an implementation of the tapchannel.ChannelFunder interface that uses lnd to carry out the PSBT funding process.

func NewLndPbstChannelFunder

func NewLndPbstChannelFunder(lnd *lndclient.LndServices) *LndPbstChannelFunder

NewLndPbstChannelFunder creates a new LndPbstChannelFunder instance.

func (*LndPbstChannelFunder) ChannelAcceptor

func (l *LndPbstChannelFunder) ChannelAcceptor(ctx context.Context,
	acceptor lndclient.AcceptorFunction) (chan error, error)

ChannelAcceptor is used to accept and potentially influence parameters of incoming channels.

func (*LndPbstChannelFunder) OpenChannel

OpenChannel attempts to open a new asset holding private channel using the backing lnd node. The PSBT flow is by default. An AssetChanIntent is returned that includes the updated PSBT template that includes the funding output. Once all other inputs+outputs have been added, then BindPsbt should be called to progress the funding process. Afterward, the funding transaction should be signed+broadcast.

NOTE: This is part of the tapchannel.ChannelFunder interface.

type LndRouterClient

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

LndRouterClient is an LND router RPC client.

func NewLndRouterClient

func NewLndRouterClient(lnd *lndclient.LndServices) *LndRouterClient

NewLndRouterClient creates a new LND router client for a given LND service.

func (*LndRouterClient) AddLocalAlias

func (l *LndRouterClient) AddLocalAlias(ctx context.Context, alias,
	baseScid lnwire.ShortChannelID) error

AddLocalAlias adds a database mapping from the passed alias to the passed base SCID.

func (*LndRouterClient) DeleteLocalAlias

func (l *LndRouterClient) DeleteLocalAlias(ctx context.Context, alias,
	baseScid lnwire.ShortChannelID) error

DeleteLocalAlias removes a mapping from the database and the Manager's maps.

func (*LndRouterClient) InterceptHtlcs

func (l *LndRouterClient) InterceptHtlcs(
	ctx context.Context, handler lndclient.HtlcInterceptHandler) error

InterceptHtlcs intercepts all incoming HTLCs and calls the given handler function with the HTLC details. The handler function can then decide whether to accept or reject the HTLC.

func (*LndRouterClient) SubscribeHtlcEvents

func (l *LndRouterClient) SubscribeHtlcEvents(
	ctx context.Context) (<-chan *routerrpc.HtlcEvent,
	<-chan error, error)

SubscribeHtlcEvents subscribes to a stream of events related to HTLC updates.

type LndRpcChainBridge

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

LndRpcChainBridge is an implementation of the tapgarden.ChainBridge interface backed by an active remote lnd node.

func NewLndRpcChainBridge

func NewLndRpcChainBridge(lnd *lndclient.LndServices,
	assetStore *tapdb.AssetStore) *LndRpcChainBridge

NewLndRpcChainBridge creates a new chain bridge from an active lnd services client.

func (*LndRpcChainBridge) CurrentHeight

func (l *LndRpcChainBridge) CurrentHeight(ctx context.Context) (uint32, error)

CurrentHeight return the current height of the main chain.

func (*LndRpcChainBridge) EstimateFee

func (l *LndRpcChainBridge) EstimateFee(ctx context.Context,
	confTarget uint32) (chainfee.SatPerKWeight, error)

EstimateFee returns a fee estimate for the confirmation target.

func (*LndRpcChainBridge) GenFileChainLookup

func (l *LndRpcChainBridge) GenFileChainLookup(
	f *proof.File) asset.ChainLookup

GenFileChainLookup generates a chain lookup interface for the given proof file that can be used to validate proofs.

func (*LndRpcChainBridge) GenProofChainLookup

func (l *LndRpcChainBridge) GenProofChainLookup(
	p *proof.Proof) (asset.ChainLookup, error)

GenProofChainLookup generates a chain lookup interface for the given single proof that can be used to validate proofs.

func (*LndRpcChainBridge) GetBlock

func (l *LndRpcChainBridge) GetBlock(ctx context.Context,
	hash chainhash.Hash) (*wire.MsgBlock, error)

GetBlock returns a chain block given its hash.

func (*LndRpcChainBridge) GetBlockHash

func (l *LndRpcChainBridge) GetBlockHash(ctx context.Context,
	blockHeight int64) (chainhash.Hash, error)

GetBlockHash returns the hash of the block in the best blockchain at the given height.

func (*LndRpcChainBridge) GetBlockHeader

func (l *LndRpcChainBridge) GetBlockHeader(ctx context.Context,
	hash chainhash.Hash) (*wire.BlockHeader, error)

GetBlockHeader returns a block header given its hash.

func (*LndRpcChainBridge) GetBlockHeaderByHeight

func (l *LndRpcChainBridge) GetBlockHeaderByHeight(ctx context.Context,
	blockHeight int64) (*wire.BlockHeader, error)

GetBlockHeaderByHeight returns a block header given the block height.

func (*LndRpcChainBridge) GetBlockTimestamp

func (l *LndRpcChainBridge) GetBlockTimestamp(ctx context.Context,
	height uint32) int64

GetBlockTimestamp returns the timestamp of the block at the given height.

func (*LndRpcChainBridge) PublishTransaction

func (l *LndRpcChainBridge) PublishTransaction(ctx context.Context,
	tx *wire.MsgTx, label string) error

PublishTransaction attempts to publish a new transaction to the network.

func (*LndRpcChainBridge) RegisterBlockEpochNtfn

func (l *LndRpcChainBridge) RegisterBlockEpochNtfn(
	ctx context.Context) (chan int32, chan error, error)

RegisterBlockEpochNtfn registers an intent to be notified of each new block connected to the main chain.

func (*LndRpcChainBridge) RegisterConfirmationsNtfn

func (l *LndRpcChainBridge) RegisterConfirmationsNtfn(ctx context.Context,
	txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32,
	includeBlock bool,
	reOrgChan chan struct{}) (*chainntnfs.ConfirmationEvent, chan error,
	error)

RegisterConfirmationsNtfn registers an intent to be notified once txid reaches numConfs confirmations.

func (*LndRpcChainBridge) VerifyBlock

func (l *LndRpcChainBridge) VerifyBlock(ctx context.Context,
	header wire.BlockHeader, height uint32) error

VerifyBlock returns an error if a block (with given header and height) is not present on-chain. It also checks to ensure that block height corresponds to the given block header.

type LndRpcKeyRing

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

LndRpcKeyRing is an implementation of the keychain.KeyRing interface backed by an active remote lnd node.

func NewLndRpcKeyRing

func NewLndRpcKeyRing(lnd *lndclient.LndServices) *LndRpcKeyRing

NewLndRpcKeyRing creates a new instance of the LndRpcKeyRing based on the passed ln client.

func (*LndRpcKeyRing) DeriveNextKey

func (l *LndRpcKeyRing) DeriveNextKey(ctx context.Context,
	keyFam keychain.KeyFamily) (keychain.KeyDescriptor, error)

DeriveNextKey attempts to derive the *next* key within the key family (account in BIP-0043) specified. This method should return the next external child within this branch.

func (*LndRpcKeyRing) DeriveNextTaprootAssetKey

func (l *LndRpcKeyRing) DeriveNextTaprootAssetKey(
	ctx context.Context) (keychain.KeyDescriptor, error)

DeriveNextTaprootAssetKey attempts to derive the *next* key within the Taproot Asset key family.

func (*LndRpcKeyRing) DeriveSharedKey

func (l *LndRpcKeyRing) DeriveSharedKey(ctx context.Context,
	ephemeralPubKey *btcec.PublicKey,
	keyLocator *keychain.KeyLocator) ([sha256.Size]byte, error)

DeriveSharedKey returns a shared secret key by performing Diffie-Hellman key derivation between the ephemeral public key and the key specified by the key locator (or the node's identity private key if no key locator is specified):

P_shared = privKeyNode * ephemeralPubkey

The resulting shared public key is serialized in the compressed format and hashed with SHA256, resulting in a final key length of 256 bits.

func (*LndRpcKeyRing) IsLocalKey

func (l *LndRpcKeyRing) IsLocalKey(ctx context.Context,
	desc keychain.KeyDescriptor) bool

IsLocalKey returns true if the key is under the control of the wallet and can be derived by it.

type LndRpcVirtualTxSigner

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

LndRpcVirtualTxSigner is an implementation of the tapscript.Signer interface backed by an active lnd node.

func NewLndRpcVirtualTxSigner

func NewLndRpcVirtualTxSigner(lnd *lndclient.LndServices) *LndRpcVirtualTxSigner

NewLndRpcVirtualTxSigner returns a new tx signer instance backed by the passed connection to a remote lnd node.

func (*LndRpcVirtualTxSigner) SignVirtualTx

func (l *LndRpcVirtualTxSigner) SignVirtualTx(signDesc *lndclient.SignDescriptor,
	tx *wire.MsgTx, prevOut *wire.TxOut) (*schnorr.Signature, error)

SignVirtualTx generates a signature according to the passed signing descriptor and virtual TX.

type LndRpcWalletAnchor

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

LndRpcWalletAnchor is an implementation of the tapgarden.WalletAnchor interfaced backed by an active remote lnd node.

func NewLndRpcWalletAnchor

func NewLndRpcWalletAnchor(lnd *lndclient.LndServices,
	opts ...WalletAnchorOption) *LndRpcWalletAnchor

NewLndRpcWalletAnchor returns a new wallet anchor instance using the passed lnd node.

func (*LndRpcWalletAnchor) FundPsbt

func (l *LndRpcWalletAnchor) FundPsbt(ctx context.Context, packet *psbt.Packet,
	minConfs uint32, feeRate chainfee.SatPerKWeight,
	changeIdx int32) (*tapsend.FundedPsbt, error)

FundPsbt attaches enough inputs to the target PSBT packet for it to be valid.

func (*LndRpcWalletAnchor) ImportTaprootOutput

func (l *LndRpcWalletAnchor) ImportTaprootOutput(ctx context.Context,
	pub *btcec.PublicKey) (btcutil.Address, error)

ImportTaprootOutput imports a new public key into the wallet, as a P2TR output.

func (*LndRpcWalletAnchor) ListChannels

func (l *LndRpcWalletAnchor) ListChannels(
	ctx context.Context) ([]lndclient.ChannelInfo, error)

ListChannels returns the list of active channels of the backing lnd node.

func (*LndRpcWalletAnchor) ListTransactions

func (l *LndRpcWalletAnchor) ListTransactions(ctx context.Context, startHeight,
	endHeight int32, account string) ([]lndclient.Transaction, error)

ListTransactions returns all known transactions of the backing lnd node. It takes a start and end block height which can be used to limit the block range that we query over. These values can be left as zero to include all blocks. To include unconfirmed transactions in the query, endHeight must be set to -1.

func (*LndRpcWalletAnchor) ListUnspentImportScripts

func (l *LndRpcWalletAnchor) ListUnspentImportScripts(
	ctx context.Context) ([]*lnwallet.Utxo, error)

ListUnspentImportScripts lists all UTXOs of the imported Taproot scripts.

func (*LndRpcWalletAnchor) MinRelayFee

MinRelayFee estimates the minimum fee rate required for a transaction.

func (*LndRpcWalletAnchor) SignAndFinalizePsbt

func (l *LndRpcWalletAnchor) SignAndFinalizePsbt(ctx context.Context,
	pkt *psbt.Packet) (*psbt.Packet, error)

SignAndFinalizePsbt fully signs and finalizes the target PSBT packet.

func (*LndRpcWalletAnchor) SignPsbt

func (l *LndRpcWalletAnchor) SignPsbt(ctx context.Context,
	packet *psbt.Packet) (*psbt.Packet, error)

SignPsbt expects a partial transaction with all inputs and outputs fully declared and tries to sign all unsigned inputs that have all required fields (UTXO information, BIP32 derivation information, witness or sig scripts) set. If no error is returned, the PSBT is ready to be given to the next signer or to be finalized if lnd was the last signer.

NOTE: See lndclient.WalletKitClient for further details.

func (*LndRpcWalletAnchor) SubscribeTransactions

func (l *LndRpcWalletAnchor) SubscribeTransactions(
	ctx context.Context) (<-chan lndclient.Transaction, <-chan error,
	error)

SubscribeTransactions creates a uni-directional stream from the server to the client in which any newly discovered transactions relevant to the wallet are sent over.

func (*LndRpcWalletAnchor) UnlockInput

func (l *LndRpcWalletAnchor) UnlockInput(ctx context.Context,
	op wire.OutPoint) error

UnlockInput unlocks the set of target inputs after a batch or send transaction is abandoned.

type ProofChainLookup

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

ProofChainLookup is an implementation of the asset.ChainLookup interface that uses a proof file to look up block height information of previous inputs while validating proofs.

func NewProofChainLookup

func NewProofChainLookup(chainBridge tapgarden.ChainBridge,
	assetStore *tapdb.AssetStore, proofFile *proof.File) *ProofChainLookup

NewProofChainLookup creates a new ProofChainLookup instance.

func (*ProofChainLookup) CurrentHeight

func (l *ProofChainLookup) CurrentHeight(ctx context.Context) (uint32, error)

CurrentHeight returns the current height of the main chain.

func (*ProofChainLookup) MeanBlockTimestamp

func (l *ProofChainLookup) MeanBlockTimestamp(ctx context.Context,
	blockHeight uint32) (time.Time, error)

MeanBlockTimestamp returns the timestamp of the block at the given height as a Unix timestamp in seconds, taking into account the mean time elapsed over the previous 11 blocks.

func (*ProofChainLookup) TxBlockHeight

func (l *ProofChainLookup) TxBlockHeight(ctx context.Context,
	txid chainhash.Hash) (uint32, error)

TxBlockHeight returns the block height that the given transaction was included in.

type WalletAnchorConfig

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

WalletAnchorConfig is a configuration for the wallet anchor.

type WalletAnchorOption

type WalletAnchorOption func(cfg *WalletAnchorConfig)

WalletAnchorOption is an optional argument that modifies the wallet anchor configuration.

func WithPsbtMaxFeeRatio

func WithPsbtMaxFeeRatio(val float64) WalletAnchorOption

WithPsbtMaxFeeRatio is an optional argument that provides a custom psbt max fee ratio.

Jump to

Keyboard shortcuts

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