@@ -1460,7 +1460,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1460
1460
Ok ( ( ) )
1461
1461
}
1462
1462
1463
- fn funding_created_signature < L : Deref > ( & mut self , sig : & Signature , logger : & L ) -> Result < ( Transaction , CommitmentTransaction , Signature ) , ChannelError > where L :: Target : Logger {
1463
+ fn funding_created_signature < L : Deref > ( & mut self , sig : & Signature , logger : & L ) -> Result < ( Txid , CommitmentTransaction , Signature ) , ChannelError > where L :: Target : Logger {
1464
1464
let funding_script = self . get_funding_redeemscript ( ) ;
1465
1465
1466
1466
let keys = self . build_holder_transaction_keys ( self . cur_holder_commitment_transaction_number ) ?;
@@ -1474,12 +1474,12 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1474
1474
let counterparty_keys = self . build_remote_transaction_keys ( ) ?;
1475
1475
let counterparty_initial_commitment_tx = self . build_commitment_transaction ( self . cur_counterparty_commitment_transaction_number , & counterparty_keys, false , false , self . feerate_per_kw , logger) . 0 ;
1476
1476
1477
- let counterparty_initial_commitment_bitcoin_tx = counterparty_initial_commitment_tx. build ( & self . get_channel_parameters ( false ) , & self . secp_ctx ) . unwrap ( ) . 0 ;
1477
+ let counterparty_initial_commitment_txid = counterparty_initial_commitment_tx. calculate_txid ( & self . get_channel_parameters ( false ) , & self . secp_ctx ) ;
1478
1478
let counterparty_signature = self . holder_keys . sign_counterparty_commitment ( & counterparty_initial_commitment_tx, & self . secp_ctx )
1479
1479
. map_err ( |_| ChannelError :: Close ( "Failed to get signatures for new commitment_signed" . to_owned ( ) ) ) ?. 0 ;
1480
1480
1481
1481
// We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
1482
- Ok ( ( counterparty_initial_commitment_bitcoin_tx , initial_commitment_tx, counterparty_signature) )
1482
+ Ok ( ( counterparty_initial_commitment_txid , initial_commitment_tx, counterparty_signature) )
1483
1483
}
1484
1484
1485
1485
// Create a directed version of the channel static fields for the holder or the counterparty.
@@ -1512,7 +1512,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1512
1512
self . channel_transaction_parameters . funding_outpoint = Some ( funding_txo) ;
1513
1513
self . holder_keys . ready_channel ( & self . channel_transaction_parameters ) ;
1514
1514
1515
- let ( counterparty_initial_commitment_bitcoin_tx , initial_commitment_tx, signature) = match self . funding_created_signature ( & msg. signature , logger) {
1515
+ let ( counterparty_initial_commitment_txid , initial_commitment_tx, signature) = match self . funding_created_signature ( & msg. signature , logger) {
1516
1516
Ok ( res) => res,
1517
1517
Err ( e) => {
1518
1518
self . channel_transaction_parameters . funding_outpoint = None ;
@@ -1540,7 +1540,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1540
1540
self . get_commitment_transaction_number_obscure_factor ( ) ,
1541
1541
holder_commitment_tx) ;
1542
1542
1543
- channel_monitor. provide_latest_counterparty_commitment_tx ( & counterparty_initial_commitment_bitcoin_tx , Vec :: new ( ) , self . cur_counterparty_commitment_transaction_number , self . counterparty_cur_commitment_point . unwrap ( ) , logger) ;
1543
+ channel_monitor. provide_latest_counterparty_commitment_tx ( counterparty_initial_commitment_txid , Vec :: new ( ) , self . cur_counterparty_commitment_transaction_number , self . counterparty_cur_commitment_point . unwrap ( ) , logger) ;
1544
1544
1545
1545
self . channel_state = ChannelState :: FundingSent as u32 ;
1546
1546
self . channel_id = funding_txo. to_channel_id ( ) ;
@@ -1573,7 +1573,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1573
1573
let counterparty_keys = self . build_remote_transaction_keys ( ) ?;
1574
1574
let counterparty_initial_commitment_tx = self . build_commitment_transaction ( self . cur_counterparty_commitment_transaction_number , & counterparty_keys, false , false , self . feerate_per_kw , logger) . 0 ;
1575
1575
// TODO this is not integration tested
1576
- let counterparty_initial_commitment_bitcoin_tx = counterparty_initial_commitment_tx. build ( & self . get_channel_parameters ( false ) , & self . secp_ctx ) . unwrap ( ) . 0 ;
1576
+ let counterparty_initial_commitment_txid = counterparty_initial_commitment_tx. calculate_txid ( & self . get_channel_parameters ( false ) , & self . secp_ctx ) ;
1577
1577
1578
1578
let holder_keys = self . build_holder_transaction_keys ( self . cur_holder_commitment_transaction_number ) ?;
1579
1579
let initial_commitment_tx = self . build_commitment_transaction ( self . cur_holder_commitment_transaction_number , & holder_keys, true , false , self . feerate_per_kw , logger) . 0 ;
@@ -1602,7 +1602,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
1602
1602
self . get_commitment_transaction_number_obscure_factor ( ) ,
1603
1603
holder_commitment_tx) ;
1604
1604
1605
- channel_monitor. provide_latest_counterparty_commitment_tx ( & counterparty_initial_commitment_bitcoin_tx , Vec :: new ( ) , self . cur_counterparty_commitment_transaction_number , self . counterparty_cur_commitment_point . unwrap ( ) , logger) ;
1605
+ channel_monitor. provide_latest_counterparty_commitment_tx ( counterparty_initial_commitment_txid , Vec :: new ( ) , self . cur_counterparty_commitment_transaction_number , self . counterparty_cur_commitment_point . unwrap ( ) , logger) ;
1606
1606
1607
1607
assert_eq ! ( self . channel_state & ( ChannelState :: MonitorUpdateFailed as u32 ) , 0 ) ; // We have no had any monitor(s) yet to fail update!
1608
1608
self . channel_state = ChannelState :: FundingSent as u32 ;
@@ -3849,7 +3849,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3849
3849
}
3850
3850
self . resend_order = RAACommitmentOrder :: RevokeAndACKFirst ;
3851
3851
3852
- let ( res, counterparty_commitment_tx , htlcs) = match self . send_commitment_no_state_update ( logger) {
3852
+ let ( res, counterparty_commitment_txid , htlcs) = match self . send_commitment_no_state_update ( logger) {
3853
3853
Ok ( ( res, ( counterparty_commitment_tx, mut htlcs) ) ) => {
3854
3854
// Update state now that we've passed all the can-fail calls...
3855
3855
let htlcs_no_ref: Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > =
@@ -3863,7 +3863,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3863
3863
let monitor_update = ChannelMonitorUpdate {
3864
3864
update_id : self . latest_monitor_update_id ,
3865
3865
updates : vec ! [ ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXInfo {
3866
- unsigned_commitment_tx : counterparty_commitment_tx . clone ( ) ,
3866
+ commitment_txid : counterparty_commitment_txid ,
3867
3867
htlc_outputs: htlcs. clone( ) ,
3868
3868
commitment_number: self . cur_counterparty_commitment_transaction_number,
3869
3869
their_revocation_point: self . counterparty_cur_commitment_point. unwrap( )
@@ -3875,7 +3875,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3875
3875
3876
3876
/// Only fails in case of bad keys. Used for channel_reestablish commitment_signed generation
3877
3877
/// when we shouldn't change HTLC/channel state.
3878
- fn send_commitment_no_state_update < L : Deref > ( & self , logger : & L ) -> Result < ( msgs:: CommitmentSigned , ( Transaction , Vec < ( HTLCOutputInCommitment , Option < & HTLCSource > ) > ) ) , ChannelError > where L :: Target : Logger {
3878
+ fn send_commitment_no_state_update < L : Deref > ( & self , logger : & L ) -> Result < ( msgs:: CommitmentSigned , ( Txid , Vec < ( HTLCOutputInCommitment , Option < & HTLCSource > ) > ) ) , ChannelError > where L :: Target : Logger {
3879
3879
let mut feerate_per_kw = self . feerate_per_kw ;
3880
3880
if let Some ( feerate) = self . pending_update_fee {
3881
3881
if self . is_outbound ( ) {
@@ -3885,7 +3885,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3885
3885
3886
3886
let counterparty_keys = self . build_remote_transaction_keys ( ) ?;
3887
3887
let counterparty_commitment_tx = self . build_commitment_transaction ( self . cur_counterparty_commitment_transaction_number , & counterparty_keys, false , true , feerate_per_kw, logger) ;
3888
- let counterparty_commitment_bitcoin_tx = counterparty_commitment_tx. 0 . build ( & self . get_channel_parameters ( false ) , & self . secp_ctx ) . unwrap ( ) . 0 ;
3888
+ let counterparty_commitment_txid = counterparty_commitment_tx. 0 . calculate_txid ( & self . get_channel_parameters ( false ) , & self . secp_ctx ) ;
3889
3889
let ( signature, htlc_signatures) ;
3890
3890
3891
3891
{
@@ -3900,13 +3900,13 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3900
3900
htlc_signatures = res. 1 ;
3901
3901
3902
3902
log_trace ! ( logger, "Signed remote commitment tx {} with redeemscript {} -> {}" ,
3903
- encode :: serialize_hex ( & counterparty_commitment_bitcoin_tx ) ,
3903
+ & counterparty_commitment_txid ,
3904
3904
encode:: serialize_hex( & self . get_funding_redeemscript( ) ) ,
3905
3905
log_bytes!( signature. serialize_compact( ) [ ..] ) ) ;
3906
3906
3907
3907
for ( ref htlc_sig, ref htlc) in htlc_signatures. iter ( ) . zip ( htlcs) {
3908
3908
log_trace ! ( logger, "Signed remote HTLC tx {} with redeemscript {} with pubkey {} -> {}" ,
3909
- encode:: serialize_hex( & chan_utils:: build_htlc_transaction( & counterparty_commitment_bitcoin_tx . txid ( ) , feerate_per_kw, self . get_holder_selected_contest_delay( ) , htlc, & counterparty_keys. broadcaster_delayed_payment_key, & counterparty_keys. revocation_key) ) ,
3909
+ encode:: serialize_hex( & chan_utils:: build_htlc_transaction( & counterparty_commitment_txid , feerate_per_kw, self . get_holder_selected_contest_delay( ) , htlc, & counterparty_keys. broadcaster_delayed_payment_key, & counterparty_keys. revocation_key) ) ,
3910
3910
encode:: serialize_hex( & chan_utils:: get_htlc_redeemscript( & htlc, & counterparty_keys) ) ,
3911
3911
log_bytes!( counterparty_keys. broadcaster_htlc_key. serialize( ) ) ,
3912
3912
log_bytes!( htlc_sig. serialize_compact( ) [ ..] ) ) ;
@@ -3917,7 +3917,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
3917
3917
channel_id : self . channel_id ,
3918
3918
signature,
3919
3919
htlc_signatures,
3920
- } , ( counterparty_commitment_bitcoin_tx , counterparty_commitment_tx. 2 ) ) )
3920
+ } , ( counterparty_commitment_txid , counterparty_commitment_tx. 2 ) ) )
3921
3921
}
3922
3922
3923
3923
/// Adds a pending outbound HTLC to this channel, and creates a signed commitment transaction
0 commit comments