@@ -199,8 +199,8 @@ pub struct OpenChannel {
199199pub  first_per_commitment_point :  PublicKey , 
200200	/// The channel flags to be used 
201201pub  channel_flags :  u8 , 
202- 	/// Optionally, a  request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close 
203- pub  shutdown_scriptpubkey :  OptionalField < Script > , 
202+ 	/// A  request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close 
203+ pub  shutdown_scriptpubkey :  Option < Script > , 
204204	/// The channel type that this channel will represent 
205205/// 
206206/// If this is `None`, we derive the channel type from the intersection of our 
@@ -241,8 +241,8 @@ pub struct AcceptChannel {
241241pub  htlc_basepoint :  PublicKey , 
242242	/// The first to-be-broadcast-by-sender transaction's per commitment point 
243243pub  first_per_commitment_point :  PublicKey , 
244- 	/// Optionally, a  request to pre-set the to-sender output's scriptPubkey for when we collaboratively close 
245- pub  shutdown_scriptpubkey :  OptionalField < Script > , 
244+ 	/// A  request to pre-set the to-sender output's scriptPubkey for when we collaboratively close 
245+ pub  shutdown_scriptpubkey :  Option < Script > , 
246246	/// The channel type that this channel will represent. 
247247/// 
248248/// If this is `None`, we derive the channel type from the intersection of 
@@ -946,20 +946,6 @@ pub struct CommitmentUpdate {
946946pub  commitment_signed :  CommitmentSigned , 
947947} 
948948
949- /// Messages could have optional fields to use with extended features 
950- /// As we wish to serialize these differently from `Option<T>`s (`Options` get a tag byte, but 
951- /// [`OptionalField`] simply gets `Present` if there are enough bytes to read into it), we have a 
952- /// separate enum type for them. 
953- /// 
954- /// This is not exported to bindings users due to a free generic in `T` 
955- #[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
956- pub  enum  OptionalField < T >  { 
957- 	/// Optional field is included in message 
958- Present ( T ) , 
959- 	/// Optional field is absent in message 
960- Absent 
961- } 
962- 
963949/// A trait to describe an object which can receive channel messages. 
964950/// 
965951/// Messages MAY be called in parallel when they originate from different `their_node_ids`, however 
@@ -1255,52 +1241,6 @@ impl From<io::Error> for DecodeError {
12551241	} 
12561242} 
12571243
1258- impl  Writeable  for  OptionalField < Script >  { 
1259- 	fn  write < W :  Writer > ( & self ,  w :  & mut  W )  -> Result < ( ) ,  io:: Error >  { 
1260- 		match  * self  { 
1261- 			OptionalField :: Present ( ref  script)  => { 
1262- 				// Note that Writeable for script includes the 16-bit length tag for us 
1263- 				script. write ( w) ?; 
1264- 			} , 
1265- 			OptionalField :: Absent  => { } 
1266- 		} 
1267- 		Ok ( ( ) ) 
1268- 	} 
1269- } 
1270- 
1271- impl  Readable  for  OptionalField < Script >  { 
1272- 	fn  read < R :  Read > ( r :  & mut  R )  -> Result < Self ,  DecodeError >  { 
1273- 		match  <u16  as  Readable >:: read ( r)  { 
1274- 			Ok ( len)  => { 
1275- 				let  mut  buf = vec ! [ 0 ;  len as  usize ] ; 
1276- 				r. read_exact ( & mut  buf) ?; 
1277- 				Ok ( OptionalField :: Present ( Script :: from ( buf) ) ) 
1278- 			} , 
1279- 			Err ( DecodeError :: ShortRead )  => Ok ( OptionalField :: Absent ) , 
1280- 			Err ( e)  => Err ( e) 
1281- 		} 
1282- 	} 
1283- } 
1284- 
1285- impl  Writeable  for  OptionalField < u64 >  { 
1286- 	fn  write < W :  Writer > ( & self ,  w :  & mut  W )  -> Result < ( ) ,  io:: Error >  { 
1287- 		match  * self  { 
1288- 			OptionalField :: Present ( ref  value)  => { 
1289- 				value. write ( w) ?; 
1290- 			} , 
1291- 			OptionalField :: Absent  => { } 
1292- 		} 
1293- 		Ok ( ( ) ) 
1294- 	} 
1295- } 
1296- 
1297- impl  Readable  for  OptionalField < u64 >  { 
1298- 	fn  read < R :  Read > ( r :  & mut  R )  -> Result < Self ,  DecodeError >  { 
1299- 		let  value:  u64  = Readable :: read ( r) ?; 
1300- 		Ok ( OptionalField :: Present ( value) ) 
1301- 	} 
1302- } 
1303- 
13041244#[ cfg( not( taproot) ) ]  
13051245impl_writeable_msg ! ( AcceptChannel ,  { 
13061246	temporary_channel_id, 
@@ -1317,8 +1257,8 @@ impl_writeable_msg!(AcceptChannel, {
13171257	delayed_payment_basepoint, 
13181258	htlc_basepoint, 
13191259	first_per_commitment_point, 
1320- 	shutdown_scriptpubkey
13211260} ,  { 
1261+ 	( 0 ,  shutdown_scriptpubkey,  ( option,  encoding:  ( Script ,  WithoutLength ) ) ) ,  // Don't encode length twice. 
13221262	( 1 ,  channel_type,  option) , 
13231263} ) ; 
13241264
@@ -1338,8 +1278,8 @@ impl_writeable_msg!(AcceptChannel, {
13381278	delayed_payment_basepoint, 
13391279	htlc_basepoint, 
13401280	first_per_commitment_point, 
1341- 	shutdown_scriptpubkey
13421281} ,  { 
1282+ 	( 0 ,  shutdown_scriptpubkey,  ( option,  encoding:  ( Script ,  WithoutLength ) ) ) ,  // Don't encode length twice. 
13431283	( 1 ,  channel_type,  option) , 
13441284	( 4 ,  next_local_nonce,  option) , 
13451285} ) ; 
@@ -1477,8 +1417,8 @@ impl_writeable_msg!(OpenChannel, {
14771417	htlc_basepoint, 
14781418	first_per_commitment_point, 
14791419	channel_flags, 
1480- 	shutdown_scriptpubkey
14811420} ,  { 
1421+ 	( 0 ,  shutdown_scriptpubkey,  ( option,  encoding:  ( Script ,  WithoutLength ) ) ) ,  // Don't encode length twice. 
14821422	( 1 ,  channel_type,  option) , 
14831423} ) ; 
14841424
@@ -2103,7 +2043,7 @@ mod tests {
21032043	use  crate :: ln:: { PaymentPreimage ,  PaymentHash ,  PaymentSecret } ; 
21042044	use  crate :: ln:: features:: { ChannelFeatures ,  ChannelTypeFeatures ,  InitFeatures ,  NodeFeatures } ; 
21052045	use  crate :: ln:: msgs; 
2106- 	use  crate :: ln:: msgs:: { FinalOnionHopData ,  OptionalField ,   OnionErrorPacket ,  OnionHopDataFormat } ; 
2046+ 	use  crate :: ln:: msgs:: { FinalOnionHopData ,  OnionErrorPacket ,  OnionHopDataFormat } ; 
21072047	use  crate :: routing:: gossip:: { NodeAlias ,  NodeId } ; 
21082048	use  crate :: util:: ser:: { Writeable ,  Readable ,  Hostname } ; 
21092049
@@ -2422,7 +2362,7 @@ mod tests {
24222362			htlc_basepoint :  pubkey_5, 
24232363			first_per_commitment_point :  pubkey_6, 
24242364			channel_flags :  if  random_bit {  1  << 5  }  else  {  0  } , 
2425- 			shutdown_scriptpubkey :  if  shutdown {  OptionalField :: Present ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed :  true ,  inner :  pubkey_1} ,  Network :: Testnet ) . script_pubkey ( ) )  }  else  {  OptionalField :: Absent  } , 
2365+ 			shutdown_scriptpubkey :  if  shutdown {  Some ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed :  true ,  inner :  pubkey_1} ,  Network :: Testnet ) . script_pubkey ( ) )  }  else  {  None  } , 
24262366			channel_type :  if  incl_chan_type {  Some ( ChannelTypeFeatures :: empty ( ) )  }  else  {  None  } , 
24272367		} ; 
24282368		let  encoded_value = open_channel. encode ( ) ; 
@@ -2478,7 +2418,7 @@ mod tests {
24782418			delayed_payment_basepoint :  pubkey_4, 
24792419			htlc_basepoint :  pubkey_5, 
24802420			first_per_commitment_point :  pubkey_6, 
2481- 			shutdown_scriptpubkey :  if  shutdown {  OptionalField :: Present ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed :  true ,  inner :  pubkey_1} ,  Network :: Testnet ) . script_pubkey ( ) )  }  else  {  OptionalField :: Absent  } , 
2421+ 			shutdown_scriptpubkey :  if  shutdown {  Some ( Address :: p2pkh ( & :: bitcoin:: PublicKey { compressed :  true ,  inner :  pubkey_1} ,  Network :: Testnet ) . script_pubkey ( ) )  }  else  {  None  } , 
24822422			channel_type :  None , 
24832423			#[ cfg( taproot) ]  
24842424			next_local_nonce :  None , 
0 commit comments