@@ -31,6 +31,7 @@ use bitcoin::hash_types::{Txid, BlockHash};
3131
3232use bitcoin:: ecdsa:: Signature as BitcoinSignature ;
3333use bitcoin:: secp256k1:: { self , SecretKey , PublicKey , Secp256k1 , ecdsa:: Signature } ;
34+ use rgb_lib:: ContractId ;
3435
3536use crate :: ln:: channel:: INITIAL_COMMITMENT_NUMBER ;
3637use crate :: ln:: types:: { PaymentHash , PaymentPreimage , ChannelId } ;
@@ -216,14 +217,14 @@ pub struct HTLCUpdate {
216217 pub ( crate ) payment_preimage : Option < PaymentPreimage > ,
217218 pub ( crate ) source : HTLCSource ,
218219 pub ( crate ) htlc_value_satoshis : Option < u64 > ,
219- pub ( crate ) htlc_value_rgb : Option < u64 > ,
220+ pub ( crate ) htlc_rgb_payment : Option < ( ContractId , u64 ) > ,
220221}
221222impl_writeable_tlv_based ! ( HTLCUpdate , {
222223 ( 0 , payment_hash, required) ,
223224 ( 1 , htlc_value_satoshis, option) ,
224225 ( 2 , source, required) ,
225226 ( 4 , payment_preimage, option) ,
226- ( 6 , htlc_value_rgb , option) ,
227+ ( 6 , htlc_rgb_payment , option) ,
227228} ) ;
228229
229230/// If an HTLC expires within this many blocks, don't try to claim it in a shared transaction,
@@ -429,7 +430,7 @@ enum OnchainEvent {
429430 source : HTLCSource ,
430431 payment_hash : PaymentHash ,
431432 htlc_value_satoshis : Option < u64 > ,
432- htlc_value_rgb : Option < u64 > ,
433+ htlc_rgb_payment : Option < ( ContractId , u64 ) > ,
433434 /// None in the second case, above, ie when there is no relevant output in the commitment
434435 /// transaction which appeared on chain.
435436 commitment_tx_output_idx : Option < u32 > ,
@@ -511,7 +512,7 @@ impl_writeable_tlv_based_enum_upgradable!(OnchainEvent,
511512 ( 1 , htlc_value_satoshis, option) ,
512513 ( 2 , payment_hash, required) ,
513514 ( 3 , commitment_tx_output_idx, option) ,
514- ( 4 , htlc_value_rgb , option) ,
515+ ( 4 , htlc_rgb_payment , option) ,
515516 } ,
516517 ( 1 , MaturingOutput ) => {
517518 ( 0 , descriptor, required) ,
@@ -1109,7 +1110,7 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
11091110 writer. write_all( & $htlc_output. cltv_expiry. to_be_bytes( ) ) ?;
11101111 writer. write_all( & $htlc_output. payment_hash. 0 [ ..] ) ?;
11111112 $htlc_output. transaction_output_index. write( writer) ?;
1112- $htlc_output. amount_rgb . write( writer) ?;
1113+ $htlc_output. rgb_payment . write( writer) ?;
11131114 }
11141115 }
11151116
@@ -2649,7 +2650,7 @@ macro_rules! fail_unbroadcast_htlcs {
26492650 source: ( * * source) . clone( ) ,
26502651 payment_hash: htlc. payment_hash. clone( ) ,
26512652 htlc_value_satoshis: Some ( htlc. amount_msat / 1000 ) ,
2652- htlc_value_rgb : htlc. amount_rgb ,
2653+ htlc_rgb_payment : htlc. rgb_payment ,
26532654 commitment_tx_output_idx: None ,
26542655 } ,
26552656 } ;
@@ -4089,7 +4090,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40894090 // Produce actionable events from on-chain events having reached their threshold.
40904091 for entry in onchain_events_reaching_threshold_conf. drain ( ..) {
40914092 match entry. event {
4092- OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, htlc_value_rgb , commitment_tx_output_idx } => {
4093+ OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, htlc_rgb_payment , commitment_tx_output_idx } => {
40934094 // Check for duplicate HTLC resolutions.
40944095 #[ cfg( debug_assertions) ]
40954096 {
@@ -4113,7 +4114,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41134114 payment_preimage : None ,
41144115 source : source. clone ( ) ,
41154116 htlc_value_satoshis,
4116- htlc_value_rgb ,
4117+ htlc_rgb_payment ,
41174118 } ) ) ;
41184119 self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
41194120 commitment_tx_output_idx,
@@ -4410,7 +4411,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44104411 if pending_htlc. payment_hash == $htlc_output. payment_hash && pending_htlc. amount_msat == $htlc_output. amount_msat {
44114412 if let & Some ( ref source) = pending_source {
44124413 log_claim!( "revoked counterparty commitment tx" , false , pending_htlc, true ) ;
4413- payment_data = Some ( ( ( * * source) . clone( ) , $htlc_output. payment_hash, $htlc_output. amount_msat, $htlc_output. amount_rgb ) ) ;
4414+ payment_data = Some ( ( ( * * source) . clone( ) , $htlc_output. payment_hash, $htlc_output. amount_msat, $htlc_output. rgb_payment ) ) ;
44144415 break ;
44154416 }
44164417 }
@@ -4429,7 +4430,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44294430 // transaction. This implies we either learned a preimage, the HTLC
44304431 // has timed out, or we screwed up. In any case, we should now
44314432 // resolve the source HTLC with the original sender.
4432- payment_data = Some ( ( ( * source) . clone( ) , htlc_output. payment_hash, htlc_output. amount_msat, htlc_output. amount_rgb ) ) ;
4433+ payment_data = Some ( ( ( * source) . clone( ) , htlc_output. payment_hash, htlc_output. amount_msat, htlc_output. rgb_payment ) ) ;
44334434 } else if !$holder_tx {
44344435 if let Some ( current_counterparty_commitment_txid) = & self . current_counterparty_commitment_txid {
44354436 check_htlc_valid_counterparty!( htlc_output, self . counterparty_claimable_outpoints. get( current_counterparty_commitment_txid) . unwrap( ) ) ;
@@ -4481,7 +4482,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44814482
44824483 // Check that scan_commitment, above, decided there is some source worth relaying an
44834484 // HTLC resolution backwards to and figure out whether we learned a preimage from it.
4484- if let Some ( ( source, payment_hash, amount_msat, amount_rgb ) ) = payment_data {
4485+ if let Some ( ( source, payment_hash, amount_msat, htlc_rgb_payment ) ) = payment_data {
44854486 if accepted_preimage_claim {
44864487 if !self . pending_monitor_events . iter ( ) . any (
44874488 |update| if let & MonitorEvent :: HTLCEvent ( ref upd) = update { upd. source == source } else { false } ) {
@@ -4501,7 +4502,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45014502 payment_preimage : Some ( payment_preimage) ,
45024503 payment_hash,
45034504 htlc_value_satoshis : Some ( amount_msat / 1000 ) ,
4504- htlc_value_rgb : amount_rgb ,
4505+ htlc_rgb_payment ,
45054506 } ) ) ;
45064507 }
45074508 } else if offered_preimage_claim {
@@ -4525,7 +4526,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45254526 payment_preimage : Some ( payment_preimage) ,
45264527 payment_hash,
45274528 htlc_value_satoshis : Some ( amount_msat / 1000 ) ,
4528- htlc_value_rgb : amount_rgb ,
4529+ htlc_rgb_payment ,
45294530 } ) ) ;
45304531 }
45314532 } else {
@@ -4546,7 +4547,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
45464547 event : OnchainEvent :: HTLCUpdate {
45474548 source, payment_hash,
45484549 htlc_value_satoshis : Some ( amount_msat / 1000 ) ,
4549- htlc_value_rgb : amount_rgb ,
4550+ htlc_rgb_payment ,
45504551 commitment_tx_output_idx : Some ( input. previous_output . vout ) ,
45514552 } ,
45524553 } ;
@@ -4740,10 +4741,10 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
47404741 let cltv_expiry: u32 = Readable :: read( reader) ?;
47414742 let payment_hash: PaymentHash = Readable :: read( reader) ?;
47424743 let transaction_output_index: Option <u32 > = Readable :: read( reader) ?;
4743- let amount_rgb : Option <u64 > = Readable :: read( reader) ?;
4744+ let rgb_payment : Option <( ContractId , u64 ) > = Readable :: read( reader) ?;
47444745
47454746 HTLCOutputInCommitment {
4746- offered, amount_msat, cltv_expiry, payment_hash, transaction_output_index, amount_rgb
4747+ offered, amount_msat, cltv_expiry, payment_hash, transaction_output_index, rgb_payment
47474748 }
47484749 }
47494750 }
0 commit comments