X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonchaintx.rs;fp=lightning%2Fsrc%2Fln%2Fonchaintx.rs;h=cb76dcb2a55255557ba1ca5209789cd3263f77d5;hb=5b24d3e3275b8ca7f0ea064cc1626c8e1def2ccb;hp=3b8238ddcae3d0b3f79d2cb63dbb4ea96eab10ad;hpb=99a34e1d17eb97f62f0f855a85c87fc770a5c1f3;p=rust-lightning diff --git a/lightning/src/ln/onchaintx.rs b/lightning/src/ln/onchaintx.rs index 3b8238dd..cb76dcb2 100644 --- a/lightning/src/ln/onchaintx.rs +++ b/lightning/src/ln/onchaintx.rs @@ -142,7 +142,6 @@ macro_rules! subtract_high_prio_fee { /// do RBF bumping if possible. pub struct OnchainTxHandler { destination_script: Script, - funding_redeemscript: Script, local_commitment: Option, prev_local_commitment: Option, local_csv: u16, @@ -185,7 +184,6 @@ pub struct OnchainTxHandler { impl OnchainTxHandler { pub(crate) fn write(&self, writer: &mut W) -> Result<(), ::std::io::Error> { self.destination_script.write(writer)?; - self.funding_redeemscript.write(writer)?; self.local_commitment.write(writer)?; self.prev_local_commitment.write(writer)?; @@ -231,7 +229,6 @@ impl OnchainTxHandler { impl ReadableArgs> for OnchainTxHandler { fn read(reader: &mut R, logger: Arc) -> Result { let destination_script = Readable::read(reader)?; - let funding_redeemscript = Readable::read(reader)?; let local_commitment = Readable::read(reader)?; let prev_local_commitment = Readable::read(reader)?; @@ -285,7 +282,6 @@ impl ReadableArgs> for OnchainTx Ok(OnchainTxHandler { destination_script, - funding_redeemscript, local_commitment, prev_local_commitment, local_csv, @@ -300,13 +296,12 @@ impl ReadableArgs> for OnchainTx } impl OnchainTxHandler { - pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, local_csv: u16, logger: Arc) -> Self { + pub(super) fn new(destination_script: Script, keys: ChanSigner, local_csv: u16, logger: Arc) -> Self { let key_storage = keys; OnchainTxHandler { destination_script, - funding_redeemscript, local_commitment: None, prev_local_commitment: None, local_csv, @@ -537,7 +532,7 @@ impl OnchainTxHandler { return None; }, &InputMaterial::Funding { ref channel_value } => { - let signed_tx = self.get_fully_signed_local_tx(*channel_value).unwrap(); + 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; @@ -585,17 +580,17 @@ impl OnchainTxHandler { // Generate claim transactions and track them to bump if necessary at // height timer expiration (i.e in how many blocks we're going to take action). - for claim in new_claims { - let mut claim_material = ClaimTxBumpMaterial { height_timer: None, feerate_previous: 0, soonest_timelock: claim.0, per_input_material: claim.1.clone() }; + for (soonest_timelock, claim) in new_claims.drain(..) { + let mut claim_material = ClaimTxBumpMaterial { height_timer: None, feerate_previous: 0, soonest_timelock, per_input_material: claim }; if let Some((new_timer, new_feerate, tx)) = self.generate_claim_tx(height, &claim_material, &*fee_estimator) { claim_material.height_timer = new_timer; claim_material.feerate_previous = new_feerate; let txid = tx.txid(); - self.pending_claim_requests.insert(txid, claim_material); - for k in claim.1.keys() { + for k in claim_material.per_input_material.keys() { log_trace!(self, "Registering claiming request for {}:{}", k.txid, k.vout); self.claimable_outpoints.insert(k.clone(), (txid, height)); } + self.pending_claim_requests.insert(txid, claim_material); log_trace!(self, "Broadcast onchain {}", log_tx!(tx)); broadcaster.broadcast_transaction(&tx); } @@ -790,19 +785,19 @@ impl OnchainTxHandler { // have empty local commitment transaction if a ChannelMonitor is asked to force-close just after Channel::get_outbound_funding_created, // before providing a initial commitment transaction. For outbound channel, init ChannelMonitor at Channel::funding_signed, there is nothing // to monitor before. - pub(super) fn get_fully_signed_local_tx(&mut self, channel_value_satoshis: u64) -> Option { + pub(super) fn get_fully_signed_local_tx(&mut self) -> Option { if let Some(ref mut local_commitment) = self.local_commitment { - self.key_storage.sign_local_commitment(local_commitment, &self.funding_redeemscript, channel_value_satoshis, &self.secp_ctx); + self.key_storage.sign_local_commitment(local_commitment, &self.secp_ctx); return Some(local_commitment.with_valid_witness().clone()); } None } #[cfg(test)] - pub(super) fn get_fully_signed_copy_local_tx(&mut self, channel_value_satoshis: u64) -> Option { + pub(super) fn get_fully_signed_copy_local_tx(&mut self) -> Option { if let Some(ref mut local_commitment) = self.local_commitment { let mut local_commitment = local_commitment.clone(); - self.key_storage.unsafe_sign_local_commitment(&mut local_commitment, &self.funding_redeemscript, channel_value_satoshis, &self.secp_ctx); + self.key_storage.unsafe_sign_local_commitment(&mut local_commitment, &self.secp_ctx); return Some(local_commitment.with_valid_witness().clone()); } None