MCPcopy Create free account
hub / github.com/ElementsProject/lightning / feature_bit_to_hex

Function feature_bit_to_hex

plugins/lsps-plugin/src/core/features.rs:57–63  ·  view source on GitHub ↗

Returns a single feature_bit in hex representation, least-significant bit first. # Arguments `feature_bit`: The 0-based index of the bit to check across the bitmap.

(feature_bit: usize)

Source from the content-addressed store, hash-verified

55/// * `feature_bit`: The 0-based index of the bit to check across the bitmap.
56///
57pub fn feature_bit_to_hex(feature_bit: usize) -> String {
58 let byte_index = feature_bit >> 3; // Equivalent to feature_bit / 8
59 let mask = 1 << (feature_bit & 7); // Equivalent to feature_bit % 8
60 let mut map = vec![0u8; byte_index + 1];
61 map[0] |= mask; // least-significant bit first ordering.
62 hex::encode(&map)
63}
64
65/// Errors that can occur when unwrapping payload data
66#[derive(Debug, Clone, PartialEq)]

Callers 3

Calls 1

encodeFunction · 0.50

Tested by 3