mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-26 00:31:32 +02:00
routing+lnrpc+lncli: allow setting min htlc policy
This commit is contained in:
parent
74c2df658e
commit
b6eb3a69ba
@ -3459,6 +3459,12 @@ var updateChannelPolicyCommand = cli.Command{
|
|||||||
Usage: "the CLTV delta that will be applied to all " +
|
Usage: "the CLTV delta that will be applied to all " +
|
||||||
"forwarded HTLCs",
|
"forwarded HTLCs",
|
||||||
},
|
},
|
||||||
|
cli.Uint64Flag{
|
||||||
|
Name: "min_htlc_msat",
|
||||||
|
Usage: "if set, the min HTLC size that will be applied " +
|
||||||
|
"to all forwarded HTLCs. If unset, the min HTLC " +
|
||||||
|
"is left unchanged.",
|
||||||
|
},
|
||||||
cli.Uint64Flag{
|
cli.Uint64Flag{
|
||||||
Name: "max_htlc_msat",
|
Name: "max_htlc_msat",
|
||||||
Usage: "if set, the max HTLC size that will be applied " +
|
Usage: "if set, the max HTLC size that will be applied " +
|
||||||
@ -3581,6 +3587,11 @@ func updateChannelPolicy(ctx *cli.Context) error {
|
|||||||
MaxHtlcMsat: ctx.Uint64("max_htlc_msat"),
|
MaxHtlcMsat: ctx.Uint64("max_htlc_msat"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.IsSet("min_htlc_msat") {
|
||||||
|
req.MinHtlcMsat = ctx.Uint64("min_htlc_msat")
|
||||||
|
req.MinHtlcMsatSpecified = true
|
||||||
|
}
|
||||||
|
|
||||||
if chanPoint != nil {
|
if chanPoint != nil {
|
||||||
req.Scope = &lnrpc.PolicyUpdateRequest_ChanPoint{
|
req.Scope = &lnrpc.PolicyUpdateRequest_ChanPoint{
|
||||||
ChanPoint: chanPoint,
|
ChanPoint: chanPoint,
|
||||||
|
1150
lnrpc/rpc.pb.go
1150
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@ -2686,6 +2686,12 @@ message PolicyUpdateRequest {
|
|||||||
|
|
||||||
/// If set, the maximum HTLC size in milli-satoshis. If unset, the maximum HTLC will be unchanged.
|
/// If set, the maximum HTLC size in milli-satoshis. If unset, the maximum HTLC will be unchanged.
|
||||||
uint64 max_htlc_msat = 6 [json_name = "max_htlc_msat"];
|
uint64 max_htlc_msat = 6 [json_name = "max_htlc_msat"];
|
||||||
|
|
||||||
|
/// The minimum HTLC size in milli-satoshis. Only applied if min_htlc_msat_specified is true.
|
||||||
|
uint64 min_htlc_msat = 7 [json_name = "min_htlc_msat"];
|
||||||
|
|
||||||
|
/// If true, min_htlc_msat is applied.
|
||||||
|
bool min_htlc_msat_specified = 8 [json_name = "set_min_htlc_msat"];
|
||||||
}
|
}
|
||||||
message PolicyUpdateResponse {
|
message PolicyUpdateResponse {
|
||||||
}
|
}
|
||||||
|
@ -3538,6 +3538,16 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "uint64",
|
"format": "uint64",
|
||||||
"description": "/ If set, the maximum HTLC size in milli-satoshis. If unset, the maximum HTLC will be unchanged."
|
"description": "/ If set, the maximum HTLC size in milli-satoshis. If unset, the maximum HTLC will be unchanged."
|
||||||
|
},
|
||||||
|
"min_htlc_msat": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uint64",
|
||||||
|
"description": "/ The minimum HTLC size in milli-satoshis. Only applied if min_htlc_msat_specified is true."
|
||||||
|
},
|
||||||
|
"min_htlc_msat_specified": {
|
||||||
|
"type": "boolean",
|
||||||
|
"format": "boolean",
|
||||||
|
"description": "/ If true, min_htlc_msat is applied."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -160,6 +160,11 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
|
|||||||
edge.MaxHTLC = amtMax
|
edge.MaxHTLC = amtMax
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a new min htlc is specified, update the edge.
|
||||||
|
if newSchema.MinHTLC != nil {
|
||||||
|
edge.MinHTLC = *newSchema.MinHTLC
|
||||||
|
}
|
||||||
|
|
||||||
// If the MaxHtlc flag wasn't already set, we can set it now.
|
// If the MaxHtlc flag wasn't already set, we can set it now.
|
||||||
edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc
|
edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc
|
||||||
|
|
||||||
|
@ -224,6 +224,10 @@ type ChannelPolicy struct {
|
|||||||
// MaxHTLC is the maximum HTLC size including fees we are allowed to
|
// MaxHTLC is the maximum HTLC size including fees we are allowed to
|
||||||
// forward over this channel.
|
// forward over this channel.
|
||||||
MaxHTLC lnwire.MilliSatoshi
|
MaxHTLC lnwire.MilliSatoshi
|
||||||
|
|
||||||
|
// MinHTLC is the minimum HTLC size including fees we are allowed to
|
||||||
|
// forward over this channel.
|
||||||
|
MinHTLC *lnwire.MilliSatoshi
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config defines the configuration for the ChannelRouter. ALL elements within
|
// Config defines the configuration for the ChannelRouter. ALL elements within
|
||||||
|
14
rpcserver.go
14
rpcserver.go
@ -4864,15 +4864,25 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
|
|||||||
FeeRate: feeRateFixed,
|
FeeRate: feeRateFixed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxHtlc := lnwire.MilliSatoshi(req.MaxHtlcMsat)
|
||||||
|
var minHtlc *lnwire.MilliSatoshi
|
||||||
|
if req.MinHtlcMsatSpecified {
|
||||||
|
min := lnwire.MilliSatoshi(req.MinHtlcMsat)
|
||||||
|
minHtlc = &min
|
||||||
|
}
|
||||||
|
|
||||||
chanPolicy := routing.ChannelPolicy{
|
chanPolicy := routing.ChannelPolicy{
|
||||||
FeeSchema: feeSchema,
|
FeeSchema: feeSchema,
|
||||||
TimeLockDelta: req.TimeLockDelta,
|
TimeLockDelta: req.TimeLockDelta,
|
||||||
MaxHTLC: lnwire.MilliSatoshi(req.MaxHtlcMsat),
|
MaxHTLC: maxHtlc,
|
||||||
|
MinHTLC: minHtlc,
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcsLog.Debugf("[updatechanpolicy] updating channel policy base_fee=%v, "+
|
rpcsLog.Debugf("[updatechanpolicy] updating channel policy base_fee=%v, "+
|
||||||
"rate_float=%v, rate_fixed=%v, time_lock_delta: %v, targets=%v",
|
"rate_float=%v, rate_fixed=%v, time_lock_delta: %v, "+
|
||||||
|
"min_htlc=%v, max_htlc=%v, targets=%v",
|
||||||
req.BaseFeeMsat, req.FeeRate, feeRateFixed, req.TimeLockDelta,
|
req.BaseFeeMsat, req.FeeRate, feeRateFixed, req.TimeLockDelta,
|
||||||
|
minHtlc, maxHtlc,
|
||||||
spew.Sdump(targetChans))
|
spew.Sdump(targetChans))
|
||||||
|
|
||||||
// With the scope resolved, we'll now send this to the local channel
|
// With the scope resolved, we'll now send this to the local channel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user