Skip to content

Commit abe85a1

Browse files
committed
Add public helper to build anchor input witnesses
1 parent 2fa45ae commit abe85a1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lightning/src/ln/chan_utils.rs

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

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

0 commit comments

Comments
 (0)