ElementsProject / ElementsProject/peerswap

Add Swap_Rejected state to allow for database pruning

Open
#13 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
128
Forks
84
Avg merge
3h 1m
Merged PRs (30d)
1

Description

```
$ lighting-cli peerswap-swap-out 100000 HIDDENxHIDDENx0 lbtc
{
"code": -1,
"message": "swap canceled, reason: unknown"

local log ...
2022-04-22T06:49:13.236Z INFO plugin-peerswap-plugin: [Swap:5e0732e795a884dff96027ffd59e12d6f0f6f4e34e453b5b2da07df8e6e8cc8b] Start new swap of type swap out: peer: HIDDEN chanId: HIDDENxHIDDENx0 initiator: HIDDEN amount 100000
```

- [x] If the swap is immediately rejected the console should say why it was rejected.
- [x] The log should print the rejection and reason.
- [x] Please simplify log prefix to "Start swap out" and equivalent for "Start swap in"

```
remote log ...
Apr 22 06:49:13 lightning-charge-production-hwwp docker[222795]: 2022-04-22T06:49:13.502Z INFO plugin-peerswap-plugin: [FSM] Action failure peer not allowed to request swaps
```

- [x] Please add the rejected peer's pubkey to this log entry.

The following allows for safely removing database entries that did not result in a corresponding database entry on the peer. This would allow for frequent swap attempts without bloating database storage with rejected swap attempts.
- [ ] Add another terminal state that can come directly from SendRequest called "State_SwapRejected" distinct from "State_SwapCanceled".
- [ ] Prune Swap_Rejected entries after it is clear the rejection happened.
- [ ] Rename cancel messages to reject messages in the code so they are more distinct from the separate cancel path.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.