Skip to content

Commit

Permalink
fix: Construct closing TX based on original funding TXO
Browse files Browse the repository at this point in the history
  • Loading branch information
luckysori committed Aug 8, 2023
1 parent 1e5b2a4 commit 9212cef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
assert!(self.shutdown_scriptpubkey.is_some());
let holder_shutdown_script = self.get_closing_scriptpubkey();
let counterparty_shutdown_script = self.counterparty_shutdown_scriptpubkey.clone().unwrap();
let funding_outpoint = self.funding_outpoint().into_bitcoin_outpoint();

// The closing transaction should always spend from the _original_ funding outpoint
// (NOT the `glue_transaction`).
let funding_outpoint = self.original_funding_outpoint().into_bitcoin_outpoint();

let closing_transaction = ClosingTransaction::new(value_to_holder as u64, value_to_counterparty as u64, holder_shutdown_script, counterparty_shutdown_script, funding_outpoint);
(closing_transaction, total_fee_satoshis)
Expand All @@ -1788,6 +1791,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
self.channel_transaction_parameters.funding_outpoint.unwrap()
}

fn original_funding_outpoint(&self) -> OutPoint {
match self.channel_transaction_parameters.original_funding_outpoint {
Some(outpoint) => outpoint,
None => self.funding_outpoint(),
}
}

#[inline]
/// Creates a set of keys for build_commitment_transaction to generate a transaction which our
/// counterparty will sign (ie DO NOT send signatures over a transaction created by this to
Expand Down

0 comments on commit 9212cef

Please sign in to comment.