X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonchaintx.rs;h=8d5ed6cbc3c0771789020ad2fd73930b8f69c0cc;hb=5381c23d729f3f7dfd08faa3a336805fb8bbd30e;hp=7aced598ecbb4f39c9a4d30dada413021c9e0bb9;hpb=00d063df5c46ef313901f2a69cff8ffe2cf8cb55;p=rust-lightning diff --git a/lightning/src/ln/onchaintx.rs b/lightning/src/ln/onchaintx.rs index 7aced598..8d5ed6cb 100644 --- a/lightning/src/ln/onchaintx.rs +++ b/lightning/src/ln/onchaintx.rs @@ -25,7 +25,7 @@ use ln::msgs::DecodeError; use ln::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER, InputMaterial, ClaimRequest}; use ln::channelmanager::PaymentPreimage; use ln::chan_utils; -use ln::chan_utils::{TxCreationKeys, LocalCommitmentTransaction}; +use ln::chan_utils::{TxCreationKeys, HolderCommitmentTransaction}; use chain::chaininterface::{FeeEstimator, BroadcasterInterface, ConfirmationTarget, MIN_RELAY_FEE_SAT_PER_1000_WEIGHT}; use chain::keysinterface::ChannelKeys; use util::logger::Logger; @@ -241,13 +241,13 @@ impl Writeable for Option>> { /// do RBF bumping if possible. pub struct OnchainTxHandler { destination_script: Script, - holder_commitment: Option, + holder_commitment: Option, // holder_htlc_sigs and prev_holder_htlc_sigs are in the order as they appear in the commitment // transaction outputs (hence the Option<>s inside the Vec). The first usize is the index in - // the set of HTLCs in the LocalCommitmentTransaction (including those which do not appear in + // the set of HTLCs in the HolderCommitmentTransaction (including those which do not appear in // the commitment transaction). holder_htlc_sigs: Option>>, - prev_holder_commitment: Option, + prev_holder_commitment: Option, prev_holder_htlc_sigs: Option>>, on_holder_tx_csv: u16, @@ -657,7 +657,7 @@ impl OnchainTxHandler { None } - pub(super) fn block_connected(&mut self, txn_matched: &[&Transaction], claimable_outpoints: Vec, height: u32, broadcaster: B, fee_estimator: F, logger: L) + pub(super) fn block_connected(&mut self, txn_matched: &[(usize, &Transaction)], claimable_outpoints: Vec, height: u32, broadcaster: B, fee_estimator: F, logger: L) where B::Target: BroadcasterInterface, F::Target: FeeEstimator, L::Target: Logger, @@ -706,7 +706,7 @@ impl OnchainTxHandler { } let mut bump_candidates = HashMap::new(); - for tx in txn_matched { + for &(_, tx) in txn_matched { // Scan all input to verify is one of the outpoint spent is of interest for us let mut claimed_outputs_material = Vec::new(); for inp in &tx.input { @@ -877,18 +877,9 @@ impl OnchainTxHandler { } } - pub(super) fn provide_latest_holder_tx(&mut self, tx: LocalCommitmentTransaction) -> Result<(), ()> { - // To prevent any unsafe state discrepancy between offchain and onchain, once holder - // commitment transaction has been signed due to an event (either block height for - // HTLC-timeout or channel force-closure), don't allow any further update of holder - // commitment transaction view to avoid delivery of revocation secret to counterparty - // for the aformentionned signed transaction. - if self.holder_htlc_sigs.is_some() || self.prev_holder_htlc_sigs.is_some() { - return Err(()); - } + pub(super) fn provide_latest_holder_tx(&mut self, tx: HolderCommitmentTransaction) { self.prev_holder_commitment = self.holder_commitment.take(); self.holder_commitment = Some(tx); - Ok(()) } fn sign_latest_holder_htlcs(&mut self) { @@ -931,7 +922,7 @@ impl OnchainTxHandler { pub(super) fn get_fully_signed_holder_tx(&mut self, funding_redeemscript: &Script) -> Option { if let Some(ref mut holder_commitment) = self.holder_commitment { match self.key_storage.sign_holder_commitment(holder_commitment, &self.secp_ctx) { - Ok(sig) => Some(holder_commitment.add_local_sig(funding_redeemscript, sig)), + Ok(sig) => Some(holder_commitment.add_holder_sig(funding_redeemscript, sig)), Err(_) => return None, } } else { @@ -944,7 +935,7 @@ impl OnchainTxHandler { if let Some(ref mut holder_commitment) = self.holder_commitment { let holder_commitment = holder_commitment.clone(); match self.key_storage.sign_holder_commitment(&holder_commitment, &self.secp_ctx) { - Ok(sig) => Some(holder_commitment.add_local_sig(funding_redeemscript, sig)), + Ok(sig) => Some(holder_commitment.add_holder_sig(funding_redeemscript, sig)), Err(_) => return None, } } else {