@@ -566,7 +566,7 @@ pub struct HTLCOutputInCommitment {
566566/// value is spent to additional transaction fees). 
567567pub  transaction_output_index :  Option < u32 > , 
568568	/// The RGB amount allocated to the HTLC 
569- pub  amount_rgb :  u64 , 
569+ pub  amount_rgb :  Option < u64 > , 
570570} 
571571
572572impl_writeable_tlv_based ! ( HTLCOutputInCommitment ,  { 
@@ -575,7 +575,7 @@ impl_writeable_tlv_based!(HTLCOutputInCommitment, {
575575	( 4 ,  cltv_expiry,  required) , 
576576	( 6 ,  payment_hash,  required) , 
577577	( 8 ,  transaction_output_index,  option) , 
578- 	( 10 ,  amount_rgb,  required ) , 
578+ 	( 10 ,  amount_rgb,  option ) , 
579579} ) ; 
580580
581581#[ inline]  
@@ -1022,7 +1022,7 @@ impl HolderCommitmentTransaction {
10221022		for  _ in  0 ..htlcs. len ( )  { 
10231023			counterparty_htlc_sigs. push ( dummy_sig) ; 
10241024		} 
1025- 		let  inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 ,  0 ,  0 ,  false ,  dummy_key. clone ( ) ,  dummy_key. clone ( ) ,  keys,  0 ,  htlcs,  & channel_parameters. as_counterparty_broadcastable ( ) ) ; 
1025+ 		let  inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 ,  0 ,  0 ,  false ,  dummy_key. clone ( ) ,  dummy_key. clone ( ) ,  keys,  0 ,  htlcs,  & channel_parameters. as_counterparty_broadcastable ( ) ,   false ) ; 
10261026		htlcs. sort_by_key ( |htlc| htlc. 0 . transaction_output_index ) ; 
10271027		HolderCommitmentTransaction  { 
10281028			inner, 
@@ -1248,6 +1248,7 @@ pub struct CommitmentTransaction {
12481248	keys :  TxCreationKeys , 
12491249	// For access to the pre-built transaction, see doc for trust() 
12501250	pub ( crate )  built :  BuiltCommitmentTransaction , 
1251+ 	pub ( crate )  is_colored :  bool , 
12511252} 
12521253
12531254impl  Eq  for  CommitmentTransaction  { } 
@@ -1278,6 +1279,7 @@ impl_writeable_tlv_based!(CommitmentTransaction, {
12781279	( 12 ,  htlcs,  vec_type) , 
12791280	( 14 ,  opt_anchors,  option) , 
12801281	( 16 ,  opt_non_zero_fee_anchors,  option) , 
1282+ 	( 18 ,  is_colored,  required) , 
12811283} ) ; 
12821284
12831285impl  CommitmentTransaction  { 
@@ -1291,7 +1293,7 @@ impl CommitmentTransaction {
12911293/// Only include HTLCs that are above the dust limit for the channel. 
12921294/// 
12931295/// This is not exported to bindings users due to the generic though we likely should expose a version without 
1294- pub  fn  new_with_auxiliary_htlc_data < T > ( commitment_number :  u64 ,  to_broadcaster_value_sat :  u64 ,  to_countersignatory_value_sat :  u64 ,  opt_anchors :  bool ,  broadcaster_funding_key :  PublicKey ,  countersignatory_funding_key :  PublicKey ,  keys :  TxCreationKeys ,  feerate_per_kw :  u32 ,  htlcs_with_aux :  & mut  Vec < ( HTLCOutputInCommitment ,  T ) > ,  channel_parameters :  & DirectedChannelTransactionParameters )  -> CommitmentTransaction  { 
1296+ pub  fn  new_with_auxiliary_htlc_data < T > ( commitment_number :  u64 ,  to_broadcaster_value_sat :  u64 ,  to_countersignatory_value_sat :  u64 ,  opt_anchors :  bool ,  broadcaster_funding_key :  PublicKey ,  countersignatory_funding_key :  PublicKey ,  keys :  TxCreationKeys ,  feerate_per_kw :  u32 ,  htlcs_with_aux :  & mut  Vec < ( HTLCOutputInCommitment ,  T ) > ,  channel_parameters :  & DirectedChannelTransactionParameters ,   is_colored :   bool )  -> CommitmentTransaction  { 
12951297		// Sort outputs and populate output indices while keeping track of the auxiliary data 
12961298		let  ( outputs,  htlcs)  = Self :: internal_build_outputs ( & keys,  to_broadcaster_value_sat,  to_countersignatory_value_sat,  htlcs_with_aux,  channel_parameters,  opt_anchors,  & broadcaster_funding_key,  & countersignatory_funding_key) . unwrap ( ) ; 
12971299
@@ -1311,6 +1313,7 @@ impl CommitmentTransaction {
13111313				txid
13121314			} , 
13131315			opt_non_zero_fee_anchors :  None , 
1316+ 			is_colored, 
13141317		} 
13151318	} 
13161319
@@ -1590,9 +1593,11 @@ impl<'a> TrustedCommitmentTransaction<'a> {
15901593		for  this_htlc in  inner. htlcs . iter ( )  { 
15911594			assert ! ( this_htlc. transaction_output_index. is_some( ) ) ; 
15921595			let  mut  htlc_tx = build_htlc_transaction ( & txid,  inner. feerate_per_kw ,  channel_parameters. contest_delay ( ) ,  & this_htlc,  self . opt_anchors ( ) ,  self . opt_non_zero_fee_anchors . is_some ( ) ,  & keys. broadcaster_delayed_payment_key ,  & keys. revocation_key ) ; 
1593- 			match  color_htlc ( & mut  htlc_tx,  & this_htlc,  & ldk_data_dir)  { 
1594- 				Err ( _e)  => return  Err ( ( ) ) , 
1595- 				_ => { } 
1596+ 			if  inner. is_colored  { 
1597+ 				match  color_htlc ( & mut  htlc_tx,  & this_htlc,  & ldk_data_dir)  { 
1598+ 					Err ( _e)  => return  Err ( ( ) ) , 
1599+ 					_ => { } 
1600+ 				} 
15961601			} 
15971602
15981603			let  htlc_redeemscript = get_htlc_redeemscript_with_explicit_keys ( & this_htlc,  self . opt_anchors ( ) ,  & keys. broadcaster_htlc_key ,  & keys. countersignatory_htlc_key ,  & keys. revocation_key ) ; 
@@ -1616,7 +1621,9 @@ impl<'a> TrustedCommitmentTransaction<'a> {
16161621		if   this_htlc. offered  && preimage. is_some ( )  {  unreachable ! ( ) ;  } 
16171622
16181623		let  mut  htlc_tx = build_htlc_transaction ( & txid,  inner. feerate_per_kw ,  channel_parameters. contest_delay ( ) ,  & this_htlc,  self . opt_anchors ( ) ,  self . opt_non_zero_fee_anchors . is_some ( ) ,  & keys. broadcaster_delayed_payment_key ,  & keys. revocation_key ) ; 
1619- 		color_htlc ( & mut  htlc_tx,  & this_htlc,  & ldk_data_dir) . expect ( "successful htlc tx coloring" ) ; 
1624+ 		if  inner. is_colored  { 
1625+ 			color_htlc ( & mut  htlc_tx,  & this_htlc,  & ldk_data_dir) . expect ( "successful htlc tx coloring" ) ; 
1626+ 		} 
16201627
16211628		let  htlc_redeemscript = get_htlc_redeemscript_with_explicit_keys ( & this_htlc,  self . opt_anchors ( ) ,  & keys. broadcaster_htlc_key ,  & keys. countersignatory_htlc_key ,  & keys. revocation_key ) ; 
16221629
0 commit comments