From 005510b54f6107240cddf980a2dfd1c64c833824 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 17 Apr 2018 20:08:50 -0700 Subject: [PATCH] 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. --- chainntnfs/bitcoindnotify/bitcoind.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index a729d044..d451db78 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -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 }