Move `broadcast_node_announcement` to `PeerManager`
[rust-lightning] / lightning / src / ln / priv_short_conf_tests.rs
index f4f52a8baf49cce4b0d1f586e92e27a72344a328..acceb43953e896e76364da8cf20c49eac6448a8b 100644 (file)
@@ -15,14 +15,14 @@ use chain::{ChannelMonitorUpdateErr, Watch};
 use chain::channelmonitor::ChannelMonitor;
 use chain::keysinterface::{Recipient, KeysInterface};
 use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, MIN_CLTV_EXPIRY_DELTA};
-use routing::network_graph::RoutingFees;
+use routing::gossip::RoutingFees;
 use routing::router::{PaymentParameters, RouteHint, RouteHintHop};
-use ln::features::{InitFeatures, InvoiceFeatures};
+use ln::features::{InitFeatures, InvoiceFeatures, ChannelTypeFeatures};
 use ln::msgs;
-use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, OptionalField, ChannelUpdate};
+use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ChannelUpdate, ErrorAction};
 use ln::wire::Encode;
 use util::enforcing_trait_impls::EnforcingSigner;
-use util::events::{ClosureReason, Event, MessageSendEvent, MessageSendEventsProvider};
+use util::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider};
 use util::config::UserConfig;
 use util::ser::{Writeable, ReadableArgs};
 use util::test_utils;
@@ -144,8 +144,8 @@ fn test_priv_forwarding_rejection() {
 
        nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: InitFeatures::known(), remote_network_address: None });
        nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: InitFeatures::empty(), remote_network_address: None });
-       let as_reestablish = get_event_msg!(nodes[0], MessageSendEvent::SendChannelReestablish, nodes[1].node.get_our_node_id());
-       let bs_reestablish = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReestablish, nodes[0].node.get_our_node_id());
+       let as_reestablish = get_chan_reestablish_msgs!(nodes[0], nodes[1]).pop().unwrap();
+       let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[0]).pop().unwrap();
        nodes[1].node.handle_channel_reestablish(&nodes[0].node.get_our_node_id(), &as_reestablish);
        nodes[0].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
        get_event_msg!(nodes[0], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
@@ -153,8 +153,8 @@ fn test_priv_forwarding_rejection() {
 
        nodes[1].node.peer_connected(&nodes[2].node.get_our_node_id(), &msgs::Init { features: InitFeatures::known(), remote_network_address: None });
        nodes[2].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: InitFeatures::empty(), remote_network_address: None });
-       let bs_reestablish = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReestablish, nodes[2].node.get_our_node_id());
-       let cs_reestablish = get_event_msg!(nodes[2], MessageSendEvent::SendChannelReestablish, nodes[1].node.get_our_node_id());
+       let bs_reestablish = get_chan_reestablish_msgs!(nodes[1], nodes[2]).pop().unwrap();
+       let cs_reestablish = get_chan_reestablish_msgs!(nodes[2], nodes[1]).pop().unwrap();
        nodes[2].node.handle_channel_reestablish(&nodes[1].node.get_our_node_id(), &bs_reestablish);
        nodes[1].node.handle_channel_reestablish(&nodes[2].node.get_our_node_id(), &cs_reestablish);
        get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[2].node.get_our_node_id());
@@ -167,16 +167,16 @@ fn test_priv_forwarding_rejection() {
 }
 
 fn do_test_1_conf_open(connect_style: ConnectStyle) {
-       // Previously, if the minium_depth config was set to 1, we'd never send a funding_locked. This
+       // Previously, if the minium_depth config was set to 1, we'd never send a channel_ready. This
        // tests that we properly send one in that case.
        let mut alice_config = UserConfig::default();
-       alice_config.own_channel_config.minimum_depth = 1;
-       alice_config.channel_options.announced_channel = true;
-       alice_config.peer_channel_config_limits.force_announced_channel_preference = false;
+       alice_config.channel_handshake_config.minimum_depth = 1;
+       alice_config.channel_handshake_config.announced_channel = true;
+       alice_config.channel_handshake_limits.force_announced_channel_preference = false;
        let mut bob_config = UserConfig::default();
-       bob_config.own_channel_config.minimum_depth = 1;
-       bob_config.channel_options.announced_channel = true;
-       bob_config.peer_channel_config_limits.force_announced_channel_preference = false;
+       bob_config.channel_handshake_config.minimum_depth = 1;
+       bob_config.channel_handshake_config.announced_channel = true;
+       bob_config.channel_handshake_limits.force_announced_channel_preference = false;
        let chanmon_cfgs = create_chanmon_cfgs(2);
        let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
        let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[Some(alice_config), Some(bob_config)]);
