Documentation
¶
Overview ¶
Package lndrpc provides a gRPC client for LND.
Ordinary credential reads use root-staged files readable by the admin user. Initialization and reconnect repair may ask the helper to refresh those files. The client holds the macaroon in memory and injects it into authenticated RPCs. Reconnect can replace the loaded credentials.
Connections use TLS to the loopback address. Close shuts down the current transport. It does not provide secure credential erasure.
Read queries and fund-moving RPCs share this one client. Every fund-moving call sits behind an explicit confirmation flow in its caller.
Index ¶
- Variables
- func NormalizeChannelPoint(point string) (string, error)
- type Channel
- type ChannelCloseRequest
- type ChannelCloseResult
- type ChannelCloseState
- type ChannelOpenRequest
- type ChannelOpenResult
- type Client
- func (c *Client) AddInvoice(amountSats int64, memo string, blind bool) (*Invoice, error)
- func (c *Client) ChannelCloseState(point string) (ChannelCloseState, error)
- func (c *Client) Close()
- func (c *Client) CloseChannel(input ChannelCloseRequest) ChannelCloseResult
- func (c *Client) ConnectPeer(pubkey, host string) error
- func (c *Client) DecodePayReq(payReq string) (*DecodedPayReq, error)
- func (c *Client) GetInfo() (*NodeInfo, error)
- func (c *Client) GetInfoContext(parent context.Context) (*NodeInfo, error)
- func (c *Client) GetNewAddress() (*OnChainAddress, error)
- func (c *Client) GetPendingChannels() (*PendingChannelInfo, error)
- func (c *Client) GetPendingChannelsContext(parent context.Context) (*PendingChannelInfo, error)
- func (c *Client) GetState() (WalletState, error)
- func (c *Client) GetStateContext(parent context.Context) (WalletState, error)
- func (c *Client) GetTransactions() ([]OnChainTx, error)
- func (c *Client) GetTransactionsContext(parent context.Context) ([]OnChainTx, error)
- func (c *Client) GetWalletBalance() (*WalletBalance, error)
- func (c *Client) GetWalletBalanceContext(parent context.Context) (*WalletBalance, error)
- func (c *Client) ListChannels() ([]Channel, error)
- func (c *Client) ListChannelsContext(parent context.Context) ([]Channel, error)
- func (c *Client) ListClosedChannels() ([]ClosedChannel, error)
- func (c *Client) ListClosedChannelsContext(parent context.Context) ([]ClosedChannel, error)
- func (c *Client) ListInvoicesContext(parent context.Context, limit uint64) ([]PaymentEntry, error)
- func (c *Client) ListPaymentsContext(parent context.Context, limit uint64) ([]PaymentEntry, error)
- func (c *Client) ListPeers() ([]PeerInfo, error)
- func (c *Client) ListUnspent(minConfs, maxConfs int32) ([]UTXO, error)
- func (c *Client) ListUnspentContext(parent context.Context, minConfs, maxConfs int32) ([]UTXO, error)
- func (c *Client) LookupInvoice(paymentHash []byte) (*Invoice, error)
- func (c *Client) OpenChannel(input ChannelOpenRequest) ChannelOpenResult
- func (c *Client) Reconnect()
- func (c *Client) ReconnectContext(ctx context.Context)
- func (c *Client) SendCoins(input SendCoinsRequest) (*SendCoinsResult, error)
- func (c *Client) SendPayment(payReq string) (*SendPaymentResult, error)
- func (c *Client) SetTransactionLabel(input TransactionLabelRequest) TransactionLabelResult
- func (c *Client) WaitForPeer(pubkey string, timeout time.Duration) error
- type ClosedChannel
- type DecodedPayReq
- type Invoice
- type NodeInfo
- type OnChainAddress
- type OnChainTx
- type PaymentEntry
- type PeerInfo
- type PendingChannel
- type PendingChannelInfo
- type PendingForceCloseChannel
- type RouteHop
- type SendCoinsRequest
- type SendCoinsResult
- type SendPaymentResult
- type TransactionLabelRequest
- type TransactionLabelResult
- type TxInput
- type TxOutput
- type UTXO
- type WaitingCloseChannel
- type WalletBalance
- type WalletState
Constants ¶
This section is empty.
Variables ¶
var ErrInvoiceNotFound = errors.New("invoice not found")
ErrInvoiceNotFound means LND has no record for the queried payment hash.
Functions ¶
func NormalizeChannelPoint ¶
NormalizeChannelPoint validates an exact funding outpoint and returns its canonical display form for request and identity comparisons.
Types ¶
type ChannelCloseRequest ¶
type ChannelCloseResult ¶
Submitted means the RPC was attempted, not that LND accepted the close. A pending transaction is a candidate, and confirmation does not prove that force-close outputs have matured or been swept.
type ChannelCloseState ¶
type ChannelOpenRequest ¶
type ChannelOpenResult ¶
Submitted means the funding RPC was attempted, even if its response was lost. It does not imply that LND accepted or broadcast the transaction.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an LND gRPC connection with macaroon authentication.
func NewContext ¶
NewContext initializes an existing wallet's client with the caller's lifetime. An unavailable GetInfo response retains the transport for normal queries. Unreadable staged credentials and cancellation return no client. Startup uses the existing probe and rate-limited repair policy, not the creation path.
func NewStagedClient ¶
NewStagedClient opens a lazy transport from credentials already staged by the wallet workflow. It does no GetInfo probe or repair and does not claim RPC readiness. Normal queries observe readiness using the existing client policy.
func (*Client) AddInvoice ¶
AddInvoice creates a new Lightning invoice. When blind is true, LND generates blinded paths that hide the node's pubkey from the sender. Requires at least one active channel with sufficient inbound capacity.
func (*Client) ChannelCloseState ¶
func (c *Client) ChannelCloseState(point string) (ChannelCloseState, error)
ChannelCloseState reads only close eligibility facts, without alias lookups. Both reads share a timeout, but they are not an atomic snapshot or a lock.
func (*Client) Close ¶
func (c *Client) Close()
Close shuts down the current gRPC transport. It does not cancel or retire queued background reconnects, which may establish a later connection.
func (*Client) CloseChannel ¶
func (c *Client) CloseChannel(input ChannelCloseRequest) ChannelCloseResult
CloseChannel makes one bounded submission and waits for a pending or confirmed transaction. Canceling the stream is not evidence that LND canceled the close.
func (*Client) ConnectPeer ¶
ConnectPeer connects to a Lightning peer. Uses perm=true for persistent connection. Does not fail if already connected.
func (*Client) DecodePayReq ¶
func (c *Client) DecodePayReq(payReq string) (*DecodedPayReq, error)
DecodePayReq decodes a bolt11 payment request without paying it.
func (*Client) GetInfoContext ¶
func (*Client) GetNewAddress ¶
func (c *Client) GetNewAddress() (*OnChainAddress, error)
func (*Client) GetPendingChannels ¶
func (c *Client) GetPendingChannels() (*PendingChannelInfo, error)
func (*Client) GetPendingChannelsContext ¶
func (c *Client) GetPendingChannelsContext(parent context.Context) (*PendingChannelInfo, error)
func (*Client) GetState ¶
func (c *Client) GetState() (WalletState, error)
GetState uses LND's state service, which remains available while the wallet is locked. This lets status distinguish an intentionally running-but-locked daemon from a stopped daemon or a generic RPC outage.
func (*Client) GetStateContext ¶
func (c *Client) GetStateContext(parent context.Context) (WalletState, error)
func (*Client) GetTransactions ¶
func (*Client) GetTransactionsContext ¶
func (*Client) GetWalletBalance ¶
func (c *Client) GetWalletBalance() (*WalletBalance, error)
func (*Client) GetWalletBalanceContext ¶
func (c *Client) GetWalletBalanceContext(parent context.Context) (*WalletBalance, error)
func (*Client) ListChannels ¶
func (*Client) ListChannelsContext ¶
func (*Client) ListClosedChannels ¶
func (c *Client) ListClosedChannels() ( []ClosedChannel, error, )
ListClosedChannels returns all historically closed channels with close type and peer info.
func (*Client) ListClosedChannelsContext ¶
func (c *Client) ListClosedChannelsContext(parent context.Context) ([]ClosedChannel, error)
func (*Client) ListInvoicesContext ¶
ListInvoicesContext returns the recent invoice window, including unsettled invoices.
func (*Client) ListPaymentsContext ¶
ListPaymentsContext returns recent outgoing payments, including incomplete attempts.
func (*Client) ListUnspent ¶
func (*Client) ListUnspentContext ¶
func (*Client) LookupInvoice ¶
LookupInvoice checks the status of an invoice by payment hash.
func (*Client) OpenChannel ¶
func (c *Client) OpenChannel(input ChannelOpenRequest) ChannelOpenResult
OpenChannel submits one funding request. The explicit outpoints restrict LND's funding pool. LND determines which coins to use and whether change is needed.
func (*Client) Reconnect ¶
func (c *Client) Reconnect()
Reconnect attempts to re-establish the gRPC connection. Called when an RPC fails, indicating LND may have restarted.
func (*Client) ReconnectContext ¶
ReconnectContext observes the caller's lifetime for the connection probe and credential restaging. A cancelled caller cannot schedule a later reconnect.
func (*Client) SendCoins ¶
func (c *Client) SendCoins(input SendCoinsRequest) (*SendCoinsResult, error)
func (*Client) SendPayment ¶
func (c *Client) SendPayment(payReq string) (*SendPaymentResult, error)
SendPayment sends a payment using SendPaymentV2 (streaming). Blocks until the payment succeeds, fails, or times out. Returns route hops on success for visualization.
If the update stream drops before a terminal status, the payment may still be running inside LND, and the one wrong answer is reporting failure — an operator who retries a payment that later settles has paid twice. The stream is re-attached by payment hash instead, and if no terminal status arrives before the deadline the result says IN_FLIGHT with an instruction to check history before retrying.
func (*Client) SetTransactionLabel ¶
func (c *Client) SetTransactionLabel(input TransactionLabelRequest) TransactionLabelResult
func (*Client) WaitForPeer ¶
WaitForPeer polls ListPeers until the pubkey appears. The timeout limits starting new polls, not lock waits or an in-flight RPC. The last poll can succeed after the interval, so this is not a total wall-clock bound.
type ClosedChannel ¶
type DecodedPayReq ¶
type OnChainAddress ¶
type OnChainAddress struct {
Address string
}
type OnChainTx ¶
type OnChainTx struct {
Txid string
Amount int64
Fee int64
Confirmations int32
BlockHeight int32
Timestamp int64
Label string
RawTxHex string
TxType string // "send", "receive", "channel_open", "channel_close"
ChannelPeer string // peer alias for channel open/close
Inputs []TxInput
Outputs []TxOutput
TotalInputSats int64
IsAnchorSweep bool // abandoned anchor sweep (0 confs, ≤330 sats)
}
type PaymentEntry ¶
type PaymentEntry struct {
Index uint64 // LND invoice add index or outgoing payment index.
PaymentHash string
AmountSats int64
FeeSats int64
Status string // Native payment/invoice state, with EXPIRED derived for open invoices.
CreationDate int64
Preimage string
PaymentRequest string
IsIncoming bool
Memo string
Hops []RouteHop
}
type PendingChannel ¶
type PendingChannelInfo ¶
type PendingChannelInfo struct {
PendingOpen int
ForceClose int
WaitingClose int
PendingOpenChannels []PendingChannel
PendingForceCloseChannels []PendingForceCloseChannel
WaitingCloseChannels []WaitingCloseChannel
}
type SendCoinsRequest ¶
type SendCoinsResult ¶
type SendCoinsResult struct {
Txid string
}
type SendPaymentResult ¶
type SendPaymentResult struct {
Preimage string
FeeSats int64
Status string
Hops []RouteHop
Error string
}
SendPaymentResult holds the outcome of a payment attempt.
type TransactionLabelRequest ¶
TransactionLabelRequest carries app-validated intent in wallet byte order.
type TransactionLabelResult ¶
TransactionLabelResult distinguishes a local refusal from an attempted RPC. Submitted alone does not confirm a wallet write.
type WaitingCloseChannel ¶
type WalletBalance ¶
type WalletState ¶
type WalletState string
WalletState is LND's live readiness state, exposed without leaking the generated protobuf type into the TUI.
const ( WalletStateUnknown WalletState = "UNKNOWN" WalletStateLocked WalletState = "LOCKED" WalletStateActive WalletState = "SERVER_ACTIVE" )
func ReadWalletSetupState ¶
func ReadWalletSetupState(parent context.Context) (WalletState, error)
ReadWalletSetupState uses the unauthenticated State service. Wallet creation cannot require a macaroon that only exists after the wallet is initialized. It neither probes GetInfo nor requests credential repair.