]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Dry-up InputMaterial::Funding
authorAntoine Riard <ariard@student.42.fr>
Tue, 21 Apr 2020 01:19:00 +0000 (21:19 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 24 Apr 2020 22:51:29 +0000 (18:51 -0400)
As channel_value last usage was for computing feerate but as this
one is static per-commitment and will always-be following specification,
we remove it.

lightning/src/ln/channelmonitor.rs
lightning/src/ln/onchaintx.rs

index c8e6b8260adbc0ec35821a2464e26678a44d4fda..da8ba03a7271a7d359f7e58dcf51851c617ee790 100644 (file)
@@ -442,9 +442,7 @@ pub(crate) enum InputMaterial {
                preimage: Option<PaymentPreimage>,
                amount: u64,
        },
-       Funding {
-               channel_value: u64,
-       }
+       Funding {}
 }
 
 impl Writeable for InputMaterial  {
@@ -471,9 +469,8 @@ impl Writeable for InputMaterial  {
                                preimage.write(writer)?;
                                writer.write_all(&byte_utils::be64_to_array(*amount))?;
                        },
-                       &InputMaterial::Funding { ref channel_value } => {
+                       &InputMaterial::Funding {} => {
                                writer.write_all(&[3; 1])?;
-                               channel_value.write(writer)?;
                        }
                }
                Ok(())
@@ -520,10 +517,7 @@ impl Readable for InputMaterial {
                                }
                        },
                        3 => {
-                               let channel_value = Readable::read(reader)?;
-                               InputMaterial::Funding {
-                                       channel_value
-                               }
+                               InputMaterial::Funding {}
                        }
                        _ => return Err(DecodeError::InvalidValue),
                };
@@ -1864,7 +1858,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                }
                let should_broadcast = self.would_broadcast_at_height(height);
                if should_broadcast {
-                       claimable_outpoints.push(ClaimRequest { absolute_timelock: height, aggregable: false, outpoint: BitcoinOutPoint { txid: self.funding_info.0.txid.clone(), vout: self.funding_info.0.index as u32 }, witness_data: InputMaterial::Funding { channel_value: self.channel_value_satoshis }});
+                       claimable_outpoints.push(ClaimRequest { absolute_timelock: height, aggregable: false, outpoint: BitcoinOutPoint { txid: self.funding_info.0.txid.clone(), vout: self.funding_info.0.index as u32 }, witness_data: InputMaterial::Funding {}});
                }
                if should_broadcast {
                        if let Some(commitment_tx) = self.onchain_tx_handler.get_fully_signed_local_tx() {
index cb76dcb2a55255557ba1ca5209789cd3263f77d5..186793581cea9cd05f9d281b77074508c72ba8c7 100644 (file)
@@ -531,16 +531,11 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
                                                }
                                                return None;
                                        },
-                                       &InputMaterial::Funding { ref channel_value } => {
+                                       &InputMaterial::Funding {} => {
                                                let signed_tx = self.get_fully_signed_local_tx().unwrap();
-                                               let mut amt_outputs = 0;
-                                               for outp in signed_tx.output.iter() {
-                                                       amt_outputs += outp.value;
-                                               }
-                                               let feerate = (channel_value - amt_outputs) * 1000 / signed_tx.get_weight() as u64;
                                                // Timer set to $NEVER given we can't bump tx without anchor outputs
                                                log_trace!(self, "Going to broadcast Local Transaction {} claiming funding output {} from {}...", signed_tx.txid(), outp.vout, outp.txid);
-                                               return Some((None, feerate, signed_tx));
+                                               return Some((None, self.local_commitment.as_ref().unwrap().feerate_per_kw, signed_tx));
                                        }
                                        _ => unreachable!()
                                }