lnd: make closechannel send an instant empty update when no_wait set
We do things this way to keep behavior consistent across REST, gRPC and CLI consistent. This was done to not alter the way we handle Recv calls from the streams.
This commit is contained in:
1 parent
ec55831229
commit
804dabb4ea
5 files changed
+3270
-3147
No files matched your search
+17
-4
@@ -2643,10 +2643,10 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
rpcsLog.Debugf("Target sat/kw for closing transaction: %v",
|
||||
int64(feeRate))
|
||||
|
||||
// Before we attempt the cooperative channel closure, we'll
|
||||
// examine the channel to ensure that it doesn't have a
|
||||
// lingering HTLC.
|
||||
if len(channel.ActiveHtlcs()) != 0 {
|
||||
// If the user hasn't specified NoWait, then before we attempt
|
||||
// to close the channel we ensure there are no active HTLCs on
|
||||
// the link.
|
||||
if !in.NoWait && len(channel.ActiveHtlcs()) != 0 {
|
||||
return fmt.Errorf("cannot co-op close channel " +
|
||||
"with active htlcs")
|
||||
}
|
||||
@@ -2690,6 +2690,19 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
maxFee, deliveryScript,
|
||||
)
|
||||
}
|
||||
|
||||
// If the user doesn't want to wait for the txid to come back then we
|
||||
// will send an empty update to kick off the stream.
|
||||
if in.NoWait {
|
||||
rpcsLog.Trace("[closechannel] sending instant update")
|
||||
if err := updateStream.Send(
|
||||
&lnrpc.CloseStatusUpdate{
|
||||
Update: &lnrpc.CloseStatusUpdate_CloseInstant{},
|
||||
},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
out:
|
||||
for {
|
||||
select {
|
||||
|
||||
Reference in new issue
Block a user