diff --git a/lnrpc/routerrpc/router_backend.go b/lnrpc/routerrpc/router_backend.go index 1e2b5ccd..7fab7354 100644 --- a/lnrpc/routerrpc/router_backend.go +++ b/lnrpc/routerrpc/router_backend.go @@ -572,6 +572,14 @@ func (r *RouterBackend) extractIntentFromSendRequest( } payIntent.MaxParts = maxParts + // If this payment had a max shard amount specified, then we'll apply + // that now, which'll force us to always make payment splits smaller + // than this. + if rpcPayReq.MaxShardSizeMsat > 0 { + shardAmtMsat := lnwire.MilliSatoshi(rpcPayReq.MaxShardSizeMsat) + payIntent.MaxShardAmt = &shardAmtMsat + } + // Take fee limit from request. payIntent.FeeLimit, err = lnrpc.UnmarshallAmt( rpcPayReq.FeeLimitSat, rpcPayReq.FeeLimitMsat, diff --git a/routing/router.go b/routing/router.go index 4c1aa221..b308338a 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1684,6 +1684,14 @@ type LightningPayment struct { // MaxParts is the maximum number of partial payments that may be used // to complete the full amount. MaxParts uint32 + + // MaxShardAmt is the largest shard that we'll attempt to split using. + // If this field is set, and we need to split, rather than attempting + // half of the original payment amount, we'll use this value if half + // the payment amount is greater than it. + // + // NOTE: This field is _optional_. + MaxShardAmt *lnwire.MilliSatoshi } // SendPayment attempts to send a payment as described within the passed