mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-13 18:10:25 +02:00
routerrpc: inject clock for testable expiry validation
Refactors payment request expiry validation to use an injected clock dependency instead of calling time.Now() directly.
This commit is contained in:
@@ -696,6 +696,7 @@ func (r *rpcServer) addDeps(s *server, macService *macaroons.Service,
|
||||
|
||||
routerBackend := &routerrpc.RouterBackend{
|
||||
SelfNode: selfNode.PubKeyBytes,
|
||||
Clock: clock.NewDefaultClock(),
|
||||
FetchChannelCapacity: func(chanID uint64) (btcutil.Amount,
|
||||
error) {
|
||||
|
||||
@@ -5609,7 +5610,9 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
|
||||
}
|
||||
|
||||
// Next, we'll ensure that this payreq hasn't already expired.
|
||||
err = routerrpc.ValidatePayReqExpiry(payReq)
|
||||
err = routerrpc.ValidatePayReqExpiry(
|
||||
r.routerBackend.Clock, payReq,
|
||||
)
|
||||
if err != nil {
|
||||
return payIntent, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user