Dry-up InputMaterial::Funding

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.
This commit is contained in:
Antoine Riard 2020-04-20 21:19:00 -04:00 committed by Matt Corallo
parent 4dc0dd17c0
commit 359b3d5702
2 changed files with 6 additions and 17 deletions

View 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() {

View 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!()
}