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

Method to_bytes

plugins/lsps-plugin/src/core/tlv.rs:46–63  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

44
45impl TlvStream {
46 pub fn to_bytes(&mut self) -> Result<Vec<u8>> {
47 self.0.sort_by_key(|r| r.type_);
48 for w in self.0.windows(2) {
49 if w[0].type_ == w[1].type_ {
50 return Err(TlvError::DuplicateType(w[0].type_).into());
51 }
52 if w[0].type_ > w[1].type_ {
53 return Err(TlvError::NotSorted.into());
54 }
55 }
56 let mut out = Vec::new();
57 for rec in &self.0 {
58 out.extend(encode_bigsize(rec.type_));
59 out.extend(encode_bigsize(rec.value.len() as u64));
60 out.extend(&rec.value);
61 }
62 Ok(out)
63 }
64
65 pub fn from_bytes(mut bytes: &[u8]) -> Result<Self> {
66 let mut recs = Vec::new();

Callers 11

write_bignumFunction · 0.45
test_xpay_fake_channeldFunction · 0.45
decision_to_responseFunction · 0.45
serializeMethod · 0.45
handleMethod · 0.45

Calls 1

encode_bigsizeFunction · 0.85