Skip to content

Commit a2b19af

Browse files
committed
channeldb+lnwallet: define Initiator for OpenChannel and LightningChannel
This commit introduces a new API to return information on which party opened the channel using the new ChannelParty type. It does not change the underlying structure of how we store this information.
1 parent e3dd886 commit a2b19af

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

channeldb/channel.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,18 @@ func (c *OpenChannel) String() string {
889889
)
890890
}
891891

892+
// Initiator returns the ChannelParty that originally opened this channel.
893+
func (c *OpenChannel) Initiator() lntypes.ChannelParty {
894+
c.RLock()
895+
defer c.RUnlock()
896+
897+
if c.IsInitiator {
898+
return lntypes.Local
899+
}
900+
901+
return lntypes.Remote
902+
}
903+
892904
// ShortChanID returns the current ShortChannelID of this channel.
893905
func (c *OpenChannel) ShortChanID() lnwire.ShortChannelID {
894906
c.RLock()

lnwallet/channel.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8709,6 +8709,14 @@ func (lc *LightningChannel) ChanType() channeldb.ChannelType {
87098709
return lc.channelState.ChanType
87108710
}
87118711

8712+
// Initiator returns the ChannelParty that originally opened this channel.
8713+
func (lc *LightningChannel) Initiator() lntypes.ChannelParty {
8714+
lc.RLock()
8715+
defer lc.RUnlock()
8716+
8717+
return lc.channelState.Initiator()
8718+
}
8719+
87128720
// FundingTxOut returns the funding output of the channel.
87138721
func (lc *LightningChannel) FundingTxOut() *wire.TxOut {
87148722
lc.RLock()

0 commit comments

Comments
 (0)