Skip to content

Commit 0d64c86

Browse files
authored
Merge pull request #4089 from tankyleo/2025-09-round-1-0fc-tests
0FC tests round 1
2 parents aa813a2 + 1618c77 commit 0d64c86

File tree

12 files changed

+610
-335
lines changed

12 files changed

+610
-335
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5842,6 +5842,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
58425842
assert_eq!(&bitcoin::Address::p2wsh(&ScriptBuf::from(input.witness.last().unwrap().to_vec()), bitcoin::Network::Bitcoin).script_pubkey(), _script_pubkey);
58435843
} else if _script_pubkey.is_p2wpkh() {
58445844
assert_eq!(&bitcoin::Address::p2wpkh(&bitcoin::CompressedPublicKey(bitcoin::PublicKey::from_slice(&input.witness.last().unwrap()).unwrap().inner), bitcoin::Network::Bitcoin).script_pubkey(), _script_pubkey);
5845+
} else if _script_pubkey == &chan_utils::shared_anchor_script_pubkey() {
5846+
assert!(input.witness.is_empty());
58455847
} else { panic!(); }
58465848
}
58475849
return true;

lightning/src/chain/package.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ pub(crate) fn verify_channel_type_features(channel_type_features: &Option<Channe
9898
let mut supported_feature_set = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
9999
supported_feature_set.set_scid_privacy_required();
100100
supported_feature_set.set_zero_conf_required();
101-
102-
#[cfg(test)]
103101
supported_feature_set.set_anchor_zero_fee_commitments_required();
104102

105103
// allow the passing of an additional necessary permitted flag

lightning/src/events/bump_transaction/mod.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use crate::io_extras::sink;
2424
use crate::ln::chan_utils;
2525
use crate::ln::chan_utils::{
2626
shared_anchor_script_pubkey, HTLCOutputInCommitment, ANCHOR_INPUT_WITNESS_WEIGHT,
27-
HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT, HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT,
27+
HTLC_SUCCESS_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT, HTLC_SUCCESS_INPUT_P2A_ANCHOR_WITNESS_WEIGHT,
28+
HTLC_TIMEOUT_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT, HTLC_TIMEOUT_INPUT_P2A_ANCHOR_WITNESS_WEIGHT,
2829
P2A_ANCHOR_INPUT_WITNESS_WEIGHT,
2930
};
3031
use crate::ln::types::ChannelId;
@@ -849,23 +850,45 @@ where
849850
&self, claim_id: ClaimId, target_feerate_sat_per_1000_weight: u32,
850851
htlc_descriptors: &[HTLCDescriptor], tx_lock_time: LockTime,
851852
) -> Result<(), ()> {
853+
let channel_type = &htlc_descriptors[0]
854+
.channel_derivation_parameters
855+
.transaction_parameters
856+
.channel_type_features;
852857
let mut htlc_tx = Transaction {
853-
version: Version::TWO,
858+
version: if channel_type.supports_anchor_zero_fee_commitments() {
859+
Version::non_standard(3)
860+
} else {
861+
Version::TWO
862+
},
854863
lock_time: tx_lock_time,
855864
input: vec![],
856865
output: vec![],
857866
};
858867
let mut must_spend = Vec::with_capacity(htlc_descriptors.len());
868+
let (htlc_success_witness_weight, htlc_timeout_witness_weight) =
869+
if channel_type.supports_anchor_zero_fee_commitments() {
870+
(
871+
HTLC_SUCCESS_INPUT_P2A_ANCHOR_WITNESS_WEIGHT,
872+
HTLC_TIMEOUT_INPUT_P2A_ANCHOR_WITNESS_WEIGHT,
873+
)
874+
} else if channel_type.supports_anchors_zero_fee_htlc_tx() {
875+
(
876+
HTLC_SUCCESS_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT,
877+
HTLC_TIMEOUT_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT,
878+
)
879+
} else {
880+
panic!("channel type should be either zero-fee HTLCs, or zero-fee commitments");
881+
};
859882
for htlc_descriptor in htlc_descriptors {
860883
let htlc_input = htlc_descriptor.unsigned_tx_input();
861884
must_spend.push(Input {
862885
outpoint: htlc_input.previous_output.clone(),
863886
previous_utxo: htlc_descriptor.previous_utxo(&self.secp),
864887
satisfaction_weight: EMPTY_SCRIPT_SIG_WEIGHT
865888
+ if htlc_descriptor.preimage.is_some() {
866-
HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT
889+
htlc_success_witness_weight
867890
} else {
868-
HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT
891+
htlc_timeout_witness_weight
869892
},
870893
});
871894
htlc_tx.input.push(htlc_input);

lightning/src/ln/async_signer_tests.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@
1111
//! properly with a signer implementation that asynchronously derives signatures.
1212
1313
use crate::prelude::*;
14-
use bitcoin::locktime::absolute::LockTime;
1514
use bitcoin::secp256k1::Secp256k1;
16-
use bitcoin::transaction::Version;
17-
use bitcoin::{Amount, Transaction, TxIn, TxOut};
1815

1916
use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
2017
use crate::chain::ChannelMonitorUpdateStatus;
21-
use crate::events::bump_transaction::sync::WalletSourceSync;
2218
use crate::events::{ClosureReason, Event};
2319
use crate::ln::chan_utils::ClosingTransaction;
2420
use crate::ln::channel::DISCONNECT_PEER_AWAITING_RESPONSE_TICKS;
@@ -972,15 +968,14 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
972968
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_2);
973969
}
974970

