Skip to content

Commit 6ae33dc

Browse files
committed
Set correct counterparty_spendable_height for outb local HTLCs
For outbound HTLCs, the counterparty can spend the output immediately. This fixes the `counterparty_spendable_height` in the `PackageTemplate` claiming outbound HTLCs on local commitment transactions, which was previously spuriously set to the HTLC timeout (at which point *we* can claim the HTLC).
1 parent d557334 commit 6ae33dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,19 +3666,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36663666
// Returns (1) `PackageTemplate`s that can be given to the OnchainTxHandler, so that the handler can
36673667
// broadcast transactions claiming holder HTLC commitment outputs and (2) a holder revokable
36683668
// script so we can detect whether a holder transaction has been seen on-chain.
3669-
fn get_broadcasted_holder_claims(&self, holder_tx: &HolderSignedTx, _conf_height: u32) -> (Vec<PackageTemplate>, Option<(ScriptBuf, PublicKey, RevocationKey)>) {
3669+
fn get_broadcasted_holder_claims(&self, holder_tx: &HolderSignedTx, conf_height: u32) -> (Vec<PackageTemplate>, Option<(ScriptBuf, PublicKey, RevocationKey)>) {
36703670
let mut claim_requests = Vec::with_capacity(holder_tx.htlc_outputs.len());
36713671

36723672
let redeemscript = chan_utils::get_revokeable_redeemscript(&holder_tx.revocation_key, self.on_holder_tx_csv, &holder_tx.delayed_payment_key);
36733673
let broadcasted_holder_revokable_script = Some((redeemscript.to_p2wsh(), holder_tx.per_commitment_point.clone(), holder_tx.revocation_key.clone()));
36743674

36753675
for &(ref htlc, _, _) in holder_tx.htlc_outputs.iter() {
36763676
if let Some(transaction_output_index) = htlc.transaction_output_index {
3677-
let htlc_output = if htlc.offered {
3677+
let (htlc_output, counterparty_spendable_height) = if htlc.offered {
36783678
let htlc_output = HolderHTLCOutput::build_offered(
36793679
htlc.amount_msat, htlc.cltv_expiry, self.onchain_tx_handler.channel_type_features().clone()
36803680
);
3681-
htlc_output
3681+
(htlc_output, conf_height)
36823682
} else {
36833683
let payment_preimage = if let Some(preimage) = self.payment_preimages.get(&htlc.payment_hash) {
36843684
preimage.clone()
@@ -3689,12 +3689,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36893689
let htlc_output = HolderHTLCOutput::build_accepted(
36903690
payment_preimage, htlc.amount_msat, self.onchain_tx_handler.channel_type_features().clone()
36913691
);
3692-
htlc_output
3692+
(htlc_output, htlc.cltv_expiry)
36933693
};
36943694
let htlc_package = PackageTemplate::build_package(
36953695
holder_tx.txid, transaction_output_index,
36963696
PackageSolvingData::HolderHTLCOutput(htlc_output),
3697-
htlc.cltv_expiry,
3697+
counterparty_spendable_height,
36983698
);
36993699
claim_requests.push(htlc_package);
37003700
}

0 commit comments

Comments
 (0)