@@ -77,6 +77,7 @@ var tab: struct {
7777 // elements visibile during lnd startup.
7878 startup : lvgl.FlexLayout ,
7979
80+ wallet_locked : lvgl.FlexLayout ,
8081 // TODO: support wallet manual unlock (LightningError.code.Locked)
8182
8283 // elements when lnd wallet is uninitialized.
@@ -115,7 +116,7 @@ var tab: struct {
115116 preserve_main_active_tab ();
116117 }
117118
118- fn setMode (self : * @This (), m : enum { setup , startup , operational }) void {
119+ fn setMode (self : * @This (), m : enum { setup , startup , wallet_locked , operational }) void {
119120 switch (m ) {
120121 .setup = > {
121122 self .nowallet .show ();
@@ -125,6 +126,7 @@ var tab: struct {
125126 self .channels .card .hide ();
126127 self .pairing .hide ();
127128 self .reset .hide ();
129+ self .wallet_locked .hide ();
128130 },
129131 .startup = > {
130132 self .startup .show ();
@@ -134,6 +136,17 @@ var tab: struct {
134136 self .channels .card .hide ();
135137 self .pairing .hide ();
136138 self .reset .hide ();
139+ self .wallet_locked .hide ();
140+ },
141+ .wallet_locked = > {
142+ self .wallet_locked .show ();
143+ self .nowallet .hide ();
144+ self .startup .hide ();
145+ self .info .card .hide ();
146+ self .balance .card .hide ();
147+ self .channels .card .hide ();
148+ self .pairing .hide ();
149+ self .reset .hide ();
137150 },
138151 .operational = > {
139152 self .info .card .show ();
@@ -143,6 +156,7 @@ var tab: struct {
143156 self .reset .show ();
144157 self .nowallet .hide ();
145158 self .startup .hide ();
159+ self .wallet_locked .hide ();
146160 },
147161 }
148162 }
@@ -174,6 +188,14 @@ pub fn initTabPanel(allocator: std.mem.Allocator, cont: lvgl.Container) !void {
174188 _ = btn .on (.click , nm_lnd_setup_click , null );
175189 }
176190
191+ // locked wallet state
192+ // TODO: handle this somehow, instead of just printing error
193+ {
194+ tab .wallet_locked = try lvgl .FlexLayout .new (parent , .row , .{ .all = .center });
195+ tab .wallet_locked .resizeToMax ();
196+ _ = try lvgl .Label .new (tab .wallet_locked , "ERROR: lightning wallet is locked." , .{});
197+ }
198+
177199 // regular operational mode
178200
179201 // info section
@@ -266,7 +288,7 @@ pub fn updateTabPanel(msg: comm.Message) !void {
266288 return switch (msg ) {
267289 .lightning_error = > | lnerr | switch (lnerr .code ) {
268290 .uninitialized = > tab .setMode (.setup ),
269- // TODO: handle "wallet locked" and other errors
291+ . locked = > tab . setMode ( .wallet_locked ),
270292 else = > tab .setMode (.startup ),
271293 },
272294 .lightning_report = > | rep | blk : {
0 commit comments