@@ -348,11 +348,17 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
348348 entry. write ( writer) ?;
349349 }
350350
351- write_tlv_fields ! ( writer, {
352- ( 1 , self . channel_id, required) ,
353- } ) ;
351+ write_tlv_fields ! ( writer, { } ) ;
354352 Ok ( ( ) )
355353 }
354+
355+ // `ChannelMonitor`s already track the `channel_id`, however, due to the derserialization order
356+ // there we can't make use of `ReadableArgs` to hand it into `OnchainTxHandler`'s
357+ // deserialization logic directly. Instead we opt to initialize it with 0s and override it
358+ // after reading the respective field via this method.
359+ pub ( crate ) fn set_channel_id ( & mut self , channel_id : ChannelId ) {
360+ self . channel_id = channel_id;
361+ }
356362}
357363
358364impl < ' a , ' b , ES : EntropySource , SP : SignerProvider > ReadableArgs < ( & ' a ES , & ' b SP , u64 , [ u8 ; 32 ] ) >
@@ -426,18 +432,13 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
426432 }
427433 }
428434
429- let mut channel_id = None ;
430- read_tlv_fields ! ( reader, {
431- ( 1 , channel_id, option) ,
432- } ) ;
435+ read_tlv_fields ! ( reader, { } ) ;
433436
434- // For backwards compatibility with monitors serialized before channel_id was added,
435- // we derive a channel_id from the funding outpoint if not present.
436- let channel_id = channel_id. or_else ( || {
437- channel_parameters. funding_outpoint
438- . map ( |op| ChannelId :: v1_from_funding_outpoint ( op) )
439- } ) // funding_outpoint must be known during intialization.
440- . ok_or ( DecodeError :: InvalidValue ) ?;
437+ // `ChannelMonitor`s already track the `channel_id`, however, due to the derserialization
438+ // order there we can't make use of `ReadableArgs` to hand it in directly. Instead we opt
439+ // to initialize it with 0s and override it after reading the respective field via
440+ // `OnchainTxHandler::set_channel_id`.
441+ let channel_id = ChannelId ( [ 0u8 ; 32 ] ) ;
441442
442443 let mut secp_ctx = Secp256k1 :: new ( ) ;
443444 secp_ctx. seeded_randomize ( & entropy_source. get_secure_random_bytes ( ) ) ;
0 commit comments