mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
lnrpc+rpcserver: allow abandonchannel to be used in regular build
An often requested feature is to use the abandonchannel API in regular builds and not only dev builds to get rid of stuck channels that had their funding transaction invalidated. The initial reason for putting the call behind the build flag was a safety concern to make sure nobody uses this on active channels by accident.
This commit is contained in:
parent
785d3c9b4f
commit
2e9dd0bcf2
4 changed files with 738 additions and 701 deletions
1411
lnrpc/rpc.pb.go
1411
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load diff
|
@ -3363,6 +3363,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": [
|
||||
|
|
13
rpcserver.go
13
rpcserver.go
|
@ -2369,8 +2369,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")
|
||||
}
|
||||
|
@ -2411,7 +2416,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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue