diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 2f77e308b..a93726e24 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -508,10 +508,6 @@ type spendCancel struct { func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, _ uint32) (*chainntnfs.SpendEvent, error) { - if err := b.chainConn.NotifySpent([]*wire.OutPoint{outpoint}); err != nil { - return nil, err - } - ntfn := &spendNotification{ targetOutpoint: outpoint, spendChan: make(chan *chainntnfs.SpendDetail, 1), @@ -524,6 +520,10 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, case b.notificationRegistry <- ntfn: } + if err := b.chainConn.NotifySpent([]*wire.OutPoint{outpoint}); err != nil { + return nil, err + } + // The following conditional checks to ensure that when a spend notification // is registered, the output hasn't already been spent. If the output // is no longer in the UTXO set, the chain will be rescanned from the point