Store+expose bits of Channel[Monitor] to figure out local state
[rust-lightning] / src / ln / channel.rs
index 28b938ec569f7762307f13e08d05a7a87a73bbb5..d4b30f0c456a8636665d5bff1c212194f186cd1f 100644 (file)
@@ -2560,6 +2560,18 @@ impl Channel {
                self.feerate_per_kw
        }
 
+       pub fn get_cur_local_commitment_transaction_number(&self) -> u64 {
+               self.cur_local_commitment_transaction_number + 1
+       }
+
+       pub fn get_cur_remote_commitment_transaction_number(&self) -> u64 {
+               self.cur_remote_commitment_transaction_number + 1 - if self.channel_state & (ChannelState::AwaitingRemoteRevoke as u32) != 0 { 1 } else { 0 }
+       }
+
+       pub fn get_revoked_remote_commitment_transaction_number(&self) -> u64 {
+               self.cur_remote_commitment_transaction_number + 2
+       }
+
        //TODO: Testing purpose only, should be changed in another way after #81
        #[cfg(test)]
        pub fn get_local_keys(&self) -> &ChannelKeys {