projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d78dd48
)
Support WithoutLength for UntrustedString
author
Jeffrey Czyz
<jkczyz@gmail.com>
Mon, 5 Jun 2023 20:55:13 +0000
(15:55 -0500)
committer
Jeffrey Czyz
<jkczyz@gmail.com>
Tue, 13 Jun 2023 18:07:41 +0000
(13:07 -0500)
lightning/src/util/ser.rs
patch
|
blob
|
history
diff --git
a/lightning/src/util/ser.rs
b/lightning/src/util/ser.rs
index cbdb5485e7bd984312c5a139e220835769f8f73b..fb0d0ad8e44e9eb40d203c50b4cf2efaa8af88a3 100644
(file)
--- a/
lightning/src/util/ser.rs
+++ b/
lightning/src/util/ser.rs
@@
-43,6
+43,7
@@
use crate::ln::msgs::PartialSignatureWithNonce;
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use crate::util::byte_utils::{be48_to_array, slice_to_be48};
use crate::ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use crate::util::byte_utils::{be48_to_array, slice_to_be48};
+use crate::util::string::UntrustedString;
/// serialization buffer size
pub const MAX_BUF_SIZE: usize = 64 * 1024;
/// serialization buffer size
pub const MAX_BUF_SIZE: usize = 64 * 1024;
@@
-629,6
+630,21
@@
impl<'a> From<&'a String> for WithoutLength<&'a String> {
fn from(s: &'a String) -> Self { Self(s) }
}
fn from(s: &'a String) -> Self { Self(s) }
}
+
+impl Writeable for WithoutLength<&UntrustedString> {
+ #[inline]
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+ WithoutLength(&self.0.0).write(w)
+ }
+}
+impl Readable for WithoutLength<UntrustedString> {
+ #[inline]
+ fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+ let s: WithoutLength<String> = Readable::read(r)?;
+ Ok(Self(UntrustedString(s.0)))
+ }
+}
+
impl<'a, T: Writeable> Writeable for WithoutLength<&'a Vec<T>> {
#[inline]
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
impl<'a, T: Writeable> Writeable for WithoutLength<&'a Vec<T>> {
#[inline]
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {