diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index 3fd41156..3fc60524 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -869,6 +869,18 @@ type confirmationNotification struct { func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { + // Before proceeding to register the notification, we'll query our + // height hint cache to determine whether a better one exists. + if hint, err := b.confirmHintCache.QueryConfirmHint(*txid); err == nil { + if hint > heightHint { + chainntnfs.Log.Debugf("Using height hint %d retrieved "+ + "from cache for %v", hint, txid) + heightHint = hint + } + } + + // Construct a notification request for the transaction and send it to + // the main event loop. ntfn := &confirmationNotification{ ConfNtfn: chainntnfs.ConfNtfn{ ConfID: atomic.AddUint64(&b.confClientCounter, 1), diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 13ad76d7..d8b4c909 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -916,6 +916,18 @@ type confirmationNotification struct { func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, _ []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { + // Before proceeding to register the notification, we'll query our + // height hint cache to determine whether a better one exists. + if hint, err := b.confirmHintCache.QueryConfirmHint(*txid); err == nil { + if hint > heightHint { + chainntnfs.Log.Debugf("Using height hint %d retrieved "+ + "from cache for %v", hint, txid) + heightHint = hint + } + } + + // Construct a notification request for the transaction and send it to + // the main event loop. ntfn := &confirmationNotification{ ConfNtfn: chainntnfs.ConfNtfn{ ConfID: atomic.AddUint64(&b.confClientCounter, 1), diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index 7ce0934e..d3aa0d6d 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -869,6 +869,18 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, pkScript []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { + // Before proceeding to register the notification, we'll query our + // height hint cache to determine whether a better one exists. + if hint, err := n.confirmHintCache.QueryConfirmHint(*txid); err == nil { + if hint > heightHint { + chainntnfs.Log.Debugf("Using height hint %d retrieved "+ + "from cache for %v", hint, txid) + heightHint = hint + } + } + + // Construct a notification request for the transaction and send it to + // the main event loop. ntfn := &confirmationsNotification{ ConfNtfn: chainntnfs.ConfNtfn{ ConfID: atomic.AddUint64(&n.confClientCounter, 1),