Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function for updating network graph with announcement with no UTXO resolver #2222

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lightning/src/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::ln::msgs::{DecodeError, ErrorAction, Init, LightningError, RoutingMes
use crate::ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, GossipTimestampFilter};
use crate::ln::msgs::{QueryChannelRange, ReplyChannelRange, QueryShortChannelIds, ReplyShortChannelIdsEnd};
use crate::ln::msgs;
use crate::routing::utxo::{self, UtxoLookup};
use crate::routing::utxo::{self, UtxoLookup, UtxoResolver};
use crate::util::ser::{Readable, ReadableArgs, Writeable, Writer, MaybeReadable};
use crate::util::logger::{Logger, Level};
use crate::util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK};
Expand Down Expand Up @@ -1438,8 +1438,8 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {

/// Store or update channel info from a channel announcement.
///
/// You probably don't want to call this directly, instead relying on a P2PGossipSync's
/// RoutingMessageHandler implementation to call it indirectly. This may be useful to accept
/// You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s
/// [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept
/// routing messages from a source using a protocol other than the lightning P2P protocol.
///
/// If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify
Expand All @@ -1458,6 +1458,19 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
self.update_channel_from_unsigned_announcement_intern(&msg.contents, Some(msg), utxo_lookup)
}

/// Store or update channel info from a channel announcement.
///
/// You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s
/// [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept
/// routing messages from a source using a protocol other than the lightning P2P protocol.
///
/// This will skip verification of if the channel is actually on-chain.
pub fn update_channel_from_announcement_no_lookup(
&self, msg: &ChannelAnnouncement
) -> Result<(), LightningError> {
self.update_channel_from_announcement::<&UtxoResolver>(msg, &None)
}

/// Store or update channel info from a channel announcement without verifying the associated
/// signatures. Because we aren't given the associated signatures here we cannot relay the
/// channel announcement to any of our peers.
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/routing/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub struct UtxoFuture {

/// A trivial implementation of [`UtxoLookup`] which is used to call back into the network graph
/// once we have a concrete resolution of a request.
struct UtxoResolver(Result<TxOut, UtxoLookupError>);
pub(crate) struct UtxoResolver(Result<TxOut, UtxoLookupError>);
impl UtxoLookup for UtxoResolver {
fn get_utxo(&self, _genesis_hash: &BlockHash, _short_channel_id: u64) -> UtxoResult {
UtxoResult::Sync(self.0.clone())
Expand Down