Merge pull request #8044 from ellemouton/g175Messages

[1/7] lnwire: add new Gossip 1.75 messages
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2024-09-18 16:05:38 -07:00
commit 13a7becb91
61 files changed
+2617 -556

No files matched your search

+1 -1
View File
@@ -86,7 +86,7 @@ type scidAliasHandler interface {
// HTLCs on option_scid_alias channels.
attachFailAliasUpdate(failClosure func(
sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate)
incoming bool) *lnwire.ChannelUpdate1)
// getAliases fetches the link's underlying aliases. This is used by
// the Switch to determine whether to forward an HTLC and where to
+12 -11
View File
@@ -120,7 +120,8 @@ type ChannelLinkConfig struct {
// specified when we receive an incoming HTLC. This will be used to
// provide payment senders our latest policy when sending encrypted
// error messages.
FetchLastChannelUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error)
FetchLastChannelUpdate func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate1, error)
// Peer is a lightning network node with which we have the channel link
// opened.
@@ -262,7 +263,7 @@ type ChannelLinkConfig struct {
// FailAliasUpdate is a function used to fail an HTLC for an
// option_scid_alias channel.
FailAliasUpdate func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate
incoming bool) *lnwire.ChannelUpdate1
// GetAliases is used by the link and switch to fetch the set of
// aliases for a given link.
@@ -765,7 +766,7 @@ func shouldAdjustCommitFee(netFee, chanFee,
}
// failCb is used to cut down on the argument verbosity.
type failCb func(update *lnwire.ChannelUpdate) lnwire.FailureMessage
type failCb func(update *lnwire.ChannelUpdate1) lnwire.FailureMessage
// createFailureWithUpdate creates a ChannelUpdate when failing an incoming or
// outgoing HTLC. It may return a FailureMessage that references a channel's
@@ -2949,7 +2950,7 @@ func (l *channelLink) getAliases() []lnwire.ShortChannelID {
//
// Part of the scidAliasHandler interface.
func (l *channelLink) attachFailAliasUpdate(closure func(
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate) {
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
l.Lock()
l.cfg.FailAliasUpdate = closure
@@ -3041,7 +3042,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
// As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up to date data.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewFeeInsufficient(amtToForward, *upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@@ -3069,7 +3070,7 @@ func (l *channelLink) CheckHtlcForward(payHash [32]byte,
// Grab the latest routing policy so the sending node is up to
// date with our current policy.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewIncorrectCltvExpiry(
incomingTimeout, *upd,
)
@@ -3118,7 +3119,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
// As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up to date data.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewAmountBelowMinimum(amt, *upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@@ -3133,7 +3134,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
// As part of the returned error, we'll send our latest routing
// policy so the sending node obtains the most up-to-date data.
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@@ -3148,7 +3149,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
"outgoing_expiry=%v, best_height=%v", payHash[:],
timeout, heightNow)
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewExpiryTooSoon(*upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@@ -3168,7 +3169,7 @@ func (l *channelLink) canSendHtlc(policy models.ForwardingPolicy,
if amt > l.Bandwidth() {
l.log.Warnf("insufficient bandwidth to route htlc: %v is "+
"larger than %v", amt, l.Bandwidth())
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage {
return lnwire.NewTemporaryChannelFailure(upd)
}
failure := l.createFailureWithUpdate(false, originalScid, cb)
@@ -3680,7 +3681,7 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg) {
l.log.Errorf("unable to encode the "+
"remaining route %v", err)
cb := func(upd *lnwire.ChannelUpdate) lnwire.FailureMessage {
cb := func(upd *lnwire.ChannelUpdate1) lnwire.FailureMessage { //nolint:lll
return lnwire.NewTemporaryChannelFailure(upd)
}
+3 -3
View File
@@ -6166,13 +6166,13 @@ func TestForwardingAsymmetricTimeLockPolicies(t *testing.T) {
// forwarding policy.
func TestCheckHtlcForward(t *testing.T) {
fetchLastChannelUpdate := func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) {
*lnwire.ChannelUpdate1, error) {
return &lnwire.ChannelUpdate{}, nil
return &lnwire.ChannelUpdate1{}, nil
}
failAliasUpdate := func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate {
incoming bool) *lnwire.ChannelUpdate1 {
return nil
}
+5 -5
View File
@@ -167,7 +167,7 @@ type mockServer struct {
var _ lnpeer.Peer = (*mockServer)(nil)
func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error) {
signAliasUpdate := func(u *lnwire.ChannelUpdate) (*ecdsa.Signature,
signAliasUpdate := func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) {
return testSig, nil
@@ -183,9 +183,9 @@ func initSwitchWithDB(startingHeight uint32, db *channeldb.DB) (*Switch, error)
events: make(map[time.Time]channeldb.ForwardingEvent),
},
FetchLastChannelUpdate: func(scid lnwire.ShortChannelID) (
*lnwire.ChannelUpdate, error) {
*lnwire.ChannelUpdate1, error) {
return &lnwire.ChannelUpdate{
return &lnwire.ChannelUpdate1{
ShortChannelID: scid,
}, nil
},
@@ -735,7 +735,7 @@ type mockChannelLink struct {
checkHtlcForwardResult *LinkError
failAliasUpdate func(sid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate
incoming bool) *lnwire.ChannelUpdate1
confirmedZC bool
}
@@ -870,7 +870,7 @@ func (f *mockChannelLink) AttachMailBox(mailBox MailBox) {
}
func (f *mockChannelLink) attachFailAliasUpdate(closure func(
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate) {
sid lnwire.ShortChannelID, incoming bool) *lnwire.ChannelUpdate1) {
f.failAliasUpdate = closure
}
+4 -3
View File
@@ -173,7 +173,8 @@ type Config struct {
// specified when we receive an incoming HTLC. This will be used to
// provide payment senders our latest policy when sending encrypted
// error messages.
FetchLastChannelUpdate func(lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error)
FetchLastChannelUpdate func(lnwire.ShortChannelID) (
*lnwire.ChannelUpdate1, error)
// Notifier is an instance of a chain notifier that we'll use to signal
// the switch when a new block has arrived.
@@ -220,7 +221,7 @@ type Config struct {
// option_scid_alias channels. This avoids a potential privacy leak by
// replacing the public, confirmed SCID with the alias in the
// ChannelUpdate.
SignAliasUpdate func(u *lnwire.ChannelUpdate) (*ecdsa.Signature,
SignAliasUpdate func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error)
// IsAlias returns whether or not a given SCID is an alias.
@@ -2640,7 +2641,7 @@ func (s *Switch) failMailboxUpdate(outgoingScid,
// and the caller is expected to handle this properly. In this case, a return
// to the original non-alias behavior is expected.
func (s *Switch) failAliasUpdate(scid lnwire.ShortChannelID,
incoming bool) *lnwire.ChannelUpdate {
incoming bool) *lnwire.ChannelUpdate1 {
// This function does not defer the unlocking because of the database
// lookups for ChannelUpdate.
+1 -1
View File
@@ -3951,7 +3951,7 @@ func TestSwitchHoldForward(t *testing.T) {
// Simulate an error during the composition of the failure message.
currentCallback := c.s.cfg.FetchLastChannelUpdate
c.s.cfg.FetchLastChannelUpdate = func(
lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
lnwire.ShortChannelID) (*lnwire.ChannelUpdate1, error) {
return nil, errors.New("cannot fetch update")
}
+4 -2
View File
@@ -91,8 +91,10 @@ func genIDs() (lnwire.ChannelID, lnwire.ChannelID, lnwire.ShortChannelID,
// mockGetChanUpdateMessage helper function which returns topology update of
// the channel
func mockGetChanUpdateMessage(cid lnwire.ShortChannelID) (*lnwire.ChannelUpdate, error) {
return &lnwire.ChannelUpdate{
func mockGetChanUpdateMessage(_ lnwire.ShortChannelID) (*lnwire.ChannelUpdate1,
error) {
return &lnwire.ChannelUpdate1{
Signature: wireSig,
}, nil
}