X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannel.rs;h=1a195d504a117ea6590c4605974568443e8f3275;hb=50668644cf69f1ce92d71b3a1627e129741f4655;hp=43f913eb2f569d37169ce91eb8609f78e030371a;hpb=2470812077dfa09b77c7ff881208a9dcb6174d7a;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 43f913eb..1a195d50 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -23,11 +23,13 @@ use chain::chaininterface::{FeeEstimator,ConfirmationTarget}; use chain::transaction::OutPoint; use util::{transaction_utils,rng}; use util::sha2::Sha256; +use util::logger::{Logger, Record}; use std; use std::default::Default; use std::{cmp,mem}; use std::time::Instant; +use std::sync::{Arc}; pub struct ChannelKeys { pub funding_key: SecretKey, @@ -86,18 +88,21 @@ impl ChannelKeys { #[derive(PartialEq)] enum HTLCState { /// Added by remote, to be included in next local commitment tx. + /// Implies HTLCOutput::outbound: false RemoteAnnounced, /// Included in a received commitment_signed message (implying we've revoke_and_ack'ed it), but /// the remote side hasn't yet revoked their previous state, which we need them to do before we /// accept this HTLC. Implies AwaitingRemoteRevoke. /// We also have not yet included this HTLC in a commitment_signed message, and are waiting on /// a remote revoke_and_ack on a previous state before we can do so. + /// Implies HTLCOutput::outbound: false AwaitingRemoteRevokeToAnnounce, /// Included in a received commitment_signed message (implying we've revoke_and_ack'ed it), but /// the remote side hasn't yet revoked their previous state, which we need them to do before we /// accept this HTLC. Implies AwaitingRemoteRevoke. /// We have included this HTLC in our latest commitment_signed and are now just waiting on a /// revoke_and_ack. + /// Implies HTLCOutput::outbound: true AwaitingAnnouncedRemoteRevoke, /// Added by us and included in a commitment_signed (if we were AwaitingRemoteRevoke when we /// created it we would have put it in the holding cell instead). When they next revoke_and_ack @@ -109,22 +114,26 @@ enum HTLCState { /// allowed to remove it, the "can only be removed once committed on both sides" requirement /// doesn't matter to us and its up to them to enforce it, worst-case they jump ahead but /// we'll never get out of sync). + /// Implies HTLCOutput::outbound: true LocalAnnounced, Committed, /// Remote removed this (outbound) HTLC. We're waiting on their commitment_signed to finalize /// the change (though they'll need to revoke before we fail the payment). + /// Implies HTLCOutput::outbound: true RemoteRemoved, /// Remote removed this and sent a commitment_signed (implying we've revoke_and_ack'ed it), but /// the remote side hasn't yet revoked their previous state, which we need them to do before we /// can do any backwards failing. Implies AwaitingRemoteRevoke. /// We also have not yet removed this HTLC in a commitment_signed message, and are waiting on a /// remote revoke_and_ack on a previous state before we can do so. + /// Implies HTLCOutput::outbound: true AwaitingRemoteRevokeToRemove, /// Remote removed this and sent a commitment_signed (implying we've revoke_and_ack'ed it), but /// the remote side hasn't yet revoked their previous state, which we need them to do before we /// can do any backwards failing. Implies AwaitingRemoteRevoke. /// We have removed this HTLC in our latest commitment_signed and are now just waiting on a /// revoke_and_ack to drop completely. + /// Implies HTLCOutput::outbound: true AwaitingRemovedRemoteRevoke, /// Removed by us and a new commitment_signed was sent (if we were AwaitingRemoteRevoke when we /// created it we would have put it in the holding cell instead). When they next revoke_and_ack @@ -134,9 +143,11 @@ enum HTLCState { /// commitment transaction without it as otherwise we'll have to force-close the channel to /// claim it before the timeout (obviously doesn't apply to revoked HTLCs that we can't claim /// anyway). + /// Implies HTLCOutput::outbound: false LocalRemoved, /// Removed by us, sent a new commitment_signed and got a revoke_and_ack. Just waiting on an /// updated local commitment transaction. Implies local_removed_fulfilled. + /// Implies HTLCOutput::outbound: false LocalRemovedAwaitingCommitment, } @@ -303,6 +314,8 @@ pub struct Channel { their_shutdown_scriptpubkey: Option