1 // This file is Copyright its original authors, visible in version control
4 // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
5 // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
7 // You may not use this file except in accordance with one or both of these
10 //! This module contains traits for LDK to access UTXOs to check gossip data is correct.
12 //! When lightning nodes gossip channel information, they resist DoS attacks by checking that each
13 //! channel matches a UTXO on-chain, requiring at least some marginal on-chain transacting in
14 //! order to announce a channel. This module handles that checking.
16 use bitcoin::{BlockHash, TxOut};
18 /// An error when accessing the chain via [`UtxoLookup`].
19 #[derive(Clone, Debug)]
20 pub enum UtxoLookupError {
21 /// The requested chain is unknown.
24 /// The requested transaction doesn't exist or hasn't confirmed.
28 /// The `UtxoLookup` trait defines behavior for accessing on-chain UTXOs.
29 pub trait UtxoLookup {
30 /// Returns the transaction output of a funding transaction encoded by [`short_channel_id`].
31 /// Returns an error if `genesis_hash` is for a different chain or if such a transaction output
34 /// [`short_channel_id`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#definition-of-short_channel_id
35 fn get_utxo(&self, genesis_hash: &BlockHash, short_channel_id: u64) -> Result<TxOut, UtxoLookupError>;