@@ -185,13 +185,13 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) {
 
        let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001, InitFeatures::known(), InitFeatures::known());
        mine_transaction(&nodes[1], &tx);
-       nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id()));
+       nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[0].node.get_our_node_id()));
        assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
 
        mine_transaction(&nodes[0], &tx);
        let as_msg_events = nodes[0].node.get_and_clear_pending_msg_events();
        assert_eq!(as_msg_events.len(), 2);
-       let as_funding_locked = if let MessageSendEvent::SendFundingLocked { ref node_id, ref msg } = as_msg_events[0] {
+       let as_channel_ready = if let MessageSendEvent::SendChannelReady { ref node_id, ref msg } = as_msg_events[0] {
                assert_eq!(*node_id, nodes[1].node.get_our_node_id());
                msg.clone()
        } else { panic!("Unexpected event"); };
@@ -199,7 +199,7 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) {
                assert_eq!(*node_id, nodes[1].node.get_our_node_id());
        } else { panic!("Unexpected event"); }
 
-       nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &as_funding_locked);
+       nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &as_channel_ready);
        let bs_msg_events = nodes[1].node.get_and_clear_pending_msg_events();
        assert_eq!(bs_msg_events.len(), 1);
        if let MessageSendEvent::SendChannelUpdate { ref node_id, msg: _ } = bs_msg_events[0] {
@@ -236,9 +236,9 @@ fn do_test_1_conf_open(connect_style: ConnectStyle) {
        assert_eq!(announcement, bs_announcement);
 
        for node in nodes {
-               assert!(node.net_graph_msg_handler.handle_channel_announcement(&announcement).unwrap());
-               node.net_graph_msg_handler.handle_channel_update(&as_update).unwrap();
-               node.net_graph_msg_handler.handle_channel_update(&bs_update).unwrap();
+               assert!(node.gossip_sync.handle_channel_announcement(&announcement).unwrap());
+               node.gossip_sync.handle_channel_update(&as_update).unwrap();
+               node.gossip_sync.handle_channel_update(&bs_update).unwrap();
        }
 }
 #[test]
@@ -259,7 +259,7 @@ fn test_routed_scid_alias() {
        let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
 
        create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 500_000_000, InitFeatures::known(), InitFeatures::known()).2;
-       let mut as_funding_locked = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000, InitFeatures::known(), InitFeatures::known()).0;
+       let mut as_channel_ready = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 500_000_000, InitFeatures::known(), InitFeatures::known()).0;
 
        let last_hop = nodes[2].node.list_usable_channels();
        let hop_hints = vec![RouteHint(vec![RouteHintHop {
@@ -284,17 +284,17 @@ fn test_routed_scid_alias() {
        pass_along_route(&nodes[0], &[&[&nodes[1], &nodes[2]]], 100_000, payment_hash, payment_secret);
        claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage);
 
-       // Now test that if a peer sends us a second funding_locked after the channel is operational we
+       // Now test that if a peer sends us a second channel_ready after the channel is operational we
        // will use the new alias.
-       as_funding_locked.short_channel_id_alias = Some(0xdeadbeef);
-       nodes[2].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &as_funding_locked);
-       // Note that we always respond to a funding_locked with a channel_update. Not a lot of reason
+       as_channel_ready.short_channel_id_alias = Some(0xdeadbeef);
+       nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &as_channel_ready);
+       // Note that we always respond to a channel_ready with a channel_update. Not a lot of reason
        // to bother updating that code, so just drop the message here.
        get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
        let updated_channel_info = nodes[2].node.list_usable_channels();
        assert_eq!(updated_channel_info.len(), 1);
        assert_eq!(updated_channel_info[0].inbound_scid_alias.unwrap(), 0xdeadbeef);
-       // Note that because we never send a duplicate funding_locked we can't send a payment through
+       // Note that because we never send a duplicate channel_ready we can't send a payment through
        // the 0xdeadbeef SCID alias.
 }
 
@@ -308,8 +308,8 @@ fn test_scid_privacy_on_pub_channel() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
 
        let mut scid_privacy_cfg = test_default_channel_config();
-       scid_privacy_cfg.channel_options.announced_channel = true;
-       scid_privacy_cfg.own_channel_config.negotiate_scid_privacy = true;
+       scid_privacy_cfg.channel_handshake_config.announced_channel = true;
+       scid_privacy_cfg.channel_handshake_config.negotiate_scid_privacy = true;
        nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, Some(scid_privacy_cfg)).unwrap();
        let mut open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
 
