@@ -14,6 +14,7 @@ use bitcoin::blockdata::script::{Script,Builder};
1414use bitcoin:: blockdata:: opcodes;
1515use bitcoin:: blockdata:: transaction:: { TxIn , TxOut , OutPoint , Transaction , EcdsaSighashType } ;
1616use bitcoin:: util:: sighash;
17+ use bitcoin:: util:: address:: Payload ;
1718
1819use bitcoin:: hashes:: { Hash , HashEngine } ;
1920use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
@@ -25,11 +26,11 @@ use crate::ln::msgs::DecodeError;
2526use crate :: util:: ser:: { Readable , Writeable , Writer } ;
2627use crate :: util:: { byte_utils, transaction_utils} ;
2728
28- use bitcoin:: hash_types:: WPubkeyHash ;
2929use bitcoin:: secp256k1:: { SecretKey , PublicKey , Scalar } ;
3030use bitcoin:: secp256k1:: { Secp256k1 , ecdsa:: Signature , Message } ;
3131use bitcoin:: secp256k1:: Error as SecpError ;
3232use bitcoin:: { PackedLockTime , secp256k1, Sequence , Witness } ;
33+ use bitcoin:: PublicKey as BitcoinPublicKey ;
3334
3435use crate :: io;
3536use crate :: prelude:: * ;
@@ -1279,7 +1280,7 @@ impl CommitmentTransaction {
12791280 let script = if opt_anchors {
12801281 get_to_countersignatory_with_anchors_redeemscript ( & countersignatory_pubkeys. payment_point ) . to_v0_p2wsh ( )
12811282 } else {
1282- get_p2wpkh_redeemscript ( & countersignatory_pubkeys. payment_point )
1283+ Payload :: p2wpkh ( & BitcoinPublicKey :: new ( countersignatory_pubkeys. payment_point ) ) . unwrap ( ) . script_pubkey ( )
12831284 } ;
12841285 txouts. push ( (
12851286 TxOut {
@@ -1585,25 +1586,21 @@ pub fn get_commitment_transaction_number_obscure_factor(
15851586 | ( ( res[ 31 ] as u64 ) << 0 * 8 )
15861587}
15871588
1588- fn get_p2wpkh_redeemscript ( key : & PublicKey ) -> Script {
1589- Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 )
1590- . push_slice ( & WPubkeyHash :: hash ( & key. serialize ( ) ) [ ..] )
1591- . into_script ( )
1592- }
1593-
15941589#[ cfg( test) ]
15951590mod tests {
15961591 use super :: CounterpartyCommitmentSecrets ;
15971592 use crate :: { hex, chain} ;
15981593 use crate :: prelude:: * ;
1599- use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, get_p2wpkh_redeemscript , CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1594+ use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
16001595 use bitcoin:: secp256k1:: { PublicKey , SecretKey , Secp256k1 } ;
16011596 use crate :: util:: test_utils;
16021597 use crate :: chain:: keysinterface:: { KeysInterface , BaseSign } ;
16031598 use bitcoin:: { Network , Txid } ;
16041599 use bitcoin:: hashes:: Hash ;
16051600 use crate :: ln:: PaymentHash ;
16061601 use bitcoin:: hashes:: hex:: ToHex ;
1602+ use bitcoin:: util:: address:: Payload ;
1603+ use bitcoin:: PublicKey as BitcoinPublicKey ;
16071604
16081605 #[ test]
16091606 fn test_anchors ( ) {
@@ -1642,7 +1639,7 @@ mod tests {
16421639 & mut htlcs_with_aux, & channel_parameters. as_holder_broadcastable ( )
16431640 ) ;
16441641 assert_eq ! ( tx. built. transaction. output. len( ) , 2 ) ;
1645- assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, get_p2wpkh_redeemscript ( & counterparty_pubkeys. payment_point) ) ;
1642+ assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, Payload :: p2wpkh ( & BitcoinPublicKey :: new ( counterparty_pubkeys. payment_point) ) . unwrap ( ) . script_pubkey ( ) ) ;
16461643
16471644 // Generate broadcaster and counterparty outputs as well as two anchors
16481645 let tx = CommitmentTransaction :: new_with_auxiliary_htlc_data (
0 commit comments