routing: move zero hops check
This commit is contained in:
parent
31b2c22cf5
commit
d85f378aa2
@ -271,6 +271,11 @@ func NewRouteFromHops(amtToSend lnwire.MilliSatoshi, timeLock uint32,
|
||||
func (r *Route) ToSphinxPath() (*sphinx.PaymentPath, error) {
|
||||
var path sphinx.PaymentPath
|
||||
|
||||
// We can only construct a route if there are hops provided.
|
||||
if len(r.Hops) == 0 {
|
||||
return nil, ErrNoRouteHopsProvided
|
||||
}
|
||||
|
||||
// Check maximum route length.
|
||||
if len(r.Hops) > sphinx.NumMaxHops {
|
||||
return nil, ErrMaxRouteHopsExceeded
|
||||
|
@ -1487,13 +1487,6 @@ func generateNewSessionKey() (*btcec.PrivateKey, error) {
|
||||
func generateSphinxPacket(rt *route.Route, paymentHash []byte,
|
||||
sessionKey *btcec.PrivateKey) ([]byte, *sphinx.Circuit, error) {
|
||||
|
||||
// As a sanity check, we'll ensure that the set of hops has been
|
||||
// properly filled in, otherwise, we won't actually be able to
|
||||
// construct a route.
|
||||
if len(rt.Hops) == 0 {
|
||||
return nil, nil, route.ErrNoRouteHopsProvided
|
||||
}
|
||||
|
||||
// Now that we know we have an actual route, we'll map the route into a
|
||||
// sphinx payument path which includes per-hop paylods for each hop
|
||||
// that give each node within the route the necessary information
|
||||
|
Loading…
Reference in New Issue
Block a user