fn handle_update_fee(&self, _their_node_id: &PublicKey, _msg: &UpdateFee) {}
fn handle_announcement_signatures(&self, _their_node_id: &PublicKey, _msg: &AnnouncementSignatures) {}
fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &ChannelUpdate) {}
+ fn handle_inbound_fees_update(&self, _their_node_id: &PublicKey, _msg: &InboundFeesUpdate) {}
fn peer_disconnected(&self, their_node_id: &PublicKey, _no_connection_possible: bool) {
if *their_node_id == self.expected_pubkey {
self.disconnected_flag.store(true, Ordering::SeqCst);
});
}
+ fn handle_inbound_fees_update(&self, counterparty_node_id: &PublicKey, msg: &msgs::InboundFeesUpdate) {
+ // TODO
+ }
+
fn handle_channel_reestablish(&self, counterparty_node_id: &PublicKey, msg: &msgs::ChannelReestablish) {
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
let _ = handle_error!(self, self.internal_channel_reestablish(counterparty_node_id, msg), *counterparty_node_id);
&events::MessageSendEvent::BroadcastChannelAnnouncement { .. } => true,
&events::MessageSendEvent::BroadcastChannelUpdate { .. } => true,
&events::MessageSendEvent::SendChannelUpdate { ref node_id, .. } => node_id != counterparty_node_id,
+ &events::MessageSendEvent::SendInboundFeesUpdate { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::HandleError { ref node_id, .. } => node_id != counterparty_node_id,
&events::MessageSendEvent::SendChannelRangeQuery { .. } => false,
&events::MessageSendEvent::SendShortIdsQuery { .. } => false,
pub contents: UnsignedChannelUpdate,
}
+/// A request to the peer to update the inbound fees used when forwarding. Note that the peer may
+/// continue to use the previous inbound fees (if they were lower) for some time to ensure HTLCs
+/// which were in-flight when the change was done are not interrupted.
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct InboundFeesUpdate {
+ /// The channel being updated
+ pub channel_id: [u8; 32],
+ /// The inbound fee to pay, in millionths of the payment amount.
+ pub inbound_forwarding_fee_proportional_millionths: i32,
+ /// The inbound fee to pay, as a static amount in millisatoshis.
+ pub inbound_forwarding_fee_base_msat: i32,
+}
+
/// A query_channel_range message is used to query a peer for channel
/// UTXOs in a range of blocks. The recipient of a query makes a best
/// effort to reply to the query using one or more reply_channel_range
/// Handle an incoming channel_ready message from the given peer.
fn handle_channel_ready(&self, their_node_id: &PublicKey, msg: &ChannelReady);
+ /// Handle an incoming update_fee message from the given peer.
+ fn handle_inbound_fees_update(&self, their_node_id: &PublicKey, msg: &InboundFeesUpdate);
+
// Channl close:
/// Handle an incoming shutdown message from the given peer.
fn handle_shutdown(&self, their_node_id: &PublicKey, their_features: &InitFeatures, msg: &Shutdown);
contents
});
+impl_writeable!(InboundFeesUpdate, {
+ channel_id,
+ inbound_forwarding_fee_proportional_millionths,
+ inbound_forwarding_fee_base_msat
+});
+
impl Writeable for ErrorMessage {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
self.channel_id.write(w)?;
fn handle_channel_reestablish(&self, their_node_id: &PublicKey, msg: &msgs::ChannelReestablish) {
ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
}
+ fn handle_inbound_fees_update(&self, their_node_id: &PublicKey, msg: &msgs::InboundFeesUpdate) {
+ ErroringMessageHandler::push_error(self, their_node_id, msg.channel_id);
+ }
// msgs::ChannelUpdate does not contain the channel_id field, so we just drop them.
fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &msgs::ChannelUpdate) {}
fn peer_disconnected(&self, _their_node_id: &PublicKey, _no_connection_possible: bool) {}
self.message_handler.chan_handler.handle_closing_signed(&their_node_id, &msg);
},
+ wire::Message::InboundFeesUpdate(msg) => {
+ self.message_handler.chan_handler.handle_inbound_fees_update(&their_node_id, &msg);
+ },
+
// Commitment messages:
wire::Message::UpdateAddHTLC(msg) => {
self.message_handler.chan_handler.handle_update_add_htlc(&their_node_id, &msg);
log_pubkey!(node_id), msg.contents.short_channel_id);
self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
},
+ MessageSendEvent::SendInboundFeesUpdate { ref node_id, ref msg } => {
+ log_trace!(self.logger, "Handling SendInboundFeesUpdate event in peer_handler for node {} for channel {}",
+ log_pubkey!(node_id), log_bytes!(msg.channel_id));
+ self.enqueue_message(&mut *get_peer_for_forwarding!(node_id), msg);
+ },
+
MessageSendEvent::HandleError { ref node_id, ref action } => {
match *action {
msgs::ErrorAction::DisconnectPeer { ref msg } => {
ChannelAnnouncement(msgs::ChannelAnnouncement),
NodeAnnouncement(msgs::NodeAnnouncement),
ChannelUpdate(msgs::ChannelUpdate),
+ InboundFeesUpdate(msgs::InboundFeesUpdate),
QueryShortChannelIds(msgs::QueryShortChannelIds),
ReplyShortChannelIdsEnd(msgs::ReplyShortChannelIdsEnd),
QueryChannelRange(msgs::QueryChannelRange),
&Message::ChannelAnnouncement(ref msg) => msg.type_id(),
&Message::NodeAnnouncement(ref msg) => msg.type_id(),
&Message::ChannelUpdate(ref msg) => msg.type_id(),
+ &Message::InboundFeesUpdate(ref msg) => msg.type_id(),
&Message::QueryShortChannelIds(ref msg) => msg.type_id(),
&Message::ReplyShortChannelIdsEnd(ref msg) => msg.type_id(),
&Message::QueryChannelRange(ref msg) => msg.type_id(),
msgs::ChannelUpdate::TYPE => {
Ok(Message::ChannelUpdate(Readable::read(buffer)?))
},
+ msgs::InboundFeesUpdate::TYPE => {
+ Ok(Message::InboundFeesUpdate(Readable::read(buffer)?))
+ },
msgs::QueryShortChannelIds::TYPE => {
Ok(Message::QueryShortChannelIds(Readable::read(buffer)?))
},
const TYPE: u16 = 265;
}
+impl Encode for msgs::InboundFeesUpdate {
+ const TYPE: u16 = 34242;
+}
+
#[cfg(test)]
mod tests {
use super::*;
/// The channel_update which should be sent.
msg: msgs::ChannelUpdate,
},
+ /// Used to indicate that an `inbound_fees_update` should be sent to a single peer.
+ SendInboundFeesUpdate {
+ /// The node_id of the node which should receive this message
+ node_id: PublicKey,
+ /// The inbound_fees_update which should be sent.
+ msg: msgs::InboundFeesUpdate,
+ },
+
/// Broadcast an error downstream to be handled
HandleError {
/// The node_id of the node which should receive this message
fn handle_channel_update(&self, _their_node_id: &PublicKey, _msg: &msgs::ChannelUpdate) {
// Don't call `received_msg` here as `TestRoutingMessageHandler` generates these sometimes
}
+ fn handle_inbound_fees_update(&self, _their_node_id: &PublicKey, msg: &msgs::InboundFeesUpdate) {
+ self.received_msg(wire::Message::InboundFeesUpdate(msg.clone()));
+ }
fn handle_announcement_signatures(&self, _their_node_id: &PublicKey, msg: &msgs::AnnouncementSignatures) {
self.received_msg(wire::Message::AnnouncementSignatures(msg.clone()));
}