diff --git a/blockchain/chain.go b/blockchain/chain.go index 485c3e0b..b2690422 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -1394,8 +1394,8 @@ func (b *BlockChain) BlockAttributesByHash(hash *chainhash.Hash, prevHash *chain attrs *BlockAttributes, best *BestState, err error) { best = b.BestSnapshot() node := b.index.LookupNode(hash) - if node == nil || !b.bestChain.Contains(node) { - str := fmt.Sprintf("block %s is not in the main chain", hash) + if node == nil { + str := fmt.Sprintf("block %s not found", hash) return nil, best, errNotInMainChain(str) } @@ -1405,6 +1405,9 @@ func (b *BlockChain) BlockAttributesByHash(hash *chainhash.Hash, prevHash *chain MedianTime: node.CalcPastMedianTime(), ChainWork: node.workSum, } + if !b.bestChain.Contains(node) { + attrs.Confirmations = -1 + } // Populate prev block hash if there is one. if node.height > 0 { diff --git a/rpcserver.go b/rpcserver.go index c9ca0eda..ab052bc4 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1211,7 +1211,7 @@ func handleGetBlock(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i if err != nil { return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCBlockNotFound, - Message: "Block not found", + Message: "Block not found: " + err.Error(), } } // If verbosity is 0, return the serialized block as a hex encoded string.