mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-26 22:17:51 +01:00
routerrpc: extend payment request parameters
Add missing parameters to routerrpc version of SendPayment.
This commit is contained in:
19
rpcserver.go
19
rpcserver.go
@@ -474,8 +474,9 @@ func newRPCServer(s *server, macService *macaroons.Service,
|
||||
|
||||
return info.NodeKey1Bytes, info.NodeKey2Bytes, nil
|
||||
},
|
||||
FindRoute: s.chanRouter.FindRoute,
|
||||
MissionControl: s.missionControl,
|
||||
FindRoute: s.chanRouter.FindRoute,
|
||||
MissionControl: s.missionControl,
|
||||
ActiveNetParams: activeNetParams.Params,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -2736,18 +2737,6 @@ func (r *rpcServer) SubscribeChannelEvents(req *lnrpc.ChannelEventSubscription,
|
||||
}
|
||||
}
|
||||
|
||||
// validatePayReqExpiry checks if the passed payment request has expired. In
|
||||
// the case it has expired, an error will be returned.
|
||||
func validatePayReqExpiry(payReq *zpay32.Invoice) error {
|
||||
expiry := payReq.Expiry()
|
||||
validUntil := payReq.Timestamp.Add(expiry)
|
||||
if time.Now().After(validUntil) {
|
||||
return fmt.Errorf("invoice expired. Valid until %v", validUntil)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// paymentStream enables different types of payment streams, such as:
|
||||
// lnrpc.Lightning_SendPaymentServer and lnrpc.Lightning_SendToRouteServer to
|
||||
// execute sendPayment. We use this struct as a sort of bridge to enable code
|
||||
@@ -2930,7 +2919,7 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error
|
||||
}
|
||||
|
||||
// Next, we'll ensure that this payreq hasn't already expired.
|
||||
err = validatePayReqExpiry(payReq)
|
||||
err = routerrpc.ValidatePayReqExpiry(payReq)
|
||||
if err != nil {
|
||||
return payIntent, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user