@@ -1516,7 +1516,7 @@ impl<Signer: Sign> Channel<Signer> {
1516
1516
& self . get_counterparty_pubkeys ( ) . funding_pubkey
1517
1517
}
1518
1518
1519
- pub fn funding_created < L : Deref > ( & mut self , msg : & msgs:: FundingCreated , logger : & L ) -> Result < ( msgs:: FundingSigned , ChannelMonitor < Signer > ) , ChannelError > where L :: Target : Logger {
1519
+ pub fn funding_created < L : Deref > ( & mut self , msg : & msgs:: FundingCreated , last_block_hash : BlockHash , logger : & L ) -> Result < ( msgs:: FundingSigned , ChannelMonitor < Signer > ) , ChannelError > where L :: Target : Logger {
1520
1520
if self . is_outbound ( ) {
1521
1521
return Err ( ChannelError :: Close ( "Received funding_created for an outbound channel?" . to_owned ( ) ) ) ;
1522
1522
}
@@ -1570,7 +1570,7 @@ impl<Signer: Sign> Channel<Signer> {
1570
1570
& self . channel_transaction_parameters ,
1571
1571
funding_redeemscript. clone ( ) , self . channel_value_satoshis ,
1572
1572
obscure_factor,
1573
- holder_commitment_tx) ;
1573
+ holder_commitment_tx, last_block_hash ) ;
1574
1574
1575
1575
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) ;
1576
1576
@@ -1587,7 +1587,7 @@ impl<Signer: Sign> Channel<Signer> {
1587
1587
1588
1588
/// Handles a funding_signed message from the remote end.
1589
1589
/// If this call is successful, broadcast the funding transaction (and not before!)
1590
- pub fn funding_signed < L : Deref > ( & mut self , msg : & msgs:: FundingSigned , logger : & L ) -> Result < ChannelMonitor < Signer > , ChannelError > where L :: Target : Logger {
1590
+ pub fn funding_signed < L : Deref > ( & mut self , msg : & msgs:: FundingSigned , last_block_hash : BlockHash , logger : & L ) -> Result < ChannelMonitor < Signer > , ChannelError > where L :: Target : Logger {
1591
1591
if !self . is_outbound ( ) {
1592
1592
return Err ( ChannelError :: Close ( "Received funding_signed for an inbound channel?" . to_owned ( ) ) ) ;
1593
1593
}
@@ -1640,7 +1640,7 @@ impl<Signer: Sign> Channel<Signer> {
1640
1640
& self . channel_transaction_parameters ,
1641
1641
funding_redeemscript. clone ( ) , self . channel_value_satoshis ,
1642
1642
obscure_factor,
1643
- holder_commitment_tx) ;
1643
+ holder_commitment_tx, last_block_hash ) ;
1644
1644
1645
1645
channel_monitor. provide_latest_counterparty_commitment_tx ( counterparty_initial_bitcoin_tx. txid , Vec :: new ( ) , self . cur_counterparty_commitment_transaction_number , self . counterparty_cur_commitment_point . unwrap ( ) , logger) ;
1646
1646
@@ -4910,6 +4910,8 @@ mod tests {
4910
4910
let secp_ctx = Secp256k1 :: new ( ) ;
4911
4911
let seed = [ 42 ; 32 ] ;
4912
4912
let network = Network :: Testnet ;
4913
+ let chain_hash = genesis_block ( network) . header . block_hash ( ) ;
4914
+ let last_block_hash = chain_hash;
4913
4915
let keys_provider = test_utils:: TestKeysInterface :: new ( & seed, network) ;
4914
4916
4915
4917
// Go through the flow of opening a channel between two nodes.
@@ -4920,7 +4922,7 @@ mod tests {
4920
4922
let mut node_a_chan = Channel :: < EnforcingSigner > :: new_outbound ( & & feeest, & & keys_provider, node_b_node_id, 10000000 , 100000 , 42 , & config) . unwrap ( ) ;
4921
4923
4922
4924
// Create Node B's channel by receiving Node A's open_channel message
4923
- let open_channel_msg = node_a_chan. get_open_channel ( genesis_block ( network ) . header . block_hash ( ) ) ;
4925
+ let open_channel_msg = node_a_chan. get_open_channel ( chain_hash ) ;
4924
4926
let node_b_node_id = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 7 ; 32 ] ) . unwrap ( ) ) ;
4925
4927
let mut node_b_chan = Channel :: < EnforcingSigner > :: new_from_req ( & & feeest, & & keys_provider, node_b_node_id, InitFeatures :: known ( ) , & open_channel_msg, 7 , & config) . unwrap ( ) ;
4926
4928
@@ -4935,10 +4937,10 @@ mod tests {
4935
4937
} ] } ;
4936
4938
let funding_outpoint = OutPoint { txid : tx. txid ( ) , index : 0 } ;
4937
4939
let funding_created_msg = node_a_chan. get_outbound_funding_created ( funding_outpoint, & & logger) . unwrap ( ) ;
4938
- let ( funding_signed_msg, _) = node_b_chan. funding_created ( & funding_created_msg, & & logger) . unwrap ( ) ;
4940
+ let ( funding_signed_msg, _) = node_b_chan. funding_created ( & funding_created_msg, last_block_hash , & & logger) . unwrap ( ) ;
4939
4941
4940
4942
// Node B --> Node A: funding signed
4941
- let _ = node_a_chan. funding_signed ( & funding_signed_msg, & & logger) ;
4943
+ let _ = node_a_chan. funding_signed ( & funding_signed_msg, last_block_hash , & & logger) ;
4942
4944
4943
4945
// Now disconnect the two nodes and check that the commitment point in
4944
4946
// Node B's channel_reestablish message is sane.
0 commit comments