-
Notifications
You must be signed in to change notification settings - Fork 123
Abandon API for pending Loop-in swaps #661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8612912
looprpc: abandon swap api
hieblmi 0fbf253
loopdb: abandon swap state
hieblmi 5e91c44
loopd: abandon loop-ins
hieblmi c0b4193
loopin: restore abandon chan on restart
hieblmi 378d817
cmd: abandon api support
hieblmi ce6f826
unit: abandon swap
hieblmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,3 +90,73 @@ func swapInfo(ctx *cli.Context) error { | |
| printRespJSON(resp) | ||
| return nil | ||
| } | ||
|
|
||
| var abandonSwapCommand = cli.Command{ | ||
| Name: "abandonswap", | ||
| Usage: "abandon a swap with a given swap hash", | ||
| Description: "This command overrides the database and abandons a " + | ||
| "swap with a given swap hash.\n\n" + | ||
| "!!! This command might potentially lead to loss of funds if " + | ||
| "it is applied to swaps that are still waiting for pending " + | ||
| "user funds. Before executing this command make sure that " + | ||
| "no funds are locked by the swap.", | ||
| ArgsUsage: "ID", | ||
| Flags: []cli.Flag{ | ||
| cli.BoolFlag{ | ||
| Name: "i_know_what_i_am_doing", | ||
| Usage: "Specify this flag if you made sure that you " + | ||
| "read and understood the following " + | ||
| "consequence of applying this command.", | ||
| }, | ||
| }, | ||
| Action: abandonSwap, | ||
| } | ||
|
|
||
| func abandonSwap(ctx *cli.Context) error { | ||
| args := ctx.Args() | ||
|
|
||
| var id string | ||
| switch { | ||
| case ctx.IsSet("id"): | ||
| id = ctx.String("id") | ||
|
|
||
| case ctx.NArg() > 0: | ||
bhandras marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id = args[0] | ||
| args = args.Tail() // nolint:wastedassign | ||
|
|
||
| default: | ||
| // Show command help if no arguments and flags were provided. | ||
| return cli.ShowCommandHelp(ctx, "abandonswap") | ||
| } | ||
|
|
||
| if len(id) != hex.EncodedLen(lntypes.HashSize) { | ||
| return fmt.Errorf("invalid swap ID") | ||
| } | ||
| idBytes, err := hex.DecodeString(id) | ||
| if err != nil { | ||
| return fmt.Errorf("cannot hex decode id: %v", err) | ||
| } | ||
|
|
||
| client, cleanup, err := getClient(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer cleanup() | ||
|
|
||
| if !ctx.Bool("i_know_what_i_am_doing") { | ||
| return cli.ShowCommandHelp(ctx, "abandonswap") | ||
| } | ||
|
|
||
| resp, err := client.AbandonSwap( | ||
| context.Background(), &looprpc.AbandonSwapRequest{ | ||
| Id: idBytes, | ||
| IKnowWhatIAmDoing: ctx.Bool("i_know_what_i_am_doing"), | ||
| }, | ||
| ) | ||
| if err != nil { | ||
| return err | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see earlier comment, but we will always error out, except on empty response. |
||
| } | ||
|
|
||
| printRespJSON(resp) | ||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.