rpc+peer: use pkScripts for close ntfns

This commit is contained in:
Olaoluwa Osuntokun
2018-05-30 22:18:44 -07:00
parent 55d6586a67
commit 07defe5f93
3 changed files with 8 additions and 7 deletions

View File

@@ -85,8 +85,8 @@ type mockNotfier struct {
confChannel chan *chainntnfs.TxConfirmation confChannel chan *chainntnfs.TxConfirmation
} }
func (m *mockNotfier) RegisterConfirmationsNtfn(txid *chainhash.Hash, numConfs, func (m *mockNotfier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
heightHint uint32) (*chainntnfs.ConfirmationEvent, error) { _ []byte, numConfs, heightHint uint32) (*chainntnfs.ConfirmationEvent, error) {
return &chainntnfs.ConfirmationEvent{ return &chainntnfs.ConfirmationEvent{
Confirmed: m.confChannel, Confirmed: m.confChannel,
}, nil }, nil

View File

@@ -1837,7 +1837,7 @@ func (p *peer) finalizeChanClosure(chanCloser *channelCloser) {
} }
go waitForChanToClose(chanCloser.negotiationHeight, notifier, errChan, go waitForChanToClose(chanCloser.negotiationHeight, notifier, errChan,
chanPoint, &closingTxid, func() { chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which requested the // Respond to the local subsystem which requested the
// channel closure. // channel closure.
if closeReq != nil { if closeReq != nil {
@@ -1872,15 +1872,16 @@ func (p *peer) finalizeChanClosure(chanCloser *channelCloser) {
// the function, then it will be sent over the errChan. // the function, then it will be sent over the errChan.
func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier, func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
errChan chan error, chanPoint *wire.OutPoint, 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 "+ peerLog.Infof("Waiting for confirmation of cooperative close of "+
"ChannelPoint(%v) with txid: %v", chanPoint, "ChannelPoint(%v) with txid: %v", chanPoint,
closingTxID) closingTxID)
// TODO(roasbeef): add param for num needed confs // TODO(roasbeef): add param for num needed confs
confNtfn, err := notifier.RegisterConfirmationsNtfn(closingTxID, 1, confNtfn, err := notifier.RegisterConfirmationsNtfn(
bestHeight) closingTxID, closeScript, 1, bestHeight,
)
if err != nil { if err != nil {
if errChan != nil { if errChan != nil {
errChan <- err errChan <- err

View File

@@ -1083,7 +1083,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
errChan = make(chan error, 1) errChan = make(chan error, 1)
notifier := r.server.cc.chainNotifier notifier := r.server.cc.chainNotifier
go waitForChanToClose(uint32(bestHeight), notifier, errChan, chanPoint, go waitForChanToClose(uint32(bestHeight), notifier, errChan, chanPoint,
&closingTxid, func() { &closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which // Respond to the local subsystem which
// requested the channel closure. // requested the channel closure.
updateChan <- &lnrpc.CloseStatusUpdate{ updateChan <- &lnrpc.CloseStatusUpdate{