projects
/
rust-lightning
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9993845
)
Make ser macro public
author
Tibo-lg
<thibaut@cryptogarage.co.jp>
Fri, 9 Jul 2021 11:40:43 +0000
(20:40 +0900)
committer
Tibo-lg
<thibaut@cryptogarage.co.jp>
Wed, 14 Jul 2021 02:29:10 +0000
(11:29 +0900)
lightning/src/ln/mod.rs
patch
|
blob
|
history
lightning/src/util/mod.rs
patch
|
blob
|
history
lightning/src/util/ser.rs
patch
|
blob
|
history
lightning/src/util/ser_macros.rs
patch
|
blob
|
history
diff --git
a/lightning/src/ln/mod.rs
b/lightning/src/ln/mod.rs
index 7500b93c0050400ae1bba70dd78a819336a5afbd..66c63f04d907ca42459cee13388540b39e3d0e07 100644
(file)
--- a/
lightning/src/ln/mod.rs
+++ b/
lightning/src/ln/mod.rs
@@
-35,7
+35,7
@@
pub(crate) mod peer_channel_encryptor;
mod channel;
mod onion_utils;
mod channel;
mod onion_utils;
-mod wire;
+
pub
mod wire;
// Older rustc (which we support) refuses to let us call the get_payment_preimage_hash!() macro
// without the node parameter being mut. This is incorrect, and thus newer rustcs will complain
// Older rustc (which we support) refuses to let us call the get_payment_preimage_hash!() macro
// without the node parameter being mut. This is incorrect, and thus newer rustcs will complain
diff --git
a/lightning/src/util/mod.rs
b/lightning/src/util/mod.rs
index cc0c3192a859fc79de02fe4bef36e8cfd2c2a2e0..5123f9db062c403bc23112657dfd13bb61d62dea 100644
(file)
--- a/
lightning/src/util/mod.rs
+++ b/
lightning/src/util/mod.rs
@@
-13,7
+13,7
@@
pub(crate) mod fuzz_wrappers;
#[macro_use]
pub(crate) mod fuzz_wrappers;
#[macro_use]
-pub
(crate)
mod ser_macros;
+pub mod ser_macros;
pub mod events;
pub mod errors;
pub mod events;
pub mod errors;
diff --git
a/lightning/src/util/ser.rs
b/lightning/src/util/ser.rs
index b02fef275d2c08d644f1f706c8440f3d688d682c..346aa76479c386520e8c0afd8e283170c07a29f4 100644
(file)
--- a/
lightning/src/util/ser.rs
+++ b/
lightning/src/util/ser.rs
@@
-303,7
+303,7
@@
impl Readable for U48 {
/// encoded in several different ways, which we must check for at deserialization-time. Thus, if
/// you're looking for an example of a variable-length integer to use for your own project, move
/// along, this is a rather poor design.
/// encoded in several different ways, which we must check for at deserialization-time. Thus, if
/// you're looking for an example of a variable-length integer to use for your own project, move
/// along, this is a rather poor design.
-pub
(crate)
struct BigSize(pub u64);
+pub struct BigSize(pub u64);
impl Writeable for BigSize {
#[inline]
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
impl Writeable for BigSize {
#[inline]
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
@@
-486,6
+486,7
@@
impl_array!(16); // for IPv6
impl_array!(32); // for channel id & hmac
impl_array!(PUBLIC_KEY_SIZE); // for PublicKey
impl_array!(COMPACT_SIGNATURE_SIZE); // for Signature
impl_array!(32); // for channel id & hmac
impl_array!(PUBLIC_KEY_SIZE); // for PublicKey
impl_array!(COMPACT_SIGNATURE_SIZE); // for Signature
+impl_array!(162); // for ECDSA adaptor signatures
impl_array!(1300); // for OnionPacket.hop_data
// HashMap
impl_array!(1300); // for OnionPacket.hop_data
// HashMap
diff --git
a/lightning/src/util/ser_macros.rs
b/lightning/src/util/ser_macros.rs
index b93115dcc95933bbc5a617bbf1dc5083f25cdd10..93387609a401e54344362cd756d7818d84cb6cc4 100644
(file)
--- a/
lightning/src/util/ser_macros.rs
+++ b/
lightning/src/util/ser_macros.rs
@@
-7,6
+7,10
@@
// You may not use this file except in accordance with one or both of these
// licenses.
// You may not use this file except in accordance with one or both of these
// licenses.
+//! Useful macros for generating serialization related code.
+
+/// Encode a TLV
+#[macro_export]
macro_rules! encode_tlv {
($stream: expr, $type: expr, $field: expr, required) => {
BigSize($type).write($stream)?;
macro_rules! encode_tlv {
($stream: expr, $type: expr, $field: expr, required) => {
BigSize($type).write($stream)?;
@@
-72,6
+76,8
@@
macro_rules! get_varint_length_prefixed_tlv_length {
};
}
};
}
+/// Encode a varint length prefixed TLV
+#[macro_export]
macro_rules! encode_varint_length_prefixed_tlv {
($stream: expr, {$(($type: expr, $field: expr, $fieldty: ident)),*}) => { {
use util::ser::BigSize;
macro_rules! encode_varint_length_prefixed_tlv {
($stream: expr, {$(($type: expr, $field: expr, $fieldty: ident)),*}) => { {
use util::ser::BigSize;
@@
-120,15
+126,17
@@
macro_rules! check_missing_tlv {
}};
}
}};
}
+/// Decode a TLV.
+#[macro_export]
macro_rules! decode_tlv {
($reader: expr, $field: ident, required) => {{
macro_rules! decode_tlv {
($reader: expr, $field: ident, required) => {{
- $field = ser::Readable::read(&mut $reader)?;
+ $field =
$crate::util::
ser::Readable::read(&mut $reader)?;
}};
($reader: expr, $field: ident, vec_type) => {{
}};
($reader: expr, $field: ident, vec_type) => {{
- $field = Some(ser::Readable::read(&mut $reader)?);
+ $field = Some(
$crate::util::
ser::Readable::read(&mut $reader)?);
}};
($reader: expr, $field: ident, option) => {{
}};
($reader: expr, $field: ident, option) => {{
- $field = Some(ser::Readable::read(&mut $reader)?);
+ $field = Some(
$crate::util::
ser::Readable::read(&mut $reader)?);
}};
}
}};
}