-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lnwire+netann: update structure of g175 messages to be pure TLV #9175
base: master
Are you sure you want to change the base?
Changes from all commits
4d46b5c
f20f507
db76d0b
1ffd3b2
34afb59
fc40b72
9d67b34
53bdf65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ import ( | |
"github.com/btcsuite/btcd/btcec/v2" | ||
"github.com/btcsuite/btcd/btcec/v2/ecdsa" | ||
"github.com/btcsuite/btcd/btcutil" | ||
"github.com/btcsuite/btcd/chaincfg" | ||
"github.com/btcsuite/btcd/chaincfg/chainhash" | ||
"github.com/btcsuite/btcd/txscript" | ||
"github.com/btcsuite/btcd/wire" | ||
"github.com/davecgh/go-spew/spew" | ||
"github.com/lightninglabs/neutrino/cache" | ||
|
@@ -166,14 +168,9 @@ type PinnedSyncers map[route.Vertex]struct{} | |
// Config defines the configuration for the service. ALL elements within the | ||
// configuration MUST be non-nil for the service to carry out its duties. | ||
type Config struct { | ||
// ChainHash is a hash that indicates which resident chain of the | ||
// AuthenticatedGossiper. Any announcements that don't match this | ||
// chain hash will be ignored. | ||
// | ||
// TODO(roasbeef): eventually make into map so can de-multiplex | ||
// incoming announcements | ||
// * also need to do same for Notifier | ||
ChainHash chainhash.Hash | ||
// ChainParams holds the chain parameters for the active network this | ||
// node is participating on. | ||
ChainParams *chaincfg.Params | ||
|
||
// Graph is the subsystem which is responsible for managing the | ||
// topology of lightning network. After incoming channel, node, channel | ||
|
@@ -359,6 +356,12 @@ type Config struct { | |
// updates for a channel and returns true if the channel should be | ||
// considered a zombie based on these timestamps. | ||
IsStillZombieChannel func(time.Time, time.Time) bool | ||
|
||
// chainHash is a hash that indicates which resident chain of the | ||
// AuthenticatedGossiper. Any announcements that don't match this | ||
// chain hash will be ignored. This is an internal config value obtained | ||
// from ChainParams. | ||
chainHash *chainhash.Hash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need it here if we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just had it there as a helper so that we dont need to do |
||
} | ||
|
||
// processedNetworkMsg is a wrapper around networkMsg and a boolean. It is | ||
|
@@ -518,6 +521,8 @@ type AuthenticatedGossiper struct { | |
// New creates a new AuthenticatedGossiper instance, initialized with the | ||
// passed configuration parameters. | ||
func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper { | ||
cfg.chainHash = cfg.ChainParams.GenesisHash | ||
|
||
gossiper := &AuthenticatedGossiper{ | ||
selfKey: selfKeyDesc.PubKey, | ||
selfKeyLoc: selfKeyDesc.KeyLocator, | ||
|
@@ -538,7 +543,7 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper | |
} | ||
|
||
gossiper.syncMgr = newSyncManager(&SyncManagerCfg{ | ||
ChainHash: cfg.ChainHash, | ||
ChainHash: *cfg.chainHash, | ||
ChanSeries: cfg.ChanSeries, | ||
RotateTicker: cfg.RotateTicker, | ||
HistoricalSyncTicker: cfg.HistoricalSyncTicker, | ||
|
@@ -1945,9 +1950,28 @@ func (d *AuthenticatedGossiper) processRejectedEdge( | |
|
||
// fetchPKScript fetches the output script for the given SCID. | ||
func (d *AuthenticatedGossiper) fetchPKScript(chanID *lnwire.ShortChannelID) ( | ||
[]byte, error) { | ||
txscript.ScriptClass, btcutil.Address, error) { | ||
|
||
pkScript, err := lnwallet.FetchPKScriptWithQuit( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the merkle proof case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that wont be supported from the get go. That will be a separate feature bit |
||
d.cfg.ChainIO, chanID, d.quit, | ||
) | ||
if err != nil { | ||
return txscript.WitnessUnknownTy, nil, err | ||
} | ||
|
||
scriptClass, addrs, _, err := txscript.ExtractPkScriptAddrs( | ||
pkScript, d.cfg.ChainParams, | ||
) | ||
if err != nil { | ||
return txscript.WitnessUnknownTy, nil, err | ||
} | ||
|
||
if len(addrs) != 1 { | ||
return txscript.WitnessUnknownTy, nil, fmt.Errorf("expected "+ | ||
"1 address, got: %d", len(addrs)) | ||
} | ||
|
||
return lnwallet.FetchPKScriptWithQuit(d.cfg.ChainIO, chanID, d.quit) | ||
return scriptClass, addrs[0], nil | ||
} | ||
|
||
// addNode processes the given node announcement, and adds it to our channel | ||
|
@@ -2447,10 +2471,10 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg, | |
|
||
// We'll ignore any channel announcements that target any chain other | ||
// than the set of chains we know of. | ||
if !bytes.Equal(ann.ChainHash[:], d.cfg.ChainHash[:]) { | ||
if !bytes.Equal(ann.ChainHash[:], d.cfg.chainHash[:]) { | ||
err := fmt.Errorf("ignoring ChannelAnnouncement1 from chain=%v"+ | ||
", gossiper on chain=%v", ann.ChainHash, | ||
d.cfg.ChainHash) | ||
d.cfg.chainHash) | ||
log.Errorf(err.Error()) | ||
|
||
key := newRejectCacheKey( | ||
|
@@ -2836,9 +2860,9 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg, | |
|
||
// We'll ignore any channel updates that target any chain other than | ||
// the set of chains we know of. | ||
if !bytes.Equal(upd.ChainHash[:], d.cfg.ChainHash[:]) { | ||
if !bytes.Equal(upd.ChainHash[:], d.cfg.chainHash[:]) { | ||
err := fmt.Errorf("ignoring ChannelUpdate from chain=%v, "+ | ||
"gossiper on chain=%v", upd.ChainHash, d.cfg.ChainHash) | ||
"gossiper on chain=%v", upd.ChainHash, d.cfg.chainHash) | ||
log.Errorf(err.Error()) | ||
|
||
key := newRejectCacheKey( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be a normal value rather than a pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wont it copy over struct values then though?