From ed7eae819ae4d42dd2e182e65525266ebd6ee8cc Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 12 Sep 2017 17:00:56 +0200 Subject: [PATCH] chainntnfs/btcdnotify: don't error if tx not found for historical conf dispatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a prior mishandled error when attempting historical confirmation dispatches. In the prior version of this code fragment, if the transaction under the spotlight wasn’t found within the mempool, or already in the chain, then an error would be returned by b.chainConn.GetRawTransactionVerbose, which would case the function to exit with an error. This behavior was incorrect, as during transaction re-broadcasts, it was possible for transaction not yet to be a member of either set. We fix this issue by ensuring that we treat the JSON error code as a benign error and continue with the notification registration. --- chainntnfs/btcdnotify/btcd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 70fdc186..b928def9 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -428,7 +428,10 @@ func (b *BtcdNotifier) attemptHistoricalDispatch(msg *confirmationsNotification, // then we may be able to dispatch it immediately. tx, err := b.chainConn.GetRawTransactionVerbose(msg.txid) if err != nil || tx == nil || tx.BlockHash == "" { - if err != nil { + jsonErr, ok := err.(*btcjson.RPCError) + switch { + case ok && jsonErr.Code == -5: + default: chainntnfs.Log.Warnf("unable to query for txid(%v): %v", msg.txid, err) }