@@ -566,7 +566,7 @@ pub struct HTLCOutputInCommitment {
566
566
/// value is spent to additional transaction fees).
567
567
pub transaction_output_index : Option < u32 > ,
568
568
/// The RGB amount allocated to the HTLC
569
- pub amount_rgb : u64 ,
569
+ pub amount_rgb : Option < u64 > ,
570
570
}
571
571
572
572
impl_writeable_tlv_based ! ( HTLCOutputInCommitment , {
@@ -575,7 +575,7 @@ impl_writeable_tlv_based!(HTLCOutputInCommitment, {
575
575
( 4 , cltv_expiry, required) ,
576
576
( 6 , payment_hash, required) ,
577
577
( 8 , transaction_output_index, option) ,
578
- ( 10 , amount_rgb, required ) ,
578
+ ( 10 , amount_rgb, option ) ,
579
579
} ) ;
580
580
581
581
#[ inline]
@@ -1022,7 +1022,7 @@ impl HolderCommitmentTransaction {
1022
1022
for _ in 0 ..htlcs. len ( ) {
1023
1023
counterparty_htlc_sigs. push ( dummy_sig) ;
1024
1024
}
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 ) ;
1026
1026
htlcs. sort_by_key ( |htlc| htlc. 0 . transaction_output_index ) ;
1027
1027
HolderCommitmentTransaction {
1028
1028
inner,
@@ -1248,6 +1248,7 @@ pub struct CommitmentTransaction {
1248
1248
keys : TxCreationKeys ,
1249
1249
// For access to the pre-built transaction, see doc for trust()
1250
1250
pub ( crate ) built : BuiltCommitmentTransaction ,
1251
+ pub ( crate ) is_colored : bool ,
1251
1252
}
1252
1253
1253
1254
impl Eq for CommitmentTransaction { }
@@ -1278,6 +1279,7 @@ impl_writeable_tlv_based!(CommitmentTransaction, {
1278
1279
( 12 , htlcs, vec_type) ,
1279
1280
( 14 , opt_anchors, option) ,
1280
1281
( 16 , opt_non_zero_fee_anchors, option) ,
1282
+ ( 18 , is_colored, required) ,
1281
1283
} ) ;
1282
1284
1283
1285
impl CommitmentTransaction {
@@ -1291,7 +1293,7 @@ impl CommitmentTransaction {
1291
1293
/// Only include HTLCs that are above the dust limit for the channel.
1292
1294
///
1293
1295
/// 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 {
1295
1297
// Sort outputs and populate output indices while keeping track of the auxiliary data
1296
1298
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 ( ) ;
1297
1299
@@ -1311,6 +1313,7 @@ impl CommitmentTransaction {
1311
1313
txid
1312
1314
} ,
1313
1315
opt_non_zero_fee_anchors : None ,
1316
+ is_colored,
1314
1317
}
1315
1318
}
1316
1319
@@ -1590,9 +1593,11 @@ impl<'a> TrustedCommitmentTransaction<'a> {
1590
1593
for this_htlc in inner. htlcs . iter ( ) {
1591
1594
assert ! ( this_htlc. transaction_output_index. is_some( ) ) ;
1592
1595
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
+ }
1596
1601
}
1597
1602
1598
1603
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> {
1616
1621
if this_htlc. offered && preimage. is_some ( ) { unreachable ! ( ) ; }
1617
1622
1618
1623
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
+ }
1620
1627
1621
1628
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 ) ;
1622
1629
0 commit comments