routing+lnrpc+lncli: allow setting min htlc policy

This commit is contained in:
Joost Jager 2019-11-15 11:24:58 +01:00
parent 74c2df658e
commit b6eb3a69ba
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
7 changed files with 633 additions and 567 deletions

View File

@ -3459,6 +3459,12 @@ var updateChannelPolicyCommand = cli.Command{
Usage: "the CLTV delta that will be applied to all " +
"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{
Name: "max_htlc_msat",
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"),
}
if ctx.IsSet("min_htlc_msat") {
req.MinHtlcMsat = ctx.Uint64("min_htlc_msat")
req.MinHtlcMsatSpecified = true
}
if chanPoint != nil {
req.Scope = &lnrpc.PolicyUpdateRequest_ChanPoint{
ChanPoint: chanPoint,

File diff suppressed because it is too large Load Diff

View File

@ -2686,6 +2686,12 @@ message PolicyUpdateRequest {
/// 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"];
/// 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 {
}

View File

@ -3538,6 +3538,16 @@
"type": "string",
"format": "uint64",
"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."
}
}
},

View File

@ -160,6 +160,11 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
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.
edge.MessageFlags |= lnwire.ChanUpdateOptionMaxHtlc

View File

@ -224,6 +224,10 @@ type ChannelPolicy struct {
// MaxHTLC is the maximum HTLC size including fees we are allowed to
// forward over this channel.
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

View File

@ -4864,15 +4864,25 @@ func (r *rpcServer) UpdateChannelPolicy(ctx context.Context,
FeeRate: feeRateFixed,
}
maxHtlc := lnwire.MilliSatoshi(req.MaxHtlcMsat)
var minHtlc *lnwire.MilliSatoshi
if req.MinHtlcMsatSpecified {
min := lnwire.MilliSatoshi(req.MinHtlcMsat)
minHtlc = &min
}
chanPolicy := routing.ChannelPolicy{
FeeSchema: feeSchema,
TimeLockDelta: req.TimeLockDelta,
MaxHTLC: lnwire.MilliSatoshi(req.MaxHtlcMsat),
MaxHTLC: maxHtlc,
MinHTLC: minHtlc,
}
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,
minHtlc, maxHtlc,
spew.Sdump(targetChans))
// With the scope resolved, we'll now send this to the local channel