chainntnfs/bitcoindnotify: fix possible panic with lack of txindex

In this commit, we fix a recently introduced bug which can result in a
panic when bitcoind nodes without a txindex active are started. The
issue was that we would still defence the transaction's blockhash, which
would be nil if we detected that the backend didn't have the txindex
active.
This commit is contained in:
Olaoluwa Osuntokun 2018-04-17 20:08:50 -07:00
parent 188b8462cd
commit 005510b54f
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -616,13 +616,10 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
// of a race condition, wherein the output itself is unspent,
// and only arrives in the mempool after the getxout call.
if blockHash != nil {
startHash, err := chainhash.NewHashFromStr(tx.BlockHash)
if err != nil {
return nil, err
}
// Rescan all the blocks until the current one.
startHeight, err := b.chainConn.GetBlockHeight(startHash)
startHeight, err := b.chainConn.GetBlockHeight(
blockHash,
)
if err != nil {
return nil, err
}