From 5a1a3c727795480b968e8ea2fa51d9ae61f47c48 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 23 Nov 2017 22:02:55 -0600 Subject: [PATCH] lnwallet: add IsInitiator and CommitFeeRate methods to LightningChannel --- lnwallet/channel.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 2a478f3d..f54889f9 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -5023,8 +5023,27 @@ func (lc *LightningChannel) CalcFee(feeRate uint64) uint64 { // RemoteNextRevocation returns the channelState's RemoteNextRevocation. func (lc *LightningChannel) RemoteNextRevocation() *btcec.PublicKey { - lc.Lock() - defer lc.Unlock() + lc.RLock() + defer lc.RUnlock() return lc.channelState.RemoteNextRevocation } + +// IsInitiator returns true if we were the ones that initiated the funding +// workflow which led to the creation of this channel. Otherwise, it returns +// false. +func (lc *LightningChannel) IsInitiator() bool { + lc.RLock() + defer lc.RUnlock() + + return lc.channelState.IsInitiator +} + +// CommitFeeRate returns the current fee rate of the commitment transaction in +// units of sat-per-kw. +func (lc *LightningChannel) CommitFeeRate() btcutil.Amount { + lc.RLock() + defer lc.RUnlock() + + return lc.channelState.LocalCommitment.FeePerKw +}