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.
This commit is contained in:
ziggie 2024-08-22 17:49:16 +02:00
parent 73984964a8
commit 25f7b1c362
No known key found for this signature in database
GPG Key ID: 1AFF9C4DCED6D666

View File

@ -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 {