chainntnfs/btcdnotify: don't error if tx not found for historical conf dispatch

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-09-12 17:00:56 +02:00
parent fe0a7b6a09
commit ed7eae819a
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -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)
}