Merge pull request #5335 from guggero/abandonchannel-no-dev
RPC/CLI: Allow abandonchannel to be used in regular build
This commit is contained in:
5 files changed
+753
-703
No files matched your search
+15
-2
@@ -1118,7 +1118,9 @@ var abandonChannelCommand = cli.Command{
|
||||
summary. This method can be used to get rid of permanently unusable
|
||||
channels due to bugs fixed in newer versions of lnd.
|
||||
|
||||
Only available when lnd is built in debug mode.
|
||||
Only available when lnd is built in debug mode. The flag
|
||||
--i_know_what_im_doing can be set to override the debug/dev mode
|
||||
requirement.
|
||||
|
||||
To view which funding_txids/output_indexes can be used for this command,
|
||||
see the channel_point values within the listchannels command output.
|
||||
@@ -1134,6 +1136,16 @@ var abandonChannelCommand = cli.Command{
|
||||
Usage: "the output index for the funding output of the funding " +
|
||||
"transaction",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "i_know_what_i_am_doing",
|
||||
Usage: "override the requirement for lnd needing to " +
|
||||
"be in dev/debug mode to use this command; " +
|
||||
"when setting this the user attests that " +
|
||||
"they know the danger of using this command " +
|
||||
"on channels and that doing so can lead to " +
|
||||
"loss of funds if the channel funding TX " +
|
||||
"ever confirms (or was confirmed)",
|
||||
},
|
||||
},
|
||||
Action: actionDecorator(abandonChannel),
|
||||
}
|
||||
@@ -1155,7 +1167,8 @@ func abandonChannel(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
req := &lnrpc.AbandonChannelRequest{
|
||||
ChannelPoint: channelPoint,
|
||||
ChannelPoint: channelPoint,
|
||||
IKnowWhatIAmDoing: ctx.Bool("i_know_what_i_am_doing"),
|
||||
}
|
||||
|
||||
resp, err := client.AbandonChannel(ctxc, req)
|
||||
|
||||
+713
-698
File diff suppressed because it is too large.
Load diff
@@ -3364,6 +3364,13 @@ message AbandonChannelRequest {
|
||||
ChannelPoint channel_point = 1;
|
||||
|
||||
bool pending_funding_shim_only = 2;
|
||||
|
||||
/*
|
||||
Override the requirement for being in dev mode by setting this to true and
|
||||
confirming the user knows what they are doing and this is a potential foot
|
||||
gun to lose funds if used on active channels.
|
||||
*/
|
||||
bool i_know_what_i_am_doing = 3;
|
||||
}
|
||||
|
||||
message AbandonChannelResponse {
|
||||
|
||||
@@ -197,6 +197,14 @@
|
||||
"required": false,
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "i_know_what_i_am_doing",
|
||||
"description": "Override the requirement for being in dev mode by setting this to true and\nconfirming the user knows what they are doing and this is a potential foot\ngun to lose funds if used on active channels.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
|
||||
+10
-3
@@ -2371,8 +2371,13 @@ func (r *rpcServer) AbandonChannel(_ context.Context,
|
||||
// If this isn't the dev build, then we won't allow the RPC to be
|
||||
// executed, as it's an advanced feature and won't be activated in
|
||||
// regular production/release builds except for the explicit case of
|
||||
// externally funded channels that are still pending.
|
||||
if !in.PendingFundingShimOnly && !build.IsDevBuild() {
|
||||
// externally funded channels that are still pending. Due to repeated
|
||||
// requests, we also allow this requirement to be overwritten by a new
|
||||
// flag that attests to the user knowing what they're doing and the risk
|
||||
// associated with the command/RPC.
|
||||
if !in.IKnowWhatIAmDoing && !in.PendingFundingShimOnly &&
|
||||
!build.IsDevBuild() {
|
||||
|
||||
return nil, fmt.Errorf("AbandonChannel RPC call only " +
|
||||
"available in dev builds")
|
||||
}
|
||||
@@ -2413,7 +2418,9 @@ func (r *rpcServer) AbandonChannel(_ context.Context,
|
||||
// PSBT) on the channel so we don't need to use the thaw height.
|
||||
isShimFunded := dbChan.ThawHeight > 0
|
||||
isPendingShimFunded := isShimFunded && dbChan.IsPending
|
||||
if in.PendingFundingShimOnly && !isPendingShimFunded {
|
||||
if !in.IKnowWhatIAmDoing && in.PendingFundingShimOnly &&
|
||||
!isPendingShimFunded {
|
||||
|
||||
return nil, fmt.Errorf("channel %v is not externally "+
|
||||
"funded or not pending", chanPoint)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user