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.
This commit is contained in:
parent
fdca047246
commit
6a0e6da280
1 changed files with 20 additions and 10 deletions
|
@ -568,55 +568,65 @@ mainLoop:
|
||||||
// Update our monitored watchlists or do a rescan.
|
// Update our monitored watchlists or do a rescan.
|
||||||
case event := <-c.rescanUpdate:
|
case event := <-c.rescanUpdate:
|
||||||
switch e := event.(type) {
|
switch e := event.(type) {
|
||||||
case struct{}:
|
|
||||||
// We're clearing the watchlists.
|
// We're clearing the watchlists.
|
||||||
|
case struct{}:
|
||||||
c.clientMtx.Lock()
|
c.clientMtx.Lock()
|
||||||
c.watchAddrs = make(map[string]struct{})
|
c.watchAddrs = make(map[string]struct{})
|
||||||
c.watchTxIDs = make(map[chainhash.Hash]struct{})
|
c.watchTxIDs = make(map[chainhash.Hash]struct{})
|
||||||
c.watchOutPoints =
|
c.watchOutPoints =
|
||||||
make(map[wire.OutPoint]struct{})
|
make(map[wire.OutPoint]struct{})
|
||||||
c.clientMtx.Unlock()
|
c.clientMtx.Unlock()
|
||||||
case []btcutil.Address:
|
|
||||||
// We're updating monitored addresses.
|
// We're updating monitored addresses.
|
||||||
|
case []btcutil.Address:
|
||||||
c.clientMtx.Lock()
|
c.clientMtx.Lock()
|
||||||
for _, addr := range e {
|
for _, addr := range e {
|
||||||
c.watchAddrs[addr.EncodeAddress()] =
|
c.watchAddrs[addr.EncodeAddress()] =
|
||||||
struct{}{}
|
struct{}{}
|
||||||
}
|
}
|
||||||
c.clientMtx.Unlock()
|
c.clientMtx.Unlock()
|
||||||
|
|
||||||
|
// We're updating monitored outpoints from
|
||||||
|
// pointers.
|
||||||
case []*wire.OutPoint:
|
case []*wire.OutPoint:
|
||||||
// We're updating monitored outpoints
|
|
||||||
// from pointers.
|
|
||||||
c.clientMtx.Lock()
|
c.clientMtx.Lock()
|
||||||
for _, op := range e {
|
for _, op := range e {
|
||||||
c.watchOutPoints[*op] = struct{}{}
|
c.watchOutPoints[*op] = struct{}{}
|
||||||
}
|
}
|
||||||
c.clientMtx.Unlock()
|
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:
|
case map[wire.OutPoint]btcutil.Address:
|
||||||
// We're updating monitored outpoints.
|
|
||||||
c.clientMtx.Lock()
|
c.clientMtx.Lock()
|
||||||
for op := range e {
|
for op := range e {
|
||||||
c.watchOutPoints[op] = struct{}{}
|
c.watchOutPoints[op] = struct{}{}
|
||||||
}
|
}
|
||||||
c.clientMtx.Unlock()
|
c.clientMtx.Unlock()
|
||||||
|
|
||||||
|
// We're adding monitored TXIDs.
|
||||||
case []*chainhash.Hash:
|
case []*chainhash.Hash:
|
||||||
// We're adding monitored TXIDs from
|
|
||||||
// pointers.
|
|
||||||
c.clientMtx.Lock()
|
c.clientMtx.Lock()
|
||||||
for _, txid := range e {
|
for _, txid := range e {
|
||||||
c.watchTxIDs[*txid] = struct{}{}
|
c.watchTxIDs[*txid] = struct{}{}
|
||||||
}
|
}
|
||||||
c.clientMtx.Unlock()
|
c.clientMtx.Unlock()
|
||||||
case []chainhash.Hash:
|
case []chainhash.Hash:
|
||||||
// We're adding monitored TXIDs.
|
|
||||||
c.clientMtx.Lock()
|
c.clientMtx.Lock()
|
||||||
for _, txid := range e {
|
for _, txid := range e {
|
||||||
c.watchTxIDs[txid] = struct{}{}
|
c.watchTxIDs[txid] = struct{}{}
|
||||||
}
|
}
|
||||||
c.clientMtx.Unlock()
|
c.clientMtx.Unlock()
|
||||||
|
|
||||||
|
// We're rescanning from the passed hash.
|
||||||
case *chainhash.Hash:
|
case *chainhash.Hash:
|
||||||
// We're rescanning from the passed
|
|
||||||
// hash.
|
|
||||||
err = c.rescan(e)
|
err = c.rescan(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("rescan failed: %s",
|
log.Errorf("rescan failed: %s",
|
||||||
|
|
Loading…
Reference in a new issue