diff --git a/api/worker.go b/api/worker.go index f59fa4bf..a6a2f304 100644 --- a/api/worker.go +++ b/api/worker.go @@ -174,6 +174,9 @@ func (w *Worker) GetTransaction(txid string, spendingTxs bool) (*Tx, error) { valOutSat.Add(&valOutSat, &bchainVout.ValueSat) vout.ScriptPubKey.Hex = bchainVout.ScriptPubKey.Hex vout.ScriptPubKey.AddrDesc, vout.ScriptPubKey.Addresses, vout.ScriptPubKey.Searchable, err = w.getAddressesFromVout(bchainVout) + if err != nil { + glog.Errorf("getAddressesFromVout error %v, %v, output %v", err, vout.ScriptPubKey.AddrDesc, vout.N) + } if ta != nil { vout.Spent = ta.Outputs[i].Spent if spendingTxs && vout.Spent { @@ -363,6 +366,9 @@ func (w *Worker) GetAddress(address string, page int, txsOnPage int, onlyTxids b } // convert the address to the format defined by the parser addresses, _, err := w.chainParser.GetAddressesFromAddrDesc(addrDesc) + if err != nil { + return nil, errors.Annotatef(err, "GetAddressesFromAddrDesc %v", addrDesc) + } if len(addresses) == 1 { address = addresses[0] } @@ -505,10 +511,15 @@ func (w *Worker) GetBlock(bid string, page int, txsOnPage int) (*Block, error) { if page < 0 { page = 0 } + // try to decide if passed string (bid) is block height or block hash + // if it's a number, must be less than int32 var hash string height, err := strconv.Atoi(bid) if err == nil && height < int(^uint32(0)) { hash, err = w.db.GetBlockHash(uint32(height)) + if err != nil { + hash = bid + } } else { hash = bid } diff --git a/bchain/coins/bch/bcashparser.go b/bchain/coins/bch/bcashparser.go index 83411081..d0d48730 100644 --- a/bchain/coins/bch/bcashparser.go +++ b/bchain/coins/bch/bcashparser.go @@ -91,7 +91,6 @@ func GetChainParams(chain string) *chaincfg.Params { panic(err) } } - var params *chaincfg.Params switch chain { case "test": return &TestNetParams @@ -100,8 +99,6 @@ func GetChainParams(chain string) *chaincfg.Params { default: return &MainNetParams } - - return params } // GetAddrDescFromAddress returns internal address representation of given address diff --git a/bchain/coins/eth/ethrpc.go b/bchain/coins/eth/ethrpc.go index ffdac499..8a5c98c9 100644 --- a/bchain/coins/eth/ethrpc.go +++ b/bchain/coins/eth/ethrpc.go @@ -416,6 +416,9 @@ func (b *EthereumRPC) GetBlock(hash string, height uint32) (*bchain.Block, error return nil, errors.Annotatef(fmt.Errorf("server returned empty transaction list but block header indicates transactions"), "hash %v, height %v", hash, height) } bbh, err := b.ethHeaderToBlockHeader(head) + if err != nil { + return nil, errors.Annotatef(err, "hash %v, height %v", hash, height) + } // TODO - this is probably not the correct size bbh.Size = len(raw) btxs := make([]bchain.Tx, len(body.Transactions)) diff --git a/bchain/coins/grs/grsparser.go b/bchain/coins/grs/grsparser.go index 460eadc9..9c560b63 100644 --- a/bchain/coins/grs/grsparser.go +++ b/bchain/coins/grs/grsparser.go @@ -66,15 +66,12 @@ func GetChainParams(chain string) *chaincfg.Params { panic(err) } } - var params *chaincfg.Params switch chain { case "test": return &TestNetParams default: return &MainNetParams } - - return params } // PackTx packs transaction to byte array using protobuf diff --git a/bchain/coins/zec/zcashparser.go b/bchain/coins/zec/zcashparser.go index 51093c1b..f2b2c5e9 100644 --- a/bchain/coins/zec/zcashparser.go +++ b/bchain/coins/zec/zcashparser.go @@ -71,7 +71,6 @@ func GetChainParams(chain string) *chaincfg.Params { panic(err) } } - var params *chaincfg.Params switch chain { case "test": return &TestNetParams @@ -80,8 +79,6 @@ func GetChainParams(chain string) *chaincfg.Params { default: return &MainNetParams } - - return params } // PackTx packs transaction to byte array using protobuf diff --git a/server/internal.go b/server/internal.go index 5e12dcf1..6ef09f1e 100644 --- a/server/internal.go +++ b/server/internal.go @@ -82,9 +82,17 @@ func (s *InternalServer) Shutdown(ctx context.Context) error { func (s *InternalServer) index(w http.ResponseWriter, r *http.Request) { si, err := s.api.GetSystemInfo(true) + if err != nil { + glog.Error(err) + w.WriteHeader(http.StatusInternalServerError) + return + } buf, err := json.MarshalIndent(si, "", " ") if err != nil { glog.Error(err) + w.WriteHeader(http.StatusInternalServerError) + return } + w.Write(buf) }