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

Display LND wallet locked error in UI instead of "Starting up" #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 22 additions & 2 deletions src/ui/lightning.zig
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var tab: struct {
// elements visibile during lnd startup.
startup: lvgl.FlexLayout,

wallet_locked: lvgl.FlexLayout,
// TODO: support wallet manual unlock (LightningError.code.Locked)

// elements when lnd wallet is uninitialized.
Expand Down Expand Up @@ -115,7 +116,7 @@ var tab: struct {
preserve_main_active_tab();
}

fn setMode(self: *@This(), m: enum { setup, startup, operational }) void {
fn setMode(self: *@This(), m: enum { setup, startup, wallet_locked, operational }) void {
switch (m) {
.setup => {
self.nowallet.show();
Expand All @@ -135,6 +136,16 @@ var tab: struct {
self.pairing.hide();
self.reset.hide();
},
.wallet_locked => {
self.wallet_locked.show();
self.nowallet.hide();
self.startup.hide();
self.info.card.hide();
self.balance.card.hide();
self.channels.card.hide();
self.pairing.hide();
self.reset.hide();
},
.operational => {
self.info.card.show();
self.balance.card.show();
Expand Down Expand Up @@ -174,6 +185,14 @@ pub fn initTabPanel(allocator: std.mem.Allocator, cont: lvgl.Container) !void {
_ = btn.on(.click, nm_lnd_setup_click, null);
}

// locked wallet state
// TODO: handle this somehow, instead of just printing error
{
tab.wallet_locked = try lvgl.FlexLayout.new(parent, .row, .{ .all = .center });
tab.wallet_locked.resizeToMax();
_ = try lvgl.Label.new(tab.wallet_locked, "ERROR: lightning wallet is locked.", .{});
}

// regular operational mode

// info section
Expand Down Expand Up @@ -266,7 +285,8 @@ pub fn updateTabPanel(msg: comm.Message) !void {
return switch (msg) {
.lightning_error => |lnerr| switch (lnerr.code) {
.uninitialized => tab.setMode(.setup),
// TODO: handle "wallet locked" and other errors
.locked => tab.setMode(.wallet_locked),
// TODO: handle other errors
else => tab.setMode(.startup),
},
.lightning_report => |rep| blk: {
Expand Down