Skip to content

Commit 5b56589

Browse files
committed
Add ChannelSigner::spend_holder_anchor_input
1 parent b6e5b72 commit 5b56589

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

lightning/src/events/bump_transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,8 @@ where
687687
anchor_tx = self.utxo_source.sign_psbt(anchor_psbt)?;
688688

689689
let signer = anchor_descriptor.derive_channel_signer(&self.signer_provider);
690-
let anchor_sig = signer.sign_holder_anchor_input(&anchor_tx, 0, &self.secp)?;
691-
anchor_tx.input[0].witness = anchor_descriptor.tx_input_witness(&anchor_sig);
690+
let anchor_witness = signer.spend_holder_anchor_output(&anchor_tx, 0, &self.secp)?;
691+
anchor_tx.input[0].witness = anchor_witness;
692692

693693
#[cfg(debug_assertions)] {
694694
let signed_tx_weight = anchor_tx.weight().to_wu();

lightning/src/sign/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,11 @@ pub trait ChannelSigner {
10451045
None
10461046
}
10471047
}
1048+
1049+
/// Spend the holder anchor output
1050+
fn spend_holder_anchor_output(
1051+
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
1052+
) -> Result<Witness, ()>;
10481053
}
10491054

10501055
/// Specifies the recipient of an invoice.
@@ -1795,6 +1800,15 @@ impl ChannelSigner for InMemorySigner {
17951800
features,
17961801
))
17971802
}
1803+
1804+
fn spend_holder_anchor_output(
1805+
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
1806+
) -> Result<Witness, ()> {
1807+
let anchor_sig =
1808+
EcdsaChannelSigner::sign_holder_anchor_input(self, anchor_tx, input_idx, secp_ctx)?;
1809+
let funding_pubkey = self.pubkeys().funding_pubkey;
1810+
Ok(chan_utils::build_anchor_input_witness(&funding_pubkey, &anchor_sig))
1811+
}
17981812
}
17991813

18001814
const MISSING_PARAMS_ERR: &'static str =

lightning/src/util/test_channel_signer.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ impl ChannelSigner for TestChannelSigner {
319319
}
320320
Ok(self.inner.sign_holder_htlc_transaction(htlc_tx, input, htlc_descriptor, secp_ctx).unwrap())
321321
}
322+
323+
fn spend_holder_anchor_output(
324+
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
325+
) -> Result<Witness, ()> {
326+
self.inner.spend_holder_anchor_output(anchor_tx, input_idx, secp_ctx)
327+
}
322328
}
323329

324330
impl EcdsaChannelSigner for TestChannelSigner {

0 commit comments

Comments
 (0)