rpc: set default values in getutxotransfers

This commit is contained in:
Evgenii Stratonikov 2020-08-07 09:47:59 +03:00
parent fe5e5ff44a
commit 02033f8355
2 changed files with 9 additions and 2 deletions

View file

@ -516,10 +516,17 @@ func (s *Server) getUTXOTransfers(ps request.Params) (interface{}, *response.Err
index++ index++
} }
start, end, err := getTimestamps(ps.Value(index), ps.Value(index+1)) p1, p2 := ps.Value(index), ps.Value(index+1)
start, end, err := getTimestamps(p1, p2)
if err != nil { if err != nil {
return nil, response.NewInvalidParamsError("", err) return nil, response.NewInvalidParamsError("", err)
} }
if p2 == nil {
end = uint32(time.Now().Unix())
if p1 == nil {
start = uint32(time.Now().Add(-time.Hour * 24 * 7).Unix())
}
}
sent, recv, err := getAssetMaps(assetName) sent, recv, err := getAssetMaps(assetName)
if err != nil { if err != nil {

View file

@ -1138,7 +1138,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
if asset != "" { if asset != "" {
ps = append(ps, fmt.Sprintf("%q", asset)) ps = append(ps, fmt.Sprintf("%q", asset))
} }
if start != 0 { if start >= 0 {
if start > int(e.chain.HeaderHeight()) { if start > int(e.chain.HeaderHeight()) {
ps = append(ps, strconv.Itoa(int(time.Now().Unix()))) ps = append(ps, strconv.Itoa(int(time.Now().Unix())))
} else { } else {