@@ -666,6 +666,24 @@ pub struct UpdateFulfillHTLC {
666
666
pub payment_preimage : PaymentPreimage ,
667
667
}
668
668
669
+ /// A [`PeerStorage`] message to be sent to or received from a peer.
670
+ ///
671
+ /// [`PeerStorage`]: https://github.com/lightning/bolts/pull/1110
672
+ #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
673
+ pub struct PeerStorageMessage {
674
+ /// Data included in the msg
675
+ pub data : Vec < u8 > ,
676
+ }
677
+
678
+ /// An [`YourPeerStorage`] message to be sent to or received from a peer.
679
+ ///
680
+ /// [`YourPeerStorage`]: https://github.com/lightning/bolts/pull/1110
681
+ #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
682
+ pub struct YourPeerStorageMessage {
683
+ /// Data included in the msg
684
+ pub data : Vec < u8 > ,
685
+ }
686
+
669
687
/// An [`update_fail_htlc`] message to be sent to or received from a peer.
670
688
///
671
689
/// [`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
@@ -1426,6 +1444,12 @@ pub trait ChannelMessageHandler : MessageSendEventsProvider {
1426
1444
/// Handle an incoming `channel_ready` message from the given peer.
1427
1445
fn handle_channel_ready ( & self , their_node_id : & PublicKey , msg : & ChannelReady ) ;
1428
1446
1447
+ // Peer Storage
1448
+ /// Handle an incoming `peer_storage` message from the given peer.
1449
+ fn handle_peer_storage ( & self , their_node_id : & PublicKey , msg : & PeerStorageMessage ) ;
1450
+ /// Handle an incoming `your_peer_storage` message from the given peer.
1451
+ fn handle_your_peer_storage ( & self , their_node_id : & PublicKey , msg : & YourPeerStorageMessage ) ;
1452
+
1429
1453
// Channel close:
1430
1454
/// Handle an incoming `shutdown` message from the given peer.
1431
1455
fn handle_shutdown ( & self , their_node_id : & PublicKey , msg : & Shutdown ) ;
@@ -2379,6 +2403,14 @@ impl_writeable_msg!(UpdateFulfillHTLC, {
2379
2403
payment_preimage
2380
2404
} , { } ) ;
2381
2405
2406
+ impl_writeable_msg ! ( PeerStorageMessage , {
2407
+ data
2408
+ } , { } ) ;
2409
+
2410
+ impl_writeable_msg ! ( YourPeerStorageMessage , {
2411
+ data
2412
+ } , { } ) ;
2413
+
2382
2414
// Note that this is written as a part of ChannelManager objects, and thus cannot change its
2383
2415
// serialization format in a way which assumes we know the total serialized length/message end
2384
2416
// position.
@@ -4177,6 +4209,26 @@ mod tests {
4177
4209
assert_eq ! ( encoded_value, target_value) ;
4178
4210
}
4179
4211
4212
+ #[ test]
4213
+ fn encoding_peer_storage ( ) {
4214
+ let peerstorage = msgs:: PeerStorageMessage {
4215
+ data : <Vec < u8 > >:: from_hex ( "01020304050607080910" ) . unwrap ( )
4216
+ } ;
4217
+ let encoded_value = peerstorage. encode ( ) ;
4218
+ let target_value = <Vec < u8 > >:: from_hex ( "000a01020304050607080910" ) . unwrap ( ) ;
4219
+ assert_eq ! ( encoded_value, target_value) ;
4220
+ }
4221
+
4222
+ #[ test]
4223
+ fn encoding_your_peer_storage ( ) {
4224
+ let yourpeerstorage = msgs:: YourPeerStorageMessage {
4225
+ data : <Vec < u8 > >:: from_hex ( "01020304050607080910" ) . unwrap ( )
4226
+ } ;
4227
+ let encoded_value = yourpeerstorage. encode ( ) ;
4228
+ let target_value = <Vec < u8 > >:: from_hex ( "000a01020304050607080910" ) . unwrap ( ) ;
4229
+ assert_eq ! ( encoded_value, target_value) ;
4230
+ }
4231
+
4180
4232
#[ test]
4181
4233
fn encoding_pong ( ) {
4182
4234
let pong = msgs:: Pong {
0 commit comments