You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f - Check KeysInterface::get_shutdown_scriptpubkey
Check that the user-provided shutdown_scriptpubkey is compatible with
the counterparty's features (option_shutdown_anysegwit).
TODO: Implement for ChannelManager::close_channel
TODO: Add unit tests
if !shutdown_scriptpubkey.is_compatible(&their_features){
604
+
returnErr(APIError::APIMisuseError{err:format!("Provided a scriptpubkey format not accepted by peer. script: ({})", shutdown_scriptpubkey.clone().into_inner().to_bytes().to_hex())});
if !shutdown_scriptpubkey.is_compatible(&their_features){
856
+
returnErr(ChannelError::Close(format!("Provided a scriptpubkey format not accepted by peer. script: ({})", shutdown_scriptpubkey.clone().into_inner().to_bytes().to_hex())));
// If we have any LocalAnnounced updates we'll probably just get back a update_fail_htlc
3274
+
// immediately after the commitment dance, but we can send a Shutdown cause we won't send
3275
+
// any further commitment updates after we set LocalShutdownSent.
3276
+
let send_shutdown = (self.channel_state&ChannelState::LocalShutdownSentasu32) != ChannelState::LocalShutdownSentasu32;
3277
+
3278
+
let shutdown_scriptpubkey = matchself.shutdown_scriptpubkey{
3279
+
Some(_) => None,
3280
+
None => {
3281
+
assert!(send_shutdown);
3282
+
let shutdown_scriptpubkey = keys_provider.get_shutdown_scriptpubkey();
3283
+
if !shutdown_scriptpubkey.is_compatible(their_features){
3284
+
returnErr(ChannelError::Close(format!("Provided a scriptpubkey format not accepted by peer. script: ({})", shutdown_scriptpubkey.clone().into_inner().to_bytes().to_hex())));
let node_a_node_id = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[42;32]).unwrap());
5214
5234
let config = UserConfig::default();
5215
-
let node_a_chan = Channel::<EnforcingSigner>::new_outbound(&&fee_est,&&keys_provider, node_a_node_id,10000000,100000,42,&config).unwrap();
5235
+
let node_a_chan = Channel::<EnforcingSigner>::new_outbound(&&fee_est,&&keys_provider, node_a_node_id,InitFeatures::known(),10000000,100000,42,&config).unwrap();
5216
5236
5217
5237
// Now change the fee so we can check that the fee in the open_channel message is the
5218
5238
// same as the old fee.
@@ -5237,7 +5257,7 @@ mod tests {
5237
5257
// Create Node A's channel pointing to Node B's pubkey
5238
5258
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[42;32]).unwrap());
let counterparty_node_id = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[42;32]).unwrap());
5480
5500
letmut config = UserConfig::default();
5481
5501
config.channel_options.announced_channel = false;
5482
-
letmut chan = Channel::<InMemorySigner>::new_outbound(&&feeest,&&keys_provider, counterparty_node_id,10_000_000,100000,42,&config).unwrap();// Nothing uses their network key in this test
5502
+
letmut chan = Channel::<InMemorySigner>::new_outbound(&&feeest,&&keys_provider, counterparty_node_id,InitFeatures::known(),10_000_000,100000,42,&config).unwrap();// Nothing uses their network key in this test
5483
5503
chan.holder_dust_limit_satoshis = 546;
5484
5504
chan.counterparty_selected_channel_reserve_satoshis = Some(0);// Filled in in accept_channel
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
7749
7749
7750
7750
// We test config.our_to_self > BREAKDOWN_TIMEOUT is enforced in Channel::new_outbound()
7751
-
if let Err(error) = Channel::new_outbound(&&test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) }, &nodes[0].keys_manager, nodes[1].node.get_our_node_id(), 1000000, 1000000, 0, &low_our_to_self_config) {
7751
+
if let Err(error) = Channel::new_outbound(&&test_utils::TestFeeEstimator { sat_per_kw: Mutex::new(253) }, &nodes[0].keys_manager, nodes[1].node.get_our_node_id(), InitFeatures::known(), 1000000, 1000000, 0, &low_our_to_self_config) {
7752
7752
match error {
7753
7753
APIError::APIMisuseError { err } => { assert!(regex::Regex::new(r"Configured with an unreasonable our_to_self_delay \(\d+\) putting user funds at risks").unwrap().is_match(err.as_str())); },
0 commit comments