Skip to content

Commit 25f7b1c

Browse files
committed
blindedpath: minHTLC for blinded path change.
We will not add a buffer to the chan policy for blinded paths in case the sender amount violates the minHTLC restriction in the first place. Moreover we disgard a route fast if the payment amount is smaller than the minHTLC along the route.
1 parent 7398496 commit 25f7b1c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

routing/blindedpath/blinded_path.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,27 @@ func collectRelayInfo(cfg *BuildBlindedPathCfg, path *candidatePath) (
437437
}
438438
}
439439

440-
policy, err = cfg.AddPolicyBuffer(policy)
440+
if policy.MinHTLCMsat > cfg.ValueMsat {
441+
return nil, 0, 0, fmt.Errorf("%w: minHTLC of hop "+
442+
"policy larger than payment amt: sentAmt(%v), "+
443+
"minHTLC(%v)", errInvalidBlindedPath,
444+
cfg.ValueMsat, policy.MinHTLCMsat)
445+
}
446+
447+
bufferPolicy, err := cfg.AddPolicyBuffer(policy)
441448
if err != nil {
442449
return nil, 0, 0, err
443450
}
444451

452+
// We only use the new buffered policy if the new minHTLC value
453+
// does not violate the sender amount.
454+
//
455+
// NOTE: We don't check this for maxHTLC, because the payment
456+
// amount can always be splitted using MPP.
457+
if bufferPolicy.MinHTLCMsat <= cfg.ValueMsat {
458+
policy = bufferPolicy
459+
}
460+
445461
// If this is the first policy we are collecting, then use this
446462
// policy to set the base values for min/max htlc.
447463
if len(hops) == 0 {

0 commit comments

Comments
 (0)