Skip to content
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

Frontend.Console: ask confirmation from funder #183

Open
wants to merge 2 commits into
base: lightning
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/GWallet.Backend/Ether/EtherExceptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type RpcErrorCode =
// so many different errors use this shitty error code... don't ask me why
| JackOfAllTradesErrorCode = -32000

// message was "rejected due to project ID settings" (don't ask me wtf this means)
| ProjectIdSettingsRejection = -32002

// ambiguous or generic because I've seen same code applied to two different error messages already:
// "Transaction with the same hash was already imported. (Transaction with the same hash was already imported.)"
// AND
Expand Down
4 changes: 3 additions & 1 deletion src/GWallet.Backend/Ether/EtherServer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ module Server =
raise <| ServerMisconfiguredException(exMsg, rpcResponseEx)
| d when d = int RpcErrorCode.EmptyResponse ->
raise <| ServerMisconfiguredException(exMsg, rpcResponseEx)
| e when e = int RpcErrorCode.DailyRequestCountExceededSoRequestRateLimited ->
| e when e = int RpcErrorCode.ProjectIdSettingsRejection ->
raise <| ServerRefusedException(exMsg, rpcResponseEx)
| f when f = int RpcErrorCode.DailyRequestCountExceededSoRequestRateLimited ->
raise <| ServerRefusedException(exMsg, rpcResponseEx)
| _ ->
raise
Expand Down
18 changes: 13 additions & 5 deletions src/GWallet.Frontend.Console/LayerTwo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,6 @@ module LayerTwo =
Console.WriteLine "In order to continue the funding for the channel needs to be locked"
let lockFundingAsync =
if channelInfo.IsFunder then
Console.WriteLine
"Ensure the fundee is ready to accept a connection to lock the funding, \
then press any key to continue."
Console.ReadKey true |> ignore
let tryLock password =
async {
let nodeClient = Lightning.Connection.StartClient channelStore password
Expand All @@ -573,7 +569,19 @@ module LayerTwo =
return! lockChannelInternal (Node.Client nodeClient) sublockFundingAsync
}

UserInteraction.TryWithPasswordAsync tryLock
let confirmation =
UserInteraction.AskYesNo
"Ensure the fundee is ready to accept a connection to lock the funding, \
Do you want to continue?"
if not confirmation then
async {
return seq {
yield! UserInteraction.DisplayLightningChannelStatus channelInfo
yield " funder didn't confirm to lock the funding!"
}
}
else
UserInteraction.TryWithPasswordAsync tryLock
else
let nodeServerType =
match channelInfo.NodeTransportType with
Expand Down