@@ -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 ( ) {
@@ -3709,8 +3669,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
37093669 where
37103670 L :: Target : Logger ,
37113671 {
3712- let redeem_script = channel_parameters. make_funding_redeemscript ( ) ;
3713- let script_pubkey = redeem_script. to_p2wsh ( ) ;
37143672 let alternative_counterparty_commitment_txid =
37153673 alternative_counterparty_commitment_tx. trust ( ) . txid ( ) ;
37163674
@@ -3770,8 +3728,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
37703728
37713729 // TODO(splicing): Enforce any necessary RBF validity checks.
37723730 let alternative_funding = FundingScope {
3773- script_pubkey : script_pubkey. clone ( ) ,
3774- redeem_script,
37753731 channel_parameters : channel_parameters. clone ( ) ,
37763732 current_counterparty_commitment_txid : Some ( alternative_counterparty_commitment_txid) ,
37773733 prev_counterparty_commitment_txid : None ,
@@ -3813,6 +3769,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
38133769 }
38143770 }
38153771
3772+ let script_pubkey = channel_parameters. make_funding_redeemscript ( ) . to_p2wsh ( ) ;
38163773 self . outputs_to_watch . insert (
38173774 alternative_funding_outpoint. txid ,
38183775 vec ! [ ( alternative_funding_outpoint. index as u32 , script_pubkey) ] ,
@@ -4018,14 +3975,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40183975 self . latest_update_id
40193976 }
40203977
3978+ /// Returns the outpoint we are currently monitoring the chain for spends. This will change for
3979+ /// every splice that has reached its intended confirmation depth.
40213980 #[ rustfmt:: skip]
40223981 fn get_funding_txo ( & self ) -> OutPoint {
40233982 self . funding . channel_parameters . funding_outpoint
40243983 . expect ( "Funding outpoint must be set for active monitor" )
40253984 }
40263985
3986+ /// Returns the P2WSH script we are currently monitoring the chain for spends. This will change
3987+ /// for every splice that has reached its intended confirmation depth.
40273988 fn get_funding_script ( & self ) -> ScriptBuf {
4028- self . funding . script_pubkey . clone ( )
3989+ self . funding . channel_parameters . make_funding_redeemscript ( ) . to_p2wsh ( )
40293990 }
40303991
40313992 pub fn channel_id ( & self ) -> ChannelId {
@@ -4716,7 +4677,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
47164677 & self . funding . channel_parameters , & self . funding . current_holder_commitment_tx ,
47174678 & self . onchain_tx_handler . secp_ctx ,
47184679 ) . expect ( "sign holder commitment" ) ;
4719- self . funding . current_holder_commitment_tx . add_holder_sig ( & self . funding . redeem_script , sig)
4680+ let redeem_script = self . funding . channel_parameters . make_funding_redeemscript ( ) ;
4681+ self . funding . current_holder_commitment_tx . add_holder_sig ( & redeem_script, sig)
47204682 } ;
47214683 let mut holder_transactions = vec ! [ commitment_tx] ;
47224684 // When anchor outputs are present, the HTLC transactions are only final once the commitment
@@ -5686,12 +5648,12 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
56865648 txid : Readable :: read ( reader) ?,
56875649 index : Readable :: read ( reader) ?,
56885650 } ;
5689- let funding_script = Readable :: read ( reader) ?;
5651+ let _funding_script : ScriptBuf = Readable :: read ( reader) ?;
56905652 let current_counterparty_commitment_txid = Readable :: read ( reader) ?;
56915653 let prev_counterparty_commitment_txid = Readable :: read ( reader) ?;
56925654
56935655 let counterparty_commitment_params = Readable :: read ( reader) ?;
5694- let funding_redeemscript = Readable :: read ( reader) ?;
5656+ let _funding_redeemscript : ScriptBuf = Readable :: read ( reader) ?;
56955657 let channel_value_satoshis = Readable :: read ( reader) ?;
56965658
56975659 let their_cur_per_commitment_points = {
@@ -5972,8 +5934,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
59725934
59735935 Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
59745936 funding : FundingScope {
5975- script_pubkey : funding_script,
5976- redeem_script : funding_redeemscript,
59775937 channel_parameters,
59785938
59795939 current_counterparty_commitment_txid,
0 commit comments