Add function for updating network graph with announcement with no UTXO resolver
authorbenthecarman <benthecarman@live.com>
Mon, 24 Apr 2023 13:10:25 +0000 (08:10 -0500)
committerbenthecarman <benthecarman@live.com>
Mon, 24 Apr 2023 19:10:25 +0000 (14:10 -0500)
lightning/src/routing/gossip.rs
lightning/src/routing/utxo.rs

index 59268b840cd4c411b7a1545905bf17a4b6a24be0..35ff1e7a1957fad4ff8f453d1a9ce494c8f58576 100644 (file)
@@ -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};
@@ -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
@@ -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.
index 43338a15969eecce33502e6238acc0691e73e105..8733def13d95d26dc3d9c446cb5851d39c3b2ca3 100644 (file)
@@ -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())