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

Function decode_frame

plugins/lsps-plugin/src/proto/lsps0.rs:55–66  ·  view source on GitHub ↗

Decode an LSPS0 frame and return the raw payload bytes. Validates that the header matches the LSPS0 message type (37913).

(bytes: &[u8])

Source from the content-addressed store, hash-verified

53///
54/// Validates that the header matches the LSPS0 message type (37913).
55pub fn decode_frame(bytes: &[u8]) -> Result<&[u8]> {
56 if bytes.len() < 2 {
57 return Err(Error::TooShort(bytes.len()));
58 }
59 let message_type = u16::from_be_bytes([bytes[0], bytes[1]]);
60 if message_type != LSPS0_MESSAGE_TYPE {
61 return Err(Error::InvalidMessageType {
62 type_: message_type,
63 });
64 }
65 Ok(&bytes[2..])
66}
67
68/// Represents a monetary amount as defined in LSPS0.msat. Is converted to a
69/// `String` in json messages with a suffix `_msat` or `_sat` and internally

Calls

no outgoing calls