Skip to content

Commit

Permalink
Validate input t-address
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 authored and Larry Ruane committed Dec 18, 2019
1 parent 1a9b3b9 commit 74b9cba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -47,6 +48,13 @@ func (s *LwdStreamer) GetLatestBlock(ctx context.Context, placeholder *walletrpc
}

func (s *LwdStreamer) GetAddressTxids(addressBlockFilter *walletrpc.TransparentAddressBlockFilter, resp walletrpc.CompactTxStreamer_GetAddressTxidsServer) error {
// Test to make sure Address is a single t address
match, err := regexp.Match("\\At[a-zA-Z0-9]{34}\\z", []byte(addressBlockFilter.Address))
if err != nil || !match {
s.log.Errorf("Unrecognized address: %s", addressBlockFilter.Address)
return nil
}

params := make([]json.RawMessage, 1)
st := "{\"addresses\": [\"" + addressBlockFilter.Address + "\"]," +
"\"start\": " + strconv.FormatUint(addressBlockFilter.Range.Start.Height, 10) +
Expand All @@ -56,8 +64,6 @@ func (s *LwdStreamer) GetAddressTxids(addressBlockFilter *walletrpc.TransparentA

result, rpcErr := s.client.RawRequest("getaddresstxids", params)

var err error

// For some reason, the error responses are not JSON
if rpcErr != nil {
s.log.Errorf("Got error: %s", rpcErr.Error())
Expand Down

0 comments on commit 74b9cba

Please sign in to comment.