@@ -711,6 +711,24 @@ pub struct UpdateFulfillHTLC {
711
711
pub payment_preimage : PaymentPreimage ,
712
712
}
713
713
714
+ /// A [`PeerStorage`] message to be sent to or received from a peer.
715
+ ///
716
+ /// [`PeerStorage`]: https://github.com/lightning/bolts/pull/1110
717
+ #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
718
+ pub struct PeerStorageMessage {
719
+ /// Data included in the msg
720
+ pub data : Vec < u8 > ,
721
+ }
722
+
723
+ /// An [`YourPeerStorage`] message to be sent to or received from a peer.
724
+ ///
725
+ /// [`YourPeerStorage`]: https://github.com/lightning/bolts/pull/1110
726
+ #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
727
+ pub struct YourPeerStorageMessage {
728
+ /// Data included in the msg
729
+ pub data : Vec < u8 > ,
730
+ }
731
+
714
732
/// An [`update_fail_htlc`] message to be sent to or received from a peer.
715
733
///
716
734
/// [`update_fail_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc
@@ -1461,6 +1479,12 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
1461
1479
/// Handle an incoming `channel_ready` message from the given peer.
1462
1480
fn handle_channel_ready ( & self , their_node_id : & PublicKey , msg : & ChannelReady ) ;
1463
1481
1482
+ // Peer Storage
1483
+ /// Handle an incoming `peer_storage` message from the given peer.
1484
+ fn handle_peer_storage ( & self , their_node_id : & PublicKey , msg : & PeerStorageMessage ) ;
1485
+ /// Handle an incoming `your_peer_storage` message from the given peer.
1486
+ fn handle_your_peer_storage ( & self , their_node_id : & PublicKey , msg : & YourPeerStorageMessage ) ;
1487
+
1464
1488
// Channel close:
1465
1489
/// Handle an incoming `shutdown` message from the given peer.
1466
1490
fn handle_shutdown ( & self , their_node_id : & PublicKey , msg : & Shutdown ) ;
@@ -2190,6 +2214,14 @@ impl_writeable_msg!(UpdateFulfillHTLC, {
2190
2214
payment_preimage
2191
2215
} , { } ) ;
2192
2216
2217
+ impl_writeable_msg ! ( PeerStorageMessage , {
2218
+ data
2219
+ } , { } ) ;
2220
+
2221
+ impl_writeable_msg ! ( YourPeerStorageMessage , {
2222
+ data
2223
+ } , { } ) ;
2224
+
2193
2225
// Note that this is written as a part of ChannelManager objects, and thus cannot change its
2194
2226
// serialization format in a way which assumes we know the total serialized length/message end
2195
2227
// position.
@@ -3982,6 +4014,26 @@ mod tests {
3982
4014
assert_eq ! ( encoded_value, target_value) ;
3983
4015
}
3984
4016
4017
+ #[ test]
4018
+ fn encoding_peer_storage ( ) {
4019
+ let peerstorage = msgs:: PeerStorageMessage {
4020
+ data : <Vec < u8 > >:: from_hex ( "01020304050607080910" ) . unwrap ( )
4021
+ } ;
4022
+ let encoded_value = peerstorage. encode ( ) ;
4023
+ let target_value = <Vec < u8 > >:: from_hex ( "000a01020304050607080910" ) . unwrap ( ) ;
4024
+ assert_eq ! ( encoded_value, target_value) ;
4025
+ }
4026
+
4027
+ #[ test]
4028
+ fn encoding_your_peer_storage ( ) {
4029
+ let yourpeerstorage = msgs:: YourPeerStorageMessage {
4030
+ data : <Vec < u8 > >:: from_hex ( "01020304050607080910" ) . unwrap ( )
4031
+ } ;
4032
+ let encoded_value = yourpeerstorage. encode ( ) ;
4033
+ let target_value = <Vec < u8 > >:: from_hex ( "000a01020304050607080910" ) . unwrap ( ) ;
4034
+ assert_eq ! ( encoded_value, target_value) ;
4035
+ }
4036
+
3985
4037
#[ test]
3986
4038
fn encoding_pong ( ) {
3987
4039
let pong = msgs:: Pong {
0 commit comments