@@ -332,8 +332,8 @@ fn test_scid_privacy_negotiation() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
 
        let mut scid_privacy_cfg = test_default_channel_config();
-       scid_privacy_cfg.channel_options.announced_channel = false;
-       scid_privacy_cfg.own_channel_config.negotiate_scid_privacy = true;
+       scid_privacy_cfg.channel_handshake_config.announced_channel = false;
+       scid_privacy_cfg.channel_handshake_config.negotiate_scid_privacy = true;
        nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, Some(scid_privacy_cfg)).unwrap();
 
        let init_open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
@@ -378,8 +378,8 @@ fn test_inbound_scid_privacy() {
        create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0, InitFeatures::known(), InitFeatures::known());
 
        let mut no_announce_cfg = test_default_channel_config();
-       no_announce_cfg.channel_options.announced_channel = false;
-       no_announce_cfg.own_channel_config.negotiate_scid_privacy = true;
+       no_announce_cfg.channel_handshake_config.announced_channel = false;
+       no_announce_cfg.channel_handshake_config.negotiate_scid_privacy = true;
        nodes[1].node.create_channel(nodes[2].node.get_our_node_id(), 100_000, 10_000, 42, Some(no_announce_cfg)).unwrap();
        let mut open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[2].node.get_our_node_id());
 
@@ -403,10 +403,10 @@ fn test_inbound_scid_privacy() {
        connect_blocks(&nodes[1], CHAN_CONFIRM_DEPTH - 1);
        confirm_transaction_at(&nodes[2], &tx, conf_height);
        connect_blocks(&nodes[2], CHAN_CONFIRM_DEPTH - 1);
-       let bs_funding_locked = get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[2].node.get_our_node_id());
-       nodes[1].node.handle_funding_locked(&nodes[2].node.get_our_node_id(), &get_event_msg!(nodes[2], MessageSendEvent::SendFundingLocked, nodes[1].node.get_our_node_id()));
+       let bs_channel_ready = get_event_msg!(nodes[1], MessageSendEvent::SendChannelReady, nodes[2].node.get_our_node_id());
+       nodes[1].node.handle_channel_ready(&nodes[2].node.get_our_node_id(), &get_event_msg!(nodes[2], MessageSendEvent::SendChannelReady, nodes[1].node.get_our_node_id()));
        let bs_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[2].node.get_our_node_id());
-       nodes[2].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &bs_funding_locked);
+       nodes[2].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &bs_channel_ready);
        let cs_update = get_event_msg!(nodes[2], MessageSendEvent::SendChannelUpdate, nodes[1].node.get_our_node_id());
 
        nodes[1].node.handle_channel_update(&nodes[2].node.get_our_node_id(), &cs_update);
