routing: move zero hops check

This commit is contained in:
Joost Jager committed 2019-12-16 14:53:47 +01:00
1 parent 31b2c22cf5
commit d85f378aa2
2 files changed
+5 -7

No files matched your search

+5
View File
@@ -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