Skip to content

Commit

Permalink
Merge pull request #3360 from tyzbit/3357_start-time
Browse files Browse the repository at this point in the history
rpcserver: startTime defaults to the unix epoch
  • Loading branch information
Roasbeef committed Oct 7, 2019
2 parents 1a5e39d + be989a8 commit 2a3538f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 4 additions & 0 deletions cmd/lncli/commands.go
Expand Up @@ -16,6 +16,7 @@ import (
"strings"
"sync"
"syscall"
"time"

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
Expand Down Expand Up @@ -3582,6 +3583,9 @@ func forwardingHistory(ctx *cli.Context) error {
return fmt.Errorf("unable to decode start_time %v", err)
}
args = args.Tail()
default:
now := time.Now()
startTime = uint64(now.Add(-time.Hour * 24).Unix())
}

switch {
Expand Down
9 changes: 2 additions & 7 deletions rpcserver.go
Expand Up @@ -4672,13 +4672,8 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
numEvents uint32
)

// If the start time wasn't specified, we'll default to 24 hours ago.
if req.StartTime == 0 {
now := time.Now()
startTime = now.Add(-time.Hour * 24)
} else {
startTime = time.Unix(int64(req.StartTime), 0)
}
// startTime defaults to the Unix epoch (0 unixtime, or midnight 01-01-1970).
startTime = time.Unix(int64(req.StartTime), 0)

// If the end time wasn't specified, assume a default end time of now.
if req.EndTime == 0 {
Expand Down

0 comments on commit 2a3538f

Please sign in to comment.