diff --git a/routing/blindedpath/blinded_path.go b/routing/blindedpath/blinded_path.go index e47114baf..bc14daa40 100644 --- a/routing/blindedpath/blinded_path.go +++ b/routing/blindedpath/blinded_path.go @@ -437,11 +437,27 @@ func collectRelayInfo(cfg *BuildBlindedPathCfg, path *candidatePath) ( } } - policy, err = cfg.AddPolicyBuffer(policy) + if policy.MinHTLCMsat > cfg.ValueMsat { + return nil, 0, 0, fmt.Errorf("%w: minHTLC of hop "+ + "policy larger than payment amt: sentAmt(%v), "+ + "minHTLC(%v)", errInvalidBlindedPath, + cfg.ValueMsat, policy.MinHTLCMsat) + } + + bufferPolicy, err := cfg.AddPolicyBuffer(policy) if err != nil { return nil, 0, 0, err } + // We only use the new buffered policy if the new minHTLC value + // does not violate the sender amount. + // + // NOTE: We don't check this for maxHTLC, because the payment + // amount can always be splitted using MPP. + if bufferPolicy.MinHTLCMsat <= cfg.ValueMsat { + policy = bufferPolicy + } + // If this is the first policy we are collecting, then use this // policy to set the base values for min/max htlc. if len(hops) == 0 {