Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,6 @@ require (
// allows us to specify that as an option.
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display

replace github.com/lightningnetwork/lnd => github.com/starius/lnd v0.19.2-beta.kweight-selection2

go 1.24.6
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,6 @@ github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display h1:Y2WiPkBS
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9 h1:6D3LrdagJweLLdFm1JNodZsBk6iU4TTsBBFLQ4yiXfI=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240815225420-8b40adf04ab9/go.mod h1:EDqJ3MuZIbMq0QI1czTIKDJ/GS8S14RXPwapHw8cw6w=
github.com/lightningnetwork/lnd v0.19.0-beta.rc5.0.20250905045430-9d74ec47701c h1:GVMiT7IwHgRCCsih7KWlOHlsyFBy7JZIGKhiSTOzduw=
github.com/lightningnetwork/lnd v0.19.0-beta.rc5.0.20250905045430-9d74ec47701c/go.mod h1:qvNSmsYOEmvb6JIewrv7vF4S2mjUTEYSxAp9m/U94Lw=
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ=
github.com/lightningnetwork/lnd/fn/v2 v2.0.8 h1:r2SLz7gZYQPVc3IZhU82M66guz3Zk2oY+Rlj9QN5S3g=
Expand Down Expand Up @@ -483,6 +481,8 @@ github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/starius/lnd v0.19.2-beta.kweight-selection2 h1:idGvTEGnBU4fedk25wyzZwlbbv8TKlf/MpvmvEiugvY=
github.com/starius/lnd v0.19.2-beta.kweight-selection2/go.mod h1:qvNSmsYOEmvb6JIewrv7vF4S2mjUTEYSxAp9m/U94Lw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
Expand Down
62 changes: 52 additions & 10 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ func WithRemoteMaxHtlc(maxHtlc uint32) OpenChannelOption {
}
}

// WithOpenChannelFeerate specifies feerate in sats/kw for OpenChannel request.
func WithOpenChannelFeerate(satPerKw chainfee.SatPerKWeight) OpenChannelOption {
return func(r *lnrpc.OpenChannelRequest) {
r.SatPerKw = uint64(satPerKw)
}
}

// LightningClient exposes base lightning functionality.
type LightningClient interface {
ServiceClient[lnrpc.LightningClient]
Expand Down Expand Up @@ -209,12 +216,13 @@ type LightningClient interface {

// SendCoins sends the passed amount of (or all) coins to the passed
// address. Either amount or sendAll must be specified, while
// confTarget, satsPerByte are optional and may be set to zero in which
// confTarget, satsPerVByte are optional and may be set to zero in which
// case automatic conf target and fee will be used. Returns the tx id
// upon success.
SendCoins(ctx context.Context, addr btcutil.Address,
amount btcutil.Amount, sendAll bool, confTarget int32,
satsPerByte int64, label string) (string, error)
satsPerVByte chainfee.SatPerVByte, label string,
opts ...SendCoinsOption) (string, error)

// ChannelBalance returns a summary of our channel balances.
ChannelBalance(ctx context.Context) (*ChannelBalance, error)
Expand Down Expand Up @@ -3149,18 +3157,35 @@ func (p *ChannelClosedUpdate) CloseTxid() chainhash.Hash {
// CloseChannelRequest.
type CloseChannelOption func(r *lnrpc.CloseChannelRequest)

// SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest.
// SatPerVbyte is an option for setting the fee rate of a CloseChannelRequest
// specified in sats/vbyte.
func SatPerVbyte(satPerVbyte chainfee.SatPerVByte) CloseChannelOption {
return func(r *lnrpc.CloseChannelRequest) {
r.SatPerVbyte = uint64(satPerVbyte)
r.SatPerKw = uint64(satPerVbyte.FeePerKWeight())
}
}

// SatPerKw is an option for setting the fee rate of a CloseChannelRequest
// specified in sats/kw.
func SatPerKw(satPerKw chainfee.SatPerKWeight) CloseChannelOption {
return func(r *lnrpc.CloseChannelRequest) {
r.SatPerKw = uint64(satPerKw)
}
}

// MaxFeePerVbyte is an option for setting the maximum fee rate a closer is
// willing to pay on a CloseChannelRequest.
func MaxFeePerVbyte(maxFeePerVbyte chainfee.SatPerVByte) CloseChannelOption {
return func(r *lnrpc.CloseChannelRequest) {
r.MaxFeePerVbyte = uint64(maxFeePerVbyte)
r.MaxFeePerKw = uint64(maxFeePerVbyte.FeePerKWeight())
}
}

// MaxFeePerKw is an option for setting the maximum fee rate a closer is
// willing to pay on a CloseChannelRequest.
func MaxFeePerKw(maxFeePerKw chainfee.SatPerKWeight) CloseChannelOption {
return func(r *lnrpc.CloseChannelRequest) {
r.MaxFeePerKw = uint64(maxFeePerKw)
}
}

Copy link

@MPins MPins Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to let you know that I addressed the MaxFeePerKw in the lightningnetwork/lnd#10067

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I used it in MaxFeePerVbyte() and MaxFeePerKw() functions.

Expand Down Expand Up @@ -3591,13 +3616,26 @@ func (s *lightningClient) Connect(ctx context.Context, peer route.Vertex,
return err
}

// SendCoinsOption is an option used in SendCoins call.
type SendCoinsOption func(*lnrpc.SendCoinsRequest)

// WithSendCoinsFeerate specifies feerate in sats/kw for SendCoins request.
// To use it pass satsPerVByte=0 and WithSendCoinsFeerate(desired_feerate) to
// SendCoins.
func WithSendCoinsFeerate(satPerKw chainfee.SatPerKWeight) SendCoinsOption {
return func(req *lnrpc.SendCoinsRequest) {
req.SatPerKw = uint64(satPerKw)
}
}

// SendCoins sends the passed amount of (or all) coins to the passed address.
// Either amount or sendAll must be specified, while confTarget, satsPerByte are
// optional and may be set to zero in which case automatic conf target and fee
// will be used. Returns the tx id upon success.
// Either amount or sendAll must be specified, while confTarget, satsPerVByte
// are optional and may be set to zero in which case automatic conf target and
// fee will be used. Returns the tx id upon success.
func (s *lightningClient) SendCoins(ctx context.Context, addr btcutil.Address,
amount btcutil.Amount, sendAll bool, confTarget int32,
satsPerByte int64, label string) (string, error) {
satsPerVByte chainfee.SatPerVByte, label string,
opts ...SendCoinsOption) (string, error) {

rpcCtx, cancel := context.WithTimeout(ctx, s.timeout)
defer cancel()
Expand All @@ -3608,11 +3646,15 @@ func (s *lightningClient) SendCoins(ctx context.Context, addr btcutil.Address,
Addr: addr.String(),
Amount: int64(amount),
TargetConf: confTarget,
SatPerByte: satsPerByte,
SatPerKw: uint64(satsPerVByte.FeePerKWeight()),
SendAll: sendAll,
Label: label,
}

for _, opt := range opts {
opt(req)
}

resp, err := s.client.SendCoins(rpcCtx, req)
if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions walletkit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,8 @@ func (m *walletKitClient) BumpFee(ctx context.Context, op wire.OutPoint,
TxidBytes: op.Hash[:],
OutputIndex: op.Index,
},
SatPerVbyte: uint64(feeRate.FeePerVByte()),
Immediate: false,
SatPerKw: uint64(feeRate),
Immediate: false,
}

for _, opt := range opts {
Expand Down