@@ -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 ( ) {
@@ -3709,8 +3669,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3709
3669
where
3710
3670
L :: Target : Logger ,
3711
3671
{
3712
- let redeem_script = channel_parameters. make_funding_redeemscript ( ) ;
3713
- let script_pubkey = redeem_script. to_p2wsh ( ) ;
3714
3672
let alternative_counterparty_commitment_txid =
3715
3673
alternative_counterparty_commitment_tx. trust ( ) . txid ( ) ;
3716
3674
@@ -3770,8 +3728,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3770
3728
3771
3729
// TODO(splicing): Enforce any necessary RBF validity checks.
3772
3730
let alternative_funding = FundingScope {
3773
- script_pubkey : script_pubkey. clone ( ) ,
3774
- redeem_script,
3775
3731
channel_parameters : channel_parameters. clone ( ) ,
3776
3732
current_counterparty_commitment_txid : Some ( alternative_counterparty_commitment_txid) ,
3777
3733
prev_counterparty_commitment_txid : None ,
@@ -3813,6 +3769,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3813
3769
}
3814
3770
}
3815
3771
3772
+ let script_pubkey = channel_parameters. make_funding_redeemscript ( ) . to_p2wsh ( ) ;
3816
3773
self . outputs_to_watch . insert (
3817
3774
alternative_funding_outpoint. txid ,
3818
3775
vec ! [ ( alternative_funding_outpoint. index as u32 , script_pubkey) ] ,
@@ -4018,14 +3975,18 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4018
3975
self . latest_update_id
4019
3976
}
4020
3977
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.
4021
3980
#[ rustfmt:: skip]
4022
3981
fn get_funding_txo ( & self ) -> OutPoint {
4023
3982
self . funding . channel_parameters . funding_outpoint
4024
3983
. expect ( "Funding outpoint must be set for active monitor" )
4025
3984
}
4026
3985
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.
4027
3988
fn get_funding_script ( & self ) -> ScriptBuf {
4028
- self . funding . script_pubkey . clone ( )
3989
+ self . funding . channel_parameters . make_funding_redeemscript ( ) . to_p2wsh ( )
4029
3990
}
4030
3991
4031
3992
pub fn channel_id ( & self ) -> ChannelId {
@@ -4716,7 +4677,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4716
4677
& self . funding . channel_parameters , & self . funding . current_holder_commitment_tx ,
4717
4678
& self . onchain_tx_handler . secp_ctx ,
4718
4679
) . 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)
4720
4682
} ;
4721
4683
let mut holder_transactions = vec ! [ commitment_tx] ;
4722
4684
// 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
5686
5648
txid : Readable :: read ( reader) ?,
5687
5649
index : Readable :: read ( reader) ?,
5688
5650
} ;
5689
- let funding_script = Readable :: read ( reader) ?;
5651
+ let _funding_script : ScriptBuf = Readable :: read ( reader) ?;
5690
5652
let current_counterparty_commitment_txid = Readable :: read ( reader) ?;
5691
5653
let prev_counterparty_commitment_txid = Readable :: read ( reader) ?;
5692
5654
5693
5655
let counterparty_commitment_params = Readable :: read ( reader) ?;
5694
- let funding_redeemscript = Readable :: read ( reader) ?;
5656
+ let _funding_redeemscript : ScriptBuf = Readable :: read ( reader) ?;
5695
5657
let channel_value_satoshis = Readable :: read ( reader) ?;
5696
5658
5697
5659
let their_cur_per_commitment_points = {
@@ -5972,8 +5934,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
5972
5934
5973
5935
Ok ( ( best_block. block_hash , ChannelMonitor :: from_impl ( ChannelMonitorImpl {
5974
5936
funding : FundingScope {
5975
- script_pubkey : funding_script,
5976
- redeem_script : funding_redeemscript,
5977
5937
channel_parameters,
5978
5938
5979
5939
current_counterparty_commitment_txid,
0 commit comments