X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchan_utils.rs;h=982257b633673f05521d7788167059ebf60af0da;hb=97c29cfd34a93e585dde3cd3efc6d6185b54fdc7;hp=4690d298aedee2a7f16b18adf09ffee8ac202c4e;hpb=4368b56eb6a0a00b2181c13cadf55ab4a0c9f9a8;p=rust-lightning diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index 4690d298..982257b6 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -564,6 +564,23 @@ pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, conte } } +/// Gets the witnessScript for an anchor output from the funding public key. +/// The witness in the spending input must be: +/// +/// After 16 blocks of confirmation, an alternative satisfying witness could be: +/// <> +#[inline] +pub(crate) fn get_anchor_redeemscript(funding_pubkey: &PublicKey) -> Script { + Builder::new().push_slice(&funding_pubkey.serialize()[..]) + .push_opcode(opcodes::all::OP_CHECKSIG) + .push_opcode(opcodes::all::OP_IFDUP) + .push_opcode(opcodes::all::OP_NOTIF) + .push_int(16) + .push_opcode(opcodes::all::OP_CSV) + .push_opcode(opcodes::all::OP_ENDIF) + .into_script() +} + /// Per-channel data used to build transactions in conjunction with the per-commitment data (CommitmentTransaction). /// The fields are organized by holder/counterparty. ///