975-
fn do_test_async_holder_signatures(anchors: bool, remote_commitment: bool) {
971+
fn do_test_async_holder_signatures(keyed_anchors: bool, p2a_anchor: bool, remote_commitment: bool) {
976972
// Ensures that we can obtain holder signatures for commitment and HTLC transactions
977973
// asynchronously by allowing their retrieval to fail and retrying via
978974
// `ChannelMonitor::signer_unblocked`.
979975
let mut config = test_default_channel_config();
980-
if anchors {
981-
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = true;
982-
config.manually_accept_inbound_channels = true;
983-
}
976+
config.channel_handshake_config.negotiate_anchors_zero_fee_htlc_tx = keyed_anchors;
977+
config.channel_handshake_config.negotiate_anchor_zero_fee_commitments = p2a_anchor;
978+
config.manually_accept_inbound_channels = keyed_anchors || p2a_anchor;
984979

985980
let chanmon_cfgs = create_chanmon_cfgs(2);
986981
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
@@ -990,23 +985,8 @@ fn do_test_async_holder_signatures(anchors: bool, remote_commitment: bool) {
990985
let node_b_id = nodes[1].node.get_our_node_id();
991986

992987
let closing_node = if remote_commitment { &nodes[1] } else { &nodes[0] };
993-
let coinbase_tx = Transaction {
994-
version: Version::TWO,
995-
lock_time: LockTime::ZERO,
996-
input: vec![TxIn { ..Default::default() }],
997-
output: vec![TxOut {
998-
value: Amount::ONE_BTC,
999-
script_pubkey: closing_node.wallet_source.get_change_script().unwrap(),
1000-
}],
1001-
};
1002-
if anchors {
1003-
*nodes[0].fee_estimator.sat_per_kw.lock().unwrap() *= 2;
1004-
*nodes[1].fee_estimator.sat_per_kw.lock().unwrap() *= 2;
1005-
closing_node.wallet_source.add_utxo(
1006-
bitcoin::OutPoint { txid: coinbase_tx.compute_txid(), vout: 0 },
1007-
coinbase_tx.output[0].value,
1008-
);
1009-
}
988+
989+
let coinbase_tx = provide_anchor_reserves(&nodes);
1010990

1011991
// Route an HTLC and set the signer as unavailable.
1012992
let (_, _, chan_id, funding_tx) = create_announced_chan_between_nodes(&nodes, 0, 1);
@@ -1051,13 +1031,18 @@ fn do_test_async_holder_signatures(anchors: bool, remote_commitment: bool) {
10511031
&nodes[0].logger,
10521032
);
10531033
}
1054-
if anchors {
1034+
if keyed_anchors || p2a_anchor {
10551035
handle_bump_close_event(closing_node);
10561036
}
10571037

10581038
let commitment_tx = {
10591039
let mut txn = closing_node.tx_broadcaster.txn_broadcast();
1060-
if anchors || remote_commitment {
1040+
if p2a_anchor {
1041+
assert_eq!(txn.len(), 2);
1042+
check_spends!(txn[0], funding_tx);
1043+
check_spends!(txn[1], txn[0], coinbase_tx);
1044+
txn.remove(0)
1045+
} else if keyed_anchors || remote_commitment {
10611046
assert_eq!(txn.len(), 1);
10621047
check_spends!(txn[0], funding_tx);
10631048
txn.remove(0)
@@ -1102,7 +1087,7 @@ fn do_test_async_holder_signatures(anchors: bool, remote_commitment: bool) {
11021087
}
11031088

11041089
// No HTLC transaction should be broadcast as the signer is not available yet.
1105-
if anchors && !remote_commitment {
1090+
if (keyed_anchors || p2a_anchor) && !remote_commitment {
11061091
handle_bump_htlc_event(&nodes[0], 1);
11071092
}
11081093
let txn = nodes[0].tx_broadcaster.txn_broadcast();
@@ -1117,7 +1102,7 @@ fn do_test_async_holder_signatures(anchors: bool, remote_commitment: bool) {
11171102
&nodes[0].logger,
11181103
);
11191104

1120-
if anchors && !remote_commitment {
1105+
if (keyed_anchors || p2a_anchor) && !remote_commitment {
11211106
handle_bump_htlc_event(&nodes[0], 1);
11221107
}
11231108
{
@@ -1129,22 +1114,32 @@ fn do_test_async_holder_signatures(anchors: bool, remote_commitment: bool) {
11291114

11301115
#[test]
11311116
fn test_async_holder_signatures_no_anchors() {
1132-
do_test_async_holder_signatures(false, false);
1117+
do_test_async_holder_signatures(false, false, false);
11331118
}
11341119

11351120
#[test]
11361121
fn test_async_holder_signatures_remote_commitment_no_anchors() {
1137-
do_test_async_holder_signatures(false, true);
1122+
do_test_async_holder_signatures(false, false, true);
1123+
}
1124+
1125+
#[test]
1126+
fn test_async_holder_signatures_keyed_anchors() {
1127+
do_test_async_holder_signatures(true, false, false);
1128+
}
1129+
1130+
#[test]
1131+
fn test_async_holder_signatures_remote_commitment_keyed_anchors() {
1132+
do_test_async_holder_signatures(true, false, true);
11381133
}
11391134

11401135
#[test]
1141-
fn test_async_holder_signatures_anchors() {
1142-
do_test_async_holder_signatures(true, false);
1136+
fn test_async_holder_signatures_p2a_anchor() {
1137+
do_test_async_holder_signatures(false, true, false);
11431138
}
11441139

11451140
#[test]
1146-
fn test_async_holder_signatures_remote_commitment_anchors() {
1147-
do_test_async_holder_signatures(true, true);
1141+
fn test_async_holder_signatures_remote_commitment_p2a_anchor() {
1142+
do_test_async_holder_signatures(false, true, true);
11481143
}
11491144

11501145
#[test]

lightning/src/ln/chan_utils.rs

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ pub fn max_htlcs(channel_type: &ChannelTypeFeatures) -> u16 {
6969
483
7070
}
7171
}
72-
/// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, non-anchor variant.
72+
/// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, non-anchor and p2a anchor variant.
7373
pub const OFFERED_HTLC_SCRIPT_WEIGHT: usize = 133;
74-
/// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, anchor variant.
75-
pub const OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS: usize = 136;
74+
/// The weight of a BIP141 witnessScript for a BOLT3's "offered HTLC output" on a commitment transaction, keyed anchor variant.
75+
pub const OFFERED_HTLC_SCRIPT_WEIGHT_KEYED_ANCHORS: usize = 136;
7676

7777
/// The weight of a BIP141 witnessScript for a BOLT3's "received HTLC output" can vary in function of its CLTV argument value.
7878
/// We define a range that encompasses both its non-anchors and anchors variants.
@@ -95,12 +95,16 @@ pub const P2A_ANCHOR_INPUT_WITNESS_WEIGHT: u64 = 1;
9595
/// The maximum value of a P2A anchor.
9696
pub const P2A_MAX_VALUE: u64 = 240;
9797

98-
/// The upper bound weight of an HTLC timeout input from a commitment transaction with anchor
99-
/// outputs.
100-
pub const HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = 288;
101-
/// The upper bound weight of an HTLC success input from a commitment transaction with anchor
102-
/// outputs.
103-
pub const HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = 327;
98+
/// The upper bound weight of an HTLC timeout input from a commitment transaction with keyed anchor outputs.
99+
pub const HTLC_TIMEOUT_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT: u64 = 288;
100+
/// The upper bound weight of an HTLC timeout input from a commitment transaction with a p2a anchor output.
101+
/// Note the corresponding outputs no longer have the 1 CSV lock.
102+
pub const HTLC_TIMEOUT_INPUT_P2A_ANCHOR_WITNESS_WEIGHT: u64 = 285;
103+
/// The upper bound weight of an HTLC success input from a commitment transaction with keyed anchor outputs.
104+
pub const HTLC_SUCCESS_INPUT_KEYED_ANCHOR_WITNESS_WEIGHT: u64 = 327;
105+
/// The upper bound weight of an HTLC success input from a commitment transaction with a p2a anchor output.
106+
/// Note the corresponding outputs no longer have the 1 CSV lock.
107+
pub const HTLC_SUCCESS_INPUT_P2A_ANCHOR_WITNESS_WEIGHT: u64 = 324;
104108

105109
/// The size of the 2-of-2 multisig script
106110
const MULTISIG_SCRIPT_SIZE: u64 = 1 + // OP_2
@@ -158,7 +162,7 @@ impl HTLCClaim {
158162
/// Check if a given input witness attempts to claim a HTLC.
159163
#[rustfmt::skip]
160164
pub fn from_witness(witness: &Witness) -> Option<Self> {
161-
debug_assert_eq!(OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS, MIN_ACCEPTED_HTLC_SCRIPT_WEIGHT);
165+
debug_assert_eq!(OFFERED_HTLC_SCRIPT_WEIGHT_KEYED_ANCHORS, MIN_ACCEPTED_HTLC_SCRIPT_WEIGHT);
162166
if witness.len() < 2 {
163167
return None;
164168
}
@@ -177,7 +181,7 @@ impl HTLCClaim {
177181
} else {
178182
None
179183
}
180-
} else if witness_script.len() == OFFERED_HTLC_SCRIPT_WEIGHT_ANCHORS {
184+
} else if witness_script.len() == OFFERED_HTLC_SCRIPT_WEIGHT_KEYED_ANCHORS {
181185
// It's possible for the weight of `offered_htlc_script` and `accepted_htlc_script` to
182186
// match so we check for both here.
183187
if witness.len() == 3 && second_to_last.len() == 33 {
@@ -2202,7 +2206,8 @@ mod tests {
22022206
use super::{ChannelPublicKeys, CounterpartyCommitmentSecrets};
22032207
use crate::chain;
22042208
use crate::ln::chan_utils::{
2205-
get_htlc_redeemscript, get_to_countersigner_keyed_anchor_redeemscript,
2209+
get_htlc_redeemscript, get_keyed_anchor_redeemscript,
2210+
get_to_countersigner_keyed_anchor_redeemscript, shared_anchor_script_pubkey,
22062211
BuiltCommitmentTransaction, ChannelTransactionParameters, CommitmentTransaction,
22072212
CounterpartyChannelTransactionParameters, HTLCOutputInCommitment,
22082213
TrustedCommitmentTransaction,
@@ -2250,7 +2255,7 @@ mod tests {
22502255
funding_outpoint: Some(chain::transaction::OutPoint { txid: Txid::all_zeros(), index: 0 }),
22512256
splice_parent_funding_txid: None,
22522257
channel_type_features: ChannelTypeFeatures::only_static_remote_key(),
2253-
channel_value_satoshis: 3000,
2258+
channel_value_satoshis: 4000,
22542259
};
22552260

22562261
Self {
@@ -2293,14 +2298,42 @@ mod tests {
22932298
let tx = builder.build(1000, 2000, Vec::new());
22942299
assert_eq!(tx.built.transaction.output.len(), 4);
22952300
assert_eq!(tx.built.transaction.output[3].script_pubkey, get_to_countersigner_keyed_anchor_redeemscript(&builder.counterparty_pubkeys.payment_point).to_p2wsh());
2301+
assert_eq!(tx.built.transaction.output[0].script_pubkey, get_keyed_anchor_redeemscript(&builder.channel_parameters.holder_pubkeys.funding_pubkey).to_p2wsh());
2302+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 330);
2303+
assert_eq!(tx.built.transaction.output[1].script_pubkey, get_keyed_anchor_redeemscript(&builder.counterparty_pubkeys.funding_pubkey).to_p2wsh());
2304+
assert_eq!(tx.built.transaction.output[1].value.to_sat(), 330);
22962305

22972306
// Generate broadcaster output and anchor
22982307
let tx = builder.build(3000, 0, Vec::new());
22992308
assert_eq!(tx.built.transaction.output.len(), 2);
2309+
assert_eq!(tx.built.transaction.output[0].script_pubkey, get_keyed_anchor_redeemscript(&builder.channel_parameters.holder_pubkeys.funding_pubkey).to_p2wsh());
2310+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 330);
23002311

23012312
// Generate counterparty output and anchor
23022313
let tx = builder.build(0, 3000, Vec::new());
23032314
assert_eq!(tx.built.transaction.output.len(), 2);
2315+
assert_eq!(tx.built.transaction.output[0].script_pubkey, get_keyed_anchor_redeemscript(&builder.counterparty_pubkeys.funding_pubkey).to_p2wsh());
2316+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 330);
2317+
2318+
// Generate broadcaster and counterparty outputs as well as a single anchor
2319+
builder.channel_parameters.channel_type_features = ChannelTypeFeatures::anchors_zero_fee_commitments();
2320+
let tx = builder.build(1000, 2000, Vec::new());
2321+
assert_eq!(tx.built.transaction.output.len(), 3);
2322+
assert_eq!(tx.built.transaction.output[2].script_pubkey, bitcoin::address::Address::p2wpkh(&CompressedPublicKey(builder.counterparty_pubkeys.payment_point), Network::Testnet).script_pubkey());
2323+
assert_eq!(tx.built.transaction.output[0].script_pubkey, shared_anchor_script_pubkey());
2324+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 240); // remember total channel value is 4000sat
2325+
2326+
// Generate broadcaster output and anchor
2327+
let tx = builder.build(3000, 0, Vec::new());
2328+
assert_eq!(tx.built.transaction.output.len(), 2);
2329+
assert_eq!(tx.built.transaction.output[0].script_pubkey, shared_anchor_script_pubkey());
2330+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 240); // remember total channel value is 4000sat
2331+
2332+
// Generate counterparty output and anchor
2333+
let tx = builder.build(0, 3000, Vec::new());
2334+
assert_eq!(tx.built.transaction.output.len(), 2);
2335+
assert_eq!(tx.built.transaction.output[0].script_pubkey, shared_anchor_script_pubkey());
2336+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 240); // remember total channel value is 4000sat
23042337

23052338
let received_htlc = HTLCOutputInCommitment {
23062339
offered: false,
@@ -2318,7 +2351,7 @@ mod tests {
23182351
transaction_output_index: None,
23192352
};
23202353

2321-
// Generate broadcaster output and received and offered HTLC outputs, w/o anchors
2354+
// Generate broadcaster output and received and offered HTLC outputs, w/o anchors
23222355
builder.channel_parameters.channel_type_features = ChannelTypeFeatures::only_static_remote_key();
23232356
let tx = builder.build(3000, 0, vec![received_htlc.clone(), offered_htlc.clone()]);
23242357
let keys = tx.trust().keys();
@@ -2330,16 +2363,33 @@ mod tests {
23302363
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::only_static_remote_key(), &keys).to_p2wsh().to_hex_string(),
23312364
"0020215d61bba56b19e9eadb6107f5a85d7f99c40f65992443f69229c290165bc00d");
23322365

2333-
// Generate broadcaster output and received and offered HTLC outputs, with anchors
2366+
// Generate broadcaster output and received and offered HTLC outputs, with keyed anchors
23342367
builder.channel_parameters.channel_type_features = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
23352368
let tx = builder.build(3000, 0, vec![received_htlc.clone(), offered_htlc.clone()]);
23362369
assert_eq!(tx.built.transaction.output.len(), 5);
2370+
assert_eq!(tx.built.transaction.output[0].script_pubkey, get_keyed_anchor_redeemscript(&builder.channel_parameters.holder_pubkeys.funding_pubkey).to_p2wsh());
2371+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 330);
2372+
assert_eq!(tx.built.transaction.output[1].script_pubkey, get_keyed_anchor_redeemscript(&builder.counterparty_pubkeys.funding_pubkey).to_p2wsh());
2373+
assert_eq!(tx.built.transaction.output[1].value.to_sat(), 330);
23372374
assert_eq!(tx.built.transaction.output[2].script_pubkey, get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_p2wsh());
23382375
assert_eq!(tx.built.transaction.output[3].script_pubkey, get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_p2wsh());
23392376
assert_eq!(get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_p2wsh().to_hex_string(),
23402377
"0020b70d0649c72b38756885c7a30908d912a7898dd5d79457a7280b8e9a20f3f2bc");
23412378
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(), &keys).to_p2wsh().to_hex_string(),
23422379
"002087a3faeb1950a469c0e2db4a79b093a41b9526e5a6fc6ef5cb949bde3be379c7");
2380+
2381+
// Generate broadcaster output and received and offered HTLC outputs, with P2A anchors
2382+
builder.channel_parameters.channel_type_features = ChannelTypeFeatures::anchors_zero_fee_commitments();
2383+
let tx = builder.build(3000, 0, vec![received_htlc.clone(), offered_htlc.clone()]);
2384+
assert_eq!(tx.built.transaction.output.len(), 4);
2385+
assert_eq!(tx.built.transaction.output[0].script_pubkey, shared_anchor_script_pubkey());
2386+
assert_eq!(tx.built.transaction.output[0].value.to_sat(), 0);
2387+
assert_eq!(tx.built.transaction.output[1].script_pubkey, get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_fee_commitments(), &keys).to_p2wsh());
2388+
assert_eq!(tx.built.transaction.output[2].script_pubkey, get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_fee_commitments(), &keys).to_p2wsh());
2389+
assert_eq!(get_htlc_redeemscript(&received_htlc, &ChannelTypeFeatures::anchors_zero_fee_commitments(), &keys).to_p2wsh().to_hex_string(),
2390+
"0020e43a7c068553003fe68fcae424fb7b28ec5ce48cd8b6744b3945631389bad2fb");
2391+
assert_eq!(get_htlc_redeemscript(&offered_htlc, &ChannelTypeFeatures::anchors_zero_fee_commitments(), &keys).to_p2wsh().to_hex_string(),
2392+
"0020215d61bba56b19e9eadb6107f5a85d7f99c40f65992443f69229c290165bc00d");
23432393
}
23442394

23452395
#[test]

lightning/src/ln/channel_open_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ pub fn test_insane_channel_opens() {
622622
});
623623
}
624624

625-
#[test]
625+
#[xtest(feature = "_externalize_tests")]
626626
fn test_insane_zero_fee_channel_open() {
627627
let mut cfg = UserConfig::default();
628628
cfg.manually_accept_inbound_channels = true;

0 commit comments

Comments
 (0)