@@ -196,9 +196,7 @@ pub enum Event {
196196 /// transaction.
197197 claim_from_onchain_tx : bool ,
198198 /// The final amount forwarded, in milli-satoshis, after the fee is deducted.
199- ///
200- /// The caveat described above the `total_fee_earned_msat` field applies here as well.
201- outbound_amount_forwarded_msat : Option < u64 > ,
199+ outbound_amount_forwarded_msat : u64 ,
202200 } ,
203201 /// A payment for a previously-registered payment hash has been received.
204202 ///
@@ -271,8 +269,10 @@ pub enum Event {
271269 /// This will be `None` for events serialized by LDK Node v0.2.1 and prior.
272270 reason : Option < ClosureReason > ,
273271 } ,
274- /// A channel splice has been negotiated and the funding transaction is pending
275- /// confirmation on-chain.
272+ /// A channel splice with local inputs or outputs has been negotiated and the funding
273+ /// transaction is pending confirmation on-chain.
274+ ///
275+ /// This event is not emitted when only the counterparty contributes to a splice.
276276 SpliceNegotiated {
277277 /// The `channel_id` of the channel.
278278 channel_id : ChannelId ,
@@ -283,7 +283,9 @@ pub enum Event {
283283 /// The outpoint of the channel's splice funding transaction.
284284 new_funding_txo : OutPoint ,
285285 } ,
286- /// A channel splice negotiation round has failed.
286+ /// A channel splice negotiation round with local inputs or outputs has failed.
287+ ///
288+ /// This event is not emitted when only the counterparty contributes to a splice.
287289 SpliceNegotiationFailed {
288290 /// The `channel_id` of the channel.
289291 channel_id : ChannelId ,
@@ -350,7 +352,7 @@ impl_writeable_tlv_based_enum!(Event,
350352 ( 8 , total_fee_earned_msat, option) ,
351353 ( 10 , skimmed_fee_msat, option) ,
352354 ( 12 , claim_from_onchain_tx, required) ,
353- ( 14 , outbound_amount_forwarded_msat, option ) ,
355+ ( 14 , outbound_amount_forwarded_msat, ( default_value , 0 ) ) ,
354356 ( 15 , prev_htlcs, ( default_value_vec, vec![ HTLCLocator {
355357 channel_id: legacy_prev_channel_id. ok_or( lightning:: ln:: msgs:: DecodeError :: InvalidValue ) ?,
356358 user_channel_id: legacy_prev_user_channel_id. map( UserChannelId ) ,
@@ -1500,7 +1502,7 @@ where
15001502 from_prev_str,
15011503 next_htlcs. len( ) ,
15021504 to_next_str,
1503- outbound_amount_forwarded_msat. unwrap_or ( 0 ) ,
1505+ outbound_amount_forwarded_msat,
15041506 fee_earned,
15051507 ) ;
15061508 } else {
@@ -1511,7 +1513,7 @@ where
15111513 from_prev_str,
15121514 next_htlcs. len( ) ,
15131515 to_next_str,
1514- outbound_amount_forwarded_msat. unwrap_or ( 0 ) ,
1516+ outbound_amount_forwarded_msat,
15151517 fee_earned,
15161518 ) ;
15171519 }
@@ -2120,6 +2122,14 @@ mod tests {
21202122 counterparty_node_id : Option < PublicKey > ,
21212123 reason : Option < ClosureReason > ,
21222124 } ,
2125+ PaymentForwarded {
2126+ prev_htlcs : Vec < HTLCLocator > ,
2127+ next_htlcs : Vec < HTLCLocator > ,
2128+ total_fee_earned_msat : Option < u64 > ,
2129+ skimmed_fee_msat : Option < u64 > ,
2130+ claim_from_onchain_tx : bool ,
2131+ outbound_amount_forwarded_msat : Option < u64 > ,
2132+ } ,
21232133 }
21242134
21252135 impl_writeable_tlv_based_enum ! ( LegacyEvent ,
@@ -2129,6 +2139,14 @@ mod tests {
21292139 ( 2 , user_channel_id, required) ,
21302140 ( 3 , reason, upgradable_option) ,
21312141 } ,
2142+ ( 7 , PaymentForwarded ) => {
2143+ ( 8 , total_fee_earned_msat, option) ,
2144+ ( 10 , skimmed_fee_msat, option) ,
2145+ ( 12 , claim_from_onchain_tx, required) ,
2146+ ( 14 , outbound_amount_forwarded_msat, option) ,
2147+ ( 15 , prev_htlcs, ( default_value_vec, Vec :: new( ) ) ) ,
2148+ ( 17 , next_htlcs, ( default_value_vec, Vec :: new( ) ) ) ,
2149+ } ,
21322150 ) ;
21332151
21342152 fn encode_legacy_event_queue ( event : LegacyEvent ) -> Vec < u8 > {
@@ -2190,6 +2208,47 @@ mod tests {
21902208 assert ! ( res. is_err( ) ) ;
21912209 }
21922210
2211+ #[ test]
2212+ fn event_queue_defaults_legacy_missing_forwarded_amount ( ) {
2213+ let store: Arc < DynStore > = Arc :: new ( DynStoreWrapper ( InMemoryStore :: new ( ) ) ) ;
2214+ let logger = Arc :: new ( TestLogger :: new ( ) ) ;
2215+ let prev_htlcs = vec ! [ HTLCLocator {
2216+ channel_id: ChannelId ( [ 1 ; 32 ] ) ,
2217+ user_channel_id: None ,
2218+ node_id: None ,
2219+ } ] ;
2220+ let next_htlcs = vec ! [ HTLCLocator {
2221+ channel_id: ChannelId ( [ 2 ; 32 ] ) ,
2222+ user_channel_id: None ,
2223+ node_id: None ,
2224+ } ] ;
2225+ let legacy_event = LegacyEvent :: PaymentForwarded {
2226+ prev_htlcs : prev_htlcs. clone ( ) ,
2227+ next_htlcs : next_htlcs. clone ( ) ,
2228+ total_fee_earned_msat : None ,
2229+ skimmed_fee_msat : None ,
2230+ claim_from_onchain_tx : true ,
2231+ outbound_amount_forwarded_msat : None ,
2232+ } ;
2233+ let expected_event = LegacyEvent :: PaymentForwarded {
2234+ prev_htlcs,
2235+ next_htlcs,
2236+ total_fee_earned_msat : None ,
2237+ skimmed_fee_msat : None ,
2238+ claim_from_onchain_tx : true ,
2239+ outbound_amount_forwarded_msat : Some ( 0 ) ,
2240+ } ;
2241+ let persisted_bytes = encode_legacy_event_queue ( legacy_event) ;
2242+
2243+ let event_queue =
2244+ EventQueue :: read ( & mut & persisted_bytes[ ..] , ( Arc :: clone ( & store) , logger) ) . unwrap ( ) ;
2245+ assert_eq ! (
2246+ event_queue. next_event( ) . unwrap( ) . encode( ) ,
2247+ expected_event. encode( ) ,
2248+ "legacy forwarded amount should normalize to zero"
2249+ ) ;
2250+ }
2251+
21932252 #[ tokio:: test]
21942253 async fn event_queue_concurrency ( ) {
21952254 let store: Arc < DynStore > = Arc :: new ( DynStoreWrapper ( InMemoryStore :: new ( ) ) ) ;
0 commit comments