Skip to content

Commit

Permalink
Merge pull request #2222 from benthecarman/pub-utxo-resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt authored Apr 25, 2023
2 parents b734735 + 09e29c8 commit c182567
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
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 @@ -1439,8 +1439,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 @@ -1459,6 +1459,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

0 comments on commit c182567

Please sign in to comment.