@@ -489,7 +489,7 @@ const MIN_SERIALIZATION_VERSION: u8 = 1;
489
489
#[ derive( Clone ) ]
490
490
pub ( crate ) enum ChannelMonitorUpdateStep {
491
491
LatestHolderCommitmentTXInfo {
492
- commitment_info : HolderCommitmentTransaction ,
492
+ commitment_tx : HolderCommitmentTransaction ,
493
493
htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Signature > , Option < HTLCSource > ) > ,
494
494
} ,
495
495
LatestCounterpartyCommitmentTXInfo {
@@ -517,9 +517,9 @@ pub(crate) enum ChannelMonitorUpdateStep {
517
517
impl Writeable for ChannelMonitorUpdateStep {
518
518
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , :: std:: io:: Error > {
519
519
match self {
520
- & ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { ref commitment_info , ref htlc_outputs } => {
520
+ & ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { ref commitment_tx , ref htlc_outputs } => {
521
521
0u8 . write ( w) ?;
522
- commitment_info . write ( w) ?;
522
+ commitment_tx . write ( w) ?;
523
523
( htlc_outputs. len ( ) as u64 ) . write ( w) ?;
524
524
for & ( ref output, ref signature, ref source) in htlc_outputs. iter ( ) {
525
525
output. write ( w) ?;
@@ -560,7 +560,7 @@ impl Readable for ChannelMonitorUpdateStep {
560
560
match Readable :: read ( r) ? {
561
561
0u8 => {
562
562
Ok ( ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo {
563
- commitment_info : Readable :: read ( r) ?,
563
+ commitment_tx : Readable :: read ( r) ?,
564
564
htlc_outputs : {
565
565
let len: u64 = Readable :: read ( r) ?;
566
566
let mut res = Vec :: new ( ) ;
@@ -952,7 +952,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
952
952
channel_parameters : & ChannelTransactionParameters ,
953
953
funding_redeemscript : Script , channel_value_satoshis : u64 ,
954
954
commitment_transaction_number_obscure_factor : u64 ,
955
- initial_holder_commitment_info : HolderCommitmentTransaction ) -> ChannelMonitor < ChanSigner > {
955
+ initial_holder_commitment_tx : HolderCommitmentTransaction ) -> ChannelMonitor < ChanSigner > {
956
956
957
957
assert ! ( commitment_transaction_number_obscure_factor <= ( 1 << 48 ) ) ;
958
958
let our_channel_close_key_hash = WPubkeyHash :: hash ( & shutdown_pubkey. serialize ( ) ) ;
@@ -969,26 +969,26 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
969
969
let secp_ctx = Secp256k1 :: new ( ) ;
970
970
971
971
let directed_channel_parameters = channel_parameters. to_directed ( true ) ;
972
- let txid = initial_holder_commitment_info . calculate_txid ( & directed_channel_parameters, & secp_ctx) ;
972
+ let txid = initial_holder_commitment_tx . calculate_txid ( & directed_channel_parameters, & secp_ctx) ;
973
973
974
974
// block for Rust 1.34 compat
975
975
let ( holder_commitment_tx, current_holder_commitment_number) = {
976
- let info = & initial_holder_commitment_info . info ;
977
- let tx_keys = & info . keys ;
978
- let current_holder_commitment_number = info . commitment_number ;
976
+ let commitment_tx = & initial_holder_commitment_tx . inner ;
977
+ let tx_keys = & commitment_tx . keys ;
978
+ let current_holder_commitment_number = commitment_tx . commitment_number ;
979
979
let holder_commitment_tx = HolderSignedTx {
980
980
txid,
981
981
revocation_key : tx_keys. revocation_key ,
982
982
a_htlc_key : tx_keys. broadcaster_htlc_key ,
983
983
b_htlc_key : tx_keys. countersignatory_htlc_key ,
984
984
delayed_payment_key : tx_keys. broadcaster_delayed_payment_key ,
985
985
per_commitment_point : tx_keys. per_commitment_point ,
986
- feerate_per_kw : info . feerate_per_kw ,
986
+ feerate_per_kw : commitment_tx . feerate_per_kw ,
987
987
htlc_outputs : Vec :: new ( ) , // There are never any HTLCs in the initial commitment transactions
988
988
} ;
989
989
( holder_commitment_tx, current_holder_commitment_number)
990
990
} ;
991
- onchain_tx_handler. provide_latest_holder_tx ( initial_holder_commitment_info ) ;
991
+ onchain_tx_handler. provide_latest_holder_tx ( initial_holder_commitment_tx ) ;
992
992
993
993
let mut outputs_to_watch = HashMap :: new ( ) ;
994
994
outputs_to_watch. insert ( funding_info. 0 . txid , vec ! [ ( funding_info. 0 . index as u32 , funding_info. 1 . clone( ) ) ] ) ;
@@ -1096,7 +1096,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1096
1096
/// The monitor watches for it to be broadcasted and then uses the HTLC information (and
1097
1097
/// possibly future revocation/preimage information) to claim outputs where possible.
1098
1098
/// We cache also the mapping hash:commitment number to lighten pruning of old preimages by watchtowers.
1099
- pub ( crate ) fn provide_latest_counterparty_commitment_tx_info < L : Deref > ( & mut self , unsigned_commitment_tx : & Transaction , htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > , commitment_number : u64 , their_revocation_point : PublicKey , logger : & L ) where L :: Target : Logger {
1099
+ pub ( crate ) fn provide_latest_counterparty_commitment_tx < L : Deref > ( & mut self , unsigned_commitment_tx : & Transaction , htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > , commitment_number : u64 , their_revocation_point : PublicKey , logger : & L ) where L :: Target : Logger {
1100
1100
// TODO: Encrypt the htlc_outputs data with the single-hash of the commitment transaction
1101
1101
// so that a remote monitor doesn't learn anything unless there is a malicious close.
1102
1102
// (only maybe, sadly we cant do the same for local info, as we need to be aware of
@@ -1145,26 +1145,26 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1145
1145
/// is important that any clones of this channel monitor (including remote clones) by kept
1146
1146
/// up-to-date as our holder commitment transaction is updated.
1147
1147
/// Panics if set_on_holder_tx_csv has never been called.
1148
- fn provide_latest_holder_commitment_tx_info ( & mut self , commitment_info : HolderCommitmentTransaction , htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Signature > , Option < HTLCSource > ) > ) -> Result < ( ) , MonitorUpdateError > {
1149
- let txid = commitment_info . calculate_txid ( & self . onchain_tx_handler . channel_transaction_parameters . to_directed ( true ) , & self . secp_ctx ) ;
1148
+ fn provide_latest_holder_commitment_tx ( & mut self , holder_commitment_tx : HolderCommitmentTransaction , htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Signature > , Option < HTLCSource > ) > ) -> Result < ( ) , MonitorUpdateError > {
1149
+ let txid = holder_commitment_tx . calculate_txid ( & self . onchain_tx_handler . channel_transaction_parameters . to_directed ( true ) , & self . secp_ctx ) ;
1150
1150
1151
1151
// block for Rust 1.34 compat
1152
1152
let mut new_holder_commitment_tx = {
1153
- let info = & commitment_info . info ;
1154
- let tx_keys = & info . keys ;
1155
- self . current_holder_commitment_number = info . commitment_number ;
1153
+ let commitment_tx = & holder_commitment_tx . inner ;
1154
+ let tx_keys = & commitment_tx . keys ;
1155
+ self . current_holder_commitment_number = commitment_tx . commitment_number ;
1156
1156
HolderSignedTx {
1157
1157
txid,
1158
1158
revocation_key : tx_keys. revocation_key ,
1159
1159
a_htlc_key : tx_keys. broadcaster_htlc_key ,
1160
1160
b_htlc_key : tx_keys. countersignatory_htlc_key ,
1161
1161
delayed_payment_key : tx_keys. broadcaster_delayed_payment_key ,
1162
1162
per_commitment_point : tx_keys. per_commitment_point ,
1163
- feerate_per_kw : info . feerate_per_kw ,
1163
+ feerate_per_kw : commitment_tx . feerate_per_kw ,
1164
1164
htlc_outputs,
1165
1165
}
1166
1166
} ;
1167
- self . onchain_tx_handler . provide_latest_holder_tx ( commitment_info ) ;
1167
+ self . onchain_tx_handler . provide_latest_holder_tx ( holder_commitment_tx ) ;
1168
1168
mem:: swap ( & mut new_holder_commitment_tx, & mut self . current_holder_commitment_tx ) ;
1169
1169
self . prev_holder_signed_commitment_tx = Some ( new_holder_commitment_tx) ;
1170
1170
if self . holder_tx_signed {
@@ -1252,14 +1252,14 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1252
1252
}
1253
1253
for update in updates. updates . iter ( ) {
1254
1254
match update {
1255
- ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { commitment_info, htlc_outputs } => {
1255
+ ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { commitment_tx : commitment_info, htlc_outputs } => {
1256
1256
log_trace ! ( logger, "Updating ChannelMonitor with latest holder commitment transaction info" ) ;
1257
1257
if self . lockdown_from_offchain { panic ! ( ) ; }
1258
- self . provide_latest_holder_commitment_tx_info ( commitment_info. clone ( ) , htlc_outputs. clone ( ) ) ?
1258
+ self . provide_latest_holder_commitment_tx ( commitment_info. clone ( ) , htlc_outputs. clone ( ) ) ?
1259
1259
} ,
1260
1260
ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXInfo { unsigned_commitment_tx, htlc_outputs, commitment_number, their_revocation_point } => {
1261
1261
log_trace ! ( logger, "Updating ChannelMonitor with latest counterparty commitment transaction info" ) ;
1262
- self . provide_latest_counterparty_commitment_tx_info ( & unsigned_commitment_tx, htlc_outputs. clone ( ) , * commitment_number, * their_revocation_point, logger)
1262
+ self . provide_latest_counterparty_commitment_tx ( & unsigned_commitment_tx, htlc_outputs. clone ( ) , * commitment_number, * their_revocation_point, logger)
1263
1263
} ,
1264
1264
ChannelMonitorUpdateStep :: PaymentPreimage { payment_preimage } => {
1265
1265
log_trace ! ( logger, "Updating ChannelMonitor with payment preimage" ) ;
@@ -2702,11 +2702,11 @@ mod tests {
2702
2702
Script :: new ( ) , 46 , 0 ,
2703
2703
HolderCommitmentTransaction :: dummy ( ) ) ;
2704
2704
2705
- monitor. provide_latest_holder_commitment_tx_info ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..10 ] ) ) . unwrap ( ) ;
2706
- monitor. provide_latest_counterparty_commitment_tx_info ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
2707
- monitor. provide_latest_counterparty_commitment_tx_info ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 15 ..20 ] ) , 281474976710654 , dummy_key, & logger) ;
2708
- monitor. provide_latest_counterparty_commitment_tx_info ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 17 ..20 ] ) , 281474976710653 , dummy_key, & logger) ;
2709
- monitor. provide_latest_counterparty_commitment_tx_info ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 18 ..20 ] ) , 281474976710652 , dummy_key, & logger) ;
2705
+ monitor. provide_latest_holder_commitment_tx ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..10 ] ) ) . unwrap ( ) ;
2706
+ monitor. provide_latest_counterparty_commitment_tx ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
2707
+ monitor. provide_latest_counterparty_commitment_tx ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 15 ..20 ] ) , 281474976710654 , dummy_key, & logger) ;
2708
+ monitor. provide_latest_counterparty_commitment_tx ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 17 ..20 ] ) , 281474976710653 , dummy_key, & logger) ;
2709
+ monitor. provide_latest_counterparty_commitment_tx ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 18 ..20 ] ) , 281474976710652 , dummy_key, & logger) ;
2710
2710
for & ( ref preimage, ref hash) in preimages. iter ( ) {
2711
2711
monitor. provide_payment_preimage ( hash, preimage, & broadcaster, & fee_estimator, & logger) ;
2712
2712
}
@@ -2728,15 +2728,15 @@ mod tests {
2728
2728
2729
2729
// Now update holder commitment tx info, pruning only element 18 as we still care about the
2730
2730
// previous commitment tx's preimages too
2731
- monitor. provide_latest_holder_commitment_tx_info ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..5 ] ) ) . unwrap ( ) ;
2731
+ monitor. provide_latest_holder_commitment_tx ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..5 ] ) ) . unwrap ( ) ;
2732
2732
secret[ 0 ..32 ] . clone_from_slice ( & hex:: decode ( "2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8" ) . unwrap ( ) ) ;
2733
2733
monitor. provide_secret ( 281474976710653 , secret. clone ( ) ) . unwrap ( ) ;
2734
2734
assert_eq ! ( monitor. payment_preimages. len( ) , 12 ) ;
2735
2735
test_preimages_exist ! ( & preimages[ 0 ..10 ] , monitor) ;
2736
2736
test_preimages_exist ! ( & preimages[ 18 ..20 ] , monitor) ;
2737
2737
2738
2738
// But if we do it again, we'll prune 5-10
2739
- monitor. provide_latest_holder_commitment_tx_info ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..3 ] ) ) . unwrap ( ) ;
2739
+ monitor. provide_latest_holder_commitment_tx ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..3 ] ) ) . unwrap ( ) ;
2740
2740
secret[ 0 ..32 ] . clone_from_slice ( & hex:: decode ( "27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116" ) . unwrap ( ) ) ;
2741
2741
monitor. provide_secret ( 281474976710652 , secret. clone ( ) ) . unwrap ( ) ;
2742
2742
assert_eq ! ( monitor. payment_preimages. len( ) , 5 ) ;
0 commit comments