@@ -1052,8 +1052,6 @@ impl TryFrom<HolderSignedTx> for CommitmentHTLCData {
1052
1052
1053
1053
#[ derive( Clone , PartialEq ) ]
1054
1054
struct FundingScope {
1055
- script_pubkey : ScriptBuf ,
1056
- redeem_script : ScriptBuf ,
1057
1055
channel_parameters : ChannelTransactionParameters ,
1058
1056
1059
1057
current_counterparty_commitment_txid : Option < Txid > ,
@@ -1090,53 +1088,14 @@ impl FundingScope {
1090
1088
}
1091
1089
}
1092
1090
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
+ } ) ;
1140
1099
1141
1100
#[ derive( Clone , PartialEq ) ]
1142
1101
pub ( crate ) struct ChannelMonitorImpl < Signer : EcdsaChannelSigner > {
@@ -1417,12 +1376,14 @@ impl<Signer: EcdsaChannelSigner> Writeable for ChannelMonitorImpl<Signer> {
1417
1376
let funding_outpoint = self . get_funding_txo ( ) ;
1418
1377
writer. write_all ( & funding_outpoint. txid [ ..] ) ?;
1419
1378
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) ?;
1421
1382
self . funding . current_counterparty_commitment_txid . write ( writer) ?;
1422
1383
self . funding . prev_counterparty_commitment_txid . write ( writer) ?;
1423
1384
1424
1385
self . counterparty_commitment_params . write ( writer) ?;
1425
- self . funding . redeem_script . write ( writer) ?;
1386
+ redeem_script. write ( writer) ?;
1426
1387
self . funding . channel_parameters . channel_value_satoshis . write ( writer) ?;
1427
1388
1428
1389
match self . their_cur_per_commitment_points {
@@ -1741,8 +1702,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1741
1702
1742
1703
Self :: from_impl ( ChannelMonitorImpl {
1743
1704
funding : FundingScope {
1744
- script_pubkey : funding_script,
1745
- redeem_script : funding_redeem_script,
1746
1705
channel_parameters : channel_parameters. clone ( ) ,
1747
1706
1748
1707
current_counterparty_commitment_txid : None ,
@@ -1979,7 +1938,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1979
1938
for funding in core:: iter:: once ( & lock. funding ) . chain ( & lock. pending_funding ) {
1980
1939
let funding_outpoint = funding. funding_outpoint ( ) ;
1981
1940
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) ;
1983
1943
}
1984
1944
for ( txid, outputs) in lock. get_outputs_to_watch ( ) . iter ( ) {
1985
1945
for ( index, script_pubkey) in outputs. iter ( ) {
@@ -3706,8 +3666,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3706
3666
where
3707
3667
L :: Target : Logger ,
3708
3668
{
3709
- let redeem_script = channel_parameters. make_funding_redeemscript ( ) ;
3710
- let script_pubkey = redeem_script. to_p2wsh ( ) ;
3711
3669
let alternative_counterparty_commitment_txid =
3712
3670
alternative_counterparty_commitment_tx. trust ( ) . txid ( ) ;
3713
3671
@@ -3767,8 +3725,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3767
3725
3768
3726
// TODO(splicing): Enforce any necessary RBF validity checks.
3769
3727
let alternative_funding = FundingScope {
3770
- script_pubkey : script_pubkey. clone ( ) ,
3771
- redeem_script,
3772
3728
channel_parameters : channel_parameters. clone ( ) ,
3773
3729
current_counterparty_commitment_txid : Some ( alternative_counterparty_commitment_txid) ,
3774
3730
prev_counterparty_commitment_txid : None ,
@@ -3810,6 +3766,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3810
3766
}
3811
3767
}
3812
3768
3769
+ let script_pubkey = channel_parameters. make_funding_redeemscript ( ) . to_p2wsh ( ) ;
3813
3770
self . outputs_to_watch . insert (
3814
3771
alternative_funding_outpoint. txid ,
3815
3772
vec ! [ ( alternative_funding_outpoint. index as u32 , script_pubkey) ] ,
@@ -4015,14 +3972,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4015
3972
self . latest_update_id
4016
3973
}
4017
3974
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.
4018
3977
#[ rustfmt:: skip]
4019
3978
fn get_funding_txo ( & self ) -> OutPoint {
4020
3979
self . funding . channel_parameters . funding_outpoint
4021
3980
. expect ( "Funding outpoint must be set for active monitor" )
4022
3981
}
4023
3982
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.
4024
3985
fn get_funding_script ( & self ) -> ScriptBuf {
4025
- self . funding . script_pubkey . clone ( )
3986
+ self . funding . channel_parameters . make_funding_redeemscript ( ) . to_p2wsh ( )
4026
3987
}
4027
3988
4028
3989
pub fn channel_id ( & self ) -> ChannelId {
@@ -4713,7 +4674,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4713
4674
& self . funding . channel_parameters , & self . funding . current_holder_commitment_tx ,
4714
4675
& self . onchain_tx_handler . secp_ctx ,
4715
4676
) . 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)
4717
4679
} ;
4718
4680
let mut holder_transactions = vec ! [ commitment_tx] ;
4719
4681
// 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
5683
5645
txid : Readable :: read ( reader) ?,
5684
5646
index : Readable :: read ( reader) ?,
5685
5647
} ;
5686
- let funding_script = Readable :: read ( reader) ?;
5648
+ let _funding_script : ScriptBuf = Readable :: read ( reader) ?;
5687
5649
let current_counterparty_commitment_txid = Readable :: read ( reader) ?;
5688
5650
let prev_counterparty_commitment_txid = Readable :: read ( reader) ?;
5689
5651
5690
5652
let counterparty_commitment_params = Readable :: read ( reader) ?;
5691
- let funding_redeemscript = Readable :: read ( reader) ?;
5653
+ let _funding_redeemscript : ScriptBuf = Readable :: read ( reader) ?;
5692
5654
let channel_value_satoshis = Readable :: read ( reader) ?;
5693
5655
5694
5656
let their_cur_per_commitment_points = {
@@ -5969,8 +5931,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
5969
5931
5970
5932
Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
5971
5933
funding : FundingScope {
5972
- script_pubkey : funding_script,
5973
- redeem_script : funding_redeemscript,
5974
5934
channel_parameters,
5975
5935
5976
5936
current_counterparty_commitment_txid,
0 commit comments