From 5f6c15cfa4c379fde59d8f11c6d5fd12c7bbdb09 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 16 Jan 2018 18:09:32 -0800 Subject: [PATCH] lnwallet: RevokeCurrentCommitment now returns the set of active HTLC's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we modify the RevokeCurrentCommitment method to now return the set of active HTLC’s. This will be used by callers in the future to update other sub-systems when the set of HTLC’s on the commitment changes, and can also be used on the RPC level to synchronize systems level integration tests. --- lnwallet/channel.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index cf304f87..13fe9d7f 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -3793,14 +3793,17 @@ func (lc *LightningChannel) FullySynced() bool { // transaction in the local commitment chain. As a result the edge of our // revocation window is extended by one, and the tail of our local commitment // chain is advanced by a single commitment. This now lowest unrevoked -// commitment becomes our currently accepted state within the channel. -func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck, error) { +// commitment becomes our currently accepted state within the channel. This +// method also returns the set of HTLC's currently active within the commitment +// transaction. This return value allows callers to act once an HTLC has been +// locked into our commitment transaction. +func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck, []channeldb.HTLC, error) { lc.Lock() defer lc.Unlock() revocationMsg, err := lc.generateRevocation(lc.currentHeight) if err != nil { - return nil, err + return nil, nil, err } walletLog.Tracef("ChannelPoint(%v): revoking height=%v, now at height=%v", @@ -3817,7 +3820,7 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck, err newCommitment := chainTail.toDiskCommit(true) err = lc.channelState.UpdateCommitment(newCommitment) if err != nil { - return nil, err + return nil, nil, err } walletLog.Tracef("ChannelPoint(%v): state transition accepted: "+ @@ -3829,7 +3832,7 @@ func (lc *LightningChannel) RevokeCurrentCommitment() (*lnwire.RevokeAndAck, err &lc.channelState.FundingOutpoint, ) - return revocationMsg, nil + return revocationMsg, newCommitment.Htlcs, nil } // ReceiveRevocation processes a revocation sent by the remote party for the