Returns the `PeerLspStatus`, containing information about the connectivity and the LSP feature bit.
(
cln_client: &mut ClnRpc,
peer_id: &str,
)
| 767 | /// Returns the `PeerLspStatus`, containing information about the connectivity |
| 768 | /// and the LSP feature bit. |
| 769 | async fn check_peer_lsp_status( |
| 770 | cln_client: &mut ClnRpc, |
| 771 | peer_id: &str, |
| 772 | ) -> Result<PeerLspStatus, anyhow::Error> { |
| 773 | let res = cln_client |
| 774 | .call_typed(&ListpeersRequest { |
| 775 | id: Some(PublicKey::from_str(peer_id)?), |
| 776 | level: None, |
| 777 | }) |
| 778 | .await?; |
| 779 | |
| 780 | let peer = match res.peers.first() { |
| 781 | None => { |
| 782 | return Ok(PeerLspStatus { |
| 783 | connected: false, |
| 784 | has_lsp_feature: false, |
| 785 | }); |
| 786 | } |
| 787 | Some(p) => p, |
| 788 | }; |
| 789 | |
| 790 | let connected = peer.connected; |
| 791 | let has_lsp_feature = if let Some(f_str) = &peer.features { |
| 792 | let feature_bits = hex::decode(f_str) |
| 793 | .map_err(|e| anyhow!("Invalid feature bits hex for peer {peer_id}, {f_str}: {e}"))?; |
| 794 | is_feature_bit_set_reversed(&feature_bits, LSP_FEATURE_BIT) |
| 795 | } else { |
| 796 | false |
| 797 | }; |
| 798 | |
| 799 | Ok(PeerLspStatus { |
| 800 | connected, |
| 801 | has_lsp_feature, |
| 802 | }) |
| 803 | } |
| 804 | |
| 805 | pub fn gen_rand_preimage_hex<R: Rng + CryptoRng>(rng: &mut R) -> String { |
| 806 | let mut pre = [0u8; 32]; |
no test coverage detected