Skip to content

Commit 46f35c0

Browse files
committed
Add public helper to build anchor input witnesses
1 parent 4edb0f4 commit 46f35c0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,14 @@ pub(crate) fn get_anchor_output<'a>(commitment_tx: &'a Transaction, funding_pubk
735735
.map(|(idx, txout)| (idx as u32, txout))
736736
}
737737

738+
/// Returns the witness required to satisfy and spend an anchor input.
739+
pub fn build_anchor_input_witness(funding_key: &PublicKey, funding_sig: &Signature) -> Witness {
740+
let anchor_redeem_script = chan_utils::get_anchor_redeemscript(funding_key);
741+
let mut funding_sig = funding_sig.serialize_der().to_vec();
742+
funding_sig.push(EcdsaSighashType::All as u8);
743+
Witness::from_vec(vec![funding_sig, anchor_redeem_script.to_bytes()])
744+
}
745+
738746
/// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction).
739747
/// The fields are organized by holder/counterparty.
740748
///

0 commit comments

Comments
 (0)