Merge pull request #3790 from Roasbeef/pay-size-consistency

multi: make SendToRoute consistent with other payment RPC
This commit is contained in:
Olaoluwa Osuntokun 2019-12-04 19:09:28 -08:00 committed by GitHub
commit 773aa390b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

@ -2359,6 +2359,9 @@ func (f *fundingManager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
if fwdMaxHTLC > capacityMSat {
fwdMaxHTLC = capacityMSat
}
if fwdMaxHTLC > MaxPaymentMSat {
fwdMaxHTLC = MaxPaymentMSat
}
// Create and broadcast the proofs required to make this channel
// public and usable for other nodes for routing.

@ -257,9 +257,9 @@ type ChannelLinkConfig struct {
// configured set of watchtowers.
TowerClient TowerClient
// MaxCltvExpiry is the maximum outgoing timelock that the link should
// accept for a forwarded HTLC. The value is relative to the current
// block height.
// MaxOutgoingCltvExpiry is the maximum outgoing timelock that the link
// should accept for a forwarded HTLC. The value is relative to the
// current block height.
MaxOutgoingCltvExpiry uint32
// MaxFeeAllocation is the highest allocation we'll allow a channel's

@ -470,6 +470,13 @@ func (r *RouterBackend) UnmarshallRoute(rpcroute *lnrpc.Route) (
return nil, err
}
if routeHop.AmtToForward > r.MaxPaymentMSat {
return nil, fmt.Errorf("payment of %v is too large, "+
"max payment allowed is %v",
routeHop.AmtToForward,
r.MaxPaymentMSat.ToSatoshis())
}
hops[i] = routeHop
prevNodePubKey = routeHop.PubKeyBytes

@ -535,6 +535,9 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) (
FeeRate: selfPolicy.FeeProportionalMillionths,
TimeLockDelta: uint32(selfPolicy.TimeLockDelta),
}
if forwardingPolicy.MaxHTLC > MaxPaymentMSat {
forwardingPolicy.MaxHTLC = MaxPaymentMSat
}
} else {
peerLog.Warnf("Unable to find our forwarding policy "+
"for channel %v, using default values",
@ -1866,6 +1869,9 @@ out:
FeeRate: defaultPolicy.FeeRate,
TimeLockDelta: defaultPolicy.TimeLockDelta,
}
if forwardingPolicy.MaxHTLC > MaxPaymentMSat {
forwardingPolicy.MaxHTLC = MaxPaymentMSat
}
// Create the link and add it to the switch.
err = p.addLink(