@@ -1052,8 +1052,6 @@ impl TryFrom<HolderSignedTx> for CommitmentHTLCData {
10521052
10531053#[ derive( Clone , PartialEq ) ]
10541054struct FundingScope {
1055- script_pubkey : ScriptBuf ,
1056- redeem_script : ScriptBuf ,
10571055 channel_parameters : ChannelTransactionParameters ,
10581056
10591057 current_counterparty_commitment_txid : Option < Txid > ,
@@ -1090,53 +1088,14 @@ impl FundingScope {
10901088 }
10911089}
10921090
1093- impl Writeable for FundingScope {
1094- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1095- write_tlv_fields ! ( w, {
1096- ( 1 , self . channel_parameters, ( required: ReadableArgs , None ) ) ,
1097- ( 3 , self . current_counterparty_commitment_txid, required) ,
1098- ( 5 , self . prev_counterparty_commitment_txid, option) ,
1099- ( 7 , self . current_holder_commitment_tx, required) ,
1100- ( 9 , self . prev_holder_commitment_tx, option) ,
1101- ( 11 , self . counterparty_claimable_outpoints, required) ,
1102- } ) ;
1103- Ok ( ( ) )
1104- }
1105- }
1106-
1107- impl Readable for FundingScope {
1108- fn read < R : io:: Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1109- let mut channel_parameters = RequiredWrapper ( None ) ;
1110- let mut current_counterparty_commitment_txid = RequiredWrapper ( None ) ;
1111- let mut prev_counterparty_commitment_txid = None ;
1112- let mut current_holder_commitment_tx = RequiredWrapper ( None ) ;
1113- let mut prev_holder_commitment_tx = None ;
1114- let mut counterparty_claimable_outpoints = RequiredWrapper ( None ) ;
1115-
1116- read_tlv_fields ! ( r, {
1117- ( 1 , channel_parameters, ( required: ReadableArgs , None ) ) ,
1118- ( 3 , current_counterparty_commitment_txid, required) ,
1119- ( 5 , prev_counterparty_commitment_txid, option) ,
1120- ( 7 , current_holder_commitment_tx, required) ,
1121- ( 9 , prev_holder_commitment_tx, option) ,
1122- ( 11 , counterparty_claimable_outpoints, required) ,
1123- } ) ;
1124-
1125- let channel_parameters: ChannelTransactionParameters = channel_parameters. 0 . unwrap ( ) ;
1126- let redeem_script = channel_parameters. make_funding_redeemscript ( ) ;
1127-
1128- Ok ( Self {
1129- script_pubkey : redeem_script. to_p2wsh ( ) ,
1130- redeem_script,
1131- channel_parameters,
1132- current_counterparty_commitment_txid : current_counterparty_commitment_txid. 0 . unwrap ( ) ,
1133- prev_counterparty_commitment_txid,
1134- current_holder_commitment_tx : current_holder_commitment_tx. 0 . unwrap ( ) ,
1135- prev_holder_commitment_tx,
1136- counterparty_claimable_outpoints : counterparty_claimable_outpoints. 0 . unwrap ( ) ,
1137- } )
1138- }
1139- }
1091+ impl_writeable_tlv_based ! ( FundingScope , {
1092+ ( 1 , channel_parameters, ( required: ReadableArgs , None ) ) ,
1093+ ( 3 , current_counterparty_commitment_txid, required) ,
1094+ ( 5 , prev_counterparty_commitment_txid, option) ,
1095+ ( 7 , current_holder_commitment_tx, required) ,
1096+ ( 9 , prev_holder_commitment_tx, option) ,
1097+ ( 11 , counterparty_claimable_outpoints, required) ,
1098+ } ) ;
11401099
11411100#[ derive( Clone , PartialEq ) ]
11421101pub ( crate ) struct ChannelMonitorImpl < Signer : EcdsaChannelSigner > {
@@ -1417,12 +1376,14 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
14171376 let funding_outpoint = self . get_funding_txo ( ) ;
14181377 writer. write_all ( & funding_outpoint. txid [ ..] ) ?;
14191378 writer. write_all ( & funding_outpoint. index . to_be_bytes ( ) ) ?;
1420- self . funding . script_pubkey . write ( writer) ?;
1379+ let redeem_script = self . funding . channel_parameters . make_funding_redeemscript ( ) ;
1380+ let script_pubkey = redeem_script. to_p2wsh ( ) ;
1381+ script_pubkey. write ( writer) ?;
14211382 self . funding . current_counterparty_commitment_txid . write ( writer) ?;
14221383 self . funding . prev_counterparty_commitment_txid . write ( writer) ?;
14231384
14241385 self . counterparty_commitment_params . write ( writer) ?;
1425- self . funding . redeem_script . write ( writer) ?;
1386+ redeem_script. write ( writer) ?;
14261387 self . funding . channel_parameters . channel_value_satoshis . write ( writer) ?;
14271388
14281389 match self . their_cur_per_commitment_points {
@@ -1741,8 +1702,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
17411702
17421703 Self :: from_impl ( ChannelMonitorImpl {
17431704 funding : FundingScope {
1744- script_pubkey : funding_script,
1745- redeem_script : funding_redeem_script,
17461705 channel_parameters : channel_parameters. clone ( ) ,
17471706
17481707 current_counterparty_commitment_txid : None ,
@@ -1979,7 +1938,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
19791938 for funding in core:: iter:: once ( & lock. funding ) . chain ( & lock. pending_funding ) {
19801939 let funding_outpoint = funding. funding_outpoint ( ) ;
19811940 log_trace ! ( & logger, "Registering funding outpoint {} with the filter to monitor confirmations" , & funding_outpoint) ;
1982- filter. register_tx ( & funding_outpoint. txid , & funding. script_pubkey ) ;
1941+ let script_pubkey = funding. channel_parameters . make_funding_redeemscript ( ) . to_p2wsh ( ) ;
1942+ filter. register_tx ( & funding_outpoint. txid , & script_pubkey) ;
19831943 }
19841944 for ( txid, outputs) in lock. get_outputs_to_watch ( ) . iter ( ) {
19851945 for ( index, script_pubkey) in outputs. iter ( ) {
@@ -3706,8 +3666,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
37063666 where
37073667 L :: Target : Logger ,
37083668 {
3709- let redeem_script = channel_parameters. make_funding_redeemscript ( ) ;
3710- let script_pubkey = redeem_script. to_p2wsh ( ) ;
37113669 let alternative_counterparty_commitment_txid =
37123670 alternative_counterparty_commitment_tx. trust ( ) . txid ( ) ;
37133671
@@ -3767,8 +3725,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
37673725
37683726 // TODO(splicing): Enforce any necessary RBF validity checks.
37693727 let alternative_funding = FundingScope {
3770- script_pubkey : script_pubkey. clone ( ) ,
3771- redeem_script,
37723728 channel_parameters : channel_parameters. clone ( ) ,
37733729 current_counterparty_commitment_txid : Some ( alternative_counterparty_commitment_txid) ,
37743730 prev_counterparty_commitment_txid : None ,
@@ -3810,6 +3766,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
38103766 }
38113767 }
38123768
3769+ let script_pubkey = channel_parameters. make_funding_redeemscript ( ) . to_p2wsh ( ) ;
38133770 self . outputs_to_watch . insert (
38143771 alternative_funding_outpoint. txid ,
38153772 vec ! [ ( alternative_funding_outpoint. index as u32 , script_pubkey) ] ,
@@ -4015,14 +3972,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40153972 self . latest_update_id
40163973 }
40173974
3975+ /// Returns the outpoint we are currently monitoring the chain for spends. This will change for
3976+ /// every splice that has reached its intended confirmation depth.
40183977 #[ rustfmt:: skip]
40193978 fn get_funding_txo ( & self ) -> OutPoint {
40203979 self . funding . channel_parameters . funding_outpoint
40213980 . expect ( "Funding outpoint must be set for active monitor" )
40223981 }
40233982
3983+ /// Returns the P2WSH script we are currently monitoring the chain for spends. This will change
3984+ /// for every splice that has reached its intended confirmation depth.
40243985 fn get_funding_script ( & self ) -> ScriptBuf {
4025- self . funding . script_pubkey . clone ( )
3986+ self . funding . channel_parameters . make_funding_redeemscript ( ) . to_p2wsh ( )
40263987 }
40273988
40283989 pub fn channel_id ( & self ) -> ChannelId {
@@ -4713,7 +4674,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
47134674 & self . funding . channel_parameters , & self . funding . current_holder_commitment_tx ,
47144675 & self . onchain_tx_handler . secp_ctx ,
47154676 ) . expect ( "sign holder commitment" ) ;
4716- self . funding . current_holder_commitment_tx . add_holder_sig ( & self . funding . redeem_script , sig)
4677+ let redeem_script = self . funding . channel_parameters . make_funding_redeemscript ( ) ;
4678+ self . funding . current_holder_commitment_tx . add_holder_sig ( & redeem_script, sig)
47174679 } ;
47184680 let mut holder_transactions = vec ! [ commitment_tx] ;
47194681 // When anchor outputs are present, the HTLC transactions are only final once the commitment
@@ -5683,12 +5645,12 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
56835645 txid : Readable :: read ( reader) ?,
56845646 index : Readable :: read ( reader) ?,
56855647 } ;
5686- let funding_script = Readable :: read ( reader) ?;
5648+ let _funding_script : ScriptBuf = Readable :: read ( reader) ?;
56875649 let current_counterparty_commitment_txid = Readable :: read ( reader) ?;
56885650 let prev_counterparty_commitment_txid = Readable :: read ( reader) ?;
56895651
56905652 let counterparty_commitment_params = Readable :: read ( reader) ?;
5691- let funding_redeemscript = Readable :: read ( reader) ?;
5653+ let _funding_redeemscript : ScriptBuf = Readable :: read ( reader) ?;
56925654 let channel_value_satoshis = Readable :: read ( reader) ?;
56935655
56945656 let their_cur_per_commitment_points = {
@@ -5969,8 +5931,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
59695931
59705932 Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
59715933 funding : FundingScope {
5972- script_pubkey : funding_script,
5973- redeem_script : funding_redeemscript,
59745934 channel_parameters,
59755935
59765936 current_counterparty_commitment_txid,
0 commit comments