From 07defe5f93b5a860d8b53830ad7c4c8ea2d6b95d Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 30 May 2018 22:18:44 -0700 Subject: [PATCH] rpc+peer: use pkScripts for close ntfns --- mock.go | 4 ++-- peer.go | 9 +++++---- rpcserver.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mock.go b/mock.go index e7b418286..28794bc4c 100644 --- a/mock.go +++ b/mock.go @@ -85,8 +85,8 @@ type mockNotfier struct { confChannel chan *chainntnfs.TxConfirmation } -func (m *mockNotfier) RegisterConfirmationsNtfn(txid *chainhash.Hash, numConfs, - heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { +func (m *mockNotfier) RegisterConfirmationsNtfn(txid *chainhash.Hash, + _ []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { return &chainntnfs.ConfirmationEvent{ Confirmed: m.confChannel, }, nil diff --git a/peer.go b/peer.go index 987f147a0..c4cad2280 100644 --- a/peer.go +++ b/peer.go @@ -1837,7 +1837,7 @@ func (p *peer) finalizeChanClosure(chanCloser *channelCloser) { } go waitForChanToClose(chanCloser.negotiationHeight, notifier, errChan, - chanPoint, &closingTxid, func() { + chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() { // Respond to the local subsystem which requested the // channel closure. if closeReq != nil { @@ -1872,15 +1872,16 @@ func (p *peer) finalizeChanClosure(chanCloser *channelCloser) { // the function, then it will be sent over the errChan. func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier, errChan chan error, chanPoint *wire.OutPoint, - closingTxID *chainhash.Hash, cb func()) { + closingTxID *chainhash.Hash, closeScript []byte, cb func()) { peerLog.Infof("Waiting for confirmation of cooperative close of "+ "ChannelPoint(%v) with txid: %v", chanPoint, closingTxID) // TODO(roasbeef): add param for num needed confs - confNtfn, err := notifier.RegisterConfirmationsNtfn(closingTxID, 1, - bestHeight) + confNtfn, err := notifier.RegisterConfirmationsNtfn( + closingTxID, closeScript, 1, bestHeight, + ) if err != nil { if errChan != nil { errChan <- err diff --git a/rpcserver.go b/rpcserver.go index 9261debe8..42e27b412 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1083,7 +1083,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest, errChan = make(chan error, 1) notifier := r.server.cc.chainNotifier go waitForChanToClose(uint32(bestHeight), notifier, errChan, chanPoint, - &closingTxid, func() { + &closingTxid, closingTx.TxOut[0].PkScript, func() { // Respond to the local subsystem which // requested the channel closure. updateChan <- &lnrpc.CloseStatusUpdate{