@@ -460,7 +460,7 @@ fn test_inbound_scid_privacy() {
        nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]);
        commitment_signed_dance!(nodes[0], nodes[1], updates.commitment_signed, false);
 
-       expect_payment_failed_conditions!(nodes[0], payment_hash_2, false,
+       expect_payment_failed_conditions(&nodes[0], payment_hash_2, false,
                PaymentFailedConditions::new().blamed_scid(last_hop[0].short_channel_id.unwrap())
                        .blamed_chan_closed(true).expected_htlc_error_data(0x4000|10, &[0; 0]));
 }
@@ -478,7 +478,7 @@ fn test_scid_alias_returned() {
        let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
 
        create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 0, InitFeatures::known(), InitFeatures::known());
-       create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 10_000, 0, InitFeatures::known(), InitFeatures::known());
+       let chan = create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 10_000, 0, InitFeatures::known(), InitFeatures::known());
 
        let last_hop = nodes[2].node.list_usable_channels();
        let mut hop_hints = vec![RouteHint(vec![RouteHintHop {
@@ -508,7 +508,7 @@ fn test_scid_alias_returned() {
        commitment_signed_dance!(nodes[1], nodes[0], &as_updates.commitment_signed, false, true);
 
        expect_pending_htlcs_forwardable!(nodes[1]);
-       expect_pending_htlcs_forwardable!(nodes[1]);
+       expect_pending_htlcs_forwardable_and_htlc_handling_failed!(nodes[1], vec![HTLCDestination::NextHopChannel { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan.0.channel_id }]);
        check_added_monitors!(nodes[1], 1);
 
        let bs_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
@@ -521,9 +521,9 @@ fn test_scid_alias_returned() {
                short_channel_id: last_hop[0].inbound_scid_alias.unwrap(),
                timestamp: 21,
                flags: 1,
-               cltv_expiry_delta: accept_forward_cfg.channel_options.cltv_expiry_delta,
+               cltv_expiry_delta: accept_forward_cfg.channel_config.cltv_expiry_delta,
                htlc_minimum_msat: 1_000,
-               htlc_maximum_msat: OptionalField::Present(1_000_000), // Defaults to 10% of the channel value
+               htlc_maximum_msat: 1_000_000, // Defaults to 10% of the channel value
                fee_base_msat: last_hop[0].counterparty.forwarding_info.as_ref().unwrap().fee_base_msat,
                fee_proportional_millionths: last_hop[0].counterparty.forwarding_info.as_ref().unwrap().fee_proportional_millionths,
                excess_data: Vec::new(),
@@ -537,7 +537,7 @@ fn test_scid_alias_returned() {
        err_data.extend_from_slice(&ChannelUpdate::TYPE.to_be_bytes());
        err_data.extend_from_slice(&msg.encode());
 
-       expect_payment_failed_conditions!(nodes[0], payment_hash, false,
+       expect_payment_failed_conditions(&nodes[0], payment_hash, false,
                PaymentFailedConditions::new().blamed_scid(last_hop[0].inbound_scid_alias.unwrap())
                        .blamed_chan_closed(false).expected_htlc_error_data(0x1000|7, &err_data));
 
@@ -560,80 +560,17 @@ fn test_scid_alias_returned() {
        err_data.extend_from_slice(&(msg.serialized_length() as u16 + 2).to_be_bytes());
        err_data.extend_from_slice(&ChannelUpdate::TYPE.to_be_bytes());
        err_data.extend_from_slice(&msg.encode());
-       expect_payment_failed_conditions!(nodes[0], payment_hash, false,
+       expect_payment_failed_conditions(&nodes[0], payment_hash, false,
                PaymentFailedConditions::new().blamed_scid(last_hop[0].inbound_scid_alias.unwrap())
                        .blamed_chan_closed(false).expected_htlc_error_data(0x1000|12, &err_data));
 }
 
-// Receiver must have been initialized with manually_accept_inbound_channels set to true.
-fn open_zero_conf_channel<'a, 'b, 'c, 'd>(initiator: &'a Node<'b, 'c, 'd>, receiver: &'a Node<'b, 'c, 'd>, initiator_config: Option<UserConfig>) -> bitcoin::Transaction {
-       initiator.node.create_channel(receiver.node.get_our_node_id(), 100_000, 10_001, 42, initiator_config).unwrap();
-       let open_channel = get_event_msg!(initiator, MessageSendEvent::SendOpenChannel, receiver.node.get_our_node_id());
-
-       receiver.node.handle_open_channel(&initiator.node.get_our_node_id(), InitFeatures::known(), &open_channel);
-       let events = receiver.node.get_and_clear_pending_events();
-       assert_eq!(events.len(), 1);
-       match events[0] {
-               Event::OpenChannelRequest { temporary_channel_id, .. } => {
-                       receiver.node.accept_inbound_channel_from_trusted_peer_0conf(&temporary_channel_id, &initiator.node.get_our_node_id(), 0).unwrap();
-               },
-               _ => panic!("Unexpected event"),
-       };
-
-       let mut accept_channel = get_event_msg!(receiver, MessageSendEvent::SendAcceptChannel, initiator.node.get_our_node_id());
-       assert_eq!(accept_channel.minimum_depth, 0);
-       initiator.node.handle_accept_channel(&receiver.node.get_our_node_id(), InitFeatures::known(), &accept_channel);
-
-       let (temporary_channel_id, tx, _) = create_funding_transaction(&initiator, &receiver.node.get_our_node_id(), 100_000, 42);
-       initiator.node.funding_transaction_generated(&temporary_channel_id, &receiver.node.get_our_node_id(), tx.clone()).unwrap();
-       let funding_created = get_event_msg!(initiator, MessageSendEvent::SendFundingCreated, receiver.node.get_our_node_id());
-
-       receiver.node.handle_funding_created(&initiator.node.get_our_node_id(), &funding_created);
-       check_added_monitors!(receiver, 1);
-       let bs_signed_locked = receiver.node.get_and_clear_pending_msg_events();
-       assert_eq!(bs_signed_locked.len(), 2);
-       let as_funding_locked;
-       match &bs_signed_locked[0] {
-               MessageSendEvent::SendFundingSigned { node_id, msg } => {
-                       assert_eq!(*node_id, initiator.node.get_our_node_id());
-                       initiator.node.handle_funding_signed(&receiver.node.get_our_node_id(), &msg);
-                       check_added_monitors!(initiator, 1);
-
-                       assert_eq!(initiator.tx_broadcaster.txn_broadcasted.lock().unwrap().len(), 1);
-                       assert_eq!(initiator.tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0)[0], tx);
-
-                       as_funding_locked = get_event_msg!(initiator, MessageSendEvent::SendFundingLocked, receiver.node.get_our_node_id());
-               }
-               _ => panic!("Unexpected event"),
-       }
-       match &bs_signed_locked[1] {
-               MessageSendEvent::SendFundingLocked { node_id, msg } => {
-                       assert_eq!(*node_id, initiator.node.get_our_node_id());
-                       initiator.node.handle_funding_locked(&receiver.node.get_our_node_id(), &msg);
-               }
-               _ => panic!("Unexpected event"),
-       }
-
-       receiver.node.handle_funding_locked(&initiator.node.get_our_node_id(), &as_funding_locked);
-
-       let as_channel_update = get_event_msg!(initiator, MessageSendEvent::SendChannelUpdate, receiver.node.get_our_node_id());
-       let bs_channel_update = get_event_msg!(receiver, MessageSendEvent::SendChannelUpdate, initiator.node.get_our_node_id());
-
-       initiator.node.handle_channel_update(&receiver.node.get_our_node_id(), &bs_channel_update);
-       receiver.node.handle_channel_update(&initiator.node.get_our_node_id(), &as_channel_update);
-
-       assert_eq!(initiator.node.list_usable_channels().len(), 1);
-       assert_eq!(receiver.node.list_usable_channels().len(), 1);
-
-       tx
-}
-
 #[test]
 fn test_simple_0conf_channel() {
        // If our peer tells us they will accept our channel with 0 confs, and we funded the channel,
        // we should trust the funding won't be double-spent (assuming `trust_own_funding_0conf` is
        // set)!
-       // Further, if we `accept_inbound_channel_from_trusted_peer_0conf`, funding locked messages
+       // Further, if we `accept_inbound_channel_from_trusted_peer_0conf`, `channel_ready` messages
        // should fly immediately and the channel should be available for use as soon as they are
        // received.
 
@@ -652,7 +589,7 @@ fn test_simple_0conf_channel() {
 
 #[test]
 fn test_0conf_channel_with_async_monitor() {
-       // Test that we properly send out funding_locked in (both inbound- and outbound-) zero-conf
+       // Test that we properly send out channel_ready in (both inbound- and outbound-) zero-conf
        // channels if ChannelMonitor updates return a `TemporaryFailure` during the initial channel
        // negotiation.
 
@@ -665,7 +602,7 @@ fn test_0conf_channel_with_async_monitor() {
 
        create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0, InitFeatures::known(), InitFeatures::known());
 
-       chan_config.channel_options.announced_channel = false;
+       chan_config.channel_handshake_config.announced_channel = false;
        nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, Some(chan_config)).unwrap();
        let open_channel = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
 
@@ -708,9 +645,9 @@ fn test_0conf_channel_with_async_monitor() {
                _ => panic!("Unexpected event"),
        }
        match &bs_signed_locked[1] {
-               MessageSendEvent::SendFundingLocked { node_id, msg } => {
+               MessageSendEvent::SendChannelReady { node_id, msg } => {
                        assert_eq!(*node_id, nodes[0].node.get_our_node_id());
-                       nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &msg);
+                       nodes[0].node.handle_channel_ready(&nodes[1].node.get_our_node_id(), &msg);
                }
                _ => panic!("Unexpected event"),
        }
@@ -727,9 +664,9 @@ fn test_0conf_channel_with_async_monitor() {
        assert_eq!(nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().split_off(0)[0], tx);
 
        match &as_locked_update[0] {
-               MessageSendEvent::SendFundingLocked { node_id, msg } => {
+               MessageSendEvent::SendChannelReady { node_id, msg } => {
                        assert_eq!(*node_id, nodes[1].node.get_our_node_id());
-                       nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &msg);
+                       nodes[1].node.handle_channel_ready(&nodes[0].node.get_our_node_id(), &msg);
                }
                _ => panic!("Unexpected event"),
        }
@@ -811,13 +748,13 @@ fn test_0conf_close_no_early_chan_update() {
        let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
 
        // This is the default but we force it on anyway
-       chan_config.channel_options.announced_channel = true;
+       chan_config.channel_handshake_config.announced_channel = true;
        open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config));
 
        // We can use the channel immediately, but won't generate a channel_update until we get confs
        send_payment(&nodes[0], &[&nodes[1]], 100_000);
 
-       nodes[0].node.force_close_all_channels();
+       nodes[0].node.force_close_all_channels_broadcasting_latest_txn();
        check_added_monitors!(nodes[0], 1);
        check_closed_event!(&nodes[0], 1, ClosureReason::HolderForceClosed);
        let _ = get_err_msg!(nodes[0], nodes[1].node.get_our_node_id());
@@ -835,8 +772,8 @@ fn test_public_0conf_channel() {
        let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
 
        // This is the default but we force it on anyway
-       chan_config.channel_options.announced_channel = true;
-       let tx = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config));
+       chan_config.channel_handshake_config.announced_channel = true;
+       let (tx, ..) = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config));
 
        // We can use the channel immediately, but we can't announce it until we get 6+ confirmations
        send_payment(&nodes[0], &[&nodes[1]], 100_000);
@@ -888,8 +825,8 @@ fn test_0conf_channel_reorg() {
        let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
 
        // This is the default but we force it on anyway
-       chan_config.channel_options.announced_channel = true;
-       let tx = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config));
+       chan_config.channel_handshake_config.announced_channel = true;
+       let (tx, ..) = open_zero_conf_channel(&nodes[0], &nodes[1], Some(chan_config));
 
        // We can use the channel immediately, but we can't announce it until we get 6+ confirmations
        send_payment(&nodes[0], &[&nodes[1]], 100_000);
@@ -922,3 +859,102 @@ fn test_0conf_channel_reorg() {
        });
        check_closed_broadcast!(nodes[1], true);
 }
+
+#[test]
+fn test_zero_conf_accept_reject() {
+       let mut channel_type_features = ChannelTypeFeatures::only_static_remote_key();
+       channel_type_features.set_zero_conf_required();
+
+       // 1. Check we reject zero conf channels by default
+       let chanmon_cfgs = create_chanmon_cfgs(2);
+       let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
+       let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
+       let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
+
+       nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42, None).unwrap();
+       let mut open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
+
+       open_channel_msg.channel_type = Some(channel_type_features.clone());
+
+       nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(), &open_channel_msg);
+
+       let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
+       match msg_events[0] {
+               MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg, .. }, .. } => {
+                       assert_eq!(msg.data, "No zero confirmation channels accepted".to_owned());
+               },
+               _ => panic!(),
+       }
+
+       // 2. Check we can manually accept zero conf channels via the right method
+       let mut manually_accept_conf = UserConfig::default();
+       manually_accept_conf.manually_accept_inbound_channels = true;
+
+       let chanmon_cfgs = create_chanmon_cfgs(2);
+       let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
+       let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs,
+               &[None, Some(manually_accept_conf.clone())]);
+       let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
+
+       // 2.1 First try the non-0conf method to manually accept
+       nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42,
+               Some(manually_accept_conf)).unwrap();
+       let mut open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel,
+               nodes[1].node.get_our_node_id());
+
+       open_channel_msg.channel_type = Some(channel_type_features.clone());
+
+       nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(),
+               &open_channel_msg);
+
+       // Assert that `nodes[1]` has no `MessageSendEvent::SendAcceptChannel` in the `msg_events`.
+       assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
+
+       let events = nodes[1].node.get_and_clear_pending_events();
+
+       match events[0] {
+               Event::OpenChannelRequest { temporary_channel_id, .. } => {
+                       // Assert we fail to accept via the non-0conf method
+                       assert!(nodes[1].node.accept_inbound_channel(&temporary_channel_id,
+                               &nodes[0].node.get_our_node_id(), 0).is_err());
+               },
+               _ => panic!(),
+       }
+
+       let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
+       match msg_events[0] {
+               MessageSendEvent::HandleError { action: ErrorAction::SendErrorMessage { ref msg, .. }, .. } => {
+                       assert_eq!(msg.data, "No zero confirmation channels accepted".to_owned());
+               },
+               _ => panic!(),
+       }
+
+       // 2.2 Try again with the 0conf method to manually accept
+       nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 100000, 10001, 42,
+               Some(manually_accept_conf)).unwrap();
+       let mut open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel,
+               nodes[1].node.get_our_node_id());
+
+       open_channel_msg.channel_type = Some(channel_type_features);
+
+       nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), InitFeatures::known(),
+               &open_channel_msg);
+
+       let events = nodes[1].node.get_and_clear_pending_events();
+
+       match events[0] {
+               Event::OpenChannelRequest { temporary_channel_id, .. } => {
+                       // Assert we can accept via the 0conf method
+                       assert!(nodes[1].node.accept_inbound_channel_from_trusted_peer_0conf(
+                               &temporary_channel_id, &nodes[0].node.get_our_node_id(), 0).is_ok());
+               },
+               _ => panic!(),
+       }
+
+       // Check we would send accept
+       let msg_events = nodes[1].node.get_and_clear_pending_msg_events();
+       match msg_events[0] {
+               MessageSendEvent::SendAcceptChannel { .. } => {},
+               _ => panic!(),
+       }
+}