}
}
+/// Gets the witnessScript for the to_remote output when anchors are enabled.
+#[inline]
+pub(crate) fn get_to_countersignatory_with_anchors_redeemscript(payment_point: &PublicKey) -> Script {
+ Builder::new()
+ .push_slice(&payment_point.serialize()[..])
+ .push_opcode(opcodes::all::OP_CHECKSIGVERIFY)
+ .push_int(1)
+ .push_opcode(opcodes::all::OP_CSV)
+ .into_script()
+}
+
/// Gets the witnessScript for an anchor output from the funding public key.
/// The witness in the spending input must be:
/// <BIP 143 funding_signature>
let mut txouts: Vec<(TxOut, Option<&mut HTLCOutputInCommitment>)> = Vec::new();
if to_countersignatory_value_sat > 0 {
- let script = script_for_p2wpkh(&countersignatory_pubkeys.payment_point);
+ let script = if opt_anchors {
+ get_to_countersignatory_with_anchors_redeemscript(&countersignatory_pubkeys.payment_point).to_v0_p2wsh()
+ } else {
+ script_for_p2wpkh(&countersignatory_pubkeys.payment_point)
+ };
txouts.push((
TxOut {
script_pubkey: script.clone(),
use super::CounterpartyCommitmentSecrets;
use ::{hex, chain};
use prelude::*;
- use ln::chan_utils::{CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment};
+ use ln::chan_utils::{get_to_countersignatory_with_anchors_redeemscript, script_for_p2wpkh, CommitmentTransaction, TxCreationKeys, ChannelTransactionParameters, CounterpartyChannelTransactionParameters, HTLCOutputInCommitment};
use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1};
use util::test_utils;
use chain::keysinterface::{KeysInterface, BaseSign};
&mut htlcs_with_aux, &channel_parameters.as_holder_broadcastable()
);
assert_eq!(tx.built.transaction.output.len(), 2);
+ assert_eq!(tx.built.transaction.output[1].script_pubkey, script_for_p2wpkh(&counterparty_pubkeys.payment_point));
// Generate broadcaster and counterparty outputs as well as two anchors
let tx = CommitmentTransaction::new_with_auxiliary_htlc_data(
&mut htlcs_with_aux, &channel_parameters.as_holder_broadcastable()
);
assert_eq!(tx.built.transaction.output.len(), 4);
+ assert_eq!(tx.built.transaction.output[3].script_pubkey, get_to_countersignatory_with_anchors_redeemscript(&counterparty_pubkeys.payment_point).to_v0_p2wsh());
// Generate broadcaster output and anchor
let tx = CommitmentTransaction::new_with_auxiliary_htlc_data(