From 6a0e6da280dcefd4696142643bf5e702244279fa Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 17 Jul 2018 18:54:20 -0700 Subject: [PATCH] chain: continue to accept []wire.OutPoint for rescan updates for bitcoind In this commit, we fix a recently introduced bug that would cause callers that attempted to get a spend notifications for a particular outpoint to no longer get that precise notification. In a prior commit, in preparation for the new neutrino gcs filter format, we added a mapping from script to outpoint that will be used by neutrino, and later other backends as well. However, we still need to match on outpoint slices for bitcoind today. --- chain/bitcoind.go | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/chain/bitcoind.go b/chain/bitcoind.go index 2611757..028483e 100644 --- a/chain/bitcoind.go +++ b/chain/bitcoind.go @@ -568,55 +568,65 @@ mainLoop: // Update our monitored watchlists or do a rescan. case event := <-c.rescanUpdate: switch e := event.(type) { + + // We're clearing the watchlists. case struct{}: - // We're clearing the watchlists. c.clientMtx.Lock() c.watchAddrs = make(map[string]struct{}) c.watchTxIDs = make(map[chainhash.Hash]struct{}) c.watchOutPoints = make(map[wire.OutPoint]struct{}) c.clientMtx.Unlock() + + // We're updating monitored addresses. case []btcutil.Address: - // We're updating monitored addresses. c.clientMtx.Lock() for _, addr := range e { c.watchAddrs[addr.EncodeAddress()] = struct{}{} } c.clientMtx.Unlock() + + // We're updating monitored outpoints from + // pointers. case []*wire.OutPoint: - // We're updating monitored outpoints - // from pointers. c.clientMtx.Lock() for _, op := range e { c.watchOutPoints[*op] = struct{}{} } c.clientMtx.Unlock() + case []wire.OutPoint: + c.clientMtx.Lock() + for _, op := range e { + c.watchOutPoints[op] = struct{}{} + } + c.clientMtx.Unlock() + + // We're updating monitored outpoints that map + // to the scripts that we should scan for. case map[wire.OutPoint]btcutil.Address: - // We're updating monitored outpoints. c.clientMtx.Lock() for op := range e { c.watchOutPoints[op] = struct{}{} } c.clientMtx.Unlock() + + // We're adding monitored TXIDs. case []*chainhash.Hash: - // We're adding monitored TXIDs from - // pointers. c.clientMtx.Lock() for _, txid := range e { c.watchTxIDs[*txid] = struct{}{} } c.clientMtx.Unlock() case []chainhash.Hash: - // We're adding monitored TXIDs. c.clientMtx.Lock() for _, txid := range e { c.watchTxIDs[txid] = struct{}{} } c.clientMtx.Unlock() + + // We're rescanning from the passed hash. case *chainhash.Hash: - // We're rescanning from the passed - // hash. err = c.rescan(e) if err != nil { log.Errorf("rescan failed: %s",