fedimint_server_ui/dashboard/
bitcoin.rs

1use fedimint_core::util::SafeUrl;
2use fedimint_server_core::dashboard_ui::ServerBitcoinRpcStatus;
3use maud::{Markup, html};
4
5pub fn render(url: SafeUrl, status: &Option<ServerBitcoinRpcStatus>) -> Markup {
6    html! {
7        div class="card h-100" {
8            div class="card-header dashboard-header" { "Bitcoin Rpc Connection" }
9            div class="card-body" {
10                div class="alert alert-info mb-3" {
11                    (url.to_unsafe().to_string())
12                }
13
14                @if let Some(status) = status {
15                    table class="table table-sm mb-0" {
16                        tbody {
17                            tr {
18                                th { "Network" }
19                                td { (format!("{:?}", status.network)) }
20                            }
21                            tr {
22                                th { "Block Count" }
23                                td { (status.block_count) }
24                            }
25                            tr {
26                                th { "Fee Rate" }
27                                td { (format!("{} sats/vB", status.fee_rate.sats_per_kvb / 1000)) }
28                            }
29                            @if let Some(sync) = status.sync_progress {
30                                tr {
31                                    th { "Sync Progress" }
32                                    td { (format!("{:.1}%", sync * 100.0)) }
33                                }
34                            }
35                        }
36                    }
37                    @if let Some(sync) = status.sync_progress {
38                        @if sync < 0.999 {
39                            div class="alert alert-warning mt-3 mb-0" {
40                                "The bitcoin backend is not fully synced yet. We need to wait for it to sync before we can participate in consensus."
41                            }
42                        }
43                    }
44                } @else {
45                    div class="alert alert-danger mb-0" {
46                        "Failed to connect to bitcoin backend. Please establish a connection in order to participate in consensus."
47                    }
48                }
49            }
50        }
51    }
52}