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
@@ -921,6 +921,10 @@ func executeChannelClose(ctxc context.Context, client lnrpc.LightningClient,
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch update := resp.Update.(type) {
|
switch update := resp.Update.(type) {
|
||||||
|
case *lnrpc.CloseStatusUpdate_CloseInstant:
|
||||||
|
if req.NoWait {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
case *lnrpc.CloseStatusUpdate_ClosePending:
|
case *lnrpc.CloseStatusUpdate_ClosePending:
|
||||||
closingHash := update.ClosePending.Txid
|
closingHash := update.ClosePending.Txid
|
||||||
txid, err := chainhash.NewHash(closingHash)
|
txid, err := chainhash.NewHash(closingHash)
|
||||||
|
|||||||
+3227
-3143
File diff suppressed because it is too large.
Load diff
@@ -2046,12 +2046,18 @@ message CloseChannelRequest {
|
|||||||
//
|
//
|
||||||
// NOTE: This field is only respected if we're the initiator of the channel.
|
// NOTE: This field is only respected if we're the initiator of the channel.
|
||||||
uint64 max_fee_per_vbyte = 7;
|
uint64 max_fee_per_vbyte = 7;
|
||||||
|
|
||||||
|
// If true, then the rpc call will not block while it awaits a closing txid.
|
||||||
|
// Consequently this RPC call will not return a closing txid if this value
|
||||||
|
// is set.
|
||||||
|
bool no_wait = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CloseStatusUpdate {
|
message CloseStatusUpdate {
|
||||||
oneof update {
|
oneof update {
|
||||||
PendingUpdate close_pending = 1;
|
PendingUpdate close_pending = 1;
|
||||||
ChannelCloseUpdate chan_close = 3;
|
ChannelCloseUpdate chan_close = 3;
|
||||||
|
InstantUpdate close_instant = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2060,6 +2066,9 @@ message PendingUpdate {
|
|||||||
uint32 output_index = 2;
|
uint32 output_index = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message InstantUpdate {
|
||||||
|
}
|
||||||
|
|
||||||
message ReadyForPsbtFunding {
|
message ReadyForPsbtFunding {
|
||||||
/*
|
/*
|
||||||
The P2WSH address of the channel funding multisig address that the below
|
The P2WSH address of the channel funding multisig address that the below
|
||||||
|
|||||||
@@ -866,6 +866,13 @@
|
|||||||
"required": false,
|
"required": false,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "uint64"
|
"format": "uint64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "no_wait",
|
||||||
|
"description": "If true, then the rpc call will not block while it awaits a closing txid.\nConsequently this RPC call will not return a closing txid if this value\nis set.",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -4367,6 +4374,9 @@
|
|||||||
},
|
},
|
||||||
"chan_close": {
|
"chan_close": {
|
||||||
"$ref": "#/definitions/lnrpcChannelCloseUpdate"
|
"$ref": "#/definitions/lnrpcChannelCloseUpdate"
|
||||||
|
},
|
||||||
|
"close_instant": {
|
||||||
|
"$ref": "#/definitions/lnrpcInstantUpdate"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -5236,6 +5246,9 @@
|
|||||||
],
|
],
|
||||||
"default": "INITIATOR_UNKNOWN"
|
"default": "INITIATOR_UNKNOWN"
|
||||||
},
|
},
|
||||||
|
"lnrpcInstantUpdate": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"lnrpcInterceptFeedback": {
|
"lnrpcInterceptFeedback": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
+17
-4
@@ -2643,10 +2643,10 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
rpcsLog.Debugf("Target sat/kw for closing transaction: %v",
|
rpcsLog.Debugf("Target sat/kw for closing transaction: %v",
|
||||||
int64(feeRate))
|
int64(feeRate))
|
||||||
|
|
||||||
// Before we attempt the cooperative channel closure, we'll
|
// If the user hasn't specified NoWait, then before we attempt
|
||||||
// examine the channel to ensure that it doesn't have a
|
// to close the channel we ensure there are no active HTLCs on
|
||||||
// lingering HTLC.
|
// the link.
|
||||||
if len(channel.ActiveHtlcs()) != 0 {
|
if !in.NoWait && len(channel.ActiveHtlcs()) != 0 {
|
||||||
return fmt.Errorf("cannot co-op close channel " +
|
return fmt.Errorf("cannot co-op close channel " +
|
||||||
"with active htlcs")
|
"with active htlcs")
|
||||||
}
|
}
|
||||||
@@ -2690,6 +2690,19 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
|||||||
maxFee, deliveryScript,
|
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:
|
out:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in new issue
Block a user