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