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 //! Traits and utility impls which allow other parts of rust-lightning to interact with the
13 //! Includes traits for monitoring and receiving notifications of new blocks and block
14 //! disconnections, transaction broadcasting, and feerate information requests.
16 use bitcoin::blockdata::transaction::Transaction;
18 /// An interface to send a transaction to the Bitcoin network.
19 pub trait BroadcasterInterface: Sync + Send {
20 /// Sends a transaction out to (hopefully) be mined.
21 fn broadcast_transaction(&self, tx: &Transaction);
24 /// An enum that represents the speed at which we want a transaction to confirm used for feerate
26 pub enum ConfirmationTarget {
27 /// We are happy with this transaction confirming slowly when feerate drops some.
29 /// We'd like this transaction to confirm without major delay, but 12-18 blocks is fine.
31 /// We'd like this transaction to confirm in the next few blocks.
35 /// A trait which should be implemented to provide feerate information on a number of time
38 /// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
39 /// called from inside the library in response to chain events, P2P events, or timer events).
40 pub trait FeeEstimator: Sync + Send {
41 /// Gets estimated satoshis of fee required per 1000 Weight-Units.
43 /// Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
44 /// don't put us below 1 satoshi-per-byte).
46 /// This translates to:
47 /// * satoshis-per-byte * 250
48 /// * ceil(satoshis-per-kbyte / 4)
49 fn get_est_sat_per_1000_weight(&self, confirmation_target: ConfirmationTarget) -> u32;
52 /// Minimum relay fee as required by bitcoin network mempool policy.
53 pub const MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = 4000;