Skip to content

Commit

Permalink
multi: replace FundingLocked and funding_locked strings
Browse files Browse the repository at this point in the history
This commit is created by running the following commands,
```shell
find . -name "*.go" -exec sed -i '' 's/\"FundingLocked/\"ChannelReady/g' {} \;
find . -name "*.go" -exec sed -i '' 's/FundingLocked\"/ChannelReady\"/g' {} \;
find . -name "*.go" -exec sed -i '' 's/\ funding_locked/\ channel_ready/g' {} \;
```
  • Loading branch information
yyforyongyu committed Mar 17, 2023
1 parent 0154465 commit f8a8326
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions aliasmgr/aliasmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
lastAliasKey = []byte("last-alias-key")

// invoiceAliasBucket is a root-level bucket that stores the alias
// SCIDs that our peers send us in the funding_locked TLV. The keys are
// SCIDs that our peers send us in the channel_ready TLV. The keys are
// the ChannelID generated from the FundingOutpoint and the values are
// the remote peer's alias SCID.
invoiceAliasBucket = []byte("invoice-alias-bucket")
Expand Down Expand Up @@ -88,7 +88,7 @@ type Manager struct {
aliasToBase map[lnwire.ShortChannelID]lnwire.ShortChannelID

// peerAlias is a cache for the alias SCIDs that our peers send us in
// the funding_locked TLV. The keys are the ChannelID generated from
// the channel_ready TLV. The keys are the ChannelID generated from
// the FundingOutpoint and the values are the remote peer's alias SCID.
// The values should match the ones stored in the "invoice-alias-bucket"
// bucket.
Expand Down Expand Up @@ -341,7 +341,7 @@ func (m *Manager) DeleteSixConfs(baseScid lnwire.ShortChannelID) error {
}

// PutPeerAlias stores the peer's alias SCID once we learn of it in the
// funding_locked message.
// channel_ready message.
func (m *Manager) PutPeerAlias(chanID lnwire.ChannelID,
alias lnwire.ShortChannelID) error {

Expand Down
2 changes: 1 addition & 1 deletion channeldb/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ func (c *OpenChannel) MarkBorked() error {
}

// SecondCommitmentPoint returns the second per-commitment-point for use in the
// funding_locked message.
// channel_ready message.
func (c *OpenChannel) SecondCommitmentPoint() (*btcec.PublicKey, error) {
c.RLock()
defer c.RUnlock()
Expand Down
6 changes: 3 additions & 3 deletions funding/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ type Controller interface {
// aliasHandler is an interface that abstracts the managing of aliases.
type aliasHandler interface {
// RequestAlias lets the funding manager request a unique SCID alias to
// use in the funding_locked message.
// use in the channel_ready message.
RequestAlias() (lnwire.ShortChannelID, error)

// PutPeerAlias lets the funding manager store the received alias SCID
// in the funding_locked message.
// in the channel_ready message.
PutPeerAlias(lnwire.ChannelID, lnwire.ShortChannelID) error

// GetPeerAlias lets the funding manager lookup the received alias SCID
// from the funding_locked message. This is not the same as GetAliases
// from the channel_ready message. This is not the same as GetAliases
// which retrieves OUR aliases for a given channel.
GetPeerAlias(lnwire.ChannelID) (lnwire.ShortChannelID, error)

Expand Down
18 changes: 9 additions & 9 deletions funding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
}

log.Debugf("Channel(%v) with ShortChanID %v: successfully "+
"sent FundingLocked", chanID, shortChanID)
"sent ChannelReady", chanID, shortChanID)

return nil

Expand Down Expand Up @@ -1054,7 +1054,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,

var peerAlias *lnwire.ShortChannelID
if channel.IsZeroConf() {
// We'll need to wait until funding_locked has been
// We'll need to wait until channel_ready has been
// received and the peer lets us know the alias they
// want to use for the channel. With this information,
// we can then construct a ChannelUpdate for them.
Expand Down Expand Up @@ -2963,7 +2963,7 @@ func (f *Manager) sendChannelReady(completeChan *channeldb.OpenChannel,
// alias feature was negotiated, check if we already
// have an alias stored in case handleFundingLocked was
// called before this. If an alias exists, use that in
// funding_locked. Otherwise, request and store an
// channel_ready. Otherwise, request and store an
// alias and use that.
aliases := f.cfg.AliasManager.GetAliases(
completeChan.ShortChannelID,
Expand All @@ -2989,7 +2989,7 @@ func (f *Manager) sendChannelReady(completeChan *channeldb.OpenChannel,
}
}

log.Infof("Peer(%x) is online, sending FundingLocked "+
log.Infof("Peer(%x) is online, sending ChannelReady "+
"for ChannelID(%v)", peerKey, chanID)

if err := peer.SendMessage(true, channelReadyMsg); err == nil {
Expand Down Expand Up @@ -3028,7 +3028,7 @@ func (f *Manager) receivedChannelReady(node *btcec.PublicKey,
channel, err := f.cfg.FindChannel(node, chanID)
if err != nil {
log.Errorf("Unable to locate ChannelID(%v) to determine if "+
"FundingLocked was received", chanID)
"ChannelReady was received", chanID)
return false, err
}

Expand Down Expand Up @@ -3397,7 +3397,7 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer,
msg *lnwire.ChannelReady) {

defer f.wg.Done()
log.Debugf("Received FundingLocked for ChannelID(%v) from "+
log.Debugf("Received ChannelReady for ChannelID(%v) from "+
"peer %x", msg.ChanID,
peer.IdentityKey().SerializeCompressed())

Expand Down Expand Up @@ -3487,14 +3487,14 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer,
// If we do not have an alias stored, we'll create one now.
// This is only used in the upgrade case where a user toggles
// the option-scid-alias feature-bit to on. We'll also send the
// funding_locked message here in case the link is created
// channel_ready message here in case the link is created
// before sendFundingLocked is called.
aliases := f.cfg.AliasManager.GetAliases(
channel.ShortChannelID,
)
if len(aliases) == 0 {
// No aliases were found so we'll request and store an
// alias and use it in the funding_locked message.
// alias and use it in the channel_ready message.
alias, err := f.cfg.AliasManager.RequestAlias()
if err != nil {
log.Errorf("unable to request alias: %v", err)
Expand Down Expand Up @@ -3535,7 +3535,7 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer,
// already processed fundingLocked for this channel, so ignore. This
// check is after the alias logic so we store the peer's most recent
// alias. The spec requires us to validate that subsequent
// funding_locked messages use the same per commitment point (the
// channel_ready messages use the same per commitment point (the
// second), but it is not actually necessary since we'll just end up
// ignoring it. We are, however, required to *send* the same per
// commitment point, since another pedantic implementation might
Expand Down
50 changes: 25 additions & 25 deletions funding/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ func assertFundingMsgSent(t *testing.T, msgChan chan lnwire.Message,
sentMsg, ok = msg.(*lnwire.FundingCreated)
case "FundingSigned":
sentMsg, ok = msg.(*lnwire.FundingSigned)
case "FundingLocked":
case "ChannelReady":
sentMsg, ok = msg.(*lnwire.ChannelReady)
case "Error":
sentMsg, ok = msg.(*lnwire.Error)
Expand Down Expand Up @@ -1407,12 +1407,12 @@ func TestFundingManagerNormalWorkflow(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Check that the state machine is updated accordingly
Expand Down Expand Up @@ -1678,7 +1678,7 @@ func TestFundingManagerRestartBehavior(t *testing.T) {

// Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Alice should still be markedOpen
Expand Down Expand Up @@ -1707,7 +1707,7 @@ func TestFundingManagerRestartBehavior(t *testing.T) {
}

channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// The state should now be fundingLockedSent
Expand Down Expand Up @@ -1835,7 +1835,7 @@ func TestFundingManagerOfflinePeer(t *testing.T) {

// Bob will send funding locked to Alice
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Alice should still be markedOpen
Expand Down Expand Up @@ -1883,7 +1883,7 @@ func TestFundingManagerOfflinePeer(t *testing.T) {

// This should make Alice send the fundingLocked.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// The state should now be fundingLockedSent
Expand Down Expand Up @@ -2312,12 +2312,12 @@ func TestFundingManagerReceiveChannelReadyTwice(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Check that the state machine is updated accordingly
Expand Down Expand Up @@ -2423,12 +2423,12 @@ func TestFundingManagerRestartAfterChanAnn(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Check that the state machine is updated accordingly
Expand Down Expand Up @@ -2520,12 +2520,12 @@ func TestFundingManagerRestartAfterReceivingChannelReady(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Check that the state machine is updated accordingly
Expand Down Expand Up @@ -2613,12 +2613,12 @@ func TestFundingManagerPrivateChannel(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Check that the state machine is updated accordingly
Expand Down Expand Up @@ -2736,12 +2736,12 @@ func TestFundingManagerPrivateRestart(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Check that the state machine is updated accordingly
Expand Down Expand Up @@ -3171,12 +3171,12 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) {
// After the funding transaction is mined, Alice will send
// fundingLocked to Bob.
channelReadyAlice := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// And similarly Bob will send funding locked to Alice.
channelReadyBob := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

// Exchange the fundingLocked messages.
Expand Down Expand Up @@ -3488,11 +3488,11 @@ func TestFundingManagerMaxPendingChannels(t *testing.T) {

// Expect both to be sending FundingLocked.
_ = assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

_ = assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)

}
Expand Down Expand Up @@ -4202,21 +4202,21 @@ func TestFundingManagerZeroConf(t *testing.T) {
Index: 0,
}

// Assert that Bob's funding_locked message has an AliasScid.
// Assert that Bob's channel_ready message has an AliasScid.
bobChannelReady := assertFundingMsgSent(
t, bob.msgChan, "FundingLocked",
t, bob.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)
require.NotNil(t, bobChannelReady.AliasScid)
require.Equal(t, *bobChannelReady.AliasScid, alias)

// Do the same for Alice as well.
aliceChannelReady := assertFundingMsgSent(
t, alice.msgChan, "FundingLocked",
t, alice.msgChan, "ChannelReady",
).(*lnwire.ChannelReady)
require.NotNil(t, aliceChannelReady.AliasScid)
require.Equal(t, *aliceChannelReady.AliasScid, alias)

// Exchange the funding_locked messages.
// Exchange the channel_ready messages.
alice.fundingMgr.ProcessFundingMsg(bobChannelReady, bob)
bob.fundingMgr.ProcessFundingMsg(aliceChannelReady, alice)

Expand Down
6 changes: 3 additions & 3 deletions htlcswitch/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ func (l *channelLink) syncChanStates() error {
localChanSyncMsg.NextLocalCommitHeight == 1 &&
!l.channel.IsPending() {

l.log.Infof("resending FundingLocked message to peer")
l.log.Infof("resending ChannelReady message to peer")

nextRevocation, err := l.channel.NextRevocationKey()
if err != nil {
Expand All @@ -740,7 +740,7 @@ func (l *channelLink) syncChanStates() error {

// For channels that negotiated the option-scid-alias
// feature bit, ensure that we send over the alias in
// the funding_locked message. We'll send the first
// the channel_ready message. We'll send the first
// alias we find for the channel since it does not
// matter which alias we send. We'll error out if no
// aliases are found.
Expand All @@ -762,7 +762,7 @@ func (l *channelLink) syncChanStates() error {
err = l.cfg.Peer.SendMessage(false, channelReadyMsg)
if err != nil {
return fmt.Errorf("unable to re-send "+
"FundingLocked: %v", err)
"ChannelReady: %v", err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions lnwire/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ const (

// ScidAliasRequired is a required feature bit that signals that the
// node requires understanding of ShortChannelID aliases in the TLV
// segment of the funding_locked message.
// segment of the channel_ready message.
ScidAliasRequired FeatureBit = 46

// ScidAliasOptional is an optional feature bit that signals that the
// node understands ShortChannelID aliases in the TLV segment of the
// funding_locked message.
// channel_ready message.
ScidAliasOptional FeatureBit = 47

// PaymentMetadataRequired is a required bit that denotes that if an
Expand Down
2 changes: 1 addition & 1 deletion lnwire/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (t MessageType) String() string {
case MsgFundingSigned:
return "MsgFundingSigned"
case MsgChannelReady:
return "FundingLocked"
return "ChannelReady"
case MsgShutdown:
return "Shutdown"
case MsgClosingSigned:
Expand Down
Loading

0 comments on commit f8a8326

Please sign in to comment.