@@ -571,6 +571,8 @@ pub struct ChannelMonitor {
571
571
key_storage : Storage ,
572
572
their_htlc_base_key : Option < PublicKey > ,
573
573
their_delayed_payment_base_key : Option < PublicKey > ,
574
+ funding_redeemscript : Option < Script > ,
575
+ channel_value_satoshis : Option < u64 > ,
574
576
// first is the idx of the first of the two revocation points
575
577
their_cur_revocation_points : Option < ( u64 , PublicKey , Option < PublicKey > ) > ,
576
578
@@ -696,6 +698,8 @@ impl PartialEq for ChannelMonitor {
696
698
self . key_storage != other. key_storage ||
697
699
self . their_htlc_base_key != other. their_htlc_base_key ||
698
700
self . their_delayed_payment_base_key != other. their_delayed_payment_base_key ||
701
+ self . funding_redeemscript != other. funding_redeemscript ||
702
+ self . channel_value_satoshis != other. channel_value_satoshis ||
699
703
self . their_cur_revocation_points != other. their_cur_revocation_points ||
700
704
self . our_to_self_delay != other. our_to_self_delay ||
701
705
self . their_to_self_delay != other. their_to_self_delay ||
@@ -743,6 +747,8 @@ impl ChannelMonitor {
743
747
} ,
744
748
their_htlc_base_key : None ,
745
749
their_delayed_payment_base_key : None ,
750
+ funding_redeemscript : None ,
751
+ channel_value_satoshis : None ,
746
752
their_cur_revocation_points : None ,
747
753
748
754
our_to_self_delay : our_to_self_delay,
@@ -1052,12 +1058,6 @@ impl ChannelMonitor {
1052
1058
Ok ( ( ) )
1053
1059
}
1054
1060
1055
- /// Panics if commitment_transaction_number_obscure_factor doesn't fit in 48 bits
1056
- pub ( super ) fn set_commitment_obscure_factor ( & mut self , commitment_transaction_number_obscure_factor : u64 ) {
1057
- assert ! ( commitment_transaction_number_obscure_factor < ( 1 << 48 ) ) ;
1058
- self . commitment_transaction_number_obscure_factor = commitment_transaction_number_obscure_factor;
1059
- }
1060
-
1061
1061
/// Allows this monitor to scan only for transactions which are applicable. Note that this is
1062
1062
/// optional, without it this monitor cannot be used in an SPV client, but you may wish to
1063
1063
/// avoid this (or call unset_funding_info) on a monitor you wish to send to a watchtower as it
@@ -1076,13 +1076,15 @@ impl ChannelMonitor {
1076
1076
}
1077
1077
1078
1078
/// We log these base keys at channel opening to being able to rebuild redeemscript in case of leaked revoked commit tx
1079
- pub ( super ) fn set_their_base_keys ( & mut self , their_htlc_base_key : & PublicKey , their_delayed_payment_base_key : & PublicKey ) {
1079
+ /// Panics if commitment_transaction_number_obscure_factor doesn't fit in 48 bits
1080
+ pub ( super ) fn set_basic_channel_info ( & mut self , their_htlc_base_key : & PublicKey , their_delayed_payment_base_key : & PublicKey , their_to_self_delay : u16 , funding_redeemscript : Script , channel_value_satoshis : u64 , commitment_transaction_number_obscure_factor : u64 ) {
1080
1081
self . their_htlc_base_key = Some ( their_htlc_base_key. clone ( ) ) ;
1081
1082
self . their_delayed_payment_base_key = Some ( their_delayed_payment_base_key. clone ( ) ) ;
1082
- }
1083
-
1084
- pub ( super ) fn set_their_to_self_delay ( & mut self , their_to_self_delay : u16 ) {
1085
1083
self . their_to_self_delay = Some ( their_to_self_delay) ;
1084
+ self . funding_redeemscript = Some ( funding_redeemscript) ;
1085
+ self . channel_value_satoshis = Some ( channel_value_satoshis) ;
1086
+ assert ! ( commitment_transaction_number_obscure_factor < ( 1 << 48 ) ) ;
1087
+ self . commitment_transaction_number_obscure_factor = commitment_transaction_number_obscure_factor;
1086
1088
}
1087
1089
1088
1090
pub ( super ) fn unset_funding_info ( & mut self ) {
@@ -1175,6 +1177,8 @@ impl ChannelMonitor {
1175
1177
1176
1178
writer. write_all ( & self . their_htlc_base_key . as_ref ( ) . unwrap ( ) . serialize ( ) ) ?;
1177
1179
writer. write_all ( & self . their_delayed_payment_base_key . as_ref ( ) . unwrap ( ) . serialize ( ) ) ?;
1180
+ self . funding_redeemscript . as_ref ( ) . unwrap ( ) . write ( writer) ?;
1181
+ self . channel_value_satoshis . unwrap ( ) . write ( writer) ?;
1178
1182
1179
1183
match self . their_cur_revocation_points {
1180
1184
Some ( ( idx, pubkey, second_option) ) => {
@@ -2994,6 +2998,8 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
2994
2998
2995
2999
let their_htlc_base_key = Some ( Readable :: read ( reader) ?) ;
2996
3000
let their_delayed_payment_base_key = Some ( Readable :: read ( reader) ?) ;
3001
+ let funding_redeemscript = Some ( Readable :: read ( reader) ?) ;
3002
+ let channel_value_satoshis = Some ( Readable :: read ( reader) ?) ;
2997
3003
2998
3004
let their_cur_revocation_points = {
2999
3005
let first_idx = <U48 as Readable < R > >:: read ( reader) ?. 0 ;
@@ -3214,6 +3220,8 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
3214
3220
key_storage,
3215
3221
their_htlc_base_key,
3216
3222
their_delayed_payment_base_key,
3223
+ funding_redeemscript,
3224
+ channel_value_satoshis,
3217
3225
their_cur_revocation_points,
3218
3226
3219
3227
our_to_self_delay,
@@ -3695,7 +3703,7 @@ mod tests {
3695
3703
// Prune with one old state and a local commitment tx holding a few overlaps with the
3696
3704
// old state.
3697
3705
let mut monitor = ChannelMonitor :: new ( & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) , & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) , & SecretKey :: from_slice ( & [ 44 ; 32 ] ) . unwrap ( ) , & SecretKey :: from_slice ( & [ 44 ; 32 ] ) . unwrap ( ) , & PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 45 ; 32 ] ) . unwrap ( ) ) , 0 , Script :: new ( ) , logger. clone ( ) ) ;
3698
- monitor. set_their_to_self_delay ( 10 ) ;
3706
+ monitor. their_to_self_delay = Some ( 10 ) ;
3699
3707
3700
3708
monitor. provide_latest_local_commitment_tx_info ( dummy_tx. clone ( ) , dummy_keys ! ( ) , 0 , preimages_to_local_htlcs ! ( preimages[ 0 ..10 ] ) ) ;
3701
3709
monitor. provide_latest_remote_commitment_tx_info ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key) ;
0 commit comments