From 7e6997d6d35fe0fb9c897c8fd03479114c4e1f71 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 17 Jul 2018 19:13:29 -0700 Subject: [PATCH] routing/chainview: update neutrino API due to recent changes In this commit, we ensure that the neutrino backend meets the target interface, and also we update the API usage for the internal neutrino rescan struct to use the new InputWithScript struct. --- routing/chainview/neutrino.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/routing/chainview/neutrino.go b/routing/chainview/neutrino.go index 53e71ba39..56d16708b 100644 --- a/routing/chainview/neutrino.go +++ b/routing/chainview/neutrino.go @@ -12,6 +12,7 @@ import ( "github.com/btcsuite/btcutil/gcs/builder" "github.com/btcsuite/btcwallet/waddrmgr" "github.com/lightninglabs/neutrino" + "github.com/lightningnetwork/lnd/channeldb" ) // CfFilteredChainView is an implementation of the FilteredChainView interface @@ -96,7 +97,7 @@ func (c *CfFilteredChainView) Start() error { // required that an user MUST set a addr/outpoint/txid when creating a // rescan. To get around this, we'll add a "zero" outpoint, that won't // actually be matched. - var zeroPoint wire.OutPoint + var zeroPoint neutrino.InputWithScript rescanOptions := []neutrino.RescanOption{ neutrino.StartBlock(startingPoint), neutrino.QuitChan(c.quit), @@ -106,7 +107,7 @@ func (c *CfFilteredChainView) Start() error { OnFilteredBlockDisconnected: c.onFilteredBlockDisconnected, }, ), - neutrino.WatchOutPoints(zeroPoint), + neutrino.WatchInputs(zeroPoint), } // Finally, we'll create our rescan struct, start it, and launch all @@ -314,7 +315,7 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB // rewound to ensure all relevant notifications are dispatched. // // NOTE: This is part of the FilteredChainView interface. -func (c *CfFilteredChainView) UpdateFilter(ops []wire.OutPoint, +func (c *CfFilteredChainView) UpdateFilter(ops []channeldb.EdgePoint, updateHeight uint32) error { log.Debugf("Updating chain filter with new UTXO's: %v", ops) @@ -323,14 +324,22 @@ func (c *CfFilteredChainView) UpdateFilter(ops []wire.OutPoint, // UTXO's, ignoring duplicates in the process. c.filterMtx.Lock() for _, op := range ops { - c.chainFilter[op] = builder.OutPointToFilterEntry(op) + c.chainFilter[op.OutPoint] = op.FundingPkScript } c.filterMtx.Unlock() + inputs := make([]neutrino.InputWithScript, len(ops)) + for i, op := range ops { + inputs[i] = neutrino.InputWithScript{ + PkScript: op.FundingPkScript, + OutPoint: op.OutPoint, + } + } + // With our internal chain view update, we'll craft a new update to the // chainView which includes our new UTXO's, and current update height. rescanUpdate := []neutrino.UpdateOption{ - neutrino.AddOutPoints(ops...), + neutrino.AddInputs(inputs...), neutrino.Rewind(updateHeight), neutrino.DisableDisconnectedNtfns(true), }