diff --git a/Gopkg.lock b/Gopkg.lock index 654a6da8a..f770fdc9b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -106,7 +106,7 @@ revision = "ab6388e0c60ae4834a1f57511e20c17b5f78be4b" [[projects]] - digest = "1:e6575f3ee773e72a38319dbd8f4cb7f1b574eccfed7cb103c3a25c254d5c250f" + digest = "1:ac01796bf202b80d6cb1b92d42df0fbbf3aff964451376bfa7c39bc2bf94d108" name = "github.com/btcsuite/btcwallet" packages = [ "chain", @@ -126,7 +126,7 @@ "wtxmgr", ] pruneopts = "UT" - revision = "421298df22601db0fe4adb8f4be71b7014324ba9" + revision = "c4dd27e481f9801866cf5226bfe532084772ec2a" [[projects]] branch = "master" @@ -268,7 +268,7 @@ revision = "462a8a75388506b68f76661af8d649f0b88e5301" [[projects]] - digest = "1:48a9bc825edca0f6b562512f77d935b26a4fa3a645dc5468ed96bdd6897f4d82" + digest = "1:231ca602530410e89201db1f6377f8699ebdb6b690bf57fd83f292722d6f2be6" name = "github.com/lightninglabs/neutrino" packages = [ ".", @@ -279,7 +279,7 @@ "headerlist", ] pruneopts = "UT" - revision = "838f7ba74d217d188efc223604bd280b4e3f0238" + revision = "4d60692991302a44509d1a9234ccd51373c120b4" [[projects]] digest = "1:58ab6d6525898cbeb86dc29a68f8e9bfe95254b9032134eb9458779574872260" diff --git a/Gopkg.toml b/Gopkg.toml index e49131b09..957f2df85 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -44,7 +44,7 @@ [[constraint]] name = "github.com/lightninglabs/neutrino" - revision = "838f7ba74d217d188efc223604bd280b4e3f0238" + revision = "4d60692991302a44509d1a9234ccd51373c120b4" [[constraint]] name = "github.com/lightningnetwork/lightning-onion" @@ -72,7 +72,7 @@ [[constraint]] name = "github.com/btcsuite/btcwallet" - revision = "421298df22601db0fe4adb8f4be71b7014324ba9" + revision = "c4dd27e481f9801866cf5226bfe532084772ec2a" [[constraint]] name = "github.com/tv42/zbase32" diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index 459904509..b1be7cb23 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -137,15 +137,12 @@ func (n *NeutrinoNotifier) Start() error { // start the auto-rescan from this point. Once a caller actually wishes // to register a chain view, the rescan state will be rewound // accordingly. - bestHeader, bestHeight, err := n.p2pNode.BlockHeaders.ChainTip() + startingPoint, err := n.p2pNode.BestBlock() if err != nil { return err } - startingPoint := &waddrmgr.BlockStamp{ - Height: int32(bestHeight), - Hash: bestHeader.BlockHash(), - } - n.bestHeight = bestHeight + + n.bestHeight = uint32(startingPoint.Height) // Next, we'll create our set of rescan options. Currently it's // required that a user MUST set an addr/outpoint/txid when creating a @@ -165,7 +162,7 @@ func (n *NeutrinoNotifier) Start() error { } n.txConfNotifier = chainntnfs.NewTxConfNotifier( - bestHeight, reorgSafetyLimit, n.confirmHintCache, + n.bestHeight, reorgSafetyLimit, n.confirmHintCache, ) n.chainConn = &NeutrinoChainConn{n.p2pNode} @@ -476,20 +473,17 @@ out: "blocks, attempting to catch up") } - header, err := n.p2pNode.BlockHeaders.FetchHeaderByHeight( - n.bestHeight, - ) + hash, err := n.p2pNode.GetBlockHash(int64(n.bestHeight)) if err != nil { - chainntnfs.Log.Errorf("Unable to fetch header"+ + chainntnfs.Log.Errorf("Unable to fetch block hash"+ "for height %d: %v", n.bestHeight, err) n.heightMtx.Unlock() continue } - hash := header.BlockHash() notifierBestBlock := chainntnfs.BlockEpoch{ Height: int32(n.bestHeight), - Hash: &hash, + Hash: hash, } newBestBlock, err := chainntnfs.RewindChain( n.chainConn, n.txConfNotifier, notifierBestBlock, @@ -536,17 +530,16 @@ func (n *NeutrinoNotifier) historicalConfDetails(targetHash *chainhash.Hash, // First, we'll fetch the block header for this height so we // can compute the current block hash. - header, err := n.p2pNode.BlockHeaders.FetchHeaderByHeight(scanHeight) + blockHash, err := n.p2pNode.GetBlockHash(int64(scanHeight)) if err != nil { return nil, fmt.Errorf("unable to get header for height=%v: %v", scanHeight, err) } - blockHash := header.BlockHash() // With the hash computed, we can now fetch the basic filter // for this height. regFilter, err := n.p2pNode.GetCFilter( - blockHash, wire.GCSFilterRegular, + *blockHash, wire.GCSFilterRegular, ) if err != nil { return nil, fmt.Errorf("unable to retrieve regular filter for "+ @@ -562,7 +555,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(targetHash *chainhash.Hash, // In the case that the filter exists, we'll attempt to see if // any element in it matches our target public key script. - key := builder.DeriveKey(&blockHash) + key := builder.DeriveKey(blockHash) match, err := regFilter.Match(key, pkScript) if err != nil { return nil, fmt.Errorf("unable to query filter: %v", err) @@ -577,7 +570,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(targetHash *chainhash.Hash, // In the case that we do have a match, we'll fetch the block // from the network so we can find the positional data required // to send the proper response. - block, err := n.p2pNode.GetBlock(blockHash) + block, err := n.p2pNode.GetBlock(*blockHash) if err != nil { return nil, fmt.Errorf("unable to get block from network: %v", err) } @@ -585,7 +578,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(targetHash *chainhash.Hash, txHash := tx.Hash() if txHash.IsEqual(targetHash) { confDetails := chainntnfs.TxConfirmation{ - BlockHash: &blockHash, + BlockHash: blockHash, BlockHeight: scanHeight, TxIndex: uint32(j), } @@ -1085,11 +1078,7 @@ type NeutrinoChainConn struct { // GetBlockHeader returns the block header for a hash. func (n *NeutrinoChainConn) GetBlockHeader(blockHash *chainhash.Hash) (*wire.BlockHeader, error) { - header, _, err := n.p2pNode.BlockHeaders.FetchHeader(blockHash) - if err != nil { - return nil, err - } - return header, nil + return n.p2pNode.GetBlockHeader(blockHash) } // GetBlockHeaderVerbose returns a verbose block header result for a hash. This @@ -1097,7 +1086,7 @@ func (n *NeutrinoChainConn) GetBlockHeader(blockHash *chainhash.Hash) (*wire.Blo func (n *NeutrinoChainConn) GetBlockHeaderVerbose(blockHash *chainhash.Hash) ( *btcjson.GetBlockHeaderVerboseResult, error) { - _, height, err := n.p2pNode.BlockHeaders.FetchHeader(blockHash) + height, err := n.p2pNode.GetBlockHeight(blockHash) if err != nil { return nil, err } @@ -1107,10 +1096,5 @@ func (n *NeutrinoChainConn) GetBlockHeaderVerbose(blockHash *chainhash.Hash) ( // GetBlockHash returns the hash from a block height. func (n *NeutrinoChainConn) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) { - header, err := n.p2pNode.BlockHeaders.FetchHeaderByHeight(uint32(blockHeight)) - if err != nil { - return nil, err - } - hash := header.BlockHash() - return &hash, nil + return n.p2pNode.GetBlockHash(blockHeight) } diff --git a/chainntnfs/neutrinonotify/neutrino_dev.go b/chainntnfs/neutrinonotify/neutrino_dev.go index 635f0d954..b069ff5d6 100644 --- a/chainntnfs/neutrinonotify/neutrino_dev.go +++ b/chainntnfs/neutrinonotify/neutrino_dev.go @@ -8,7 +8,6 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcwallet/waddrmgr" "github.com/lightninglabs/neutrino" "github.com/lightningnetwork/lnd/chainntnfs" ) @@ -26,14 +25,10 @@ func (n *NeutrinoNotifier) UnsafeStart(bestHeight int32, bestHash *chainhash.Has // start the auto-rescan from this point. Once a caller actually wishes // to register a chain view, the rescan state will be rewound // accordingly. - header, height, err := n.p2pNode.BlockHeaders.ChainTip() + startingPoint, err := n.p2pNode.BestBlock() if err != nil { return err } - startingPoint := &waddrmgr.BlockStamp{ - Height: int32(height), - Hash: header.BlockHash(), - } // Next, we'll create our set of rescan options. Currently it's // required that a user MUST set an addr/outpoint/txid when creating a diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 40d7f4e99..b52ba4888 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -750,17 +750,5 @@ func (b *BtcWallet) IsSynced() (bool, int64, error) { return false, bestTimestamp, nil } - // If this is neutrino, then we'll also want to wait until the set of - // filter headers also match - if neutrinoNode, ok := b.chain.(*chain.NeutrinoClient); ok { - filterDB := neutrinoNode.CS.RegFilterHeaders - _, filterHeaderTip, err := filterDB.ChainTip() - if err != nil { - return false, 0, err - } - - return filterHeaderTip == uint32(bestHeight), bestTimestamp, nil - } - return true, bestTimestamp, nil } diff --git a/routing/chainview/neutrino.go b/routing/chainview/neutrino.go index 61d4601c1..c681d0f8d 100644 --- a/routing/chainview/neutrino.go +++ b/routing/chainview/neutrino.go @@ -10,7 +10,6 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil/gcs/builder" - "github.com/btcsuite/btcwallet/waddrmgr" "github.com/lightninglabs/neutrino" "github.com/lightningnetwork/lnd/channeldb" ) @@ -84,14 +83,10 @@ func (c *CfFilteredChainView) Start() error { // start the auto-rescan from this point. Once a caller actually wishes // to register a chain view, the rescan state will be rewound // accordingly. - bestHeader, bestHeight, err := c.p2pNode.BlockHeaders.ChainTip() + startingPoint, err := c.p2pNode.BestBlock() if err != nil { return err } - startingPoint := &waddrmgr.BlockStamp{ - Height: int32(bestHeight), - Hash: bestHeader.BlockHash(), - } // Next, we'll create our set of rescan options. Currently it's // required that an user MUST set a addr/outpoint/txid when creating a @@ -215,14 +210,14 @@ func (c *CfFilteredChainView) chainFilterer() { func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredBlock, error) { // First, we'll fetch the block header itself so we can obtain the // height which is part of our return value. - _, blockHeight, err := c.p2pNode.BlockHeaders.FetchHeader(blockHash) + blockHeight, err := c.p2pNode.GetBlockHeight(blockHash) if err != nil { return nil, err } filteredBlock := &FilteredBlock{ Hash: *blockHash, - Height: blockHeight, + Height: uint32(blockHeight), } // If we don't have any items within our current chain filter, then we