Skip to content

Commit

Permalink
lnrpc/routerrpc+routing: add new MaxShardAmt field to LightningPayment
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Feb 12, 2021
1 parent 5164487 commit 3dcb5bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lnrpc/routerrpc/router_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@ func (r *RouterBackend) extractIntentFromSendRequest(
}
payIntent.MaxParts = defaultMaxParts

// 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.MaxShardSizeSat > 0 {
shardAmtMsat := lnwire.NewMSatFromSatoshis(
btcutil.Amount(rpcPayReq.MaxShardSizeSat),
)
payIntent.MaxShardAmt = &shardAmtMsat
}

// Take fee limit from request.
payIntent.FeeLimit, err = lnrpc.UnmarshallAmt(
rpcPayReq.FeeLimitSat, rpcPayReq.FeeLimitMsat,
Expand Down
8 changes: 8 additions & 0 deletions routing/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3dcb5bf

Please sign in to comment.