self.prev_local_signed_commitment_tx = self.current_local_signed_commitment_tx.take();
self.current_local_signed_commitment_tx = Some(LocalSignedTx {
txid: commitment_tx.txid(),
- tx: commitment_tx,
+ tx: commitment_tx.clone(),
revocation_key: local_keys.revocation_key,
a_htlc_key: local_keys.a_htlc_key,
b_htlc_key: local_keys.b_htlc_key,
feerate_per_kw,
htlc_outputs,
});
+ self.onchain_tx_handler.provide_latest_local_tx(commitment_tx);
Ok(())
}
use ln::msgs::DecodeError;
use ln::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER, InputMaterial, ClaimRequest};
-use ln::chan_utils::HTLCType;
+use ln::chan_utils::{HTLCType, LocalCommitmentTransaction};
use chain::chaininterface::{FeeEstimator, BroadcasterInterface, ConfirmationTarget, MIN_RELAY_FEE_SAT_PER_1000_WEIGHT};
use chain::keysinterface::ChannelKeys;
use util::logger::Logger;
pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
destination_script: Script,
funding_redeemscript: Script,
+ local_commitment: Option<LocalCommitmentTransaction>,
+ prev_local_commitment: Option<LocalCommitmentTransaction>,
key_storage: ChanSigner,
pub(crate) fn write<W: Writer>(&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)?;
self.key_storage.write(writer)?;
fn read<R: ::std::io::Read>(reader: &mut R, logger: Arc<Logger>) -> Result<Self, DecodeError> {
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)?;
let key_storage = Readable::read(reader)?;
Ok(OnchainTxHandler {
destination_script,
funding_redeemscript,
+ local_commitment,
+ prev_local_commitment,
key_storage,
claimable_outpoints,
pending_claim_requests,
OnchainTxHandler {
destination_script,
funding_redeemscript,
+ local_commitment: None,
+ prev_local_commitment: None,
key_storage,
pending_claim_requests: HashMap::new(),
claimable_outpoints: HashMap::new(),
self.pending_claim_requests.remove(&req);
}
}
+
+ pub(super) fn provide_latest_local_tx(&mut self, tx: LocalCommitmentTransaction) {
+ self.prev_local_commitment = self.local_commitment.take();
+ self.local_commitment = Some(tx);
+ }
}