X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannel.rs;h=7cc0dea5ff7e75875d901218b44fc223e9d3dd81;hb=refs%2Fheads%2F2018-07-68-rebased;hp=536d107dc46d4f2bde0df21c5a11493b595e545d;hpb=fd141bbed2a900070cbecf7ef9f22e377e1f353f;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 536d107d..7cc0dea5 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -2,7 +2,6 @@ use bitcoin::blockdata::block::BlockHeader; use bitcoin::blockdata::script::{Script,Builder}; use bitcoin::blockdata::transaction::{TxIn, TxOut, Transaction, SigHashType}; use bitcoin::blockdata::opcodes; -use bitcoin::util::uint::Uint256; use bitcoin::util::hash::{Sha256dHash, Hash160}; use bitcoin::util::bip143; use bitcoin::network::serialize::BitcoinHash; @@ -231,12 +230,12 @@ const BOTH_SIDES_SHUTDOWN_MASK: u32 = (ChannelState::LocalShutdownSent as u32 | // TODO: We should refactor this to be an Inbound/OutboundChannel until initial setup handshaking // has been completed, and then turn into a Channel to get compiler-time enforcement of things like -// calling get_channel_id() before we're set up or things like get_outbound_funding_signed on an +// calling channel_id() before we're set up or things like get_outbound_funding_signed on an // inbound channel. pub struct Channel { user_id: u64, - channel_id: Uint256, + channel_id: [u8; 32], channel_state: u32, channel_outbound: bool, secp_ctx: Secp256k1, @@ -380,7 +379,7 @@ impl Channel { Channel { user_id: user_id, - channel_id: rng::rand_uint256(), + channel_id: rng::rand_u832(), channel_state: ChannelState::OurInitSent as u32, channel_outbound: true, secp_ctx: secp_ctx, @@ -1798,7 +1797,7 @@ impl Channel { // Public utilities: - pub fn channel_id(&self) -> Uint256 { + pub fn channel_id(&self) -> [u8; 32] { self.channel_id } @@ -1843,6 +1842,10 @@ impl Channel { self.channel_update_count } + pub fn should_announce(&self) -> bool { + self.announce_publicly + } + /// Gets the fee we'd want to charge for adding an HTLC output to this Channel pub fn get_our_fee_base_msat(&self, fee_estimator: &FeeEstimator) -> u32 { // For lack of a better metric, we calculate what it would cost to consolidate the new HTLC