@@ -2203,8 +2203,8 @@ mod tests {
2203
2203
use crate :: chain;
2204
2204
use crate :: ln:: chan_utils:: {
2205
2205
get_htlc_redeemscript, get_to_countersigner_keyed_anchor_redeemscript,
2206
- BuiltCommitmentTransaction , ChannelTransactionParameters , CommitmentTransaction ,
2207
- CounterpartyChannelTransactionParameters , HTLCOutputInCommitment ,
2206
+ shared_anchor_script_pubkey , BuiltCommitmentTransaction , ChannelTransactionParameters ,
2207
+ CommitmentTransaction , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment ,
2208
2208
TrustedCommitmentTransaction ,
2209
2209
} ;
2210
2210
use crate :: sign:: { ChannelSigner , SignerProvider } ;
@@ -2250,7 +2250,7 @@ mod tests {
2250
2250
funding_outpoint : Some ( chain:: transaction:: OutPoint { txid : Txid :: all_zeros ( ) , index : 0 } ) ,
2251
2251
splice_parent_funding_txid : None ,
2252
2252
channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( ) ,
2253
- channel_value_satoshis : 3000 ,
2253
+ channel_value_satoshis : 4000 ,
2254
2254
} ;
2255
2255
2256
2256
Self {
@@ -2302,6 +2302,21 @@ mod tests {
2302
2302
let tx = builder. build ( 0 , 3000 , Vec :: new ( ) ) ;
2303
2303
assert_eq ! ( tx. built. transaction. output. len( ) , 2 ) ;
2304
2304
2305
+ // Generate broadcaster and counterparty outputs as well as a single anchor
2306
+ builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: anchors_zero_fee_commitments ( ) ;
2307
+ let tx = builder. build ( 1000 , 2000 , Vec :: new ( ) ) ;
2308
+ assert_eq ! ( tx. built. transaction. output. len( ) , 3 ) ;
2309
+ assert_eq ! ( tx. built. transaction. output[ 2 ] . script_pubkey, bitcoin:: address:: Address :: p2wpkh( & CompressedPublicKey ( builder. counterparty_pubkeys. payment_point) , Network :: Testnet ) . script_pubkey( ) ) ;
2310
+ assert_eq ! ( tx. built. transaction. output[ 0 ] . script_pubkey, shared_anchor_script_pubkey( ) ) ;
2311
+
2312
+ // Generate broadcaster output and anchor
2313
+ let tx = builder. build ( 3000 , 0 , Vec :: new ( ) ) ;
2314
+ assert_eq ! ( tx. built. transaction. output. len( ) , 2 ) ;
2315
+
2316
+ // Generate counterparty output and anchor
2317
+ let tx = builder. build ( 0 , 3000 , Vec :: new ( ) ) ;
2318
+ assert_eq ! ( tx. built. transaction. output. len( ) , 2 ) ;
2319
+
2305
2320
let received_htlc = HTLCOutputInCommitment {
2306
2321
offered : false ,
2307
2322
amount_msat : 400000 ,
@@ -2330,7 +2345,7 @@ mod tests {
2330
2345
assert_eq ! ( get_htlc_redeemscript( & offered_htlc, & ChannelTypeFeatures :: only_static_remote_key( ) , & keys) . to_p2wsh( ) . to_hex_string( ) ,
2331
2346
"0020215d61bba56b19e9eadb6107f5a85d7f99c40f65992443f69229c290165bc00d" ) ;
2332
2347
2333
- // Generate broadcaster output and received and offered HTLC outputs, with anchors
2348
+ // Generate broadcaster output and received and offered HTLC outputs, with CSV anchors
2334
2349
builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) ;
2335
2350
let tx = builder. build ( 3000 , 0 , vec ! [ received_htlc. clone( ) , offered_htlc. clone( ) ] ) ;
2336
2351
assert_eq ! ( tx. built. transaction. output. len( ) , 5 ) ;
@@ -2340,6 +2355,17 @@ mod tests {
2340
2355
"0020b70d0649c72b38756885c7a30908d912a7898dd5d79457a7280b8e9a20f3f2bc" ) ;
2341
2356
assert_eq ! ( get_htlc_redeemscript( & offered_htlc, & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies( ) , & keys) . to_p2wsh( ) . to_hex_string( ) ,
2342
2357
"002087a3faeb1950a469c0e2db4a79b093a41b9526e5a6fc6ef5cb949bde3be379c7" ) ;
2358
+
2359
+ // Generate broadcaster output and received and offered HTLC outputs, with P2A anchors
2360
+ builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: anchors_zero_fee_commitments ( ) ;
2361
+ let tx = builder. build ( 3000 , 0 , vec ! [ received_htlc. clone( ) , offered_htlc. clone( ) ] ) ;
2362
+ assert_eq ! ( tx. built. transaction. output. len( ) , 4 ) ;
2363
+ assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, get_htlc_redeemscript( & received_htlc, & ChannelTypeFeatures :: anchors_zero_fee_commitments( ) , & keys) . to_p2wsh( ) ) ;
2364
+ assert_eq ! ( tx. built. transaction. output[ 2 ] . script_pubkey, get_htlc_redeemscript( & offered_htlc, & ChannelTypeFeatures :: anchors_zero_fee_commitments( ) , & keys) . to_p2wsh( ) ) ;
2365
+ assert_eq ! ( get_htlc_redeemscript( & received_htlc, & ChannelTypeFeatures :: anchors_zero_fee_commitments( ) , & keys) . to_p2wsh( ) . to_hex_string( ) ,
2366
+ "0020e43a7c068553003fe68fcae424fb7b28ec5ce48cd8b6744b3945631389bad2fb" ) ;
2367
+ assert_eq ! ( get_htlc_redeemscript( & offered_htlc, & ChannelTypeFeatures :: anchors_zero_fee_commitments( ) , & keys) . to_p2wsh( ) . to_hex_string( ) ,
2368
+ "0020215d61bba56b19e9eadb6107f5a85d7f99c40f65992443f69229c290165bc00d" ) ;
2343
2369
}
2344
2370
2345
2371
#[ test]
0 commit comments