Rename RemoteTxCache as RemoteCommitmentTransaction and document better
[rust-lightning] / lightning / src / ln / channelmonitor.rs
index f547bcc2370895716823a3b9054fd5f17997dd3c..f36f531201bd1c6a06049997bf02a39b4798276d 100644 (file)
@@ -418,14 +418,14 @@ struct LocalSignedTx {
        htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Signature>, Option<HTLCSource>)>,
 }
 
-/// Cache remote basepoint to compute any transaction on
-/// remote outputs, either justice or preimage/timeout transactions.
+/// We use this to track remote commitment transactions and htlcs outputs and
+/// use it to generate any justice or 2nd-stage preimage/timeout transactions.
 #[derive(PartialEq)]
-struct RemoteTxCache {
+struct RemoteCommitmentTransaction {
        remote_delayed_payment_base_key: PublicKey,
        remote_htlc_base_key: PublicKey,
        on_remote_tx_csv: u16,
-       per_htlc: HashMap<Txid, Vec<(HTLCOutputInCommitment)>>
+       per_htlc: HashMap<Txid, Vec<HTLCOutputInCommitment>>
 }
 
 /// When ChannelMonitor discovers an onchain outpoint being a step of a channel and that it needs
@@ -737,7 +737,7 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
        current_remote_commitment_txid: Option<Txid>,
        prev_remote_commitment_txid: Option<Txid>,
 
-       remote_tx_cache: RemoteTxCache,
+       remote_tx_cache: RemoteCommitmentTransaction,
        funding_redeemscript: Script,
        channel_value_satoshis: u64,
        // first is the idx of the first of the two revocation points
@@ -1071,7 +1071,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                let payment_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_point.serialize());
                let remote_payment_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_key_hash[..]).into_script();
 
-               let remote_tx_cache = RemoteTxCache { remote_delayed_payment_base_key: *remote_delayed_payment_base_key, remote_htlc_base_key: *remote_htlc_base_key, on_remote_tx_csv, per_htlc: HashMap::new() };
+               let remote_tx_cache = RemoteCommitmentTransaction { remote_delayed_payment_base_key: *remote_delayed_payment_base_key, remote_htlc_base_key: *remote_htlc_base_key, on_remote_tx_csv, per_htlc: HashMap::new() };
 
                let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), on_local_tx_csv, logger.clone());
 
@@ -2244,7 +2244,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (BlockHas
                                        return Err(DecodeError::InvalidValue);
                                }
                        }
-                       RemoteTxCache {
+                       RemoteCommitmentTransaction {
                                remote_delayed_payment_base_key,
                                remote_htlc_base_key,
                                on_remote_tx_csv,